Completed
Push — master ( 83f4e7...6bcd51 )
by
unknown
02:32
created

Zanox::getDeals()   F

Complexity

Conditions 17
Paths 587

Size

Total Lines 92
Code Lines 68

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 92
rs 2.4543
c 0
b 0
f 0
cc 17
eloc 68
nc 587
nop 3

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Padosoft\AffiliateNetwork\Networks;
4
5
use Padosoft\AffiliateNetwork\DealsResultset;
6
use Padosoft\AffiliateNetwork\Product;
7
use Padosoft\AffiliateNetwork\ProductsResultset;
8
use Padosoft\AffiliateNetwork\Transaction;
9
use Padosoft\AffiliateNetwork\Merchant;
10
use Padosoft\AffiliateNetwork\Stat;
11
use Padosoft\AffiliateNetwork\Deal;
12
use Padosoft\AffiliateNetwork\AbstractNetwork;
13
use Padosoft\AffiliateNetwork\NetworkInterface;
14
use Padosoft\AffiliateNetwork\ZanoxEx;
15
16
// require "../vendor/fubralimited/php-oara/Oara/Network/Publisher/Zanox/Zapi/ApiClient.php";
17
18
/**
19
 * Class Zanox
20
 * @package Padosoft\AffiliateNetwork\Networks
21
 */
22
class Zanox extends AbstractNetwork implements NetworkInterface
23
{
24
    /**
25
     * @var object
26
     */
27
    private $_network   = null;
28
    protected $_apiClient = null;
29
    private $_username  = '';
30
    private $_password  = '';
31
    private $_logged    = false;
32
    protected $_tracking_parameter    = 'zpar0';
33
34
35
    /**
36
     * @method __construct
37
     */
38 View Code Duplication
    public function __construct(string $username, string $password,string $idSite='')
0 ignored issues
show
Unused Code introduced by
The parameter $idSite is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        $this->_network = new ZanoxEx;
41
        $this->_username = $username;
42
        $this->_password = $password;
43
        $this->login( $this->_username, $this->_password );
44
45
    }
46
47
    public function login(string $username, string $password,string $idSite=''): bool
0 ignored issues
show
Unused Code introduced by
The parameter $idSite is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
    {
49
        $this->_logged = false;
50
        if (isNullOrEmpty( $username ) || isNullOrEmpty( $password )) {
51
52
            return false;
53
        }
54
        $this->_username = $username;
55
        $this->_password = $password;
56
        $credentials = array();
57
        $credentials["connectid"] = $this->_username;
58
        $credentials["secretkey"] = $this->_password;
59
        $this->_network->login( $credentials );
60
        $this->_apiClient = $this->_network->getApiClient();
61
        if ($this->_network->checkConnection()) {
62
            $this->_logged = true;
63
64
        }
65
66
        return $this->_logged;
67
    }
68
69
    /**
70
     * @return bool
71
     */
72
    public function checkLogin(): bool
73
    {
74
        return $this->_logged;
75
    }
76
77
    /**
78
     * @return array of Merchants
79
     */
80 View Code Duplication
    public function getMerchants(): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
    {
82
        if (!$this->checkLogin()) {
83
            return array();
84
        }
85
        $arrResult = array();
86
        $merchantList = $this->_network->getMerchantList();
87
        foreach ($merchantList as $merchant) {
88
            $Merchant = Merchant::createInstance();
89
            $Merchant->merchant_ID = $merchant['cid'];
90
            $Merchant->name = $merchant['name'];
91
            $arrResult[] = $Merchant;
92
        }
93
94
        return $arrResult;
95
    }
96
97
    /**
98
     * @param int|null $merchantID
99
     * @param int $page
100
     * @param int $items_per_page
101
     *
102
     * @return DealsResultset
103
     */
104
    public function getDeals($merchantID=NULL,int $page = 0, int $items_per_page = 0 ): DealsResultset
