1
0
Files
PayPal-PHP-Server-SDK/doc/api-response.md
Patrick Powers 504c367386 Release 0.7.0
Beta Release 0.7.0 including:

- Bug fixes
- Updated model/function names
- Updated models to reflect changes in APIs
2025-03-20 13:18:55 -05:00

32 lines
992 B
Markdown

# ApiResponse
Represents the result of an API call, including the request details, response metadata, and the returned data.
## Methods
| Name | Type | Description |
| --- | --- | --- |
| `getRequest()` | [`HttpRequest`](http-request.md) | Returns the original request that resulted in this response. |
| `getStatusCode()` | `?int` | Returns the response status code. |
| `getHeaders()` | `?array` | Returns the response headers. |
| `getResult()` | `mixed` | Returns the response data. |
| `getBody()` | `mixed` | Returns the original body from the response. |
| `isSuccess()` | `bool` | Checks if the response is successful (HTTP 2xx). |
| `isError()` | `bool` | Checks if the response indicates an error. (not HTTP 2xx) |
## Example Usage
```php
$response = $client->exampleController()->exampleEndpoint($input);
if ($response->isSuccess()) {
echo "Success! Result: ";
print_r($response->getResult());
} else {
echo "Error: ";
print_r($response->getBody());
}
```