diff --git a/src/Wuunder/Api/DraftsApiResponse.php b/src/Wuunder/Api/DraftsApiResponse.php index 1e2f8c1..416ed48 100644 --- a/src/Wuunder/Api/DraftsApiResponse.php +++ b/src/Wuunder/Api/DraftsApiResponse.php @@ -8,14 +8,4 @@ public function __construct($header, $body, $error) { parent::__construct($header, $body, $error); } - - /** - * Returns booking url - * - * @return mixed - */ - public function getBookingUrl() - { - return $this->getBody(); - } } \ No newline at end of file diff --git a/src/Wuunder/Api/Endpoints/Drafts.php b/src/Wuunder/Api/Endpoints/Drafts.php index 6e508c7..d0c1baa 100644 --- a/src/Wuunder/Api/Endpoints/Drafts.php +++ b/src/Wuunder/Api/Endpoints/Drafts.php @@ -55,10 +55,10 @@ public function getConfig() */ public function fire() { - $bookingRequest = new PostRequest($this->apiEnvironment->getStageBaseUrl() . "/drafts", + $draftRequest = new PostRequest($this->apiEnvironment->getStageBaseUrl() . "/drafts", $this->apiKey->getApiKey(), json_encode($this->config->getDrafts())); try { - $bookingRequest->send(); + $draftRequest->send(); } catch(Exception $e) { $this->logger->log($e); } @@ -67,10 +67,13 @@ public function fire() $header = null; $error = null; - if (isset($bookingRequest->getResponseHeaders()["location"])) { - $header = $bookingRequest->getResponseHeaders(); + if (isset($draftRequest->getResponseHeaders()["http_code"]) + && strpos($draftRequest->getResponseHeaders()["http_code"], "200 OK") !== false + ) { + $header = $draftRequest->getResponseHeaders(); + $body = $draftRequest->getBody(); } else { - $error = $bookingRequest->getResponse(); + $error = $draftRequest->getResponse(); } $this->draftsResponse = new DraftsApiResponse($header, $body, $error);