-
Notifications
You must be signed in to change notification settings - Fork 262
Upgrading from v1 to v2
Ian Christopher B. de Jesus edited this page Sep 7, 2015
·
24 revisions
Intro to why we rewrote the API Client.
Client -> HTTPClient
// v1
use Zendesk\API\Client as ZendeskAPI;
$client->setAuth('token', $token);
// v2
use Zendesk\API\HTTPClient as ZendeskAPI;
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
Most basic operations are very similar. We've tried to keep them as consistent as possible between v1 and v2, but there are some slight differences.
Get & create a ticket
// v1
$tickets = $client->tickets()->findAll();
$newTicket = $client->tickets()->create(array(
'subject' => 'The quick brown fox jumps over the lazy dog',
'comment' => array(
'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
),
'priority' => 'normal'
));
// v2
$tickets = $client->tickets()->findAll();
$newTicket = $client->tickets()->create(array(
'subject' => 'The quick brown fox jumps over the lazy dog',
'comment' => array(
'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
),
'priority' => 'normal'
));
Get & create a user
//v1
$listusers = $client->users()->findAll();
$newuser = $client->users()->create(array(
'name' => 'foo bar',
'email' => '[email protected]'
));
//v2
$listusers = $client->users()->findAll();
$newuser = $client->users()->create(array(
'name' => 'foo bar',
'email' => '[email protected]'
));
Get & create organizations List triggers
v1 there was nothing
v2 it's a LOT better