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 Response from 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 Collection is returned.

Returns:array|Collection
merge(Response $response)

Merges the contents of this response with $response and returns a new Response instance.

Parameters:
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 pagination field with a next_url key, then returns true, otherwise false.

Returns:bool
nextUrl()

Returns the next URL, if available, otherwise null.

Returns:string|null
__toString()

Returns the JSON-encoded raw response.

Returns:string