Skip to content

Commit

Permalink
fixed draft endpoint response model
Browse files Browse the repository at this point in the history
  • Loading branch information
timoj committed May 1, 2019
1 parent 84d7fa0 commit a636e2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
10 changes: 0 additions & 10 deletions src/Wuunder/Api/DraftsApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
13 changes: 8 additions & 5 deletions src/Wuunder/Api/Endpoints/Drafts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);

Expand Down

0 comments on commit a636e2e

Please sign in to comment.