Skip to content

Commit

Permalink
Merge pull request #4 from wuunder/development
Browse files Browse the repository at this point in the history
fixed draft endpoint response model
  • Loading branch information
TimD90 committed May 1, 2019
2 parents 8b3ac24 + a636e2e commit fbcf87b
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 fbcf87b

Please sign in to comment.