ApiRequest
in package

This is the ApiRequest class in the LogiCommerce SDK package.

All LogiCommerce API Requests are prepared and executed through this class.

Tags
see
ApiRequest::__construct()
see
ApiRequest::setToken()
see
ApiRequest::setHeader()
see
ApiRequest::setData()
see
ApiRequest::setBody()
see
ApiRequest::setParams()
see
ApiRequest::send()

Table of Contents

BASKET_TOKEN  = 'basketToken'
__construct() Constructor.  : mixed
addApiRequestContentLength()  : mixed
addApiRequestCount()  : mixed
getApiRequestContentLength()  : int
getApiRequestCount()  : int
getApiURL()  : string
send() Send the request to the LogiCommerce API.  : array<string|int, mixed>
setBody() Set the API request body.  : void
setData() Set form (POST) parameters on the API request.  : void
setHeader() Set headers on the API request.  : void
setParams() Set URL (GET) parameters on the API request.  : void
setToken() Get the application token and set it to the request.  : void

Constants

BASKET_TOKEN

public mixed BASKET_TOKEN = 'basketToken'

Methods

__construct()

Constructor.

public __construct(string $path[, string $method = 'get' ][, array<string|int, mixed> $headers = [] ][, array<string|int, mixed> $data = [] ][, string $apiUrl = null ]) : mixed

This will prepare the object to made the API request. By default the method add the following headers:

  • Content-Type
  • Accept
That headers could be overwrited adding them on the $data param
Parameters
$path : string

API resource to call

$method : string = 'get'

HTTP method

$headers : array<string|int, mixed> = []

headers to add into the curl request

$data : array<string|int, mixed> = []

data to add into the curl request as form (POST) parameters

$apiUrl : string = null

The URL of the API we want to do the request on

Return values
mixed

addApiRequestContentLength()

public static addApiRequestContentLength(int $contentLength) : mixed
Parameters
$contentLength : int
Return values
mixed

addApiRequestCount()

public static addApiRequestCount([int $numOfRequests = 1 ]) : mixed
Parameters
$numOfRequests : int = 1
Return values
mixed

getApiRequestContentLength()

public static getApiRequestContentLength() : int
Return values
int

getApiRequestCount()

public static getApiRequestCount() : int
Return values
int

getApiURL()

public static getApiURL([string|null $apiUrl = null ]) : string
Parameters
$apiUrl : string|null = null
Return values
string

send()

Send the request to the LogiCommerce API.

public send() : array<string|int, mixed>

The return value will be a decode of the given API JSON

Tags
throws
ApiRequestException
Return values
array<string|int, mixed>

setBody()

Set the API request body.

public setBody(string $body) : void
Parameters
$body : string
Return values
void

setData()

Set form (POST) parameters on the API request.

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

These data will be send with the API petition

Parameters
$data : array<string|int, mixed>

Array containing the values you want to set as POST parameters on the request.

Return values
void

setHeader()

Set headers on the API request.

public setHeader(string $key, mixed $value) : void

These headers will be send with the API petition

Parameters
$key : string

Name of the header you want to set the value.

$value : mixed

The value you want to set on the given header key.

Return values
void

setParams()

Set URL (GET) parameters on the API request.

public setParams(array<string|int, mixed> $params) : void

These parameters will be send with the API petition

Parameters
$params : array<string|int, mixed>

Array containing the values you want to set as GET parameters on the request.

Return values
void

setToken()

Get the application token and set it to the request.

public setToken() : void
Return values
void

Search results