Skip to content

Unsupported Endpoints

Jay edited this page May 30, 2024 · 8 revisions

Constructing a request

For unimplemented API endpoints, you can construct a generic request using a request.

$request = $api->getRequest()
    ->create($method, $endpoint, $headers = [], $bodyData = []);

$response = $api->sendRequest($request);

Processing a response

The response object implements a PSR-7 response, Psr\Http\Message\ResponseInterface, see https://docs.guzzlephp.org/en/stable/quickstart.html#using-responses for more information.

As the SupportPal API returns JSON, you will need to JSON decode the string.

$body = (string) $response->getBody();
$data = json_decode($body, true);

Examples

Fetching comments

$request = $api->getRequest()
    ->create('GET', 'selfservice/comment');

$api->sendRequest($request);

Fetching comments awaiting moderation

$request = $api->getRequest()
    ->create('GET', 'selfservice/comment', [], ['status' => 0]);

$api->sendRequest($request);

Posting a comment

$data = [
    'text'         => 'text',
    'article_id'   => 3,
    'type_id'      => 1,
    'parent_id'    => 1,
    'status'       => 3,
    'notify_reply' => 0,
];
$request = $api->getRequest()
    ->create('POST', 'selfservice/comment', [], $data);

$api->sendRequest($request);

Deleting a comment

$request = $api->getRequest()
    ->create('DELETE', 'selfservice/comment/1');

$api->sendRequest($request);