@@ -151,30 +151,30 @@ discard block |
||
151 | 151 | protected function request($path, $params = [], $type = 'GET') |
152 | 152 | { |
153 | 153 | // default params |
154 | - if (empty($this->config[ 'apiUrl' ])) { |
|
154 | + if (empty($this->config['apiUrl'])) { |
|
155 | 155 | throw new \InvalidArgumentException('Citcall: API Url is not set!'); |
156 | 156 | } |
157 | 157 | |
158 | - if (empty($this->config[ 'userId' ])) { |
|
158 | + if (empty($this->config['userId'])) { |
|
159 | 159 | throw new \InvalidArgumentException('Citcall: User ID is not set'); |
160 | 160 | } |
161 | 161 | |
162 | - if (empty($this->config[ 'apiKey' ])) { |
|
162 | + if (empty($this->config['apiKey'])) { |
|
163 | 163 | throw new \InvalidArgumentException('Citcall: API Key is not set'); |
164 | 164 | } |
165 | 165 | |
166 | - $uri = (new Uri($this->config[ 'apiUrl' ])) |
|
167 | - ->addPath($this->config[ 'version' ]) |
|
166 | + $uri = (new Uri($this->config['apiUrl'])) |
|
167 | + ->addPath($this->config['version']) |
|
168 | 168 | ->addPath($path); |
169 | 169 | |
170 | 170 | $request = new Curl\Request(); |
171 | 171 | $request->setHeaders([ |
172 | - 'Authorization' => base64_encode($this->config[ 'userId' ] . ':' . $this->config[ 'apiKey' ]), |
|
172 | + 'Authorization' => base64_encode($this->config['userId'] . ':' . $this->config['apiKey']), |
|
173 | 173 | ]); |
174 | 174 | $request->setConnectionTimeout(500); |
175 | 175 | |
176 | - if ($this->config[ 'retry' ] > 0 and $this->config[ 'retry' ] <= 20) { |
|
177 | - $params[ 'limit_try' ] = $this->config[ 'retry' ]; // default 5 |
|
176 | + if ($this->config['retry'] > 0 and $this->config['retry'] <= 20) { |
|
177 | + $params['limit_try'] = $this->config['retry']; // default 5 |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | if ($this->response = $request->setUri($uri)->post($params, true)) { |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | throw new \InvalidArgumentException('Citcall: Invalid MSISDN Number'); |
231 | 231 | } |
232 | 232 | |
233 | - $senderId = empty($this->config[ 'senderId' ]) ? $this->config[ 'userId' ] : $this->config[ 'senderId' ]; |
|
233 | + $senderId = empty($this->config['senderId']) ? $this->config['userId'] : $this->config['senderId']; |
|
234 | 234 | |
235 | 235 | return $this->request('sms', [ |
236 | 236 | 'senderid' => $senderId, |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | throw new \InvalidArgumentException('Citcall: Invalid MSISDN Number'); |
260 | 260 | } |
261 | 261 | |
262 | - if ( ! is_int($gateway) or $gateway > 5 or $gateway < 0) { |
|
262 | + if (!is_int($gateway) or $gateway > 5 or $gateway < 0) { |
|
263 | 263 | throw new \InvalidArgumentException('Citcall: Invalid Gateway Number'); |
264 | 264 | } |
265 | 265 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | return $this->request($path, [ |
269 | 269 | 'msisdn' => $msisdn, |
270 | - 'gateway' => (int)$gateway, |
|
270 | + 'gateway' => (int) $gateway, |
|
271 | 271 | ], 'POST'); |
272 | 272 | } |
273 | 273 | // ------------------------------------------------------------------------ |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | throw new \InvalidArgumentException('Citcall: Invalid MSISDN Number'); |
292 | 292 | } |
293 | 293 | |
294 | - $params[ 'msisdn' ] = $msisdn; |
|
295 | - $params[ 'senderid' ] = empty($this->config[ 'senderId' ]) ? $this->config[ 'userId' ] : $this->config[ 'senderId' ]; |
|
294 | + $params['msisdn'] = $msisdn; |
|
295 | + $params['senderid'] = empty($this->config['senderId']) ? $this->config['userId'] : $this->config['senderId']; |
|
296 | 296 | |
297 | 297 | $token = trim($token); |
298 | 298 | if (strlen($token) < 4) { |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | throw new \InvalidArgumentException('Citcall: OTP Code maximum length is 8 digit'); |
302 | 302 | } |
303 | 303 | |
304 | - $params[ 'token' ] = $token; |
|
305 | - $params[ 'text' ] = $params[ 'token' ] . ' is your ' . $this->config[ 'appName' ] . 'OTP code.'; |
|
304 | + $params['token'] = $token; |
|
305 | + $params['text'] = $params['token'] . ' is your ' . $this->config['appName'] . 'OTP code.'; |
|
306 | 306 | |
307 | 307 | if ($expires > 0) { |
308 | - $params[ 'valid_time' ] = $expires; |
|
308 | + $params['valid_time'] = $expires; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | return $this->request('smsotp', $params, 'POST'); |