/** * @param string $method * @param string $path * @param string|null $body * * @throws UnauthorisedRequestException * * @return array */ public function send($method, $path, $body = null) { $headers = ['x-api-key' => $this->config->getApiKey(), 'content-type' => 'application/json']; $url = $this->config->getDomain() . $path; $body = $body ? json_encode($body) : null; $response = $this->client->send(new Request($method, $url, $headers, $body)); $body = json_decode($response->getBody(), true); $status = $response->getStatusCode(); if ($status < 400) { return $body; } else { throw $this->makeException($this->getExceptionName($status), $body); } }
/** * @param $config * * @return WebHooker */ public static function usingGuzzle($config) { if (!$config instanceof Config) { $config = Config::make($config); // passing in API Key } return new self(new ApiClient(new GuzzleHttpClient(new Client()), $config)); }