示例#1
0
 /**
  * @param $ticket
  * @param $assignee
  *
  * @return array
  */
 protected function formatIssueDatas($ticket, $assignee)
 {
     $prefix = isset($this->config['issue_prefix']) ? $this->config['issue_prefix'] : 'Z';
     $datas['title'] = sprintf('[%s-%s] %s', $prefix, $ticket->id, $ticket->subject);
     $labelsCfg = $this->config['labels'];
     $datas['labels'] = [$labelsCfg['default']];
     if (isset($labelsCfg['priority']) && isset($labelsCfg['priority'][$ticket->priority])) {
         $datas['labels'][] = $labelsCfg['priority'][$ticket->priority];
     }
     $datas['assignee'] = $assignee;
     $body = $this->translator->trans('ticketprocessor.request.from') . $this->getTicketRequester($ticket->requester_id) . "\n\n";
     $body .= $ticket->description;
     $comments = $this->zClient->ticket($ticket->id)->comments()->findAll();
     if (is_array($comments->comments)) {
         $last = array_pop($comments->comments);
         $body .= $this->getAttachments($last);
     }
     $datas['body'] = $body;
     return $datas;
 }
 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;
 }
<?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();
示例#4
0
 /**
  * Execute the job
  *
  * @return void
  */
 public function execute()
 {
     $this->client->ticket()->create($this->getContent());
 }