| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * You are hereby granted a non-exclusive, worldwide, royalty-free license to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * use, copy, modify, and distribute this software in source code or binary | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * form for use in connection with the web services and APIs provided by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Facebook. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * As with any software that integrates with the Facebook platform, your use | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * of this software is subject to the Facebook Developer Principles and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * Policies [http://developers.facebook.com/policy/]. This copyright notice | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * shall be included in all copies or substantial portions of the software. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * DEALINGS IN THE SOFTWARE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | namespace FacebookAds\Object; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use FacebookAds\Object\Fields\AdAccountFields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use FacebookAds\Object\Traits\CannotCreate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use FacebookAds\Object\Traits\CannotDelete; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use FacebookAds\Object\Traits\FieldValidation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use FacebookAds\Http\RequestInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use FacebookAds\Cursor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | class AdAccount extends AbstractCrudObject { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |   use FieldValidation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |   use CannotCreate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |   use CannotDelete; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |    * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |   protected function getEndpoint() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     return 'adaccounts'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |    * @return AdAccountFields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |   public static function getFieldsEnum() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     return AdAccountFields::getInstance(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |   public function getActivities( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |       Activity::className(), $fields, $params, 'activities'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |   public function getAdUsers(array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     return $this->getManyByConnection(AdUser::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |    /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |   public function getCampaigns( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |       Campaign::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |   public function getAdSets(array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     return $this->getManyByConnection(AdSet::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |   public function getAds( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     return $this->getManyByConnection(Ad::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |   public function getAdCreatives( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |       AdCreative::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |   public function getAdImages( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     return $this->getManyByConnection(AdImage::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |   public function getAdsPixels( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     return $this->getManyByConnection(AdsPixel::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |   public function getAdVideos( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     return $this->getManyByConnection(AdVideo::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |   public function getBroadCategoryTargeting( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |       BroadCategoryTargeting::className(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |       $fields, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |       $params, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |       'broadtargetingcategories' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |   public function getConnectionObjects( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |       ConnectionObject::className(), $fields, $params, 'connectionobjects'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |   public function getCustomAudiences( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |       CustomAudience::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |    * @return Cursor | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 185 |  |  |    */ | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |   public function getConversionPixels( | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |     return $this->getManyByConnection( | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  |       AdConversionPixel::className(), $fields, $params); | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |   public function getPartnerCategories( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |       PartnerCategory::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |   public function getRateCards( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |       RateCard::className(), $fields, $params, 'ratecard'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |    * @return ReachEstimate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |   public function getReachEstimate( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     return $this->getOneByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |       ReachEstimate::className(), $fields, $params, 'reachestimate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |   public function getReachFrequencyPredictions( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |       ReachFrequencyPrediction::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |    * @return TargetingDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |   public function getTargetingDescription( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     return $this->getOneByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |       TargetingDescription::className(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |       $fields, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |       $params, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |       'targetingsentencelines'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |   public function getTransactions( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |       Transaction::className(), $fields, $params, 'transactions'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |   public function getAdPreviews( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |       AdPreview::classname(), $fields, $params, 'generatepreviews'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |   public function getInsights( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |       Insights::classname(), $fields, $params, 'insights'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |    * @return AsyncJobInsights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |   public function getInsightsAsync( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |     return $this->createAsyncJob( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |       AsyncJobInsights::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |   public function getAgencies( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |       Agency::className(), $fields, $params, 'agencies'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |    * @param int $business_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |    * @param array $permitted_roles | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |   public function grantAgencyAcccess($business_id, $permitted_roles) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |     $params = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |       'business' => $business_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |       'permitted_roles' => $permitted_roles, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |     $this->getApi()->call( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |       '/'.$this->assureId().'/agencies', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |       RequestInterface::METHOD_POST, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |       $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |    * @param int $business_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |   public function revokeAgencyAccess($business_id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |     $params = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |       'business' => $business_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |     $this->getApi()->call( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |       '/'.$this->assureId().'/agencies', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |       RequestInterface::METHOD_DELETE, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |       $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |   public function getMinimumBudgets( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |       MinimumBudget::className(), $fields, $params, 'minimum_budgets'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |   public function getAdPlacePageSets( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |       AdPlacePageSet::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |   public function getAdLabels( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |       AdLabel::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |   public function getCampaignsByLabel( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |       Campaign::classname(), $fields, $params, 'campaignsbylabels'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |   public function getAdSetsByLabel( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |       AdSet::classname(), $fields, $params, 'adsetsbylabels'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |   public function getAdsByLabel( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |       Ad::classname(), $fields, $params, 'adsbylabels'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |   public function getAdCreativesByLabel( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |       AdCreative::classname(), $fields, $params, 'adcreativesbylabels'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |    * @param array $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |    * @param array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |    * @return Cursor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |   public function getCustomConversions ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |     array $fields = array(), array $params = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |     return $this->getManyByConnection( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |       CustomConversion::className(), $fields, $params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |   } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 423 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 424 |  |  |  | 
            
                        
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_functionexpects aPostobject, and outputs the author of the post. The base classPostreturns a simple string and outputting a simple string will work just fine. However, the child classBlogPostwhich is a sub-type ofPostinstead decided to return anobject, and is therefore violating the SOLID principles. If aBlogPostwere passed tomy_function, PHP would not complain, but ultimately fail when executing thestrtouppercall in its body.