Larabros\Elogram\Http\Response¶
-
class
Response¶ Represents a response returned from the API.
-
property
raw¶ protected array
-
property
meta¶ protected array
-
property
data¶ protected array
-
property
pagination¶ protected array
-
__construct($meta =, []$data =, []$pagination =[])¶ Creates a new instance of
Response.Parameters: - $meta (array) –
- $data (array) –
- $pagination (array) –
-
createFromJson($response)¶ Creates a new instance of
Responsefrom a JSON-decoded response body.Parameters: - $response (array) –
Returns: static
-
getRaw($key = null)¶ Gets the JSON-decoded raw response.
Parameters: - $key (string|null) –
Returns: array
-
get()¶ Gets the response body. If the response contains multiple records, a
Collectionis returned.Returns: array|Collection
-
merge(Response $response)¶ Merges the contents of this response with
$responseand returns a newResponseinstance.Parameters: - $response (Response) –
Returns: Response
-
isCollection($data)¶ Tests the current response data to see if one or more records were returned.
Parameters: - $data (array|Collection) –
Returns: bool
-
isRecord($data)¶ Tests the current response data to see if a single record was returned.
Parameters: - $data (array|Collection) –
Returns: bool
-
hasPages()¶ If the response has a
paginationfield with anext_urlkey, then returnstrue, otherwisefalse.Returns: bool
-
nextUrl()¶ Returns the next URL, if available, otherwise
null.Returns: string|null
-
__toString()¶ Returns the JSON-encoded raw response.
Returns: string
-
property