@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | const RESPONSE_TYPE = "code"; |
12 | 12 | |
13 | 13 | const HTTP_RESPONSE_STATUSES = [ |
14 | - 'success' => 200, |
|
15 | - 'failed' => 400, |
|
16 | - 'validationError' => 422, |
|
17 | - 'authenticationError' => 401, |
|
18 | - 'authorizationError' => 403, |
|
19 | - 'serverError' => 500, |
|
14 | + 'success' => 200, |
|
15 | + 'failed' => 400, |
|
16 | + 'validationError' => 422, |
|
17 | + 'authenticationError' => 401, |
|
18 | + 'authorizationError' => 403, |
|
19 | + 'serverError' => 500, |
|
20 | 20 | ]; |
21 | 21 | |
22 | 22 | const AUTH_GRANT_TYPE = "client_credentials"; |
@@ -31,31 +31,31 @@ discard block |
||
31 | 31 | const API_VERSION = 'v1'; |
32 | 32 | |
33 | 33 | const API_ENDPOINTS = [ |
34 | - 'oauth' => Constant::API_VERSION . '/oauth/token', |
|
35 | - 'create_order' => Constant::API_VERSION . '/order/create', |
|
36 | - 'order_status' => Constant::API_VERSION . '/order/status', |
|
37 | - 'verify_client' => Constant::API_VERSION . '/sso/verify-client', |
|
38 | - 'customer_profile' => Constant::API_VERSION . '/sso/customer/profile', |
|
34 | + 'oauth' => Constant::API_VERSION . '/oauth/token', |
|
35 | + 'create_order' => Constant::API_VERSION . '/order/create', |
|
36 | + 'order_status' => Constant::API_VERSION . '/order/status', |
|
37 | + 'verify_client' => Constant::API_VERSION . '/sso/verify-client', |
|
38 | + 'customer_profile' => Constant::API_VERSION . '/sso/customer/profile', |
|
39 | 39 | ]; |
40 | 40 | |
41 | 41 | const APP_ENVIRONMENT = [ |
42 | - 'live', |
|
43 | - 'sandbox', |
|
42 | + 'live', |
|
43 | + 'sandbox', |
|
44 | 44 | ]; |
45 | 45 | |
46 | 46 | const APP_TYPE = [ |
47 | - 'checkout' => 1, |
|
48 | - 'sdk' => 2, |
|
47 | + 'checkout' => 1, |
|
48 | + 'sdk' => 2, |
|
49 | 49 | ]; |
50 | 50 | |
51 | 51 | const OrderStatus = [ |
52 | - 'created' => 1, |
|
53 | - 'initiated' => 2, |
|
54 | - 'placed' => 3, |
|
55 | - 'awaiting-confirmation' => 4, |
|
56 | - 'canceled' => 5, |
|
57 | - 'expired' => 6, |
|
58 | - 'failed' => 7 |
|
52 | + 'created' => 1, |
|
53 | + 'initiated' => 2, |
|
54 | + 'placed' => 3, |
|
55 | + 'awaiting-confirmation' => 4, |
|
56 | + 'canceled' => 5, |
|
57 | + 'expired' => 6, |
|
58 | + 'failed' => 7 |
|
59 | 59 | ]; |
60 | 60 | |
61 | 61 | const BUILDERS_DASHBOARD_LINK = "http://builder.bsecure.pk/"; |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | |
30 | 30 | /** @var array The shipment object to be used for Create Order requests. */ |
31 | 31 | private static $shipment = [ |
32 | - "charges" => '', |
|
33 | - "method_name" => '', |
|
32 | + "charges" => '', |
|
33 | + "method_name" => '', |
|
34 | 34 | ]; |
35 | 35 | |
36 | 36 | /* @var string $orderPayload this variable is used for, setting payload for create order API call to bSecure server */ |
37 | 37 | private static $orderPayload = [ |
38 | - 'order_id' => null, |
|
39 | - 'customer' => null, |
|
40 | - 'products' => null, |
|
41 | - 'shipment_charges' => null, |
|
42 | - 'shipment_method_name' => null, |
|
43 | - 'sub_total_amount' => null, |
|
44 | - 'discount_amount' => null, |
|
45 | - 'total_amount' => null |
|
38 | + 'order_id' => null, |
|
39 | + 'customer' => null, |
|
40 | + 'products' => null, |
|
41 | + 'shipment_charges' => null, |
|
42 | + 'shipment_method_name' => null, |
|
43 | + 'sub_total_amount' => null, |
|
44 | + 'discount_amount' => null, |
|
45 | + 'total_amount' => null |
|
46 | 46 | ]; |
47 | 47 | |
48 | 48 | /** |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | $product_sub_total = ( $price + $options_price ) * $quantity; |
112 | 112 | |
113 | 113 | $orderItems[] = [ |
114 | - "id" => array_key_exists('id',$product) ? $product['id'] : null, |
|
115 | - "name" => array_key_exists('name',$product) ? $product['name'] : null, |
|
116 | - "sku" => array_key_exists('sku',$product) ? $product['sku'] : null, |
|
117 | - "quantity" => $quantity, |
|
118 | - "price" => $product_price, |
|
119 | - "sale_price" => $sale_price, |
|
120 | - "discount" => $discount, |
|
121 | - "sub_total" => $product_sub_total, |
|
122 | - "image" => array_key_exists('image',$product) ? $product['image'] : null, |
|
123 | - "short_description" => array_key_exists('short_description',$product) ? $product['short_description'] : null, |
|
124 | - "description" => array_key_exists('description',$product) ? $product['description'] : null, |
|
125 | - "product_options" => $options |
|
114 | + "id" => array_key_exists('id',$product) ? $product['id'] : null, |
|
115 | + "name" => array_key_exists('name',$product) ? $product['name'] : null, |
|
116 | + "sku" => array_key_exists('sku',$product) ? $product['sku'] : null, |
|
117 | + "quantity" => $quantity, |
|
118 | + "price" => $product_price, |
|
119 | + "sale_price" => $sale_price, |
|
120 | + "discount" => $discount, |
|
121 | + "sub_total" => $product_sub_total, |
|
122 | + "image" => array_key_exists('image',$product) ? $product['image'] : null, |
|
123 | + "short_description" => array_key_exists('short_description',$product) ? $product['short_description'] : null, |
|
124 | + "description" => array_key_exists('description',$product) ? $product['description'] : null, |
|
125 | + "product_options" => $options |
|
126 | 126 | ]; |
127 | 127 | } |
128 | 128 | |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | if( !empty( $auth_code ) ) |
155 | 155 | { |
156 | 156 | $customer = [ |
157 | - "auth_code" => $auth_code, |
|
157 | + "auth_code" => $auth_code, |
|
158 | 158 | ];; |
159 | 159 | } |
160 | 160 | else{ |
161 | 161 | $customer = [ |
162 | - "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
|
163 | - "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
|
164 | - "name" => array_key_exists('name',$customerData) ? $customerData['name'] : '', |
|
165 | - "email" => array_key_exists('email',$customerData) ? $customerData['email'] : '', |
|
162 | + "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
|
163 | + "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
|
164 | + "name" => array_key_exists('name',$customerData) ? $customerData['name'] : '', |
|
165 | + "email" => array_key_exists('email',$customerData) ? $customerData['email'] : '', |
|
166 | 166 | ]; |
167 | 167 | } |
168 | 168 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | private static function _setShipmentDetails($shipmentData) |
174 | 174 | { |
175 | 175 | $shipmentDetail = [ |
176 | - "charges" => '', |
|
177 | - "method_name" => '', |
|
176 | + "charges" => '', |
|
177 | + "method_name" => '', |
|
178 | 178 | ]; |
179 | 179 | if(!empty($shipmentData)) |
180 | 180 | { |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | return [ |
210 | - 'price' => $price, |
|
211 | - 'options' => $product_options |
|
210 | + 'price' => $price, |
|
211 | + 'options' => $product_options |
|
212 | 212 | ]; |
213 | 213 | } |
214 | 214 | |
@@ -217,34 +217,34 @@ discard block |
||
217 | 217 | if(!self::$chargesDefinition) |
218 | 218 | { |
219 | 219 | $msg = 'No charges provided. (HINT: set your sub_total, discount and total amount using ' |
220 | - . '"bSecure::setCharges(<ARRAY>). See"' |
|
221 | - . Constant::DOCUMENTATION_LINK.' for details, ' |
|
222 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
220 | + . '"bSecure::setCharges(<ARRAY>). See"' |
|
221 | + . Constant::DOCUMENTATION_LINK.' for details, ' |
|
222 | + . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
223 | 223 | throw new Exception\UnexpectedValueException($msg); |
224 | 224 | }else if(!self::$productsDefinition) |
225 | 225 | { |
226 | 226 | $msg = 'No cart_items provided. (HINT: set your cart_items using ' |
227 | - . '"bSecure::setCartItems(<ARRAY>). See"' |
|
228 | - . Constant::DOCUMENTATION_LINK.' for details, ' |
|
229 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
227 | + . '"bSecure::setCartItems(<ARRAY>). See"' |
|
228 | + . Constant::DOCUMENTATION_LINK.' for details, ' |
|
229 | + . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
230 | 230 | throw new Exception\UnexpectedValueException($msg); |
231 | 231 | }else if(!self::$customerDefinition) |
232 | 232 | { |
233 | 233 | $msg = 'No customer_details provided. (HINT: set your customer_details using ' |
234 | - . '"bSecure::setCustomer(<ARRAY>). See"' |
|
235 | - . Constant::DOCUMENTATION_LINK.' for details, ' |
|
236 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
234 | + . '"bSecure::setCustomer(<ARRAY>). See"' |
|
235 | + . Constant::DOCUMENTATION_LINK.' for details, ' |
|
236 | + . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
237 | 237 | throw new Exception\UnexpectedValueException($msg); |
238 | 238 | }else{ |
239 | 239 | self::$orderPayload = [ |
240 | - 'order_id' => self::$orderId, |
|
241 | - 'customer' => self::$customer, |
|
242 | - 'products' => self::$products, |
|
243 | - 'shipment_charges' => self::$shipment['charges'], |
|
244 | - 'shipment_method_name' => self::$shipment['method_name'], |
|
245 | - 'sub_total_amount' => self::$sub_total_amount, |
|
246 | - 'discount_amount' => self::$discount_amount, |
|
247 | - 'total_amount' => self::$total_amount |
|
240 | + 'order_id' => self::$orderId, |
|
241 | + 'customer' => self::$customer, |
|
242 | + 'products' => self::$products, |
|
243 | + 'shipment_charges' => self::$shipment['charges'], |
|
244 | + 'shipment_method_name' => self::$shipment['method_name'], |
|
245 | + 'sub_total_amount' => self::$sub_total_amount, |
|
246 | + 'discount_amount' => self::$discount_amount, |
|
247 | + 'total_amount' => self::$total_amount |
|
248 | 248 | ]; |
249 | 249 | return self::$orderPayload; |
250 | 250 | } |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | self::_setOrderPayload(); |
266 | 266 | |
267 | 267 | $msg = 'No auth_token provided. (HINT: set your auth_token using ' |
268 | - . '"bSecure::setAuthToken()". See ' |
|
269 | - . Constant::DOCUMENTATION_LINK.', for details, ' |
|
270 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
268 | + . '"bSecure::setAuthToken()". See ' |
|
269 | + . Constant::DOCUMENTATION_LINK.', for details, ' |
|
270 | + . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
271 | 271 | $access_token = bSecure::getAuthToken(); |
272 | 272 | if($access_token == null) |
273 | 273 | throw new Exception\AuthenticationException($msg); |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | if($order_ref == null || $order_ref == "") |
291 | 291 | { |
292 | 292 | $msg = 'No order_ref provided. See"' |
293 | - . Constant::DOCUMENTATION_LINK.' for details, ' |
|
294 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
293 | + . Constant::DOCUMENTATION_LINK.' for details, ' |
|
294 | + . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
295 | 295 | throw new Exception\UnexpectedValueException($msg); |
296 | 296 | } |
297 | 297 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public static function setOrderId($orderId) |
54 | 54 | { |
55 | - self::$orderIdDefinition =true; |
|
55 | + self::$orderIdDefinition = true; |
|
56 | 56 | self::$orderId = $orderId; |
57 | 57 | } |
58 | 58 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public static function setCustomer($customerData) |
64 | 64 | { |
65 | - self::$customerDefinition =true; |
|
65 | + self::$customerDefinition = true; |
|
66 | 66 | $customer = self::_setCustomer($customerData); |
67 | 67 | self::$customer = $customer; |
68 | 68 | } |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | { |
91 | 91 | $orderItems = []; |
92 | 92 | |
93 | - if(!empty($products)) |
|
93 | + if (!empty($products)) |
|
94 | 94 | { |
95 | 95 | foreach ($products as $key => $product) { |
96 | 96 | //Product Price |
97 | - $price = array_key_exists('price',$product) ? $product['price'] : 0; |
|
98 | - $sale_price = array_key_exists('sale_price',$product) ? $product['sale_price'] : 0; |
|
99 | - $quantity = array_key_exists('quantity',$product) ? $product['quantity'] : 1; |
|
97 | + $price = array_key_exists('price', $product) ? $product['price'] : 0; |
|
98 | + $sale_price = array_key_exists('sale_price', $product) ? $product['sale_price'] : 0; |
|
99 | + $quantity = array_key_exists('quantity', $product) ? $product['quantity'] : 1; |
|
100 | 100 | |
101 | 101 | //Product options |
102 | 102 | $product_options = self::_setProductOptionsDataStructure($product); |
@@ -106,29 +106,29 @@ discard block |
||
106 | 106 | |
107 | 107 | |
108 | 108 | #Product charges |
109 | - $discount = ( $price - $sale_price ) * $quantity; |
|
110 | - $product_price = ( $price + $options_price ) * $quantity; |
|
111 | - $product_sub_total = ( $price + $options_price ) * $quantity; |
|
109 | + $discount = ($price - $sale_price) * $quantity; |
|
110 | + $product_price = ($price + $options_price) * $quantity; |
|
111 | + $product_sub_total = ($price + $options_price) * $quantity; |
|
112 | 112 | |
113 | 113 | $orderItems[] = [ |
114 | - "id" => array_key_exists('id',$product) ? $product['id'] : null, |
|
115 | - "name" => array_key_exists('name',$product) ? $product['name'] : null, |
|
116 | - "sku" => array_key_exists('sku',$product) ? $product['sku'] : null, |
|
114 | + "id" => array_key_exists('id', $product) ? $product['id'] : null, |
|
115 | + "name" => array_key_exists('name', $product) ? $product['name'] : null, |
|
116 | + "sku" => array_key_exists('sku', $product) ? $product['sku'] : null, |
|
117 | 117 | "quantity" => $quantity, |
118 | 118 | "price" => $product_price, |
119 | 119 | "sale_price" => $sale_price, |
120 | 120 | "discount" => $discount, |
121 | 121 | "sub_total" => $product_sub_total, |
122 | - "image" => array_key_exists('image',$product) ? $product['image'] : null, |
|
123 | - "short_description" => array_key_exists('short_description',$product) ? $product['short_description'] : null, |
|
124 | - "description" => array_key_exists('description',$product) ? $product['description'] : null, |
|
122 | + "image" => array_key_exists('image', $product) ? $product['image'] : null, |
|
123 | + "short_description" => array_key_exists('short_description', $product) ? $product['short_description'] : null, |
|
124 | + "description" => array_key_exists('description', $product) ? $product['description'] : null, |
|
125 | 125 | "product_options" => $options |
126 | 126 | ]; |
127 | 127 | } |
128 | 128 | |
129 | 129 | } |
130 | 130 | self::$products = $orderItems; |
131 | - self::$productsDefinition =true; |
|
131 | + self::$productsDefinition = true; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -141,28 +141,28 @@ discard block |
||
141 | 141 | self::$sub_total_amount = array_key_exists('sub_total', $orderCharges) ? $orderCharges['sub_total'] : 0; |
142 | 142 | self::$discount_amount = array_key_exists('discount', $orderCharges) ? $orderCharges['discount'] : 0; |
143 | 143 | self::$total_amount = array_key_exists('total', $orderCharges) ? $orderCharges['total'] : 0; |
144 | - self::$chargesDefinition =true; |
|
144 | + self::$chargesDefinition = true; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | private static function _setCustomer($customerData) |
148 | 148 | { |
149 | 149 | $customer = []; |
150 | - if(!empty($customerData)) |
|
150 | + if (!empty($customerData)) |
|
151 | 151 | { |
152 | - $auth_code = array_key_exists('auth_code',$customerData) ? $customerData['auth_code'] : '' ; |
|
152 | + $auth_code = array_key_exists('auth_code', $customerData) ? $customerData['auth_code'] : ''; |
|
153 | 153 | |
154 | - if( !empty( $auth_code ) ) |
|
154 | + if (!empty($auth_code)) |
|
155 | 155 | { |
156 | 156 | $customer = [ |
157 | 157 | "auth_code" => $auth_code, |
158 | - ];; |
|
158 | + ]; ; |
|
159 | 159 | } |
160 | - else{ |
|
160 | + else { |
|
161 | 161 | $customer = [ |
162 | - "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
|
163 | - "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
|
164 | - "name" => array_key_exists('name',$customerData) ? $customerData['name'] : '', |
|
165 | - "email" => array_key_exists('email',$customerData) ? $customerData['email'] : '', |
|
162 | + "country_code" => array_key_exists('country_code', $customerData) ? $customerData['country_code'] : '', |
|
163 | + "phone_number" => array_key_exists('phone_number', $customerData) ? $customerData['phone_number'] : '', |
|
164 | + "name" => array_key_exists('name', $customerData) ? $customerData['name'] : '', |
|
165 | + "email" => array_key_exists('email', $customerData) ? $customerData['email'] : '', |
|
166 | 166 | ]; |
167 | 167 | } |
168 | 168 | } |
@@ -176,28 +176,28 @@ discard block |
||
176 | 176 | "charges" => '', |
177 | 177 | "method_name" => '', |
178 | 178 | ]; |
179 | - if(!empty($shipmentData)) |
|
179 | + if (!empty($shipmentData)) |
|
180 | 180 | { |
181 | - $shipmentDetail['charges'] = array_key_exists('charges',$shipmentData) ? $shipmentData['charges'] : ''; |
|
182 | - $shipmentDetail['method_name'] = array_key_exists('method_name',$shipmentData) ? $shipmentData['method_name'] : ''; |
|
181 | + $shipmentDetail['charges'] = array_key_exists('charges', $shipmentData) ? $shipmentData['charges'] : ''; |
|
182 | + $shipmentDetail['method_name'] = array_key_exists('method_name', $shipmentData) ? $shipmentData['method_name'] : ''; |
|
183 | 183 | } |
184 | 184 | return $shipmentDetail; |
185 | 185 | } |
186 | 186 | |
187 | 187 | private static function _setProductOptionsDataStructure($product) |
188 | 188 | { |
189 | - $product_options = array_key_exists('product_options',$product) ? $product['product_options'] : []; |
|
189 | + $product_options = array_key_exists('product_options', $product) ? $product['product_options'] : []; |
|
190 | 190 | |
191 | 191 | $price = 0; |
192 | - if( isset($product_options) && !empty($product_options) ) |
|
192 | + if (isset($product_options) && !empty($product_options)) |
|
193 | 193 | { |
194 | - foreach( $product_options as $productOption ) |
|
194 | + foreach ($product_options as $productOption) |
|
195 | 195 | { |
196 | - $productValue = array_key_exists('value',$productOption) ? $productOption['value'] : []; |
|
197 | - foreach( $productValue as $key => $optionValue ) |
|
196 | + $productValue = array_key_exists('value', $productOption) ? $productOption['value'] : []; |
|
197 | + foreach ($productValue as $key => $optionValue) |
|
198 | 198 | { |
199 | - $optionPrice = array_key_exists('price',$optionValue) ? $optionValue['price'] : []; |
|
200 | - if(!empty($optionPrice)) |
|
199 | + $optionPrice = array_key_exists('price', $optionValue) ? $optionValue['price'] : []; |
|
200 | + if (!empty($optionPrice)) |
|
201 | 201 | { |
202 | 202 | #Price ++ |
203 | 203 | $price += $optionPrice; |
@@ -214,28 +214,28 @@ discard block |
||
214 | 214 | |
215 | 215 | private static function _setOrderPayload() |
216 | 216 | { |
217 | - if(!self::$chargesDefinition) |
|
217 | + if (!self::$chargesDefinition) |
|
218 | 218 | { |
219 | 219 | $msg = 'No charges provided. (HINT: set your sub_total, discount and total amount using ' |
220 | 220 | . '"bSecure::setCharges(<ARRAY>). See"' |
221 | - . Constant::DOCUMENTATION_LINK.' for details, ' |
|
222 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
221 | + . Constant::DOCUMENTATION_LINK . ' for details, ' |
|
222 | + . 'or email ' . Constant::SUPPORT_EMAIL . ' if you have any questions.'; |
|
223 | 223 | throw new Exception\UnexpectedValueException($msg); |
224 | - }else if(!self::$productsDefinition) |
|
224 | + } else if (!self::$productsDefinition) |
|
225 | 225 | { |
226 | 226 | $msg = 'No cart_items provided. (HINT: set your cart_items using ' |
227 | 227 | . '"bSecure::setCartItems(<ARRAY>). See"' |
228 | - . Constant::DOCUMENTATION_LINK.' for details, ' |
|
229 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
228 | + . Constant::DOCUMENTATION_LINK . ' for details, ' |
|
229 | + . 'or email ' . Constant::SUPPORT_EMAIL . ' if you have any questions.'; |
|
230 | 230 | throw new Exception\UnexpectedValueException($msg); |
231 | - }else if(!self::$customerDefinition) |
|
231 | + } else if (!self::$customerDefinition) |
|
232 | 232 | { |
233 | 233 | $msg = 'No customer_details provided. (HINT: set your customer_details using ' |
234 | 234 | . '"bSecure::setCustomer(<ARRAY>). See"' |
235 | - . Constant::DOCUMENTATION_LINK.' for details, ' |
|
236 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
235 | + . Constant::DOCUMENTATION_LINK . ' for details, ' |
|
236 | + . 'or email ' . Constant::SUPPORT_EMAIL . ' if you have any questions.'; |
|
237 | 237 | throw new Exception\UnexpectedValueException($msg); |
238 | - }else{ |
|
238 | + } else { |
|
239 | 239 | self::$orderPayload = [ |
240 | 240 | 'order_id' => self::$orderId, |
241 | 241 | 'customer' => self::$customer, |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | |
267 | 267 | $msg = 'No auth_token provided. (HINT: set your auth_token using ' |
268 | 268 | . '"bSecure::setAuthToken()". See ' |
269 | - . Constant::DOCUMENTATION_LINK.', for details, ' |
|
270 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
269 | + . Constant::DOCUMENTATION_LINK . ', for details, ' |
|
270 | + . 'or email ' . Constant::SUPPORT_EMAIL . ' if you have any questions.'; |
|
271 | 271 | $access_token = bSecure::getAuthToken(); |
272 | - if($access_token == null) |
|
272 | + if ($access_token == null) |
|
273 | 273 | throw new Exception\AuthenticationException($msg); |
274 | - else{ |
|
274 | + else { |
|
275 | 275 | return OrderController::createOrder(self::$orderPayload); |
276 | 276 | } |
277 | 277 | } |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public static function orderStatus($order_ref) |
289 | 289 | { |
290 | - if($order_ref == null || $order_ref == "") |
|
290 | + if ($order_ref == null || $order_ref == "") |
|
291 | 291 | { |
292 | 292 | $msg = 'No order_ref provided. See"' |
293 | - . Constant::DOCUMENTATION_LINK.' for details, ' |
|
294 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
293 | + . Constant::DOCUMENTATION_LINK . ' for details, ' |
|
294 | + . 'or email ' . Constant::SUPPORT_EMAIL . ' if you have any questions.'; |
|
295 | 295 | throw new Exception\UnexpectedValueException($msg); |
296 | 296 | } |
297 | 297 |
@@ -156,8 +156,7 @@ discard block |
||
156 | 156 | $customer = [ |
157 | 157 | "auth_code" => $auth_code, |
158 | 158 | ];; |
159 | - } |
|
160 | - else{ |
|
159 | + } else{ |
|
161 | 160 | $customer = [ |
162 | 161 | "country_code" => array_key_exists('country_code',$customerData) ? $customerData['country_code'] : '', |
163 | 162 | "phone_number" => array_key_exists('phone_number',$customerData) ? $customerData['phone_number'] : '', |
@@ -221,21 +220,21 @@ discard block |
||
221 | 220 | . Constant::DOCUMENTATION_LINK.' for details, ' |
222 | 221 | . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
223 | 222 | throw new Exception\UnexpectedValueException($msg); |
224 | - }else if(!self::$productsDefinition) |
|
223 | + } else if(!self::$productsDefinition) |
|
225 | 224 | { |
226 | 225 | $msg = 'No cart_items provided. (HINT: set your cart_items using ' |
227 | 226 | . '"bSecure::setCartItems(<ARRAY>). See"' |
228 | 227 | . Constant::DOCUMENTATION_LINK.' for details, ' |
229 | 228 | . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
230 | 229 | throw new Exception\UnexpectedValueException($msg); |
231 | - }else if(!self::$customerDefinition) |
|
230 | + } else if(!self::$customerDefinition) |
|
232 | 231 | { |
233 | 232 | $msg = 'No customer_details provided. (HINT: set your customer_details using ' |
234 | 233 | . '"bSecure::setCustomer(<ARRAY>). See"' |
235 | 234 | . Constant::DOCUMENTATION_LINK.' for details, ' |
236 | 235 | . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
237 | 236 | throw new Exception\UnexpectedValueException($msg); |
238 | - }else{ |
|
237 | + } else{ |
|
239 | 238 | self::$orderPayload = [ |
240 | 239 | 'order_id' => self::$orderId, |
241 | 240 | 'customer' => self::$customer, |
@@ -269,9 +268,9 @@ discard block |
||
269 | 268 | . Constant::DOCUMENTATION_LINK.', for details, ' |
270 | 269 | . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
271 | 270 | $access_token = bSecure::getAuthToken(); |
272 | - if($access_token == null) |
|
273 | - throw new Exception\AuthenticationException($msg); |
|
274 | - else{ |
|
271 | + if($access_token == null) { |
|
272 | + throw new Exception\AuthenticationException($msg); |
|
273 | + } else{ |
|
275 | 274 | return OrderController::createOrder(self::$orderPayload); |
276 | 275 | } |
277 | 276 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | { |
20 | 20 | $requestor = new ApiRequest(); |
21 | 21 | $response = $requestor->request( |
22 | - 'post', |
|
23 | - Constant::API_ENDPOINTS['create_order'], |
|
24 | - $orderPayload, |
|
25 | - Constant::YES |
|
22 | + 'post', |
|
23 | + Constant::API_ENDPOINTS['create_order'], |
|
24 | + $orderPayload, |
|
25 | + Constant::YES |
|
26 | 26 | ); |
27 | 27 | return $response[0]; |
28 | 28 | } |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @throws \bSecure\ApiResponse if the request fails |
36 | 36 | * @return \bSecure\ApiResponse |
37 | - */ |
|
37 | + */ |
|
38 | 38 | |
39 | 39 | public static function orderStatus($orderRef) |
40 | 40 | { |
41 | 41 | $requestor = new ApiRequest(); |
42 | 42 | $response = $requestor->request( |
43 | - 'post', |
|
44 | - Constant::API_ENDPOINTS['order_status'], |
|
45 | - ['order_ref' => $orderRef], |
|
46 | - Constant::YES |
|
43 | + 'post', |
|
44 | + Constant::API_ENDPOINTS['order_status'], |
|
45 | + ['order_ref' => $orderRef], |
|
46 | + Constant::YES |
|
47 | 47 | ); |
48 | 48 | return $response[0]; |
49 | 49 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | * @return InvalidRequestException |
22 | 22 | */ |
23 | 23 | public static function factory( |
24 | - $message, |
|
25 | - $httpStatus = null, |
|
26 | - $httpBody = null, |
|
27 | - $jsonBody = null, |
|
28 | - $httpHeaders = null, |
|
29 | - $Code = null |
|
24 | + $message, |
|
25 | + $httpStatus = null, |
|
26 | + $httpBody = null, |
|
27 | + $jsonBody = null, |
|
28 | + $httpHeaders = null, |
|
29 | + $Code = null |
|
30 | 30 | ) { |
31 | 31 | var_dump($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders); |
32 | 32 | $message = is_array($message) ? implode (", ", $message) : $message; |
@@ -30,7 +30,7 @@ |
||
30 | 30 | ) { |
31 | 31 | var_dump($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders); |
32 | 32 | $message = is_array($message) ? implode (", ", $message) : $message; |
33 | - $instance = parent::factory($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders,$Code); |
|
33 | + $instance = parent::factory($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders, $Code); |
|
34 | 34 | return $instance; |
35 | 35 | } |
36 | 36 | } |
37 | 37 | \ No newline at end of file |
@@ -28,12 +28,12 @@ |
||
28 | 28 | * @return static |
29 | 29 | */ |
30 | 30 | public static function factory( |
31 | - $message, |
|
32 | - $httpStatus = null, |
|
33 | - $httpBody = null, |
|
34 | - $jsonBody = null, |
|
35 | - $httpHeaders = null, |
|
36 | - $code = null |
|
31 | + $message, |
|
32 | + $httpStatus = null, |
|
33 | + $httpBody = null, |
|
34 | + $jsonBody = null, |
|
35 | + $httpHeaders = null, |
|
36 | + $code = null |
|
37 | 37 | ) { |
38 | 38 | $instance = new static($message); |
39 | 39 | $instance->setHttpStatus($httpStatus); |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @param null|array $message |
34 | 34 | * @param null|array $exception |
35 | 35 | */ |
36 | - public function __construct( $body, $status, $message, $exception) |
|
36 | + public function __construct($body, $status, $message, $exception) |
|
37 | 37 | { |
38 | 38 | $this->body = $body; |
39 | 39 | $this->status = $status; |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | { |
86 | 86 | $curlVersion = \curl_version(); |
87 | 87 | $this->userAgentInfo = [ |
88 | - 'httplib' => 'curl ' . $curlVersion['version'], |
|
89 | - 'ssllib' => $curlVersion['ssl_version'], |
|
88 | + 'httplib' => 'curl ' . $curlVersion['version'], |
|
89 | + 'ssllib' => $curlVersion['ssl_version'], |
|
90 | 90 | ]; |
91 | 91 | } |
92 | 92 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | $opts[\CURLOPT_POSTFIELDS] = http_build_query($params); |
212 | 212 | $opts[\CURLOPT_VERBOSE] = true; |
213 | 213 | $optsHeaders = [ |
214 | - 'X-HTTP-Method-Override: POST', |
|
215 | - 'Content-Type:application/x-www-form-urlencoded', |
|
216 | - 'Content-Length: ' . strlen(http_build_query($params)) |
|
214 | + 'X-HTTP-Method-Override: POST', |
|
215 | + 'Content-Type:application/x-www-form-urlencoded', |
|
216 | + 'Content-Length: ' . strlen(http_build_query($params)) |
|
217 | 217 | ]; |
218 | 218 | } else { |
219 | 219 | throw new Exception\UnexpectedValueException("Unrecognized method {$method}"); |
@@ -280,22 +280,22 @@ discard block |
||
280 | 280 | case \CURLE_COULDNT_RESOLVE_HOST: |
281 | 281 | case \CURLE_OPERATION_TIMEOUTED: |
282 | 282 | $msg = "Could not connect to bSecure ({$url}). Please check your " |
283 | - . 'internet connection and try again, or'; |
|
283 | + . 'internet connection and try again, or'; |
|
284 | 284 | |
285 | 285 | break; |
286 | 286 | |
287 | 287 | case \CURLE_SSL_CACERT: |
288 | 288 | case \CURLE_SSL_PEER_CERTIFICATE: |
289 | 289 | $msg = "Could not verify bSecure's SSL certificate. Please make sure " |
290 | - . 'that your network is not intercepting certificates. ' |
|
291 | - . "(Try going to {$url} in your browser.) " |
|
292 | - . 'If this problem persists,'; |
|
290 | + . 'that your network is not intercepting certificates. ' |
|
291 | + . "(Try going to {$url} in your browser.) " |
|
292 | + . 'If this problem persists,'; |
|
293 | 293 | |
294 | 294 | break; |
295 | 295 | |
296 | 296 | default: |
297 | 297 | $msg = 'Unexpected error communicating with bSecure. ' |
298 | - . 'If this problem persists,'; |
|
298 | + . 'If this problem persists,'; |
|
299 | 299 | } |
300 | 300 | $msg .= ' let us know at '.Constant::SUPPORT_EMAIL.'.'; |
301 | 301 |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | $optsHeaders = [ |
214 | 214 | 'X-HTTP-Method-Override: POST', |
215 | 215 | 'Content-Type:application/x-www-form-urlencoded', |
216 | - 'Content-Length: ' . strlen(http_build_query($params)) |
|
216 | + 'Content-Length: ' . strlen(http_build_query($params)) |
|
217 | 217 | ]; |
218 | 218 | } else { |
219 | 219 | throw new Exception\UnexpectedValueException("Unrecognized method {$method}"); |
220 | 220 | } |
221 | 221 | |
222 | 222 | $opts[\CURLOPT_URL] = $absUrl; |
223 | - $opts[\CURLOPT_HTTPHEADER] = array_merge($optsHeaders,$headers); |
|
223 | + $opts[\CURLOPT_HTTPHEADER] = array_merge($optsHeaders, $headers); |
|
224 | 224 | list($rbody, $rcode, $rheaders) = $this->executeRequestWithRetries($opts, $absUrl); |
225 | 225 | |
226 | 226 | return [$rbody, $rcode, $rheaders]; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $msg = 'Unexpected error communicating with bSecure. ' |
298 | 298 | . 'If this problem persists,'; |
299 | 299 | } |
300 | - $msg .= ' let us know at '.Constant::SUPPORT_EMAIL.'.'; |
|
300 | + $msg .= ' let us know at ' . Constant::SUPPORT_EMAIL . '.'; |
|
301 | 301 | |
302 | 302 | $msg .= "\n\n(Network error [errno {$errno}]: {$message})"; |
303 | 303 |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | |
27 | 27 | $requestor = new ApiRequest(); |
28 | 28 | $response = $requestor->request( |
29 | - 'post', |
|
30 | - Constant::API_ENDPOINTS['oauth'], |
|
31 | - $credentials, |
|
32 | - Constant::NO |
|
29 | + 'post', |
|
30 | + Constant::API_ENDPOINTS['oauth'], |
|
31 | + $credentials, |
|
32 | + Constant::NO |
|
33 | 33 | ); |
34 | 34 | return $response[0]; |
35 | 35 | } |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | } |
45 | 45 | if (null === $clientId) { |
46 | 46 | $msg = 'No client_id provided. (HINT: set your client_id using ' |
47 | - . '"bSecure::setClientId(<CLIENT-ID>)". You can find your client_ids ' |
|
48 | - . 'in your bSecure Builder\'s dashboard at ' |
|
49 | - . Constant::BUILDERS_DASHBOARD_LINK.', ' |
|
50 | - . 'after registering your account as a platform. See ' |
|
51 | - . '.Constant::SUPPORT_EMAIL.'.' for details, ' |
|
52 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
47 | + . '"bSecure::setClientId(<CLIENT-ID>)". You can find your client_ids ' |
|
48 | + . 'in your bSecure Builder\'s dashboard at ' |
|
49 | + . Constant::BUILDERS_DASHBOARD_LINK.', ' |
|
50 | + . 'after registering your account as a platform. See ' |
|
51 | + . '.Constant::SUPPORT_EMAIL.'.' for details, ' |
|
52 | + . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
53 | 53 | throw new Exception\AuthenticationException($msg); |
54 | 54 | } |
55 | 55 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | } |
68 | 68 | if (null === $clientSecret) { |
69 | 69 | $msg = 'No client_secret provided. (HINT: set your client_secret using ' |
70 | - . '"bSecure::setClientSecret(<CLIENT-SECRET>)". You can find your client_secrets ' |
|
71 | - . 'in your bSecure Builder\'s dashboard at ' |
|
72 | - . Constant::BUILDERS_DASHBOARD_LINK.', ' |
|
73 | - . 'after registering your account as a platform. See ' |
|
74 | - . Constant::INTEGRATION_TAB_LINK.','.' for details, ' |
|
75 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
70 | + . '"bSecure::setClientSecret(<CLIENT-SECRET>)". You can find your client_secrets ' |
|
71 | + . 'in your bSecure Builder\'s dashboard at ' |
|
72 | + . Constant::BUILDERS_DASHBOARD_LINK.', ' |
|
73 | + . 'after registering your account as a platform. See ' |
|
74 | + . Constant::INTEGRATION_TAB_LINK.','.' for details, ' |
|
75 | + . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
76 | 76 | |
77 | 77 | throw new Exception\AuthenticationException($msg); |
78 | 78 | } |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | private static function verifyAppCredentials() |
84 | 84 | { |
85 | 85 | return [ |
86 | - "grant_type"=> self::GRANT_TYPE, |
|
87 | - 'client_id' => self::_getClientId(), |
|
88 | - 'client_secret' => self::_getClientSecret(), |
|
86 | + "grant_type"=> self::GRANT_TYPE, |
|
87 | + 'client_id' => self::_getClientId(), |
|
88 | + 'client_secret' => self::_getClientSecret(), |
|
89 | 89 | ]; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | $msg = 'No client_id provided. (HINT: set your client_id using ' |
47 | 47 | . '"bSecure::setClientId(<CLIENT-ID>)". You can find your client_ids ' |
48 | 48 | . 'in your bSecure Builder\'s dashboard at ' |
49 | - . Constant::BUILDERS_DASHBOARD_LINK.', ' |
|
49 | + . Constant::BUILDERS_DASHBOARD_LINK . ', ' |
|
50 | 50 | . 'after registering your account as a platform. See ' |
51 | - . '.Constant::SUPPORT_EMAIL.'.' for details, ' |
|
52 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
51 | + . '.Constant::SUPPORT_EMAIL.' . ' for details, ' |
|
52 | + . 'or email ' . Constant::SUPPORT_EMAIL . ' if you have any questions.'; |
|
53 | 53 | throw new Exception\AuthenticationException($msg); |
54 | 54 | } |
55 | 55 | |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | $msg = 'No client_secret provided. (HINT: set your client_secret using ' |
70 | 70 | . '"bSecure::setClientSecret(<CLIENT-SECRET>)". You can find your client_secrets ' |
71 | 71 | . 'in your bSecure Builder\'s dashboard at ' |
72 | - . Constant::BUILDERS_DASHBOARD_LINK.', ' |
|
72 | + . Constant::BUILDERS_DASHBOARD_LINK . ', ' |
|
73 | 73 | . 'after registering your account as a platform. See ' |
74 | - . Constant::INTEGRATION_TAB_LINK.','.' for details, ' |
|
75 | - . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
|
74 | + . Constant::INTEGRATION_TAB_LINK . ',' . ' for details, ' |
|
75 | + . 'or email ' . Constant::SUPPORT_EMAIL . ' if you have any questions.'; |
|
76 | 76 | |
77 | 77 | throw new Exception\AuthenticationException($msg); |
78 | 78 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $params = $params ?: []; |
48 | 48 | list($rcode, $rbody, $rheaders) = |
49 | - $this->_requestRaw($method, $url, $params, $authKey); |
|
49 | + $this->_requestRaw($method, $url, $params, $authKey); |
|
50 | 50 | list($message, $exception, $rbody) = $this->_interpretResponse( $rcode,$rbody, $rheaders); |
51 | 51 | |
52 | 52 | $resp = new ApiResponse($rbody, $rcode, $message, $exception); |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $rawHeaders[] = $header . ': ' . $value; |
103 | 103 | } |
104 | 104 | list($rbody, $rcode, $rheaders) = $this->httpClient()->request( |
105 | - $method, |
|
106 | - $absUrl, |
|
107 | - $rawHeaders, |
|
108 | - $params, |
|
109 | - false |
|
105 | + $method, |
|
106 | + $absUrl, |
|
107 | + $rawHeaders, |
|
108 | + $params, |
|
109 | + false |
|
110 | 110 | ); |
111 | 111 | return [$rbody, $rcode, $rheaders]; |
112 | 112 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | if (null === $resp && \JSON_ERROR_NONE !== $jsonError) { |
130 | 130 | $msg = "Invalid response body from API: {$rbody} " |
131 | - . "(HTTP response code was {$rcode}, json_last_error() was {$jsonError})"; |
|
131 | + . "(HTTP response code was {$rcode}, json_last_error() was {$jsonError})"; |
|
132 | 132 | throw new Exception\UnexpectedValueException($msg, $rcode); |
133 | 133 | } |
134 | 134 | $message = $resp['message']; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | }else{ |
157 | 157 | if (!\is_array($resp) || !isset($resp['error'])) { |
158 | 158 | $msg = "Invalid response object from API: {$rbody} " |
159 | - . "(HTTP response code was {$rcode})"; |
|
159 | + . "(HTTP response code was {$rcode})"; |
|
160 | 160 | |
161 | 161 | throw new Exception\UnexpectedValueException($msg); |
162 | 162 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param null|string $apiBase |
26 | 26 | */ |
27 | - public function __construct( $apiBase = null) |
|
27 | + public function __construct($apiBase = null) |
|
28 | 28 | { |
29 | 29 | if (!$apiBase) { |
30 | 30 | $apiBase = bSecure::$apiBase; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $params = $params ?: []; |
48 | 48 | list($rcode, $rbody, $rheaders) = |
49 | 49 | $this->_requestRaw($method, $url, $params, $authKey); |
50 | - list($message, $exception, $rbody) = $this->_interpretResponse( $rcode,$rbody, $rheaders); |
|
50 | + list($message, $exception, $rbody) = $this->_interpretResponse($rcode, $rbody, $rheaders); |
|
51 | 51 | |
52 | 52 | $resp = new ApiResponse($rbody, $rcode, $message, $exception); |
53 | 53 | return [$resp]; |
@@ -65,17 +65,17 @@ discard block |
||
65 | 65 | $authHeader = []; |
66 | 66 | $defaultHeaders = []; |
67 | 67 | |
68 | - if($authKey) |
|
68 | + if ($authKey) |
|
69 | 69 | { |
70 | 70 | $authToken = bSecure::getAuthToken(); |
71 | - if(gettype($authToken) == "string") |
|
71 | + if (gettype($authToken) == "string") |
|
72 | 72 | { |
73 | - $authHeader = ['Authorization' => 'Bearer ' .$authToken]; |
|
74 | - }else if(gettype($authToken) == "object"){ |
|
73 | + $authHeader = ['Authorization' => 'Bearer ' . $authToken]; |
|
74 | + } else if (gettype($authToken) == "object") { |
|
75 | 75 | $authHeader = []; |
76 | 76 | } |
77 | 77 | } |
78 | - $headers = array_merge($defaultHeaders,$authHeader); |
|
78 | + $headers = array_merge($defaultHeaders, $authHeader); |
|
79 | 79 | return $headers; |
80 | 80 | } |
81 | 81 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return array |
123 | 123 | */ |
124 | - private function _interpretResponse( $rcode,$rbody, $rheaders) |
|
124 | + private function _interpretResponse($rcode, $rbody, $rheaders) |
|
125 | 125 | { |
126 | 126 | $resp = \json_decode($rbody, true); |
127 | 127 | $jsonError = \json_last_error(); |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | $errorData = $resp['message']; |
153 | 153 | $error = null; |
154 | 154 | if (\is_array($errorData) && $errorData != []) { |
155 | - $error = self::_specificAPIError($resp,$rheaders,$rcode); |
|
156 | - }else{ |
|
155 | + $error = self::_specificAPIError($resp, $rheaders, $rcode); |
|
156 | + } else { |
|
157 | 157 | if (!\is_array($resp) || !isset($resp['error'])) { |
158 | 158 | $msg = "Invalid response object from API: {$rbody} " |
159 | 159 | . "(HTTP response code was {$rcode})"; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return Exception\ApiErrorException |
177 | 177 | */ |
178 | - private static function _specificAPIError($errorData,$rheaders, $code) |
|
178 | + private static function _specificAPIError($errorData, $rheaders, $code) |
|
179 | 179 | { |
180 | 180 | $msg = isset($errorData['message']) ? $errorData['message'] : null; |
181 | 181 | $body = isset($errorData['body']) ? $errorData['body'] : null; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if(gettype($authToken) == "string") |
72 | 72 | { |
73 | 73 | $authHeader = ['Authorization' => 'Bearer ' .$authToken]; |
74 | - }else if(gettype($authToken) == "object"){ |
|
74 | + } else if(gettype($authToken) == "object"){ |
|
75 | 75 | $authHeader = []; |
76 | 76 | } |
77 | 77 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $error = null; |
154 | 154 | if (\is_array($errorData) && $errorData != []) { |
155 | 155 | $error = self::_specificAPIError($resp,$rheaders,$rcode); |
156 | - }else{ |
|
156 | + } else{ |
|
157 | 157 | if (!\is_array($resp) || !isset($resp['error'])) { |
158 | 158 | $msg = "Invalid response object from API: {$rbody} " |
159 | 159 | . "(HTTP response code was {$rcode})"; |