Skip to content

Commit

Permalink
TopicTranslations
Browse files Browse the repository at this point in the history
  • Loading branch information
bradfeehan committed Jun 6, 2013
1 parent ab13a29 commit fdbc07c
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/Desk/Client/desk.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
"extends": "list",
"summary": "Retrieve a paginated list of translations for a particular topic",
"uri": "topics/{topic_id}/translations",
"responseClass": "TopicTranslationsPage",
"parameters": {
"topic_id": {
"$ref": "id",
Expand Down Expand Up @@ -1176,6 +1177,36 @@
}
}
},
"TopicTranslationsPage": {
"extends": "page",
"data": {
"links": {
"entries": {
"model": "TopicTranslationModel"
},
"self": {
"operation": "ListTopicTranslations",
"pattern": "#/topics/(?P<topic_id>[0-9]+)/translations\\?page=(?P<page>[0-9]+)&per_page=(?P<per_page>[0-9]+)$#"
},
"first": {
"operation": "ListTopicTranslations",
"pattern": "#/topics/(?P<topic_id>[0-9]+)/translations\\?page=(?P<page>[0-9]+)&per_page=(?P<per_page>[0-9]+)$#"
},
"last": {
"operation": "ListTopicTranslations",
"pattern": "#/topics/(?P<topic_id>[0-9]+)/translations\\?page=(?P<page>[0-9]+)&per_page=(?P<per_page>[0-9]+)$#"
},
"next": {
"operation": "ListTopicTranslations",
"pattern": "#/topics/(?P<topic_id>[0-9]+)/translations\\?page=(?P<page>[0-9]+)&per_page=(?P<per_page>[0-9]+)$#"
},
"previous": {
"operation": "ListTopicTranslations",
"pattern": "#/topics/(?P<topic_id>[0-9]+)/translations\\?page=(?P<page>[0-9]+)&per_page=(?P<per_page>[0-9]+)$#"
}
}
}
},



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Desk\Test\Operation\Topics\Translations;

use Desk\Test\Helper\Operation\ListSubOperationTestCase;

/**
* @coversNothing
* @group system
*/
class ListTopicTranslationsOperationTest extends ListSubOperationTestCase
{

/**
* {@inheritdoc}
*/
protected function getOperationName()
{
return 'ListTopicTranslations';
}

/**
* {@inheritdoc}
*/
protected function getIdProperty()
{
return 'topic_id';
}

/**
* {@inheritdoc}
*/
protected function assertSystem(array $translations)
{
foreach ($translations as $translation) {
$this->assertSame('TopicTranslationModel', $translation->getStructure()->getName());
}

$this->assertSame(2, count($translations));


$enUs = $translations[0];
$this->assertSame('Customer Support', $enUs->get('name'));
$this->assertSame('en_us', $enUs->get('locale'));

$enUsSelf = $enUs->getLink('self');
$this->assertInstanceOf('Guzzle\\Service\\Command\\AbstractCommand', $enUsSelf);
$this->assertSame('ShowTopicTranslation', $enUsSelf->getName());
$this->assertSame(1, $enUsSelf->get('topic_id'));
$this->assertSame('en_us', $enUsSelf->get('locale'));


$ja = $translations[1];
$this->assertSame('Japanese Translation', $ja->get('name'));
$this->assertSame('ja', $ja->get('locale'));

$jaSelf = $ja->getLink('self');
$this->assertInstanceOf('Guzzle\\Service\\Command\\AbstractCommand', $jaSelf);
$this->assertSame('ShowTopicTranslation', $jaSelf->getName());
$this->assertSame(1, $jaSelf->get('topic_id'));
$this->assertSame('ja', $jaSelf->get('locale'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: must-revalidate, private, max-age=0
Content-Type: application/json; charset=utf-8
Status: 200
X-Rate-Limit-Limit: 60
X-Rate-Limit-Remaining: 59
X-Rate-Limit-Reset: 2
Content-Length: 1414
Connection: keep-alive

{
"total_entries": 2,
"_links": {
"self": {
"href": "/api/v2/topics/1/translations?page=1&per_page=30",
"class": "page"
},
"first": {
"href": "/api/v2/topics/1/translations?page=1&per_page=30",
"class": "page"
},
"last": {
"href": "/api/v2/topics/1/translations?page=1&per_page=30",
"class": "page"
},
"next": null,
"previous": null
},
"_embedded": {
"entries": [
{
"name": "Customer Support",
"locale": "en_us",
"created_at": "2013-05-25T19:54:11Z",
"updated_at": "2013-05-30T19:54:11Z",
"_links": {
"self": {
"href": "/api/v2/topics/1/translations/en_us",
"class": "topic_translation"
}
}
},
{
"name": "Japanese Translation",
"locale": "ja",
"created_at": "2013-06-04T19:53:15Z",
"updated_at": "2013-06-04T19:53:15Z",
"_links": {
"self": {
"href": "/api/v2/topics/1/translations/ja",
"class": "topic_translation"
}
}
}
]
}
}

0 comments on commit fdbc07c

Please sign in to comment.