commercesignals / csapi-php
API client library to work with the Commerce Signals platform.
Requires
- php: >=5.6
Requires (Dev)
- internations/http-mock: ^0.8.1
- phpunit/php-code-coverage: ^4.0
- phpunit/phpunit: 5.7.*
This package is not auto-updated.
Last update: 2025-03-23 10:16:50 UTC
README
Library to interface with the Commerce Signals platform.
Installing with Composer
composer require commercesignals/csapi-php
Usage
Authorize your client
const CERT_FILE_NAME = 'my-api-key-private-cert.pem'; const API_KEY = '0b70012a-5a7a-2b90-815a-aa73a7f8001a'; // My API Key const API_BASE = 'https://api.commercesignals.com/'; $api = new CommerceSignals\API(API_BASE, [ 'apiKey' => API_KEY, 'cert' => file_get_contents(__DIR__ . '/' . CERT_FILE_NAME) ]);
The API class
The main API class is used to build the API request to issue.
The methods of the API call can be chained to create the segments of the request you are making.
Each chained method has an optional $id
paramater that can be passed to request a specific resource from the segment part.
The final method in the call determins the type of HTTP request being made and has an optional $payload
paramater that will be used as the request BODY.
get() => GET request
update() => PATCH request
save() => POST or PUT (depending on if the payload BODY has an id set or not)
Example
$api->signals('0a000337-574f-223e-8156-4f3a98e707a1') ->requests('0a00017c-5aac-1195-82ba-ae6ea3fa000a') ->results() ->get();
HTTP Request
GET https://api.commercesignals.com/rest/v1/signals/0a00...07a1/requests/0a00...a000a/results