PHP Pantry Cloud Library

Client
in package

Table of Contents

Constants

PANTRY_URL  = 'https://getpantry.cloud/apiv1/pantry/'

Properties

$async  : bool
$data  : object|null
$HttpClient  : Client
$pantryID  : string

Methods

__construct()  : mixed
Client constructor.
__debugInfo()  : array<string|int, mixed>
Returns the pantry data as an array.
__invoke()  : object
Returns the pantry data as an object.
__toString()  : string
Returns the pantry data as json.
createBasket()  : Basket
Creates a new basket.
get()  : object
Returns the pantry data as an object.
getBasket()  : Basket
Gets information about a basket.
getData()  : object
Gets information about the pantry.
update()  : void
Updates the pantry with the given data.
request()  : object|null
Performs a request to the getpantry API

Constants

PANTRY_URL

public mixed PANTRY_URL = 'https://getpantry.cloud/apiv1/pantry/'

Properties

$async

private bool $async = false

$HttpClient

private Client $HttpClient

$pantryID

private string $pantryID

Methods

__construct()

Client constructor.

public __construct(string $pantryID[, bool $async = false ]) : mixed
Parameters
$pantryID : string

The Pantry ID used to access your dashboard.

$async : bool = false

Wheter the request should be asyncronous or not.

__debugInfo()

Returns the pantry data as an array.

public __debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>

The data.

__invoke()

Returns the pantry data as an object.

public __invoke() : object
Return values
object

The data.

__toString()

Returns the pantry data as json.

public __toString() : string
Return values
string

The data.

createBasket()

Creates a new basket.

public createBasket(string $name, array<string|int, mixed> $contents) : Basket
Parameters
$name : string

The name of the basket.

$contents : array<string|int, mixed>

The basket contents.

Tags
throws
RequestException

On general error.

Return values
Basket

The basket object.

get()

Returns the pantry data as an object.

public get() : object
Return values
object

The data.

getBasket()

Gets information about a basket.

public getBasket(string $name) : Basket
Parameters
$name : string

The name of the basket.

Tags
throws
BasketNotFoundException

If the basket doesn't exists.

throws
RequestException

On general error.

Return values
Basket

The basket object.

getData()

Gets information about the pantry.

public getData() : object
Return values
object

The pantry data.

update()

Updates the pantry with the given data.

public update(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>

The data to update.

Tags
throws
RequestException

On error.

request()

Performs a request to the getpantry API

protected request([string $method = "GET" ][, string $path = "" ][, array<string|int, mixed>|null $body = null ][, array<string|int, mixed>|null $headers = ['Content-Type' => 'application/json'] ]) : object|null
Parameters
$method : string = "GET"

The HTTP method.

$path : string = ""

The path to the resource

$body : array<string|int, mixed>|null = null

The body of the request.

$headers : array<string|int, mixed>|null = ['Content-Type' => 'application/json']

Additional headers.

Return values
object|null

The body of the response.


On this page

Search results