105
    {
106
        $result = DealsResultset::createInstance();
107
        if (!$this->checkLogin()) {
108
            return $result;
109
        }
110
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
111
        if (!isIntegerPositive($items_per_page) || $items_per_page <= 0 || $items_per_page > 999) {
112
            $items_per_page = 999;
113
        }
114
        */
115
        $adSpaces=$this->_apiClient->getAdspaces(0,100);
116
        if (!is_object($adSpaces)){
117
            $adSpaces=json_encode($adSpaces);
118
        }
119
        if ($adSpaces->items<1){
120
            return $result;
121
        }
122
123
        $adSpaceId=$adSpaces->adspaceItems->adspaceItem[0]->id;
124
        if (!isIntegerPositive($merchantID)){
125
            $merchantID=NULL;
126
        }
127
128
        $Response = $this->_apiClient->searchIncentives($merchantID,$adSpaceId,null,null, $page, $items_per_page);
129
        
130
        if (!is_object($Response)){
131
            $Response=json_decode($Response);
132
        }
133
        $result->page=$Response->page;
134
        $result->items=$Response->items;
135
        $result->total=$Response->total;
136
        // ($Response->total>0)?$result->num_pages=(int)ceil($Response->total/$items_per_page):$result->num_pages=0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
137
        $arrAdmediumItems = $Response->incentiveItems->incentiveItem;
138
139
        foreach ($arrAdmediumItems as $admediumItems) {
140
            $Deal = Deal::createInstance();
141
            $Deal->deal_ID = (int)$admediumItems->id;
142
            $Deal->start_date = $Deal->convertDate($admediumItems->startDate);
0 ignored issues
show
Documentation Bug introduced by
It seems like $Deal->convertDate($admediumItems->startDate) can also be of type false. However, the property $start_date is declared as type object<DateTime>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
143
            isset($admediumItems->endDate) ? $Deal->end_date = $Deal->convertDate($admediumItems->endDate): $Deal->end_date = '2099-12-31';
0 ignored issues
show
Documentation Bug introduced by
It seems like $Deal->convertDate($admediumItems->endDate) can also be of type false. However, the property $end_date is declared as type object<DateTime>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
Documentation Bug introduced by
It seems like '2099-12-31' of type string is incompatible with the declared type object<DateTime> of property $end_date.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
144
            $Deal->name = $admediumItems->name;
145
            $Deal->code = $admediumItems->couponCode;
146
            $Deal->description = $admediumItems->info4customer;
147
            $Deal->information = $admediumItems->info4publisher.' '.$admediumItems->restrictions;
148
            $Deal->is_percentage = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $is_percentage was declared of type boolean, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
149
            $Deal->discount_amount = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $discount_amount was declared of type string, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
150
            $Deal->currency_initial = '';
151
            if (isset($admediumItems->percentage) && isIntegerPositive($admediumItems->percentage)){
152
                $Deal->is_percentage = 1;
0 ignored issues
show
Documentation Bug introduced by
The property $is_percentage was declared of type boolean, but 1 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
153
                $Deal->discount_amount = $admediumItems->percentage;
154
            }elseif (isset($admediumItems->total)){
155
                $Deal->discount_amount = $admediumItems->total;
156
                $Deal->currency_initial = $admediumItems->currency;
157
            }
158
            switch ($admediumItems->incentiveType) {
159
                case 'coupons':
160
                    $Deal->deal_type = \Oara\Utilities::OFFER_TYPE_VOUCHER;
161
                    break;
162
                case 'bargains':
163
                    $Deal->deal_type = \Oara\Utilities::OFFER_TYPE_DISCOUNT;
164
                    break;
165
                case 'noShippingCosts':
166
                    $Deal->deal_type = \Oara\Utilities::OFFER_TYPE_FREE_SHIPPING;
167
                    break;
168
                case 'freeProducts':
169
                    $Deal->deal_type = \Oara\Utilities::OFFER_TYPE_FREE_ARTICLE;
170
                    break;
171
                case 'lotteries':
172
                    $Deal->deal_type = \Oara\Utilities::OFFER_TYPE_LOTTERY;
173
                    break;
174
                default:
175
                    $Deal->deal_type = \Oara\Utilities::OFFER_TYPE_DISCOUNT;
176
                    break;
177
            }
178
            $Deal->merchant_ID = (int)$admediumItems->program->id;
179
            
180
            $Deal->merchant_name = $admediumItems->program->_;
181
            if (isset($admediumItems->admedia->admediumItem[0]->trackingLinks->trackingLink)) {
182
                $Deal->ppv = $admediumItems->admedia->admediumItem[0]->trackingLinks->trackingLink[0]->ppv;
183
                $Deal->ppc = $admediumItems->admedia->admediumItem[0]->trackingLinks->trackingLink[0]->ppc;
184
                $Deal->default_track_uri = $Deal->ppc;
185
            }
186
            else {
187
                $Deal->ppv = "*** NO LINK ***";
188
                $Deal->ppc = "*** NO LINK ***";
189
190
            }
191
            $arrResult[] = $Deal;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$arrResult was never initialized. Although not strictly required by PHP, it is generally a good practice to add $arrResult = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
192
        }
193
        $result->deals[] = $arrResult;
0 ignored issues
show
Bug introduced by
The variable $arrResult does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
194
        return $result;
195
    }
196
197
198
    /**
199
     * @param \DateTime $dateFrom
200
     * @param \DateTime $dateTo
201
     * @param int $merchantID
0 ignored issues
show
Documentation introduced by
There is no parameter named $merchantID. Did you maybe mean $arrMerchantID?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
202
     *
203
     * @return array of Transaction
204
     */
205
    public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()): array
