\Revel\ApiProducts

Summary

Methods
Properties
Constants
__construct()
buildApiUrl()
get()
post()
all()
findById()
findByBarcode()
findByUUID()
No public properties found
No constants found
call()
cache()
$revel
N/A
No private methods found
$_cache
N/A

Properties

$_cache

$_cache : array

Type

array

Methods

__construct()

__construct(\Revel\Revel  $revel) 

Api constructor.

Parameters

\Revel\Revel $revel

Reference to the core {@link Revel} object.

buildApiUrl()

buildApiUrl(string  $resource) : string

Builds an API URL relative to {@link getFullUrl()}.

Parameters

string $resource

The resource relative to {@link getFullUrl()}.

Returns

string

get()

get(string  $resource) : \Revel\Api\Response

GET resource data.

Parameters

string $resource

The API endpoint, relative to the domain.

Returns

\Revel\Api\Response

post()

post(string  $resource, array  $body = array()) : \Revel\Api\Response

POST to a resource.

Parameters

string $resource

The API endpoint, relative to the domain.

array $body

The POST body.

Returns

\Revel\Api\Response

all()

all() : array<mixed,\Revel\Models\Product>

Get all {@link Product products}.

Returns

array<mixed,\Revel\Models\Product>

findById()

findById(  $id) : \Revel\Models\Product

Get a single product.

Parameters

$id

Returns

\Revel\Models\Product

findByBarcode()

findByBarcode(string  $barcode) : \Revel\Models\Product

Get a single product using its barcode.

Parameters

string $barcode

The product barcode.

Returns

\Revel\Models\Product

findByUUID()

findByUUID(string  $uuid) : \Revel\Models\Product

Get a single product using its UUI.

Parameters

string $uuid

The product UUID.

Returns

\Revel\Models\Product

call()

call(string  $method, string  $resource, array  $body = array()) : \Revel\Api\Response

Perform a Revel API request.

Parameters

string $method

The HTTP method.

string $resource

The API endpoint, relative to the domain.

array $body

The request body.

Returns

\Revel\Api\Response

cache()

cache(string  $key, mixed|callable  $value) : mixed

Cache the result of the API call for future access.

Parameters

string $key

Unique key.

mixed|callable $value

Returns

mixed