| Conditions | 6 |
| Paths | 12 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 52 | protected function callApi($method, $url, $params = null, $headers = []) |
||
| 53 | { |
||
| 54 | $options = [ |
||
| 55 | 'query' => [ |
||
| 56 | 'usercode' => $this->credentials['user_code'], |
||
| 57 | 'password' => $this->credentials['secret'], |
||
| 58 | ], |
||
| 59 | ]; |
||
| 60 | |||
| 61 | if ($method == 'POST') { |
||
| 62 | if (is_array($params)) { |
||
| 63 | $options['form_params'] = $params; |
||
| 64 | } else { |
||
| 65 | $options['body'] = $params; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | if ($method == 'GET' && is_array($params)) { |
||
| 70 | $options['query'] = array_merge($options['query'], $params); |
||
| 71 | } |
||
| 72 | |||
| 73 | if ($headers) { |
||
| 74 | $options['headers'] = $headers; |
||
| 75 | } |
||
| 76 | |||
| 77 | $response = $this->client->request($method, $url, $options); |
||
| 78 | |||
| 79 | return $response->getBody()->getContents(); |
||
| 80 | } |
||
| 82 |