/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return Client */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Configuration'); $client = new Client($config['zendesk']['subdomain'], $config['zendesk']['username']); $client->setAuth('token', $config['zendesk']['token']); return $client; }
/** * Register the application services. * * @return void */ public function register() { $this->app->bind(Ticket::class, function () { $client = new Client(getenv('ZENDESK_SUBDOMAIN'), getenv('ZENDESK_USERNAME')); $client->setAuth('token', getenv('ZENDESK_TOKEN')); return new ZendeskTicket($client); }); }
/** * Perform the actual check and return a ResultInterface * * @return ResultInterface */ public function check() { try { $this->client->settings(); return new Success(); } catch (\Exception $e) { return new Failure($e->getMessage()); } }
public function setUP() { $username = getenv('END_USER_USERNAME'); $password = getenv('END_USER_PASSWORD'); $client_end_user = new Client($this->subdomain, $username); $client_end_user->setAuth('password', $password); $testTicket = array('subject' => 'Activity Stream Test', 'comment' => array('body' => 'ce est biche Actions test.'), 'priority' => 'normal'); $request = $client_end_user->requests()->create($testTicket); $this->ticket_id = $request->request->id; }
public function setUp() { // Auth as end user $username = getenv('END_USER_USERNAME'); $password = getenv('END_USER_PASSWORD'); $client_end_user = new Client($this->subdomain, $username); $client_end_user->setAuth('password', $password); $testTicket = array('subject' => 'Satisfaction Ratings Test', 'comment' => array('body' => 'Dette er for tilfredshed ratings test.'), 'priority' => 'normal'); $request = $client_end_user->requests()->create($testTicket); $this->ticket_id = $request->request->id; // Agent set ticket status to be solved $testTicket['status'] = 'solved'; $this->client->ticket($this->ticket_id)->update($testTicket); $rating = $client_end_user->ticket($this->ticket_id)->satisfactionRatings()->create(array('score' => 'good', 'comment' => 'Awesome support')); $this->assertEquals(is_object($rating), true, 'Should return an object'); $this->assertEquals(is_object($rating->satisfaction_rating), true, 'Should return an object called "satisfaction_rating"'); $this->assertGreaterThan(0, $rating->satisfaction_rating->id, 'Returns a non-numeric id for satisfaction_rating'); $this->assertEquals($rating->satisfaction_rating->score, 'good', 'Score of test rating does not match'); $this->assertEquals($client_end_user->getDebug()->lastResponseCode, '200', 'Does not return HTTP code 200'); $this->id = $rating->satisfaction_rating->id; }
/** * @param $requester_id * @return string * @throws \Zendesk\API\MissingParametersException * @throws \Zendesk\API\ResponseException */ public function getTicketRequester($requester_id) { $ret = ''; $requester = $this->zClient->user($requester_id)->find(); if (is_object($requester->user)) { $ret .= $requester->user->name; if (isset($requester->user->organization_id)) { $org = $this->zClient->organization($requester->user->organization_id)->find(); if (is_object($org->organization)) { $ret .= ' ' . $org->organization->name; } } } return $ret; }
<?php include "vendor/autoload.php"; use Zendesk\API\Client as ZendeskAPI; $subdomain = "paperstreet-ray"; $username = "******"; //$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; // replace this with your token $password = "******"; $client = new ZendeskAPI($subdomain, $username); $client->setAuth('password', $password); // set either token or password // Get all tickets //$tickets = $client->tickets()->findAll(); //echo '<pre>'; //print_r($tickets); //echo '</pre>'; //print_r($newTicket); // Create a new ticket /*$newTicket = $client->tickets()->create(array( 'requester_id' => 1145878187, 'subject' => 'this is the subject of tickets for chrome of chris requester', 'comment' => array( 'body' => 'my username is not working in chorme' ), 'recipient' => '*****@*****.**', 'custom_fields' => array( '26660777' => 'google chrome', '26660787' => '192.168.1.1', ),
<?php require 'vendor/autoload.php'; use Zendesk\API\Client as ZendeskAPI; ini_set('display_errors', 0); error_reporting(0); $subdomain = ""; $username = ""; $token = ""; $client = new ZendeskAPI($subdomain, $username); $client->setAuth('token', $token); $input = array('subject' => 'Test Ticket', 'type' => 'problem', 'priority' => 'low', 'description' => 'Test', 'external_id' => '25', 'status' => 'new', 'assignee_id' => '', 'requester' => array("name" => 'Name', "email" => '*****@*****.**')); $newTicket = $client->tickets()->create($input); $ticket_info = $newTicket->ticket; echo var_dump($ticket_info);
<?php include "vendor/autoload.php"; use Zendesk\API\Client as ZendeskAPI; $subdomain = "subdomain"; $username = "******"; $token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; // replace this with your token //$password = "******"; $client = new ZendeskAPI($subdomain, $username); $client->setAuth('token', $token); // set either token or password // Get all tickets $tickets = $client->tickets()->findAll(); print_r($tickets); // Create a new ticket $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')); print_r($newTicket); // Update multiple tickets $client->ticket(array(123, 456))->update(array('status' => 'urgent')); // Delete a ticket $client->ticket(123)->delete();
/** * Execute the job * * @return void */ public function execute() { $this->client->ticket()->create($this->getContent()); }