InsightlyRequest
in package
API Requests class
Helper class for executing REST requests to the Insightly API.
Usage: - Instanciate: $request = new InsightlyRequest('GET', $apikey, 'create.../)
- Execute: $request->toString();
- Or implicitly execute: $request->asJSON();
Table of Contents
Constants
- URL_BASE = 'https://api.insight.ly'
- API URL
Properties
- $body : string
- Response body
- $curl : resource
- CURL resource
- $headers : array<string|int, mixed>
- Request headers
- $querystrings : array<string|int, mixed>
- Request parameters
- $url_path : string
- URL path outside the base URL
Methods
- __construct() : mixed
- Request initialisation
- asJSON() : mixed
- Return decoded JSON response
- asString() : string
- Get executed request response
- body() : InsightlyRequest
- Add data to the current request
- queryParam() : InsightlyRequest
- Add query parameter to the current request
- buildQueryString() : string
- Build query string for the current request
- method() : InsightlyRequest
- Set request method
Constants
URL_BASE
API URL
public
string
URL_BASE
= 'https://api.insight.ly'
Properties
$body
Response body
private
string
$body
$curl
CURL resource
private
resource
$curl
$headers
Request headers
private
array<string|int, mixed>
$headers
$querystrings
Request parameters
private
array<string|int, mixed>
$querystrings
$url_path
URL path outside the base URL
private
string
$url_path
Methods
__construct()
Request initialisation
public
__construct(string $method, string $apikey, string $url_path) : mixed
Parameters
- $method : string
-
(GET|DELETE|POST|PUT)
- $apikey : string
- $url_path : string
Tags
asJSON()
Return decoded JSON response
public
asJSON() : mixed
Tags
asString()
Get executed request response
public
asString([mixed $returnHeader = false ]) : string
Parameters
- $returnHeader : mixed = false
Tags
Return values
stringbody()
Add data to the current request
public
body(mixed $obj) : InsightlyRequest
Parameters
- $obj : mixed
Tags
Return values
InsightlyRequestqueryParam()
Add query parameter to the current request
public
queryParam(string $name, mixed $value) : InsightlyRequest
Parameters
- $name : string
- $value : mixed
Return values
InsightlyRequestbuildQueryString()
Build query string for the current request
private
buildQueryString() : string
Return values
stringmethod()
Set request method
private
method(string $method) : InsightlyRequest
Parameters
- $method : string