commercesignals/csapi-php

API client library to work with the Commerce Signals platform.

v0.0.2 2017-05-02 19:26 UTC

This package is not auto-updated.

Last update: 2025-03-23 10:16:50 UTC


README

Databridge by Commerce Signals

Build Status License

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

Calling Endpoint Examples