PHP Pantry Cloud Library

Basket extends Client
in package

Table of Contents

Constants

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

Properties

$async  : bool
$data  : object
$HttpClient  : Client
$name  : string
$pantryID  : string

Methods

__construct()  : mixed
Basket constructor.
__debugInfo()  : array<string|int, mixed>
Returns the basket data as an array.
__invoke()  : object
Returns the basket data as an object.
__toString()  : string
Returns the basket data as json.
createBasket()  : Basket
Creates a new basket.
delete()  : void
Deletes the basket.
get()  : object
Returns the basket data as an object.
getBasket()  : Basket
Gets information about a basket.
getData()  : object
Gets information about the pantry.
update()  : void
Updates the basket 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()

Basket constructor.

public __construct(string $pantryID, string $name, object $data) : mixed
Parameters
$pantryID : string

The Pantry ID used to access your dashboard.

$name : string

The basket name.

$data : object

The contents of the basket.

__debugInfo()

Returns the basket data as an array.

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

The data.

__invoke()

Returns the basket data as an object.

public __invoke() : object
Return values
object

The data.

__toString()

Returns the basket 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 basket 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 basket 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