206
    {
207
        if (!$this->checkLogin()) {
208
            return array();
209
        }
210
        $dateFrom2=new \DateTime($dateFrom->format('Y-m-d'));
211
        if ($dateTo->format('Y-m-d')==$dateFrom2->format('Y-m-d')){
212
            $dateFrom2->sub(new \DateInterval('P1D'));
213
        }
214
215
        $arrResult = array();
216 View Code Duplication
        if (count( $arrMerchantID ) < 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
217
            $merchants = $this->getMerchants();
218
            foreach ($merchants as $merchant) {
219
                $arrMerchantID[$merchant->merchant_ID] = ['cid' => $merchant->merchant_ID, 'name' => $merchant->name];
220
            }
221
        }
222
        $transcationList = $this->_network->getTransactionList( $arrMerchantID, $dateFrom2, $dateTo );
223
        foreach ($transcationList as $transaction) {
224
            $Transaction = Transaction::createInstance();
225
            array_key_exists_safe( $transaction,
226
                'currency' ) ? $Transaction->currency = $transaction['currency'] : $Transaction->currency = '';
227
            array_key_exists_safe( $transaction,
228
                'status' ) ? $Transaction->status = $transaction['status'] : $Transaction->status = '';
229
            array_key_exists_safe( $transaction,
230
                'amount' ) ? $Transaction->amount = $transaction['amount'] : $Transaction->amount = '';
0 ignored issues
show
Documentation Bug introduced by
The property $amount was declared of type double, but '' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
231
            array_key_exists_safe( $transaction,
232
                'custom_id' ) ? $Transaction->custom_ID = $transaction['custom_id'] : $Transaction->custom_ID = '';
233
            array_key_exists_safe( $transaction,
234
                'title' ) ? $Transaction->title = $transaction['title'] : $Transaction->title = '';
235
            array_key_exists_safe( $transaction,
236
                'unique_id' ) ? $Transaction->unique_ID = $transaction['unique_id'] : $Transaction->unique_ID = '';
237
            array_key_exists_safe( $transaction,
238
                'commission' ) ? $Transaction->commission = $transaction['commission'] : $Transaction->commission = '';
0 ignored issues
show
Documentation Bug introduced by
The property $commission was declared of type double, but '' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
239
            $date = new \DateTime( $transaction['date'] );
240
            $Transaction->date = $date; // $date->format('Y-m-d H:i:s');
0 ignored issues
show
Documentation Bug introduced by
It seems like $date of type object<DateTime> is incompatible with the declared type string of property $date.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
241
            array_key_exists_safe( $transaction,
242
                'merchantId' ) ? $Transaction->merchant_ID = $transaction['merchantId'] : $Transaction->merchant_ID = '';
0 ignored issues
show
Documentation Bug introduced by
The property $merchant_ID was declared of type integer, but '' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
243
            array_key_exists_safe( $transaction,
244
                'approved' ) ? $Transaction->approved = $transaction['approved'] : $Transaction->approved = '';
0 ignored issues
show
Documentation Bug introduced by
The property $approved was declared of type boolean, but '' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
245
            $arrResult[] = $Transaction;
246
        }
247
248
        return $arrResult;
249
    }
250
251
    /**
252
     * @param \DateTime $dateFrom
253
     * @param \DateTime $dateTo
254
     * @param int $merchantID
255
     *
256
     * @return array of Stat
257
     */
258
    public function getStats(\DateTime $dateFrom, \DateTime $dateTo, int $merchantID = 0): array
259
    {
260
        return array();
261
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
262
        $this->_apiClient->setConnectId($this->_username);
263
        $this->_apiClient->setSecretKey($this->_password);
264
        $dateFromIsoEngFormat = $dateFrom->format('Y-m-d');
265
        $dateToIsoEngFormat = $dateTo->format('Y-m-d');
266
        $response = $this->_apiClient->getReportBasic($dateFromIsoEngFormat, $dateToIsoEngFormat);
267
        $arrResponse = json_decode($response, true);
268
        $reportItems = $arrResponse['reportItems'];
269
        $Stat = Stat::createInstance();
270
        $Stat->reportItems = $reportItems;
271
272
        return array($Stat);
273
        */
274
    }
275
276
    /**
277
     * @param  array $params  this array can contains these keys
278
     *                        string      query          search string
279
     *                        string      searchType     search type (optional) (contextual or phrase)
280
     *                        string      region         limit search to region (optional)
281
     *                        int         categoryId     limit search to categorys (optional)
282
     *                        array       programId      limit search to program list of programs (optional)
283
     *                        boolean     hasImages      products with images (optional)
284
     *                        float       minPrice       minimum price (optional)
285
     *                        float       maxPrice       maximum price (optional)
286
     *                        int         adspaceId      adspace id (optional)
287
     *                        int         page           page of result set (optional)
288
     *                        int         items          items per page (optional)
289
     *
290
     * @return ProductsResultset
291
     */
