Skip to content

Commit

Permalink
Merge pull request #226 from zendesk/mio/satisfaction-rating
Browse files Browse the repository at this point in the history
[MI-480] Update CSAT rating creation to be chainable with ticket.
  • Loading branch information
miogalang committed Dec 2, 2015
2 parents 35dfc43 + a4b42bd commit 5dea57b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Zendesk/API/Resources/Core/SatisfactionRatings.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ protected function setUpRoutes()
}

/**
* Returns all comments for a particular ticket
* Creates a Satisfaction Rating
* https://developer.zendesk.com/rest_api/docs/core/satisfaction_ratings#create-a-satisfaction-rating
*
* @param array $queryParams
*
Expand Down
13 changes: 7 additions & 6 deletions src/Zendesk/API/Resources/Core/Tickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ class Tickets extends ResourceAbstract
public static function getValidSubResources()
{
return [
'comments' => TicketComments::class,
'forms' => TicketForms::class,
'tags' => Tags::class,
'audits' => TicketAudits::class,
'attachments' => Attachments::class,
'metrics' => TicketMetrics::class,
'comments' => TicketComments::class,
'forms' => TicketForms::class,
'tags' => Tags::class,
'audits' => TicketAudits::class,
'attachments' => Attachments::class,
'metrics' => TicketMetrics::class,
'satisfactionRatings' => SatisfactionRatings::class,
];
}

Expand Down
Empty file removed tests/Zendesk/API/MockTests/TOUCH
Empty file.
37 changes: 37 additions & 0 deletions tests/Zendesk/API/UnitTests/Core/SatisfactionRatingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,41 @@ public function testMethods()
$this->assertTrue(method_exists($this->client->satisfactionRatings(), 'find'));
$this->assertTrue(method_exists($this->client->satisfactionRatings(), 'findAll'));
}

/**
* Test the create method.
*/
public function testCreate()
{
$postParams = [
'score' => 'good',
'comment' => 'Awesome Support!',
];

$ticketId = 123;

$this->assertEndpointCalled(
function () use ($ticketId, $postParams) {
$this->client->tickets($ticketId)->satisfactionRatings()->create($postParams);
},
"tickets/{$ticketId}/satisfaction_rating.json",
'POST'
);
}

/**
* Test the create method requires a ticket id
*
* @expectedException Zendesk\API\Exceptions\MissingParametersException
* @expectedExceptionMessage Missing parameters: 'ticket_id' must be supplied for Zendesk\API\Resources\Core\SatisfactionRatings::create
*/
public function testCreateNeedsTicketId()
{
$postParams = [
'score' => 'good',
'comment' => 'Awesome Support!',
];

$this->client->satisfactionRatings()->create($postParams);
}
}

0 comments on commit 5dea57b

Please sign in to comment.