PHP wrapper for Desk.com's API. A work in progress. Currently, only the "Customers" endpoint is hooked up. Requires PHP 5.4+. Contributions appreciated.
Not yet published to packagist since it is half-baked. You can use it by adding the repository to your composer.json file:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/bradleyboy/desk-php"
}
],
"require": {
"bradleyboy/desk-php": "dev-master"
}
use Desk\Desk;
// With basic auth. For example, myaccount.desk.com:
$desk = new Desk('myaccount', '[email protected]', 'password');
// With oauth. For example, myaccount.desk.com:
$desk = new Desk('myaccount', null, null, 'myconsumerkey', 'myconsumersecret', 'mytoken', 'mytokensecret');
// Get all customers
$customers = $desk->customers->all();
// Search customers
$customers = $desk->customers->search(['email' => '[email protected]']);
// Get a customer
// Desk uses HAL identifiers instead of numeric IDs.
$customer = $desk->customers->setIdentifier('/api/v2/customers/111111')->get();
// Create a customer
$customer = $desk->customers->create([
'emails' => [
[ 'type' => 'home', 'value' => '[email protected]' ]
],
'first_name' => 'Jill',
'last_name' => 'Doe'
]);
// Update a customer
$customer = $desk->customers->setIdentifier('/api/v2/customers/111111')->update([
'first_name' => 'Jane'
]);
// Get a customer's cases
$customer = $desk->customers->setIdentifier('/api/v2/customers/111111')->cases();