desk_api 0.1.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile +0 -6
- data/README.md +38 -31
- data/desk_api.gemspec +1 -4
- data/lib/desk_api.rb +5 -7
- data/lib/desk_api/client.rb +44 -57
- data/lib/desk_api/configuration.rb +89 -95
- data/lib/desk_api/default.rb +51 -55
- data/lib/desk_api/error.rb +42 -44
- data/lib/desk_api/rate_limit.rb +20 -22
- data/lib/desk_api/resource.rb +142 -65
- data/lib/desk_api/version.rb +1 -1
- data/spec/cassettes/DeskApi_Client/using_Basic_Authentication/_delete/deletes_a_resource.yml +22 -22
- data/spec/cassettes/DeskApi_Client/using_Basic_Authentication/_get/fetches_resources.yml +26 -26
- data/spec/cassettes/DeskApi_Client/using_Basic_Authentication/_patch/updates_a_resource.yml +30 -30
- data/spec/cassettes/DeskApi_Client/using_Basic_Authentication/_post/creates_a_resource.yml +27 -27
- data/spec/cassettes/DeskApi_Client/using_OAuth/_delete/deletes_a_resource.yml +22 -22
- data/spec/cassettes/DeskApi_Client/using_OAuth/_get/fetches_resources.yml +31 -286
- data/spec/cassettes/DeskApi_Client/using_OAuth/_patch/updates_a_resource.yml +35 -35
- data/spec/cassettes/DeskApi_Client/using_OAuth/_post/creates_a_resource.yml +28 -28
- data/spec/cassettes/DeskApi_Error/_from_response/can_be_created_from_a_faraday_response.yml +22 -22
- data/spec/cassettes/DeskApi_Error/_from_response/uses_the_body_message_if_present.yml +22 -22
- data/spec/cassettes/DeskApi_Error/on_validation_error/allows_access_to_error_hash.yml +22 -22
- data/spec/cassettes/DeskApi_Resource/_by_url/finds_resources_by_url.yml +37 -286
- data/spec/cassettes/DeskApi_Resource/_create/creates_a_new_topic.yml +27 -27
- data/spec/cassettes/DeskApi_Resource/_create/throws_an_error_creating_a_user.yml +54 -0
- data/spec/cassettes/DeskApi_Resource/_delete/deletes_a_resource.yml +83 -79
- data/spec/cassettes/DeskApi_Resource/_delete/throws_an_error_deleting_a_non_deletalbe_resource.yml +78 -28
- data/spec/cassettes/DeskApi_Resource/_exec_/can_be_forced_to_reload.yml +34 -285
- data/spec/cassettes/DeskApi_Resource/_exec_/loads_the_current_resource.yml +34 -285
- data/spec/cassettes/DeskApi_Resource/_find/has_an_alias_by_id.yml +54 -0
- data/spec/cassettes/DeskApi_Resource/_find/loads_the_requested_resource.yml +54 -0
- data/spec/cassettes/DeskApi_Resource/_get_linked_resource/returns_linked_resources.yml +113 -0
- data/spec/cassettes/DeskApi_Resource/_get_linked_resource/returns_nil_if_link_is_nil.yml +62 -0
- data/spec/cassettes/DeskApi_Resource/_get_linked_resource/saves_the_linked_resource_instead_of_the_url.yml +113 -0
- data/spec/cassettes/DeskApi_Resource/_method_missing/loads_the_resource_to_find_a_suitable_method.yml +34 -285
- data/spec/cassettes/DeskApi_Resource/_method_missing/raises_an_error_if_method_does_not_exist.yml +34 -285
- data/spec/cassettes/DeskApi_Resource/_page/keeps_the_resource_as_loaded.yml +113 -0
- data/spec/cassettes/DeskApi_Resource/_page/returns_the_current_page_and_loads_if_page_not_defined.yml +62 -0
- data/spec/cassettes/DeskApi_Resource/_page/sets_the_resource_to_not_loaded.yml +113 -0
- data/spec/cassettes/DeskApi_Resource/_search/allows_searching_on_search_enabled_resources.yml +23 -23
- data/spec/cassettes/DeskApi_Resource/_search/throws_an_error_if_search_is_not_enabled.yml +52 -0
- data/spec/cassettes/DeskApi_Resource/_update/can_update_without_a_hash.yml +178 -58
- data/spec/cassettes/DeskApi_Resource/_update/throws_an_error_updating_a_user.yml +86 -28
- data/spec/cassettes/DeskApi_Resource/_update/updates_a_topic.yml +61 -57
- data/spec/desk_api/client_spec.rb +9 -16
- data/spec/desk_api/resource_spec.rb +118 -43
- data/spec/spec_helper.rb +1 -1
- metadata +24 -102
- data/lib/desk_api/action/create.rb +0 -15
- data/lib/desk_api/action/delete.rb +0 -9
- data/lib/desk_api/action/embeddable.rb +0 -47
- data/lib/desk_api/action/field.rb +0 -33
- data/lib/desk_api/action/link.rb +0 -29
- data/lib/desk_api/action/resource.rb +0 -14
- data/lib/desk_api/action/search.rb +0 -15
- data/lib/desk_api/action/update.rb +0 -17
- data/lib/desk_api/error/method_not_supported.rb +0 -9
- data/lib/desk_api/error/not_embeddable.rb +0 -8
- data/lib/desk_api/error/not_updateable.rb +0 -10
- data/lib/desk_api/error/parse_error.rb +0 -9
- data/lib/desk_api/resource/article.rb +0 -10
- data/lib/desk_api/resource/article_translation.rb +0 -8
- data/lib/desk_api/resource/attachment.rb +0 -8
- data/lib/desk_api/resource/case.rb +0 -11
- data/lib/desk_api/resource/company.rb +0 -8
- data/lib/desk_api/resource/customer.rb +0 -9
- data/lib/desk_api/resource/filter.rb +0 -7
- data/lib/desk_api/resource/inbound_mailbox.rb +0 -7
- data/lib/desk_api/resource/integration_url.rb +0 -9
- data/lib/desk_api/resource/job.rb +0 -9
- data/lib/desk_api/resource/label.rb +0 -9
- data/lib/desk_api/resource/macro.rb +0 -9
- data/lib/desk_api/resource/macro_action.rb +0 -7
- data/lib/desk_api/resource/note.rb +0 -7
- data/lib/desk_api/resource/page.rb +0 -64
- data/lib/desk_api/resource/reply.rb +0 -10
- data/lib/desk_api/resource/topic.rb +0 -9
- data/lib/desk_api/resource/topic_translation.rb +0 -9
- data/lib/desk_api/resource/user_preference.rb +0 -7
- data/lib/desk_api/resources.json +0 -76
- data/spec/cassettes/DeskApi_Client/_delete/deletes_a_resource.yml +0 -48
- data/spec/cassettes/DeskApi_Client/_get/fetches_resources.yml +0 -55
- data/spec/cassettes/DeskApi_Client/_patch/updates_a_resource.yml +0 -62
- data/spec/cassettes/DeskApi_Client/_post/creates_a_resource.yml +0 -58
- data/spec/cassettes/DeskApi_Resource_Case/once_closed/can_not_be_updated.yml +0 -124
- data/spec/cassettes/DeskApi_Resource_Page/_find/has_an_alias_by_id.yml +0 -54
- data/spec/cassettes/DeskApi_Resource_Page/_find/loads_the_requested_resource.yml +0 -54
- data/spec/cassettes/DeskApi_Resource_Page/_page/keeps_the_resource_as_loaded.yml +0 -113
- data/spec/cassettes/DeskApi_Resource_Page/_page/returns_the_current_page_and_loads_if_page_not_defined.yml +0 -313
- data/spec/cassettes/DeskApi_Resource_Page/_page/sets_the_resource_to_not_loaded.yml +0 -113
- data/spec/desk_api/resource/case_spec.rb +0 -28
- data/spec/desk_api/resource/page_spec.rb +0 -68
@@ -10,47 +10,105 @@ http_interactions:
|
|
10
10
|
Accept:
|
11
11
|
- application/json
|
12
12
|
User-Agent:
|
13
|
-
- desk.com Ruby Gem v0.1.
|
13
|
+
- desk.com Ruby Gem v0.1.3
|
14
14
|
response:
|
15
15
|
status:
|
16
16
|
code: 200
|
17
17
|
message:
|
18
18
|
headers:
|
19
|
-
|
19
|
+
accept-ranges:
|
20
20
|
- bytes
|
21
|
-
|
21
|
+
cache-control:
|
22
22
|
- no-cache, private
|
23
|
-
|
23
|
+
content-type:
|
24
24
|
- application/json; charset=utf-8
|
25
|
-
|
26
|
-
-
|
27
|
-
|
28
|
-
- '"
|
29
|
-
|
25
|
+
date:
|
26
|
+
- Thu, 12 Dec 2013 19:48:10 GMT
|
27
|
+
etag:
|
28
|
+
- '"1386874620"'
|
29
|
+
status:
|
30
30
|
- 200 OK
|
31
|
-
|
31
|
+
vary:
|
32
|
+
- X-AppVersion
|
33
|
+
x-appversion:
|
34
|
+
- '15.6'
|
35
|
+
x-frame-options:
|
36
|
+
- SAMEORIGIN
|
37
|
+
x-rate-limit-limit:
|
38
|
+
- '60'
|
39
|
+
x-rate-limit-remaining:
|
40
|
+
- '57'
|
41
|
+
x-rate-limit-reset:
|
42
|
+
- '50'
|
43
|
+
x-request-id:
|
44
|
+
- 01bc92aa110d2b588c8383c7e8e7eee6
|
45
|
+
content-length:
|
46
|
+
- '4293'
|
47
|
+
connection:
|
48
|
+
- Close
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"total_entries":6,"_links":{"self":{"href":"/api/v2/users?page=1&per_page=50","class":"page"},"first":{"href":"/api/v2/users?page=1&per_page=50","class":"page"},"last":{"href":"/api/v2/users?page=1&per_page=50","class":"page"},"previous":null,"next":null},"_embedded":{"entries":[{"name":"Thomas
|
52
|
+
Stachl","public_name":"Thomas Stachl","email":"tstachl@salesforce.com","level":"siteadmin_billing","avatar":"http://www.gravatar.com/avatar/9d1a9e1a385960d1ba80fb873128cf73?rating=PG&size=50&default=https%3A%2F%2Fd218iqt4mo6adh.cloudfront.net%2Fassets%2Funknown_user_50-521aae04e00222d7dd814e72d7d869d0.png","created_at":"2012-06-06T14:51:21Z","updated_at":"2013-12-11T18:08:41Z","current_login_at":"2013-12-11T18:08:41Z","last_login_at":"2013-12-11T00:50:06Z","_links":{"self":{"href":"/api/v2/users/16096734","class":"user"},"preferences":{"href":"/api/v2/users/16096734/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/16096734/searches","class":"search"}}},{"name":"Dan
|
53
|
+
Stern","public_name":"Dan","email":"dan@desk.com","level":"siteadmin","avatar":"http://www.gravatar.com/avatar/5f56818e857c5776e02779aa2a4f8ea4?rating=PG&size=50&default=https%3A%2F%2Fd218iqt4mo6adh.cloudfront.net%2Fassets%2Funknown_user_50-521aae04e00222d7dd814e72d7d869d0.png","created_at":"2012-06-06T18:24:08Z","updated_at":"2013-08-05T22:33:48Z","current_login_at":"2013-08-05T22:33:48Z","last_login_at":"2013-08-05T22:32:16Z","_links":{"self":{"href":"/api/v2/users/16107036","class":"user"},"preferences":{"href":"/api/v2/users/16107036/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/16107036/searches","class":"search"}}},{"name":"Mark","public_name":"Mark","email":"mchasse_old@desk.com","level":"siteadmin_billing","avatar":"http://www.gravatar.com/avatar/f2d79817f28bbe7b89081b59b9a370d0?rating=PG&size=50&default=https%3A%2F%2Fd218iqt4mo6adh.cloudfront.net%2Fassets%2Funknown_user_50-521aae04e00222d7dd814e72d7d869d0.png","created_at":"2012-06-22T21:52:55Z","updated_at":"2013-05-16T01:30:48Z","current_login_at":"2013-05-16T01:30:34Z","last_login_at":"2012-07-17T19:24:54Z","_links":{"self":{"href":"/api/v2/users/17069383","class":"user"},"preferences":{"href":"/api/v2/users/17069383/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/17069383/searches","class":"search"}}},{"name":"Mich","public_name":"Mich","email":"mich@desk.com","level":"siteadmin_billing","avatar":"http://www.gravatar.com/avatar/73a4ddb25d4f0ce32eddb64add48a730?rating=PG&size=50&default=https%3A%2F%2Fd218iqt4mo6adh.cloudfront.net%2Fassets%2Funknown_user_50-521aae04e00222d7dd814e72d7d869d0.png","created_at":"2012-06-22T21:53:12Z","updated_at":"2012-06-22T21:55:12Z","current_login_at":"2012-06-22T21:55:08Z","last_login_at":null,"_links":{"self":{"href":"/api/v2/users/17069397","class":"user"},"preferences":{"href":"/api/v2/users/17069397/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/17069397/searches","class":"search"}}},{"name":"Keith","public_name":"Keith","email":"keith@desk.com","level":"agent","avatar":"http://www.gravatar.com/avatar/c492d3f749ce562f187fb738ef6adaa7?rating=PG&size=50&default=https%3A%2F%2Fd218iqt4mo6adh.cloudfront.net%2Fassets%2Funknown_user_50-521aae04e00222d7dd814e72d7d869d0.png","created_at":"2012-06-26T00:11:48Z","updated_at":"2012-06-26T19:02:52Z","current_login_at":"2012-06-26T19:02:51Z","last_login_at":null,"_links":{"self":{"href":"/api/v2/users/17250751","class":"user"},"preferences":{"href":"/api/v2/users/17250751/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/17250751/searches","class":"search"}}},{"name":"Thomas
|
54
|
+
Stachl","public_name":"Thomas Stachl","email":"thomas@desk.com","level":"flexagent","avatar":"http://www.gravatar.com/avatar/9385d65da0b8577fef3fc472dd8b5e1b?rating=PG&size=50&default=https%3A%2F%2Fd218iqt4mo6adh.cloudfront.net%2Fassets%2Funknown_user_50-521aae04e00222d7dd814e72d7d869d0.png","created_at":"2013-09-11T20:24:06Z","updated_at":"2013-09-11T20:24:23Z","current_login_at":null,"last_login_at":null,"_links":{"self":{"href":"/api/v2/users/21410327","class":"user"},"preferences":{"href":"/api/v2/users/21410327/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/21410327/searches","class":"search"}}}]}}'
|
55
|
+
http_version:
|
56
|
+
recorded_at: Thu, 12 Dec 2013 19:48:10 GMT
|
57
|
+
- request:
|
58
|
+
method: patch
|
59
|
+
uri: https://devel.desk.com/api/v2/users/16096734
|
60
|
+
body:
|
61
|
+
encoding: UTF-8
|
62
|
+
string: '{"name":"Some User"}'
|
63
|
+
headers:
|
64
|
+
Accept:
|
65
|
+
- application/json
|
66
|
+
User-Agent:
|
67
|
+
- desk.com Ruby Gem v0.1.3
|
68
|
+
Content-Type:
|
69
|
+
- application/json
|
70
|
+
response:
|
71
|
+
status:
|
72
|
+
code: 405
|
73
|
+
message:
|
74
|
+
headers:
|
75
|
+
cache-control:
|
76
|
+
- no-cache
|
77
|
+
content-type:
|
78
|
+
- application/json; charset=utf-8
|
79
|
+
date:
|
80
|
+
- Thu, 12 Dec 2013 19:48:10 GMT
|
81
|
+
server:
|
82
|
+
- nginx
|
83
|
+
status:
|
84
|
+
- 405 Method Not Allowed
|
85
|
+
vary:
|
32
86
|
- X-AppVersion
|
33
|
-
|
34
|
-
- '
|
35
|
-
|
87
|
+
x-appversion:
|
88
|
+
- '15.6'
|
89
|
+
x-frame-options:
|
36
90
|
- SAMEORIGIN
|
37
|
-
|
91
|
+
x-rack-cache:
|
92
|
+
- invalidate, pass
|
93
|
+
x-rate-limit-limit:
|
38
94
|
- '60'
|
39
|
-
|
40
|
-
- '
|
41
|
-
|
42
|
-
- '
|
43
|
-
|
44
|
-
-
|
45
|
-
|
46
|
-
- '
|
47
|
-
|
48
|
-
-
|
95
|
+
x-rate-limit-remaining:
|
96
|
+
- '56'
|
97
|
+
x-rate-limit-reset:
|
98
|
+
- '50'
|
99
|
+
x-request-id:
|
100
|
+
- 30d39d0e087f2bcbc04472e00eec6732
|
101
|
+
x-runtime:
|
102
|
+
- '0.057366'
|
103
|
+
x-ua-compatible:
|
104
|
+
- IE=Edge,chrome=1
|
105
|
+
content-length:
|
106
|
+
- '32'
|
107
|
+
connection:
|
108
|
+
- Close
|
49
109
|
body:
|
50
110
|
encoding: UTF-8
|
51
|
-
string: '{"
|
52
|
-
Stachl","public_name":"Thomas Stachl","email":"tstachl@salesforce.com","level":"siteadmin_billing","_links":{"self":{"href":"/api/v2/users/16096734","class":"user"},"preferences":{"href":"/api/v2/users/16096734/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/16096734/searches","class":"search"}}},{"name":"Dan
|
53
|
-
Stern","public_name":"Dan","email":"dan@desk.com","level":"siteadmin","_links":{"self":{"href":"/api/v2/users/16107036","class":"user"},"preferences":{"href":"/api/v2/users/16107036/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/16107036/searches","class":"search"}}},{"name":"Mark","public_name":"Mark","email":"mchasse_old@desk.com","level":"siteadmin_billing","_links":{"self":{"href":"/api/v2/users/17069383","class":"user"},"preferences":{"href":"/api/v2/users/17069383/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/17069383/searches","class":"search"}}},{"name":"Mich","public_name":"Mich","email":"mich@desk.com","level":"siteadmin_billing","_links":{"self":{"href":"/api/v2/users/17069397","class":"user"},"preferences":{"href":"/api/v2/users/17069397/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/17069397/searches","class":"search"}}},{"name":"Keith","public_name":"Keith","email":"keith@desk.com","level":"agent","_links":{"self":{"href":"/api/v2/users/17250751","class":"user"},"preferences":{"href":"/api/v2/users/17250751/preferences","class":"user_preference"},"searches":{"href":"/api/v2/users/17250751/searches","class":"search"}}}]}}'
|
111
|
+
string: '{"message":"Method Not Allowed"}'
|
54
112
|
http_version:
|
55
|
-
recorded_at:
|
113
|
+
recorded_at: Thu, 12 Dec 2013 19:48:10 GMT
|
56
114
|
recorded_with: VCR 2.5.0
|
@@ -10,50 +10,54 @@ http_interactions:
|
|
10
10
|
Accept:
|
11
11
|
- application/json
|
12
12
|
User-Agent:
|
13
|
-
- desk.com Ruby Gem v0.1.
|
13
|
+
- desk.com Ruby Gem v0.1.3
|
14
14
|
response:
|
15
15
|
status:
|
16
16
|
code: 200
|
17
17
|
message:
|
18
18
|
headers:
|
19
|
-
|
19
|
+
accept-ranges:
|
20
20
|
- bytes
|
21
|
-
|
21
|
+
cache-control:
|
22
22
|
- must-revalidate, private, max-age=0
|
23
|
-
|
23
|
+
content-type:
|
24
24
|
- application/json; charset=utf-8
|
25
|
-
|
26
|
-
-
|
27
|
-
|
28
|
-
- '"
|
29
|
-
|
25
|
+
date:
|
26
|
+
- Thu, 12 Dec 2013 19:48:09 GMT
|
27
|
+
etag:
|
28
|
+
- '"e3114a0601687cc0b64b8e6c67c5091f"'
|
29
|
+
status:
|
30
30
|
- 200 OK
|
31
|
-
|
31
|
+
vary:
|
32
32
|
- X-AppVersion
|
33
|
-
|
34
|
-
- '
|
35
|
-
|
33
|
+
x-appversion:
|
34
|
+
- '15.6'
|
35
|
+
x-frame-options:
|
36
36
|
- SAMEORIGIN
|
37
|
-
|
37
|
+
x-rate-limit-limit:
|
38
38
|
- '60'
|
39
|
-
|
39
|
+
x-rate-limit-remaining:
|
40
|
+
- '59'
|
41
|
+
x-rate-limit-reset:
|
40
42
|
- '51'
|
41
|
-
|
42
|
-
-
|
43
|
-
|
44
|
-
-
|
45
|
-
|
46
|
-
-
|
47
|
-
Connection:
|
48
|
-
- keep-alive
|
43
|
+
x-request-id:
|
44
|
+
- 429e13bfddb8999e46597e90f6c05ba8
|
45
|
+
content-length:
|
46
|
+
- '3137'
|
47
|
+
connection:
|
48
|
+
- Close
|
49
49
|
body:
|
50
50
|
encoding: UTF-8
|
51
|
-
string: '{"total_entries":
|
52
|
-
English","description":"Another description update.","position":1,"allow_questions":true,"in_support_center":true,"created_at":"2013-04-22T23:46:42Z","updated_at":"2013-
|
53
|
-
Updated Topic","description":null,"position":2,"allow_questions":true,"in_support_center":null,"created_at":"2013-08-14T19:37:08Z","updated_at":"2013-08-
|
54
|
-
new topic","description":null,"position":3,"allow_questions":true,"in_support_center":null,"created_at":"2013-08-15T21:20:32Z","updated_at":"2013-08-
|
51
|
+
string: '{"total_entries":7,"_links":{"self":{"href":"/api/v2/topics?page=1&per_page=50","class":"page"},"first":{"href":"/api/v2/topics?page=1&per_page=50","class":"page"},"last":{"href":"/api/v2/topics?page=1&per_page=50","class":"page"},"previous":null,"next":null},"_embedded":{"entries":[{"name":"Testing
|
52
|
+
English","description":"Another description update.","position":1,"allow_questions":true,"in_support_center":true,"created_at":"2013-04-22T23:46:42Z","updated_at":"2013-12-12T03:00:21Z","_links":{"self":{"href":"/api/v2/topics/498301","class":"topic"},"articles":{"href":"/api/v2/topics/498301/articles","class":"article"},"translations":{"href":"/api/v2/topics/498301/translations","class":"topic_translation"}}},{"name":"Test
|
53
|
+
Updated Topic","description":null,"position":2,"allow_questions":true,"in_support_center":null,"created_at":"2013-08-14T19:37:08Z","updated_at":"2013-08-19T23:53:31Z","_links":{"self":{"href":"/api/v2/topics/556402","class":"topic"},"articles":{"href":"/api/v2/topics/556402/articles","class":"article"},"translations":{"href":"/api/v2/topics/556402/translations","class":"topic_translation"}}},{"name":"My
|
54
|
+
new topic","description":null,"position":3,"allow_questions":true,"in_support_center":null,"created_at":"2013-08-15T21:20:32Z","updated_at":"2013-08-19T23:53:31Z","_links":{"self":{"href":"/api/v2/topics/556908","class":"topic"},"articles":{"href":"/api/v2/topics/556908/articles","class":"article"},"translations":{"href":"/api/v2/topics/556908/translations","class":"topic_translation"}}},{"name":"My
|
55
|
+
new topic","description":null,"position":4,"allow_questions":true,"in_support_center":null,"created_at":"2013-08-19T23:51:34Z","updated_at":"2013-08-19T23:53:31Z","_links":{"self":{"href":"/api/v2/topics/558244","class":"topic"},"articles":{"href":"/api/v2/topics/558244/articles","class":"article"},"translations":{"href":"/api/v2/topics/558244/translations","class":"topic_translation"}}},{"name":"Test
|
56
|
+
Topic","description":null,"position":5,"allow_questions":true,"in_support_center":null,"created_at":"2013-09-03T02:04:32Z","updated_at":"2013-09-03T02:04:32Z","_links":{"self":{"href":"/api/v2/topics/563658","class":"topic"},"articles":{"href":"/api/v2/topics/563658/articles","class":"article"},"translations":{"href":"/api/v2/topics/563658/translations","class":"topic_translation"}}},{"name":"Test
|
57
|
+
Topic","description":null,"position":6,"allow_questions":true,"in_support_center":null,"created_at":"2013-12-12T02:51:59Z","updated_at":"2013-12-12T02:51:59Z","_links":{"self":{"href":"/api/v2/topics/601116","class":"topic"},"articles":{"href":"/api/v2/topics/601116/articles","class":"article"},"translations":{"href":"/api/v2/topics/601116/translations","class":"topic_translation"}}},{"name":"My
|
58
|
+
new topic","description":null,"position":7,"allow_questions":true,"in_support_center":null,"created_at":"2013-12-12T19:45:06Z","updated_at":"2013-12-12T19:45:06Z","_links":{"self":{"href":"/api/v2/topics/601361","class":"topic"},"articles":{"href":"/api/v2/topics/601361/articles","class":"article"},"translations":{"href":"/api/v2/topics/601361/translations","class":"topic_translation"}}}]}}'
|
55
59
|
http_version:
|
56
|
-
recorded_at:
|
60
|
+
recorded_at: Thu, 12 Dec 2013 19:48:09 GMT
|
57
61
|
- request:
|
58
62
|
method: patch
|
59
63
|
uri: https://devel.desk.com/api/v2/topics/498301
|
@@ -64,7 +68,7 @@ http_interactions:
|
|
64
68
|
Accept:
|
65
69
|
- application/json
|
66
70
|
User-Agent:
|
67
|
-
- desk.com Ruby Gem v0.1.
|
71
|
+
- desk.com Ruby Gem v0.1.3
|
68
72
|
Content-Type:
|
69
73
|
- application/json
|
70
74
|
response:
|
@@ -72,45 +76,45 @@ http_interactions:
|
|
72
76
|
code: 200
|
73
77
|
message:
|
74
78
|
headers:
|
75
|
-
|
79
|
+
cache-control:
|
76
80
|
- max-age=0, private, must-revalidate
|
77
|
-
|
81
|
+
content-type:
|
78
82
|
- application/json; charset=utf-8
|
79
|
-
|
80
|
-
-
|
81
|
-
|
82
|
-
- '"
|
83
|
-
|
83
|
+
date:
|
84
|
+
- Thu, 12 Dec 2013 19:48:10 GMT
|
85
|
+
etag:
|
86
|
+
- '"5c3d0145d8847569b17c6a6c4007de80"'
|
87
|
+
server:
|
84
88
|
- nginx
|
85
|
-
|
89
|
+
status:
|
86
90
|
- 200 OK
|
87
|
-
|
91
|
+
vary:
|
88
92
|
- X-AppVersion
|
89
|
-
|
90
|
-
- '
|
91
|
-
|
93
|
+
x-appversion:
|
94
|
+
- '15.6'
|
95
|
+
x-frame-options:
|
92
96
|
- SAMEORIGIN
|
93
|
-
|
97
|
+
x-rack-cache:
|
94
98
|
- invalidate, pass
|
95
|
-
|
99
|
+
x-rate-limit-limit:
|
96
100
|
- '60'
|
97
|
-
|
98
|
-
- '
|
99
|
-
|
100
|
-
- '
|
101
|
-
|
102
|
-
-
|
103
|
-
|
104
|
-
- '0.
|
105
|
-
|
101
|
+
x-rate-limit-remaining:
|
102
|
+
- '58'
|
103
|
+
x-rate-limit-reset:
|
104
|
+
- '51'
|
105
|
+
x-request-id:
|
106
|
+
- 9aa12860c6a7e9adbfc3ce0c4b07faea
|
107
|
+
x-runtime:
|
108
|
+
- '0.113486'
|
109
|
+
x-ua-compatible:
|
106
110
|
- IE=Edge,chrome=1
|
107
|
-
|
111
|
+
content-length:
|
108
112
|
- '426'
|
109
|
-
|
110
|
-
-
|
113
|
+
connection:
|
114
|
+
- Close
|
111
115
|
body:
|
112
116
|
encoding: UTF-8
|
113
|
-
string: '{"name":"Updated topic name","description":"Some new description","position":1,"allow_questions":true,"in_support_center":true,"created_at":"2013-04-22T23:46:42Z","updated_at":"2013-
|
117
|
+
string: '{"name":"Updated topic name","description":"Some new description","position":1,"allow_questions":true,"in_support_center":true,"created_at":"2013-04-22T23:46:42Z","updated_at":"2013-12-12T19:48:10Z","_links":{"self":{"href":"/api/v2/topics/498301","class":"topic"},"articles":{"href":"/api/v2/topics/498301/articles","class":"article"},"translations":{"href":"/api/v2/topics/498301/translations","class":"topic_translation"}}}'
|
114
118
|
http_version:
|
115
|
-
recorded_at:
|
119
|
+
recorded_at: Thu, 12 Dec 2013 19:48:10 GMT
|
116
120
|
recorded_with: VCR 2.5.0
|
@@ -73,39 +73,32 @@ describe DeskApi::Client do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
77
|
-
it 'sets up default resources on client' do
|
78
|
-
subject.methods include(:articles, :cases, :companies, :custom_fields, :customers)
|
79
|
-
subject.methods include(:filters, :groups, :inbound_mailboxes, :integration_urls)
|
80
|
-
subject.methods include(:jobs, :labels, :macros, :rules, :site_settings)
|
81
|
-
subject.methods include(:system_message, :topics, :twitter_accounts, :users)
|
82
|
-
end
|
83
76
|
end
|
84
77
|
|
85
78
|
context 'using Basic Authentication' do
|
86
79
|
describe '#get', :vcr do
|
87
80
|
it 'fetches resources' do
|
88
81
|
response = subject.get('/api/v2/cases/3014')
|
89
|
-
response.body
|
82
|
+
response.body['subject'].should eq('Testing Quick Case')
|
90
83
|
end
|
91
84
|
end
|
92
85
|
|
93
86
|
describe '#post', :vcr do
|
94
87
|
it 'creates a resource' do
|
95
88
|
response = subject.post('/api/v2/topics', @topic_create_data)
|
96
|
-
response.body
|
89
|
+
response.body['name'].should eq(@topic_create_data[:name])
|
97
90
|
end
|
98
91
|
end
|
99
92
|
|
100
93
|
describe '#patch', :vcr do
|
101
94
|
it 'updates a resource' do
|
102
|
-
subject.patch('/api/v2/topics/
|
95
|
+
subject.patch('/api/v2/topics/601117', @topic_update_data).body['name'].should eq(@topic_update_data[:name])
|
103
96
|
end
|
104
97
|
end
|
105
98
|
|
106
99
|
describe '#delete', :vcr do
|
107
100
|
it 'deletes a resource' do
|
108
|
-
subject.delete('/api/v2/topics/
|
101
|
+
subject.delete('/api/v2/topics/601117').status.should eq(204)
|
109
102
|
end
|
110
103
|
end
|
111
104
|
end
|
@@ -119,27 +112,27 @@ describe DeskApi::Client do
|
|
119
112
|
|
120
113
|
describe '#get', :vcr do
|
121
114
|
it 'fetches resources' do
|
122
|
-
response = @client.get('/api/v2/articles/
|
123
|
-
response.body
|
115
|
+
response = @client.get('/api/v2/articles/1391017')
|
116
|
+
response.body['subject'].should eq('Testing OAuth')
|
124
117
|
end
|
125
118
|
end
|
126
119
|
|
127
120
|
describe '#post', :vcr do
|
128
121
|
it 'creates a resource' do
|
129
122
|
response = @client.post('/api/v2/articles', @article_create_data)
|
130
|
-
response.body
|
123
|
+
response.body['subject'].should eq(@article_create_data[:subject])
|
131
124
|
end
|
132
125
|
end
|
133
126
|
|
134
127
|
describe '#patch', :vcr do
|
135
128
|
it 'updates a resource' do
|
136
|
-
@client.patch('/api/v2/articles/
|
129
|
+
@client.patch('/api/v2/articles/1391017', @article_update_data).body['subject'].should eq(@article_update_data[:subject])
|
137
130
|
end
|
138
131
|
end
|
139
132
|
|
140
133
|
describe '#delete', :vcr do
|
141
134
|
it 'deletes a resource' do
|
142
|
-
@client.delete('/api/v2/articles/
|
135
|
+
@client.delete('/api/v2/articles/1391017').status.should eq(204)
|
143
136
|
end
|
144
137
|
end
|
145
138
|
end
|
@@ -7,25 +7,25 @@ describe DeskApi::Resource do
|
|
7
7
|
|
8
8
|
context '#initialize' do
|
9
9
|
it 'stores the client' do
|
10
|
-
subject.articles.instance_variable_get(:@
|
10
|
+
subject.articles.instance_variable_get(:@_client).should eq(subject)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'is not loaded initially' do
|
14
|
-
subject.articles.instance_variable_get(:@
|
14
|
+
subject.articles.instance_variable_get(:@_loaded).should be_false
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'sets up the link to self' do
|
18
|
-
subject.articles.
|
18
|
+
subject.articles.href.should_not be_nil
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
context '#exec!', :vcr do
|
23
23
|
it 'loads the current resource' do
|
24
|
-
subject.articles.send(:exec!).instance_variable_get(:@
|
24
|
+
subject.articles.send(:exec!).instance_variable_get(:@_loaded).should be_true
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'can be forced to reload' do
|
28
|
-
subject.articles.instance_variable_set(:@
|
28
|
+
subject.articles.instance_variable_set(:@_loaded, true)
|
29
29
|
subject.should_receive(:get).and_call_original
|
30
30
|
subject.articles.send(:exec!, true)
|
31
31
|
end
|
@@ -33,44 +33,53 @@ describe DeskApi::Resource do
|
|
33
33
|
|
34
34
|
context '#method_missing', :vcr do
|
35
35
|
it 'loads the resource to find a suitable method' do
|
36
|
-
subject.articles
|
37
|
-
|
38
|
-
|
36
|
+
articles = subject.articles
|
37
|
+
articles.instance_variable_set(:@_loaded, false)
|
38
|
+
articles.should_receive(:exec!).and_call_original
|
39
|
+
articles.entries
|
39
40
|
end
|
40
41
|
|
41
42
|
it 'raises an error if method does not exist' do
|
42
|
-
lambda { subject.articles.some_other_method }.should raise_error(
|
43
|
+
lambda { subject.articles.some_other_method }.should raise_error(NoMethodError)
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
context '#by_url', :vcr do
|
47
48
|
it 'finds resources by url' do
|
48
|
-
subject.articles.by_url('/api/v2/articles/
|
49
|
+
subject.articles.by_url('/api/v2/articles/1295677').should be_an_instance_of(DeskApi::Resource)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
53
|
context '#get_self' do
|
53
54
|
it 'returns the hash for self' do
|
54
55
|
subject.articles.get_self.should eq({
|
55
|
-
"href" => "/api/v2/articles"
|
56
|
-
"class" => "page"
|
56
|
+
"href" => "/api/v2/articles"
|
57
57
|
})
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context '#
|
61
|
+
context '#href' do
|
62
62
|
it 'returns the href for self' do
|
63
|
-
subject.articles.
|
63
|
+
subject.articles.href.should eq('/api/v2/articles')
|
64
64
|
end
|
65
|
-
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
it 'sets the href' do
|
67
|
+
res = DeskApi::Resource.new(subject, {
|
68
|
+
'_links'=>{'self'=>{'href'=>'/api/v2/cases'}}
|
69
|
+
}, true)
|
70
|
+
|
71
|
+
res.href.should eq('/api/v2/cases')
|
72
|
+
res.href = '/api/v2/articles'
|
73
|
+
res.href.should eq('/api/v2/articles')
|
70
74
|
end
|
75
|
+
end
|
71
76
|
|
72
|
-
|
73
|
-
|
77
|
+
context '#type' do
|
78
|
+
it 'returns the resources type' do
|
79
|
+
res = DeskApi::Resource.new(subject, {
|
80
|
+
'_links'=>{'self'=>{'href'=>'/api/v2/cases','class'=>'page'}}
|
81
|
+
}, true)
|
82
|
+
res.type.should eq('page')
|
74
83
|
end
|
75
84
|
end
|
76
85
|
|
@@ -78,10 +87,6 @@ describe DeskApi::Resource do
|
|
78
87
|
it 'allows searching on search enabled resources', :vcr do
|
79
88
|
subject.articles.search(text: 'Lorem Ipsum').total_entries.should eq(0)
|
80
89
|
end
|
81
|
-
|
82
|
-
it 'throws an error if search is not enabled' do
|
83
|
-
lambda { subject.users.search(test: 'something') }.should raise_error(DeskApi::Error::MethodNotSupported)
|
84
|
-
end
|
85
90
|
end
|
86
91
|
|
87
92
|
context '#create' do
|
@@ -91,14 +96,14 @@ describe DeskApi::Resource do
|
|
91
96
|
}).name.should eq('My new topic')
|
92
97
|
end
|
93
98
|
|
94
|
-
it 'throws an error creating a user' do
|
95
|
-
lambda { subject.users.create(name: 'Some User') }.should raise_error(DeskApi::Error::
|
99
|
+
it 'throws an error creating a user', :vcr do
|
100
|
+
lambda { subject.users.create(name: 'Some User') }.should raise_error(DeskApi::Error::MethodNotAllowed)
|
96
101
|
end
|
97
102
|
end
|
98
103
|
|
99
104
|
context '#update' do
|
100
105
|
it 'updates a topic', :vcr do
|
101
|
-
topic = subject.topics.first
|
106
|
+
topic = subject.topics.entries.first
|
102
107
|
|
103
108
|
topic.description = 'Some new description'
|
104
109
|
topic.update({
|
@@ -110,15 +115,15 @@ describe DeskApi::Resource do
|
|
110
115
|
end
|
111
116
|
|
112
117
|
it 'throws an error updating a user', :vcr do
|
113
|
-
user = subject.users.first
|
114
|
-
lambda { user.update(name: 'Some User') }.should raise_error(DeskApi::Error::
|
118
|
+
user = subject.users.entries.first
|
119
|
+
lambda { user.update(name: 'Some User') }.should raise_error(DeskApi::Error::MethodNotAllowed)
|
115
120
|
end
|
116
121
|
|
117
122
|
it 'can update without a hash', :vcr do
|
118
|
-
topic = subject.topics.first
|
123
|
+
topic = subject.topics.entries.first
|
119
124
|
topic.description = 'Another description update.'
|
120
125
|
topic.update
|
121
|
-
subject.topics.first.description.should eq('Another description update.')
|
126
|
+
subject.topics.entries.first.description.should eq('Another description update.')
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
@@ -128,30 +133,24 @@ describe DeskApi::Resource do
|
|
128
133
|
subject: 'My subject',
|
129
134
|
body: 'Some text for this new article',
|
130
135
|
_links: {
|
131
|
-
topic: subject.topics.first.get_self
|
136
|
+
topic: subject.topics.entries.first.get_self
|
132
137
|
}
|
133
138
|
}).delete.should be_true
|
134
139
|
end
|
135
140
|
|
136
141
|
it 'throws an error deleting a non deletalbe resource', :vcr do
|
137
|
-
user = subject.users.first
|
138
|
-
lambda { user.delete }.should raise_error(DeskApi::Error::
|
142
|
+
user = subject.users.entries.first
|
143
|
+
lambda { user.delete }.should raise_error(DeskApi::Error::MethodNotAllowed)
|
139
144
|
end
|
140
145
|
end
|
141
146
|
|
142
147
|
describe 'embeddable' do
|
143
|
-
it 'has resources defined' do
|
144
|
-
DeskApi::Resource::Case.embeddable?(:assigned_user).should be_true
|
145
|
-
DeskApi::Resource::Case.embeddable?(:message).should be_false
|
146
|
-
end
|
147
|
-
|
148
148
|
it 'allows to declare embedds' do
|
149
149
|
lambda { subject.cases.embed(:assigned_user) }.should_not raise_error
|
150
|
-
lambda { subject.cases.embed(:message) }.should raise_error(DeskApi::Error::NotEmbeddable)
|
151
150
|
end
|
152
151
|
|
153
152
|
it 'changes the url' do
|
154
|
-
subject.cases.embed(:assigned_user).
|
153
|
+
subject.cases.embed(:assigned_user).href.should eq('/api/v2/cases?embed=assigned_user')
|
155
154
|
end
|
156
155
|
|
157
156
|
context 'if you use embed' do
|
@@ -184,9 +183,9 @@ describe DeskApi::Resource do
|
|
184
183
|
]
|
185
184
|
end
|
186
185
|
|
187
|
-
first_case = @client.cases.embed(:assigned_user).first
|
186
|
+
first_case = @client.cases.embed(:assigned_user).entries.first
|
188
187
|
first_case.assigned_user.name.should eq('Thomas Stachl')
|
189
|
-
first_case.assigned_user.instance_variable_get(:@
|
188
|
+
first_case.assigned_user.instance_variable_get(:@_loaded).should be_true
|
190
189
|
times_called.should eq(1)
|
191
190
|
end
|
192
191
|
|
@@ -206,4 +205,80 @@ describe DeskApi::Resource do
|
|
206
205
|
end
|
207
206
|
end
|
208
207
|
end
|
208
|
+
|
209
|
+
context '#query_params' do
|
210
|
+
before do
|
211
|
+
@page = DeskApi::Resource.new(subject, {
|
212
|
+
'_links'=>{'self'=>{'href'=>'/api/v2/cases?page=2&per_page=50'}}
|
213
|
+
}, true)
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'allows to get query params from the current resource' do
|
217
|
+
@page.send(:query_params_include?, 'page').should eq('2')
|
218
|
+
@page.send(:query_params_include?, 'per_page').should eq('50')
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'returns nil if param not found' do
|
222
|
+
@page.send(:query_params_include?, 'blup').should be_nil
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context '#query_params=' do
|
227
|
+
before do
|
228
|
+
@page = DeskApi::Resource.new(subject, {
|
229
|
+
'_links'=>{'self'=>{'href'=>'/api/v2/cases'}}
|
230
|
+
}, true)
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'sets query params on the current url' do
|
234
|
+
@page.send(:query_params=, { page: 5, per_page: 50 })
|
235
|
+
@page.instance_variable_get(:@_definition)['_links']['self']['href'].should eq('/api/v2/cases?page=5&per_page=50')
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
context '#get_linked_resource' do
|
240
|
+
it 'returns linked resources', :vcr do
|
241
|
+
subject.cases.entries.first.customer.should be_an_instance_of(DeskApi::Resource)
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'returns nil if link is nil', :vcr do
|
245
|
+
subject.articles.next.should be_nil
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'saves the linked resource instead of the url', :vcr do
|
249
|
+
first_case = subject.cases.entries.first
|
250
|
+
first_case.customer.should be_an_instance_of(DeskApi::Resource)
|
251
|
+
first_case.instance_variable_get(:@_definition)['_links']['customer'].should be_an_instance_of(DeskApi::Resource)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
context '#page' do
|
256
|
+
it 'returns the current page and loads if page not defined', :vcr do
|
257
|
+
subject.articles.page.should eq(1)
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'sets the page' do
|
261
|
+
subject.cases.page(5).page.should eq(5)
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'sets the resource to not loaded', :vcr do
|
265
|
+
cases = subject.cases.send(:exec!)
|
266
|
+
cases.page(5).instance_variable_get(:@_loaded).should be_false
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'keeps the resource as loaded', :vcr do
|
270
|
+
cases = subject.cases.send(:exec!)
|
271
|
+
cases.page(1).instance_variable_get(:@_loaded).should be_true
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context '#find' do
|
276
|
+
it 'loads the requested resource', :vcr do
|
277
|
+
subject.cases.find(3065).subject.should eq('Testing the Tank again')
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'has an alias by_id', :vcr do
|
281
|
+
subject.cases.find(3065).subject.should eq('Testing the Tank again')
|
282
|
+
end
|
283
|
+
end
|
209
284
|
end
|