@@ 98-138 (lines=41) @@ | ||
95 | * |
|
96 | * @return DealsResultset |
|
97 | */ |
|
98 | public function getDeals($merchantID,int $page=0,int $items_per_page=10) : DealsResultset |
|
99 | { |
|
100 | if (!isIntegerPositive($items_per_page)){ |
|
101 | $items_per_page=10; |
|
102 | } |
|
103 | $result=DealsResultset::createInstance(); |
|
104 | if (!$this->checkLogin()) { |
|
105 | return $result; |
|
106 | } |
|
107 | $arrResult = array(); |
|
108 | $jsonVouchers = file_get_contents("https://api.tradedoubler.com/1.0/vouchers.json;voucherTypeId=1?token=".$_ENV['TRADEDOUBLER_TOKEN']); |
|
109 | $arrVouchers = json_decode($jsonVouchers, true); |
|
110 | ||
111 | foreach($arrVouchers as $vouchers) { |
|
112 | $Deal = Deal::createInstance(); |
|
113 | $Deal->deal_ID = $vouchers['id']; |
|
114 | $Deal->merchant_ID = $vouchers['programId']; |
|
115 | $Deal->merchant_name = $vouchers['programName']; |
|
116 | $Deal->code = $vouchers['code']; |
|
117 | $Deal->name = $vouchers['title']; |
|
118 | $Deal->short_description = $vouchers['shortDescription']; |
|
119 | $Deal->description = $vouchers['description']; |
|
120 | $Deal->deal_type = $vouchers['voucherTypeId']; |
|
121 | $Deal->default_track_uri = $vouchers['defaultTrackUri']; |
|
122 | $Deal->default_track_uri = $vouchers['landingUrl']; |
|
123 | $Deal->discount_amount = $vouchers['discountAmount']; |
|
124 | $Deal->is_percentage = $vouchers['isPercentage']; |
|
125 | $Deal->currency_initial = $vouchers['currencyId']; |
|
126 | $Deal->logo_path = $vouchers['logoPath']; |
|
127 | if($merchantID > 0) { |
|
128 | if($vouchers['programId'] == $merchantID) { |
|
129 | $arrResult[] = $Deal; |
|
130 | } |
|
131 | } |
|
132 | else { |
|
133 | $arrResult[] = $Deal; |
|
134 | } |
|
135 | } |
|
136 | $result->deals[]=$arrResult; |
|
137 | return $result; |
|
138 | } |
|
139 | ||
140 | /** |
|
141 | * @param \DateTime $dateFrom |
@@ 103-143 (lines=41) @@ | ||
100 | * |
|
101 | * @return DealsResultset |
|
102 | */ |
|
103 | public function getDeals($merchantID,int $page=0,int $items_per_page=10) : DealsResultset |
|
104 | { |
|
105 | if (!isIntegerPositive($items_per_page)){ |
|
106 | $items_per_page=10; |
|
107 | } |
|
108 | $result=DealsResultset::createInstance(); |
|
109 | if (!$this->checkLogin()) { |
|
110 | return $result; |
|
111 | } |
|
112 | $arrResult = array(); |
|
113 | $jsonVouchers = file_get_contents("https://api.tradedoubler.com/1.0/vouchers.json;voucherTypeId=1?token=".$_ENV['TRADEDOUBLER_TOKEN']); |
|
114 | $arrVouchers = json_decode($jsonVouchers, true); |
|
115 | ||
116 | foreach($arrVouchers as $vouchers) { |
|
117 | $Deal = Deal::createInstance(); |
|
118 | $Deal->deal_ID = $vouchers['id']; |
|
119 | $Deal->merchant_ID = $vouchers['programId']; |
|
120 | $Deal->merchant_name = $vouchers['programName']; |
|
121 | $Deal->code = $vouchers['code']; |
|
122 | $Deal->name = $vouchers['title']; |
|
123 | $Deal->short_description = $vouchers['shortDescription']; |
|
124 | $Deal->description = $vouchers['description']; |
|
125 | $Deal->deal_type = $vouchers['voucherTypeId']; |
|
126 | $Deal->default_track_uri = $vouchers['defaultTrackUri']; |
|
127 | $Deal->default_track_uri = $vouchers['landingUrl']; |
|
128 | $Deal->discount_amount = $vouchers['discountAmount']; |
|
129 | $Deal->is_percentage = $vouchers['isPercentage']; |
|
130 | $Deal->currency_initial = $vouchers['currencyId']; |
|
131 | $Deal->logo_path = $vouchers['logoPath']; |
|
132 | if($merchantID > 0) { |
|
133 | if($vouchers['programId'] == $merchantID) { |
|
134 | $arrResult[] = $Deal; |
|
135 | } |
|
136 | } |
|
137 | else { |
|
138 | $arrResult[] = $Deal; |
|
139 | } |
|
140 | } |
|
141 | $result->deals[]=$arrResult; |
|
142 | return $result; |
|
143 | } |
|
144 | ||
145 | /** |
|
146 | * @param \DateTime $dateFrom |