| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Padosoft\AffiliateNetwork\Networks; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Padosoft\AffiliateNetwork\Transaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Padosoft\AffiliateNetwork\Merchant; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Padosoft\AffiliateNetwork\Stat; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Padosoft\AffiliateNetwork\Deal; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Padosoft\AffiliateNetwork\AbstractNetwork; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Padosoft\AffiliateNetwork\NetworkInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Padosoft\AffiliateNetwork\DealsResultset; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Padosoft\AffiliateNetwork\ProductsResultset; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Padosoft\AffiliateNetwork\AffilinetEx; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * Class Affilinet | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @package Padosoft\AffiliateNetwork\Networks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | class Affilinet extends AbstractNetwork implements NetworkInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @var object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     private $_network = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     // private $_apiClient = null; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private $_username = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     private $_password = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     private $_passwordApi = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     private $_website_id = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     protected $_tracking_parameter = 'subid';   // Default value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @method __construct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 35 |  | View Code Duplication |     public function __construct(string $username, string $passwordApi, string $idSite='') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->_network = new AffilinetEx; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->_username = $username; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $this->_password = $passwordApi; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $this->_passwordApi = $passwordApi; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $this->_website_id = $idSite; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $this->login( $this->_username, $this->_password ,$idSite); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         // $this->_apiClient = \ApiClient::factory(PROTOCOL_JSON); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 49 |  | View Code Duplication |     public function login(string $username, string $password,string $idSite=''): bool | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $this->_logged = false; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         if (isNullOrEmpty( $username ) && isNullOrEmpty( $password )) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->_username = $username; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $this->_password = $password; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $this->_passwordApi= $password; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $credentials = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $credentials["user"] = $this->_username; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $credentials["password"] = $this->_username; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $credentials["apipassword"] = $this->_passwordApi; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->_network->login($credentials); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         if ($this->_network->checkConnection()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             $this->_logged = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         return $this->_logged; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     public function checkLogin() : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         return $this->_logged; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * @return array of Merchants | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 82 |  | View Code Duplication |     public function getMerchants(): array | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $arrResult = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $merchantList = $this->_network->getMerchantList(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         foreach ($merchantList as $merchant) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             $Merchant = Merchant::createInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             $Merchant->merchant_ID = $merchant['cid']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             $Merchant->name = $merchant['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             $arrResult[] = $Merchant; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         return $arrResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * @param int $merchantID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @return array of Deal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     public function getDeals($merchantID = NULL, int $page = 0, int $items_per_page = 10): DealsResultset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $arrResult = new DealsResultset(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         // <TODO> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         /* | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         if ($page<1){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $page=1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         $response = $this->_apiCall('https://link-search.api.cj.com/v2/link-search?website-id=' . $this->_website_id . '&advertiser-ids='.$merchantID.'&records-per-page='.$items_per_page.'&page-number='.$page); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         //var_dump($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         if ($response===false || \preg_match("/error/", $response)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             return $arrResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $arrResponse = xml2array($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         if (!is_array($arrResponse) || count($arrResponse) <= 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             return $arrResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         if (!isset($arrResponse['cj-api']['links'])){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             return $arrResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         $arrResult->page=$arrResponse['cj-api']['links_attr']['page-number']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $arrResult->items=$arrResponse['cj-api']['links_attr']['records-returned']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $arrResult->total=$arrResponse['cj-api']['links_attr']['total-matched']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         ($arrResult->total>0)?$arrResult->num_pages=(int)ceil($arrResult->total/$items_per_page):$arrResult->num_pages=0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         $arrCoupon = $arrResponse['cj-api']['links']['link']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         foreach ($arrCoupon as $coupon) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             //  var_dump($coupon); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             $Deal = Deal::createInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             $Deal->id = $coupon['link-id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             $Deal->name = $coupon['link-name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             $Deal->description = $coupon['description']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |             $Deal->note = $coupon['description']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             $Deal->merchant_ID = $coupon['advertiser-id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             $Deal->merchant_name = $coupon['advertiser-name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             $Deal->ppc = $coupon['clickUrl']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             $Deal->description = $coupon['description']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             if (!empty($coupon['promotion-start-date'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                 $startDate = new \DateTime($coupon['promotion-start-date']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |                 $Deal->startDate = $startDate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                 $Deal->created_at = $startDate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             if (!empty($coupon['promotion-end-date'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                 $endDate = new \DateTime($coupon['promotion-end-date']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |                 $Deal->endDate = $endDate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |             $Deal->code = $coupon['coupon-code']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             $arrResult->deals[] = $Deal; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         return $arrResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      * @param \DateTime $dateFrom | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * @param \DateTime $dateTo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      * @param int $merchantID | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * @return array of Transaction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         $arrResult = array(); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 166 |  | View Code Duplication |         if (count( $arrMerchantID ) < 1) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             $merchants = $this->getMerchants(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             foreach ($merchants as $merchant) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |                 $arrMerchantID[$merchant->merchant_ID] = ['cid' => $merchant->merchant_ID, 'name' => $merchant->name]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom,$dateTo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         //echo "<br>merchants id array<br>".print_r($arrMerchantID); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         //$counter=0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         foreach($transactionList as $transaction) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             $myTransaction = Transaction::createInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |                 $myTransaction->status = $transaction['status']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |                 $myTransaction->amount = $transaction['amount']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                 $myTransaction->custom_ID = $transaction['custom_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |                 $myTransaction->unique_ID = $transaction['unique_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |                 $myTransaction->commission = $transaction['commission']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |                 if (!empty($transaction['date'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |                     $date = new \DateTime($transaction['date']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |                     $myTransaction->date = $date; // $date->format('Y-m-d H:i:s'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |                 $myTransaction->merchant_ID = $transaction['merchantId']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |                 // Future use - Only few providers returns these dates values - <PN> - 2017-06-26 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 189 |  | View Code Duplication |                 if (isset($transaction['click_date']) && !empty($transaction['click_date'])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |                     $myTransaction->click_date = new \DateTime($transaction['click_date']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |                 } | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 192 |  | View Code Duplication |                 if (isset($transaction['update_date']) && !empty($transaction['update_date'])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |                     $myTransaction->update_date = new \DateTime($transaction['update_date']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |                 $arrResult[] = $myTransaction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             } catch (\Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |                 //echo "stepE "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |                 echo "<br><br>errore transazione Affilinet, id: ".$myTransaction->unique_ID." msg: ".$e->getMessage()."<br><br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |                 var_dump($e->getTraceAsString()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         return $arrResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |      * @param \DateTime $dateFrom | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |      * @param \DateTime $dateTo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |      * @param int $merchantID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * @return array of Stat | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     public function getStats(\DateTime $dateFrom, \DateTime $dateTo, int $merchantID = 0): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |         /* | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         $this->_apiClient->setConnectId($this->_username); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         $this->_apiClient->setSecretKey($this->_password); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         $dateFromIsoEngFormat = $dateFrom->format('Y-m-d'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         $dateToIsoEngFormat = $dateTo->format('Y-m-d'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         $response = $this->_apiClient->getReportBasic($dateFromIsoEngFormat, $dateToIsoEngFormat); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         $arrResponse = json_decode($response, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $reportItems = $arrResponse['reportItems']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $Stat = Stat::createInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         $Stat->reportItems = $reportItems; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         return array($Stat); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      * @param  array $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |      * @return ProductsResultset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     public function getProducts(array $params = []): ProductsResultset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         // TODO: Implement getProducts() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         throw new \Exception("Not implemented yet"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |      * Api call CommissionJunction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 243 |  | View Code Duplication |     private function _apiCall($url) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         $ch = curl_init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         curl_setopt($ch, CURLOPT_URL, $url); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         curl_setopt($ch, CURLOPT_POST, FALSE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: " . $this->_passwordApi)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |         $curl_results = curl_exec($ch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         curl_close($ch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         return $curl_results; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 257 |  |  |     public function getTrackingParameter() | 
            
                                                        
            
                                    
            
            
                | 258 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 259 |  |  |         return $this->_tracking_parameter; | 
            
                                                        
            
                                    
            
            
                | 260 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 261 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 262 |  |  |  | 
            
                        
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.