1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Iris\Api; |
4
|
|
|
|
5
|
|
|
class PartnerClient extends BaseClient |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Partner Create Order on External Shop |
9
|
|
|
* |
10
|
|
|
* @param string $ventureCode |
11
|
|
|
* @param array $orderData |
12
|
|
|
* @return bool |
13
|
|
|
*/ |
14
|
2 |
|
public function createOrderOnVenture($ventureCode, $orderData) |
15
|
|
|
{ |
16
|
|
|
try { |
17
|
2 |
|
$this->doRequest( |
18
|
2 |
|
'post', |
19
|
2 |
|
$this->buildRequestUrl('/fulfillment/order/create', $ventureCode), |
20
|
2 |
|
array('body' => json_encode($orderData)) |
21
|
2 |
|
); |
22
|
2 |
|
} catch (\Exception $e) { |
23
|
1 |
|
$this->throwException( |
24
|
1 |
|
$e, |
|
|
|
|
25
|
1 |
|
'Unable to create order on Externalshop', |
|
|
|
|
26
|
1 |
|
['VentureCode' => $ventureCode, 'OrderData' => $orderData] |
27
|
1 |
|
); |
28
|
|
|
} |
29
|
2 |
|
return true; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Partner Confirm Paid Order on External Shop |
34
|
|
|
* |
35
|
|
|
* @param string $ventureCode |
36
|
|
|
* @param int $orderNumber |
37
|
|
|
* @return bool |
38
|
|
|
*/ |
39
|
2 |
|
public function confirmPaymentOnVenture($ventureCode, $orderNumber) |
40
|
|
|
{ |
41
|
|
|
try { |
42
|
2 |
|
$this->doRequest( |
43
|
2 |
|
'put', |
44
|
2 |
|
$this->buildRequestUrl(sprintf('/fulfillment/order/confirm/%s', $orderNumber), $ventureCode) |
45
|
2 |
|
); |
46
|
2 |
|
} catch (\Exception $e) { |
47
|
1 |
|
$this->throwException( |
48
|
1 |
|
$e, |
|
|
|
|
49
|
1 |
|
'Unable to confirm payment for venture on Externalshop', |
|
|
|
|
50
|
1 |
|
['VentureCode' => $ventureCode, 'OrderNr' => $orderNumber] |
51
|
1 |
|
); |
52
|
|
|
} |
53
|
2 |
|
return true; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Partner Cancel Order on External Shop |
58
|
|
|
* |
59
|
|
|
* @param string $ventureCode |
60
|
|
|
* @param int $orderNumber |
61
|
|
|
* @return bool |
62
|
|
|
*/ |
63
|
2 |
|
public function cancelOrderOnVenture($ventureCode, $orderNumber) |
64
|
|
|
{ |
65
|
|
|
try { |
66
|
2 |
|
$this->doRequest( |
67
|
2 |
|
'put', |
68
|
2 |
|
$this->buildRequestUrl(sprintf('/fulfillment/order/cancel/%s', $orderNumber), $ventureCode) |
69
|
2 |
|
); |
70
|
2 |
|
} catch (\Exception $e) { |
71
|
1 |
|
$this->throwException( |
72
|
1 |
|
$e, |
|
|
|
|
73
|
1 |
|
'Unable to cancel order on Externalshop', |
|
|
|
|
74
|
1 |
|
['VentureCode' => $ventureCode, 'OrderNr' => $orderNumber] |
75
|
1 |
|
); |
76
|
|
|
} |
77
|
2 |
|
return true; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Partner Confirm Paid Order on External Shop |
82
|
|
|
* @param string $ventureCode |
83
|
|
|
* @param int $orderNumber |
84
|
|
|
* @return bool |
85
|
|
|
*/ |
86
|
|
|
public function partnerConfirmPaymentForVenture($ventureCode, $orderNumber) |
87
|
|
|
{ |
88
|
|
|
try { |
89
|
|
|
$this->doRequest( |
90
|
|
|
'put', |
91
|
|
|
$this->buildRequestUrl(sprintf('/fulfillment/order/confirm/%s', $orderNumber), $ventureCode) |
92
|
|
|
); |
93
|
|
|
} catch (RequestException $e) { |
|
|
|
|
94
|
|
|
$this->throwException($e); |
95
|
|
|
} |
96
|
|
|
return true; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Partner Cancel Order on External Shop |
101
|
|
|
* @param string $ventureCode |
102
|
|
|
* @param int $orderNumber |
103
|
|
|
* @return bool |
104
|
|
|
*/ |
105
|
|
|
public function partnerCancelOrderOnVenture($ventureCode, $orderNumber) |
106
|
|
|
{ |
107
|
|
|
try { |
108
|
|
|
$this->doRequest( |
109
|
|
|
'put', |
110
|
|
|
$this->buildRequestUrl(sprintf('/fulfillment/order/cancel/%s', $orderNumber), $ventureCode) |
111
|
|
|
); |
112
|
|
|
} catch (RequestException $e) { |
|
|
|
|
113
|
|
|
$this->throwException($e); |
114
|
|
|
} |
115
|
|
|
return true; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param RequestException $e |
120
|
|
|
* @throw Iris_Service_Exception_RetryMessage |
121
|
|
|
*/ |
122
|
|
|
private function throwException(RequestException $e) |
123
|
|
|
{ |
124
|
|
|
Bob_Log::exception($e); |
125
|
|
|
$message = 'Try Again'; |
126
|
|
|
$code = 500; |
127
|
|
|
if ($e->hasResponse()) { |
128
|
|
|
$this->logResponse($e->getResponse()); |
129
|
|
|
$message = $e->getResponse()->getBody(); |
130
|
|
|
$code = $e->getResponse()->getStatusCode(); |
131
|
|
|
} |
132
|
|
|
throw new Iris_Service_Exception_RetryMessage($message, $code); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: