Skip to content

feat(v1): adding new failed, __toString & toPsrResponse to Response #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name-template: 'v$NEXT_PATCH_VERSION 🌈'
name-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: '🚀 Features'
Expand All @@ -11,9 +11,14 @@ categories:
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
labels:
- 'chore'
- 'documentation'
- 'dependencies'
- title: ':boom: BREAKING CHANGE'
label: 'BREAKING CHANGE'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
## Changes

$CHANGES
$CHANGES
33 changes: 32 additions & 1 deletion src/Client/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,24 @@ public static function fromSoapFault(\SoapFault $soapFault)
/**
* Get the full SOAP enveloppe response.
*
* @deprecated removed in v2 and replaced by toPsrResponse
* @return string
*/
public function getResponse(): string
{
return $this->response;
}

/**
* Get the underlying PSR response for the response.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function toPsrResponse()
{
return $this->response;
}

/**
* Get the JSON decoded body of the response as an object.
*
Expand Down Expand Up @@ -133,6 +144,16 @@ public function ok()
return $this->status() === 200;
}

/**
* Determine if the response indicates a client or server error occurred.
*
* @return bool
*/
public function failed()
{
return $this->serverError() || $this->clientError();
}

/**
* Determine if the response was a redirect.
*
Expand All @@ -152,7 +173,7 @@ public function redirect()
*/
public function throw()
{
if ($this->serverError() || $this->clientError()) {
if ($this->failed()) {
throw new RequestException($this);
}

Expand Down Expand Up @@ -242,6 +263,16 @@ public function offsetUnset($offset)
throw new LogicException('Response data may not be mutated using array access.');
}

/**
* Get the body of the response.
*
* @return string
*/
public function __toString()
{
return $this->body();
}

/**
* Dynamically proxy other methods to the underlying response.
*
Expand Down