Skip to content

crisphive/crisphive-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crisphive PHP

The official PHP SDK for the Crisphive API.

Typed access to the public /v1 API — customers, bookings, catalog, team and fleet.

Requirements

PHP 7.4+ with the curl, json and mbstring extensions.

Installation

composer require crisphive/crisphive-php

Authentication

Every request is authenticated with a secret API key sent as a bearer token. Create keys from your Crisphive business dashboard. The key prefix selects the data environment:

  • chsk_live_… → live (production) data
  • chsk_test_… → sandbox (isolated test) data

Load keys from the environment — never commit them.

Usage

<?php
require_once __DIR__ . '/vendor/autoload.php';

$config = Crisphive\Configuration::getDefaultConfiguration()
    ->setAccessToken(getenv('CRISPHIVE_API_KEY')); // SDK adds the "Bearer " prefix

$customers = new Crisphive\Api\CustomerApi(new GuzzleHttp\Client(), $config);

// List customers.
$res = $customers->listCustomers(null, null, null, null, null, 1, 20);
foreach ($res->getData()->getCustomers() ?? [] as $c) {
    echo $c->getId() . ' ' . $c->getFullName() . "\n";
}

// Create a customer.
try {
    $body = new Crisphive\Model\CustomerCreateRequest([
        'full_name' => 'Ada Lovelace',
        'email'     => '[email protected]',
    ]);
    $created = $customers->createCustomer($body);
    echo 'created ' . $created->getData()->getCustomerId() . "\n";
} catch (Crisphive\ApiException $e) {
    echo 'error ' . $e->getCode() . ' ' . $e->getResponseBody() . "\n";
}

Method parameter lists follow the generated signatures — see the API reference for the exact arguments of each call.

Pagination

List methods accept $page / $limit and return a meta object (total, count, per_page, current_page, total_pages).

Idempotency

create* calls (customers, bookings) accept an Idempotency-Key so retries never create a duplicate.

Errors

Non-2xx responses throw Crisphive\ApiException; inspect $e->getCode() and $e->getResponseBody() for the Crisphive error code.

Documentation

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages