\SinusBotRestClient

Class RestClient

RestClient is used to perform the http requests to the SinusBot API

Summary

Methods
Properties
Constants
addHeader()
setAuthToken()
No public properties found
No constants found
__construct()
request()
$timeout
$token
$url
$headers
N/A
getError()
No private properties found
N/A

Properties

$timeout

$timeout : integer

Timeout represents the HTTP timeout when HTTP requests to the SinusBot API are performed

Type

integer

$token

$token : string

Token is the SinusBot auth token which will be there temporary stored.

Type

string

$url

$url : string

URL is the SinusBot URL with the port and the HTTP protocol

Type

string

$headers

$headers : array

headers are http headers which will be added on every request

Type

array

Methods

addHeader()

addHeader(string  $key, string  $value) 

addHeader adds a header to every http request

Parameters

string $key

http header key

string $value

http header value

setAuthToken()

setAuthToken(string  $token) 

setAuthToken overrides the auth token

Parameters

string $token

Auth-Token, when you want to override

__construct()

__construct(\SinusBot\API  $api) 

__construct

Parameters

\SinusBot\API $api

SinusBot API

request()

request(string  $path, string  $method = "GET", string  $payload = null, boolean  $encoded = false) : array

request executes a request to the SinusBot API

Parameters

string $path

/api/v1/

string $method

http method

string $payload

http POST payload

boolean $encoded

when not encoded it will be JSON marshalled

Returns

array —

decoded JSON response

getError()

getError(integer  $code) : string

getError returns the string representive to the given http status code

Parameters

integer $code

http status code

Returns

string —

http status code string representive