292
    public function getProducts(array $params = []): ProductsResultset
293
    {
294
        $_params = array_merge([
295
            'query' => null,
296
            'searchType' => null,
297
            'query' => null,
298
            'searchType' => null,
299
            'region' => null,
300
            'categoryId' => null,
301
            'programId' => null,
302
            'hasImages' => null,
303
            'minPrice' => null,
304
            'maxPrice' => null,
305
            'adspaceId' => null,
306
            'page' => 0,
307
            'items' => 10
308
        ], $params);
309
        $products =  $this->_network->getProducts($_params);
310
        $set = ProductsResultset::createInstance();
311
        if (!property_exists($products, 'productItems') || !property_exists($products->productItems, 'productItem'))
312
        {
313
            return ProductsResultset::createInstance();
314
        }
315
316
        $set->page = $products->page;
317
        $set->items = $products->items;
318
        $set->total = $products->total;
319
320
        foreach ($products->productItems->productItem as $productItem) {
321
            $Product = Product::createInstance();
322
            if (property_exists($productItem, 'name')) {
323
                $Product->name = $productItem->name;//'Danava',
324
            }
325
            if (property_exists($productItem, 'modified')) {
326
                $Product->modified = $productItem->modified; //'2016-11-24T11:52:03Z',
327
            }
328
            if (property_exists($productItem, 'program')) {
329
                $Product->merchant_ID = $productItem->program->id; //'Twelve Thirteen DE'
330
                $Product->merchant_name = $productItem->program->_; //17434,
331
            }
332
            if (property_exists($productItem, 'price'))
333
                $Product->price = $productItem->price; //129.0
334
            if (property_exists($productItem, 'currency'))
335
                $Product->currency = $productItem->currency; //'EUR'
336
            if (property_exists($productItem, 'trackingLinks') && property_exists($productItem->trackingLinks, 'trackingLink')) {
337
                $Product->ppv = $productItem->trackingLinks->trackingLink[0]->ppv;
338
                $Product->ppc = $productItem->trackingLinks->trackingLink[0]->ppc;
339
                $Product->adspaceId = $productItem->trackingLinks->trackingLink[0]->adspaceId;
0 ignored issues
show
Bug introduced by
The property adspaceId does not seem to exist in Padosoft\AffiliateNetwork\Product.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
340
            }
341
            if (property_exists($productItem, 'description'))
342
                $Product->description = $productItem->description; //'Rosegold trifft auf puristisches Schwarz ? aufwendige und traditionelle Makramee Technik trifft auf Eleganz. Das neue Danava Buddha Armband besteht aus schwarzem Onyx, dieser Edelstein wird sehr gerne als Schmuckstein verwendet und viel lieber getragen. Der feingearbeitete rosegoldene Buddha verleiht diesem Armband einen fernöstlichen Stil. Es lässt sich wunderbar zu allen Anlässen Tragen und zu vielen Outfits kombinieren, da es Eleganz ausstrahlt. Das Symbol des Buddhas ist besonders in dieser Saison sehr gefragt.',
343
            if (property_exists($productItem, 'manufacturer'))
344
                $Product->manufacturer = $productItem->manufacturer; //'Twelve Thirteen Jewelry'
345
            if (property_exists($productItem, 'ean'))
346
                $Product->ean = $productItem->ean; //'0796716271505'
347
            if (property_exists($productItem, 'deliveryTime'))
348
                $Product->deliveryTime = $productItem->deliveryTime; //'1-3 Tage'
349
            if (property_exists($productItem, 'priceOld'))
350
                $Product->priceOld = $productItem->priceOld; //0.0
351
            if (property_exists($productItem, 'shippingCosts'))
352
                $Product->shippingCosts = $productItem->shippingCosts; //'0.0'
353
            if (property_exists($productItem, 'shipping'))
354
                $Product->shipping = $productItem->shipping; // '0.0'
355
            if (property_exists($productItem, 'merchantCategory'))
356
                $Product->merchantCategory = $productItem->merchantCategory; //'Damen / Damen Armbänder / Buddha Armbänder'
357
            if (property_exists($productItem, 'merchantProductId'))
358
                $Product->merchantProductId = $productItem->merchantProductId; //'BR018.M'
359
            if (property_exists($productItem, 'id'))
360
                $Product->id = $productItem->id; //'1ed7c3b4ab79cdbbf127cb78ec2aaff4'
361
            if (property_exists($productItem, 'image') && property_exists($productItem->image, 'large')) {
362
                $Product->image = $productItem->image->large;
363
            }
364
            $set->products[] = $Product;
365
        }
366
367
        return $set;
368
    }
369
370
    public function getTrackingParameter(){
371
        return $this->_tracking_parameter;
372
    }
373
}
374