desk_api 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -1
- data/lib/desk_api/action/embeddable.rb +47 -0
- data/lib/desk_api/action/update.rb +5 -0
- data/lib/desk_api/error/not_embeddable.rb +8 -0
- data/lib/desk_api/error/not_updateable.rb +10 -0
- data/lib/desk_api/error/unprocessable_entity.rb +1 -0
- data/lib/desk_api/error.rb +7 -9
- data/lib/desk_api/resource/case.rb +2 -0
- data/lib/desk_api/resource/filter.rb +7 -0
- data/lib/desk_api/resource/inbound_mailbox.rb +7 -0
- data/lib/desk_api/resource/job.rb +2 -0
- data/lib/desk_api/resource/page.rb +10 -27
- data/lib/desk_api/resource/reply.rb +2 -0
- data/lib/desk_api/resource.rb +28 -3
- data/lib/desk_api/version.rb +1 -1
- data/spec/cassettes/DeskApi_Error/on_validation_error/allows_access_to_error_hash.yml +54 -0
- data/spec/cassettes/DeskApi_Resource_Case/once_closed/can_not_be_updated.yml +124 -0
- data/spec/cassettes/DeskApi_Resource_Page/{_by_id/loads_the_requested_resource.yml → _find/has_an_alias_by_id.yml} +6 -6
- data/spec/cassettes/DeskApi_Resource_Page/_find/loads_the_requested_resource.yml +54 -0
- data/spec/desk_api/error_spec.rb +11 -0
- data/spec/desk_api/request/retry_spec.rb +9 -3
- data/spec/desk_api/resource/case_spec.rb +28 -0
- data/spec/desk_api/{resources → resource}/page_spec.rb +9 -5
- data/spec/desk_api/resource_spec.rb +68 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/stubs/case_embed_customer.json +115 -0
- data/spec/stubs/cases_embed_assigned_user.json +105 -0
- metadata +23 -7
- data/lib/desk_api/action/embedded.rb +0 -12
@@ -0,0 +1,124 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://devel.desk.com/api/v2/customers
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
User-Agent:
|
13
|
+
- desk.com Ruby Gem v0.1.2
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message:
|
18
|
+
headers:
|
19
|
+
Accept-Ranges:
|
20
|
+
- bytes
|
21
|
+
Cache-Control:
|
22
|
+
- must-revalidate, private, max-age=0
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
Date:
|
26
|
+
- Fri, 06 Sep 2013 21:59:05 GMT
|
27
|
+
ETag:
|
28
|
+
- '"e60e588bcd3e052370e36555fc307738"'
|
29
|
+
Status:
|
30
|
+
- 200 OK
|
31
|
+
Vary:
|
32
|
+
- X-AppVersion
|
33
|
+
X-AppVersion:
|
34
|
+
- '9.9'
|
35
|
+
X-Frame-Options:
|
36
|
+
- SAMEORIGIN
|
37
|
+
X-Rate-Limit-Limit:
|
38
|
+
- '60'
|
39
|
+
X-Rate-Limit-Remaining:
|
40
|
+
- '59'
|
41
|
+
X-Rate-Limit-Reset:
|
42
|
+
- '55'
|
43
|
+
X-Request-Id:
|
44
|
+
- de1a0bfc6a858410f780bc8f2386be51
|
45
|
+
Content-Length:
|
46
|
+
- '31501'
|
47
|
+
Connection:
|
48
|
+
- keep-alive
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"total_entries":189,"_links":{"self":{"href":"/api/v2/customers?page=1&per_page=50","class":"page"},"first":{"href":"/api/v2/customers?page=1&per_page=50","class":"page"},"last":{"href":"/api/v2/customers?page=4&per_page=50","class":"page"},"previous":null,"next":{"href":"/api/v2/customers?page=2&per_page=50","class":"page"}},"_embedded":{"entries":[{"first_name":"Alex","last_name":"Bard","company":"Desk.com","title":"CEO","external_id":null,"background":"Wowing
|
52
|
+
customer","language":null,"locked_until":null,"created_at":"2012-06-06T14:51:30Z","updated_at":"2013-08-20T18:45:04Z","custom_fields":{"my_custom_field":"","my_number_field":"0","my_boolean_field":"0","my_date_field":"","my_list_field":"Option
|
53
|
+
1"},"emails":[{"type":"work","value":"support@desk.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/34290812","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/138963","class":"company"},"cases":{"href":"/api/v2/customers/34290812/cases","class":"case"}}},{"first_name":"Stella","last_name":"Pavlova","company":"Morpon
|
54
|
+
Brothers","title":"SVP Production","external_id":null,"background":"","language":null,"locked_until":null,"created_at":"2012-06-06T15:01:44Z","updated_at":"2012-12-07T23:56:00Z","custom_fields":{"my_custom_field":"","my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/34292086","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/138965","class":"company"},"cases":{"href":"/api/v2/customers/34292086/cases","class":"case"}}},{"first_name":"Mike","last_name":"Malmin","company":"Mike
|
55
|
+
Malmin","title":"","external_id":null,"background":"","language":null,"locked_until":null,"created_at":"2012-06-07T13:50:04Z","updated_at":"2012-12-07T23:56:00Z","custom_fields":{"my_custom_field":"","my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/34406867","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/138578","class":"company"},"cases":{"href":"/api/v2/customers/34406867/cases","class":"case"}}},{"first_name":"Janice","last_name":"Bergman","company":"Data
|
56
|
+
Mart","title":"VP Purchasing","external_id":null,"background":"","language":null,"locked_until":null,"created_at":"2012-06-07T14:07:13Z","updated_at":"2012-12-07T23:56:00Z","custom_fields":{"my_custom_field":"","my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/34408491","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/138446","class":"company"},"cases":{"href":"/api/v2/customers/34408491/cases","class":"case"}}},{"first_name":"Bob","last_name":"Hodges","company":"United
|
57
|
+
Partners*","title":"President and CEO","external_id":null,"background":"","language":null,"locked_until":null,"created_at":"2012-06-22T21:56:31Z","updated_at":"2012-12-07T23:56:01Z","custom_fields":{"my_custom_field":"","my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/36328589","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/113131","class":"company"},"cases":{"href":"/api/v2/customers/36328589/cases","class":"case"}}},{"first_name":"Ron","last_name":"Adkins","company":"Valley
|
58
|
+
Supply Inc.","title":"President Sales Exec Finance Exec","external_id":null,"background":"","language":null,"locked_until":null,"created_at":"2012-06-25T21:12:05Z","updated_at":"2012-12-07T23:56:01Z","custom_fields":{"my_custom_field":"","my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/36652658","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/114536","class":"company"},"cases":{"href":"/api/v2/customers/36652658/cases","class":"case"}}},{"first_name":"Thomas","last_name":"Stachl","company":"stachl.me","title":"Master
|
59
|
+
of Script Artistry","external_id":null,"background":"Some Background information.","language":"de","locked_until":null,"created_at":"2012-07-04T14:33:39Z","updated_at":"2013-07-15T18:10:21Z","custom_fields":{"my_custom_field":"","my_number_field":"0","my_boolean_field":"0","my_date_field":"","my_list_field":"Option
|
60
|
+
1"},"emails":[{"type":"home","value":"thomas@stachl.me"},{"type":"home","value":"tstachl@salesforce.com"}],"phone_numbers":[{"type":"mobile","value":"4156060761"}],"addresses":[{"type":"home","value":"600
|
61
|
+
William Street #526\nOakland, CA 94612"}],"_links":{"self":{"href":"/api/v2/customers/37823480","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/373760","class":"company"},"cases":{"href":"/api/v2/customers/37823480/cases","class":"case"}}},{"first_name":"Lauren","last_name":"Boyle*","company":"mailinator.com","title":"","external_id":"0033000001JLAZrAAP","background":"","language":null,"locked_until":null,"created_at":"2012-12-07T23:36:46Z","updated_at":"2013-04-13T03:47:03Z","custom_fields":{"my_custom_field":"","my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"work","value":"lauren.boyle@mailinator.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/58278628","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/2278303","class":"company"},"cases":{"href":"/api/v2/customers/58278628/cases","class":"case"}}},{"first_name":"Sandy","last_name":"Knudson","company":"mailinator.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-02-28T19:28:28Z","updated_at":"2013-02-28T19:45:43Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"work","value":"sandyknudson@mailinator.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/71433005","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/2278303","class":"company"},"cases":{"href":"/api/v2/customers/71433005/cases","class":"case"}}},{"first_name":"Brad","last_name":"Anastasio","company":"fakeemail.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-01T13:51:56Z","updated_at":"2013-03-01T13:51:56Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"work","value":"brad.anastasio@fakeemail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/71579966","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4036540","class":"company"},"cases":{"href":"/api/v2/customers/71579966/cases","class":"case"}}},{"first_name":"Leena","last_name":"Cianflone","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:45Z","updated_at":"2013-03-22T23:49:45Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"leenacianflone@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923712","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/75923712/cases","class":"case"}}},{"first_name":"Quinton","last_name":"Swanda","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:45Z","updated_at":"2013-03-22T23:49:45Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"quintonswanda@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923713","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/75923713/cases","class":"case"}}},{"first_name":"Jennifer","last_name":"Hansen","company":"zendesk.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:46Z","updated_at":"2013-03-22T23:49:46Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"jennifer@zendesk.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923714","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4451253","class":"company"},"cases":{"href":"/api/v2/customers/75923714/cases","class":"case"}}},{"first_name":"Hue","last_name":"Gottesman","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:46Z","updated_at":"2013-03-22T23:49:46Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"huegottesman@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923715","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/75923715/cases","class":"case"}}},{"first_name":"Hal","last_name":"Raxter","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:47Z","updated_at":"2013-03-22T23:49:47Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"raxterhal@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923716","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/75923716/cases","class":"case"}}},{"first_name":"Colmo","last_name":"","company":"zendesk.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:47Z","updated_at":"2013-03-22T23:49:47Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"colmo@zendesk.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923717","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4451253","class":"company"},"cases":{"href":"/api/v2/customers/75923717/cases","class":"case"}}},{"first_name":"Brice","last_name":"Baggenstoss","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:47Z","updated_at":"2013-03-22T23:49:47Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"bricebaggenstoss@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923718","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/75923718/cases","class":"case"}}},{"first_name":"Support","last_name":"","company":"zendesk.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:47Z","updated_at":"2013-03-22T23:49:47Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"support@zendesk.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923719","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4451253","class":"company"},"cases":{"href":"/api/v2/customers/75923719/cases","class":"case"}}},{"first_name":"Noreply","last_name":"","company":"postmaster.twitter.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:48Z","updated_at":"2013-03-22T23:49:48Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"noreply@postmaster.twitter.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923720","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4451254","class":"company"},"cases":{"href":"/api/v2/customers/75923720/cases","class":"case"}}},{"first_name":"Hal","last_name":"Schellhase","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-22T23:49:48Z","updated_at":"2013-03-22T23:49:48Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"halschellhase@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/75923721","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/75923721/cases","class":"case"}}},{"first_name":"Test","last_name":"Tester","company":"example.com","title":"CEO","external_id":null,"background":"","language":"en","locked_until":null,"created_at":"2013-03-27T17:35:51Z","updated_at":"2013-03-27T18:04:48Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"work","value":"tester@example.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/76863359","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4543697","class":"company"},"cases":{"href":"/api/v2/customers/76863359/cases","class":"case"}}},{"first_name":"barr_tim","last_name":"","company":"grandhotels.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-03-29T00:04:09Z","updated_at":"2013-04-15T23:59:05Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"barr_tim@grandhotels.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/77160792","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4574466","class":"company"},"cases":{"href":"/api/v2/customers/77160792/cases","class":"case"}}},{"first_name":"John","last_name":"","company":"example.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-06T22:12:56Z","updated_at":"2013-04-15T16:42:57Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"john@example.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/78914102","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4543697","class":"company"},"cases":{"href":"/api/v2/customers/78914102/cases","class":"case"}}},{"first_name":"Stachl","last_name":"Testing
|
62
|
+
Page","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-08T20:06:40Z","updated_at":"2013-04-08T20:06:40Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/79246639","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/79246639/cases","class":"case"}}},{"first_name":"Thomas","last_name":"Stachl","company":null,"title":null,"external_id":null,"background":null,"language":"en_us","locked_until":null,"created_at":"2013-04-08T20:18:56Z","updated_at":"2013-04-08T20:18:56Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/79249149","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/79249149/cases","class":"case"}}},{"first_name":"Andrew","last_name":"Frauen","company":null,"title":null,"external_id":null,"background":null,"language":"en","locked_until":null,"created_at":"2013-04-11T17:39:26Z","updated_at":"2013-04-11T17:39:26Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"frauen.a@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/79858779","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/79858779/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-12T23:46:33Z","updated_at":"2013-04-12T23:46:33Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80192856","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80192856/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-12T23:48:05Z","updated_at":"2013-04-12T23:48:05Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80193061","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80193061/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-13T02:37:48Z","updated_at":"2013-04-13T02:37:48Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80212952","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80212952/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-13T02:39:12Z","updated_at":"2013-04-13T02:39:12Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80213083","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80213083/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-13T02:40:10Z","updated_at":"2013-04-13T02:40:10Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80213160","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80213160/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-13T02:41:53Z","updated_at":"2013-04-13T02:41:53Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80213349","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80213349/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-13T02:43:59Z","updated_at":"2013-04-13T02:43:59Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80213634","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80213634/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-13T02:45:57Z","updated_at":"2013-04-13T02:45:57Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80213888","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80213888/cases","class":"case"}}},{"first_name":null,"last_name":null,"company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-13T02:46:52Z","updated_at":"2013-04-13T02:46:52Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80214018","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/80214018/cases","class":"case"}}},{"first_name":"John","last_name":"Smith","company":"Glorious
|
63
|
+
D","title":"Senior Vice President of Awesome","external_id":null,"background":"Some
|
64
|
+
description.","language":null,"locked_until":null,"created_at":"2013-04-15T16:58:30Z","updated_at":"2013-04-15T16:58:31Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"john@gd.com"}],"phone_numbers":[{"type":"home","value":"4155551235"}],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/80640812","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4912151","class":"company"},"cases":{"href":"/api/v2/customers/80640812/cases","class":"case"}}},{"first_name":"Larita","last_name":"Villas","company":null,"title":null,"external_id":null,"background":"","language":null,"locked_until":null,"created_at":"2013-04-22T22:37:00Z","updated_at":"2013-04-22T22:37:00Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"laritavillas@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113673","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113673/cases","class":"case"}}},{"first_name":"Nolan","last_name":"Gett","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:37:01Z","updated_at":"2013-04-22T22:37:01Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"nolangett@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113675","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113675/cases","class":"case"}}},{"first_name":"Moises","last_name":"Sabio","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:37:02Z","updated_at":"2013-04-22T22:37:02Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"sabiomoises@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113682","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113682/cases","class":"case"}}},{"first_name":"Twitter","last_name":"","company":"postmaster.twitter.com","title":null,"external_id":null,"background":"","language":null,"locked_until":null,"created_at":"2013-04-22T22:37:02Z","updated_at":"2013-04-22T22:37:02Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"n-tybonyfhespb=tznvy.pbz-9b29b@postmaster.twitter.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113684","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4451254","class":"company"},"cases":{"href":"/api/v2/customers/82113684/cases","class":"case"}}},{"first_name":"Zendesk","last_name":"","company":"zendesk.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:37:03Z","updated_at":"2013-04-22T22:37:03Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"noreply@zendesk.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113685","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/4451253","class":"company"},"cases":{"href":"/api/v2/customers/82113685/cases","class":"case"}}},{"first_name":"Richie","last_name":"Kalter","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:37:03Z","updated_at":"2013-04-22T22:37:03Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"richiekalter11@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113689","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113689/cases","class":"case"}}},{"first_name":"The","last_name":"Desk.com
|
65
|
+
Team","company":"Desk.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:37:04Z","updated_at":"2013-04-22T22:37:04Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"welcome@desk.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113693","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/138963","class":"company"},"cases":{"href":"/api/v2/customers/82113693/cases","class":"case"}}},{"first_name":"Rupert","last_name":"Warstler","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:37:04Z","updated_at":"2013-04-22T22:37:04Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"rupertwarstler@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113694","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113694/cases","class":"case"}}},{"first_name":"Suzy","last_name":"Galicinao","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:38:00Z","updated_at":"2013-04-22T22:38:00Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"suzygalicinao@gmail.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113926","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113926/cases","class":"case"}}},{"first_name":"ashley","last_name":"lawrence","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:38:01Z","updated_at":"2013-04-22T22:38:01Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113930","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113930/cases","class":"case"}}},{"first_name":"Keshia","last_name":"Hohenstein","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:38:01Z","updated_at":"2013-04-22T22:38:01Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113931","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113931/cases","class":"case"}}},{"first_name":"Alex","last_name":"Hisaka","company":"Desk.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:38:01Z","updated_at":"2013-04-22T22:38:02Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"alex.hisaka@desk.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113933","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/138963","class":"company"},"cases":{"href":"/api/v2/customers/82113933/cases","class":"case"}}},{"first_name":"seethaji","last_name":"","company":null,"title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:38:02Z","updated_at":"2013-04-22T22:38:02Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"seethaji@yahoo.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113936","class":"customer"},"locked_by":null,"cases":{"href":"/api/v2/customers/82113936/cases","class":"case"}}},{"first_name":"Sukhjit","last_name":"","company":"Desk.com","title":null,"external_id":null,"background":null,"language":null,"locked_until":null,"created_at":"2013-04-22T22:38:02Z","updated_at":"2013-04-22T22:38:02Z","custom_fields":{"my_custom_field":null,"my_number_field":null,"my_boolean_field":null,"my_date_field":null,"my_list_field":null},"emails":[{"type":"home","value":"sukhjit@desk.com"}],"phone_numbers":[],"addresses":[],"_links":{"self":{"href":"/api/v2/customers/82113939","class":"customer"},"locked_by":null,"company":{"href":"/api/v2/companies/138963","class":"company"},"cases":{"href":"/api/v2/customers/82113939/cases","class":"case"}}}]}}'
|
66
|
+
http_version:
|
67
|
+
recorded_at: Fri, 06 Sep 2013 21:59:05 GMT
|
68
|
+
- request:
|
69
|
+
method: post
|
70
|
+
uri: https://devel.desk.com/api/v2/customers/34290812/cases
|
71
|
+
body:
|
72
|
+
encoding: UTF-8
|
73
|
+
string: '{"type":"phone","subject":"Phone Case Subject","priority":4,"status":"closed","message":{"direction":"in","body":"Example
|
74
|
+
Body"}}'
|
75
|
+
headers:
|
76
|
+
Accept:
|
77
|
+
- application/json
|
78
|
+
User-Agent:
|
79
|
+
- desk.com Ruby Gem v0.1.2
|
80
|
+
Content-Type:
|
81
|
+
- application/json
|
82
|
+
response:
|
83
|
+
status:
|
84
|
+
code: 201
|
85
|
+
message:
|
86
|
+
headers:
|
87
|
+
Accept-Ranges:
|
88
|
+
- bytes
|
89
|
+
Cache-Control:
|
90
|
+
- max-age=0, private, must-revalidate
|
91
|
+
Content-Type:
|
92
|
+
- application/json; charset=utf-8
|
93
|
+
Date:
|
94
|
+
- Fri, 06 Sep 2013 21:59:05 GMT
|
95
|
+
ETag:
|
96
|
+
- '"8b8c5604fbc6d1fad236c6c47663b87d"'
|
97
|
+
Location:
|
98
|
+
- https://devel.desk.com/api/v2/cases/3344
|
99
|
+
Status:
|
100
|
+
- 201 Created
|
101
|
+
Vary:
|
102
|
+
- X-AppVersion
|
103
|
+
X-AppVersion:
|
104
|
+
- '9.9'
|
105
|
+
X-Frame-Options:
|
106
|
+
- SAMEORIGIN
|
107
|
+
X-Rate-Limit-Limit:
|
108
|
+
- '60'
|
109
|
+
X-Rate-Limit-Remaining:
|
110
|
+
- '58'
|
111
|
+
X-Rate-Limit-Reset:
|
112
|
+
- '55'
|
113
|
+
X-Request-Id:
|
114
|
+
- 19249bfef63cea6a01a2e45c2137ce09
|
115
|
+
Content-Length:
|
116
|
+
- '877'
|
117
|
+
Connection:
|
118
|
+
- keep-alive
|
119
|
+
body:
|
120
|
+
encoding: UTF-8
|
121
|
+
string: '{"external_id":null,"subject":"Phone Case Subject","priority":4,"locked_until":null,"description":null,"status":"closed","type":"phone","labels":[],"language":"de","active_at":null,"created_at":"2013-09-06T21:59:05Z","updated_at":"2013-09-06T21:59:05Z","received_at":null,"custom_fields":{"my_new_custom_field":null,"my_new_number_field":null,"my_new_date_field":null,"my_new_boolean_field":null,"my_new_list_field":null},"_links":{"self":{"href":"/api/v2/cases/3344","class":"case"},"message":{"href":"/api/v2/cases/3344/message","class":"phone"},"customer":{"href":"/api/v2/customers/34290812","class":"customer"},"assigned_user":null,"assigned_group":null,"locked_by":null,"replies":{"href":"/api/v2/cases/3344/replies","class":"reply"},"notes":{"href":"/api/v2/cases/3344/notes","class":"note"},"attachments":{"href":"/api/v2/cases/3344/attachments","class":"attachment"}}}'
|
122
|
+
http_version:
|
123
|
+
recorded_at: Fri, 06 Sep 2013 21:59:05 GMT
|
124
|
+
recorded_with: VCR 2.5.0
|
@@ -10,7 +10,7 @@ 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.2
|
14
14
|
response:
|
15
15
|
status:
|
16
16
|
code: 200
|
@@ -23,7 +23,7 @@ http_interactions:
|
|
23
23
|
Content-Type:
|
24
24
|
- application/json; charset=utf-8
|
25
25
|
Date:
|
26
|
-
-
|
26
|
+
- Sat, 07 Sep 2013 21:40:49 GMT
|
27
27
|
ETag:
|
28
28
|
- '"cbba64bc7fe9b35611cc745f75671fb6"'
|
29
29
|
Status:
|
@@ -31,7 +31,7 @@ http_interactions:
|
|
31
31
|
Vary:
|
32
32
|
- X-AppVersion
|
33
33
|
X-AppVersion:
|
34
|
-
- '
|
34
|
+
- '9.9'
|
35
35
|
X-Frame-Options:
|
36
36
|
- SAMEORIGIN
|
37
37
|
X-Rate-Limit-Limit:
|
@@ -39,9 +39,9 @@ http_interactions:
|
|
39
39
|
X-Rate-Limit-Remaining:
|
40
40
|
- '59'
|
41
41
|
X-Rate-Limit-Reset:
|
42
|
-
- '
|
42
|
+
- '11'
|
43
43
|
X-Request-Id:
|
44
|
-
-
|
44
|
+
- 2c92e26b679018d276ba9790a631d5f0
|
45
45
|
Content-Length:
|
46
46
|
- '897'
|
47
47
|
Connection:
|
@@ -50,5 +50,5 @@ http_interactions:
|
|
50
50
|
encoding: UTF-8
|
51
51
|
string: '{"external_id":null,"subject":"Testing the Tank again","priority":5,"locked_until":null,"description":null,"status":"open","type":"email","labels":[],"language":"de","active_at":"2013-05-13T19:20:59Z","created_at":"2013-05-13T18:13:39Z","updated_at":"2013-05-13T18:13:39Z","received_at":null,"custom_fields":{"my_new_custom_field":null,"my_new_number_field":null,"my_new_date_field":null,"my_new_boolean_field":null,"my_new_list_field":null},"_links":{"self":{"href":"/api/v2/cases/3065","class":"case"},"message":{"href":"/api/v2/cases/3065/message","class":"email"},"customer":{"href":"/api/v2/customers/86101780","class":"customer"},"assigned_user":null,"assigned_group":null,"locked_by":null,"replies":{"href":"/api/v2/cases/3065/replies","class":"reply"},"notes":{"href":"/api/v2/cases/3065/notes","class":"note"},"attachments":{"href":"/api/v2/cases/3065/attachments","class":"attachment"}}}'
|
52
52
|
http_version:
|
53
|
-
recorded_at:
|
53
|
+
recorded_at: Sat, 07 Sep 2013 21:40:49 GMT
|
54
54
|
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://devel.desk.com/api/v2/cases/3065
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
User-Agent:
|
13
|
+
- desk.com Ruby Gem v0.1.2
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message:
|
18
|
+
headers:
|
19
|
+
Accept-Ranges:
|
20
|
+
- bytes
|
21
|
+
Cache-Control:
|
22
|
+
- must-revalidate, private, max-age=0
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
Date:
|
26
|
+
- Sat, 07 Sep 2013 21:40:49 GMT
|
27
|
+
ETag:
|
28
|
+
- '"cbba64bc7fe9b35611cc745f75671fb6"'
|
29
|
+
Status:
|
30
|
+
- 200 OK
|
31
|
+
Vary:
|
32
|
+
- X-AppVersion
|
33
|
+
X-AppVersion:
|
34
|
+
- '9.9'
|
35
|
+
X-Frame-Options:
|
36
|
+
- SAMEORIGIN
|
37
|
+
X-Rate-Limit-Limit:
|
38
|
+
- '60'
|
39
|
+
X-Rate-Limit-Remaining:
|
40
|
+
- '58'
|
41
|
+
X-Rate-Limit-Reset:
|
42
|
+
- '11'
|
43
|
+
X-Request-Id:
|
44
|
+
- a33f162a33593ce4444ffeaacb9b6364
|
45
|
+
Content-Length:
|
46
|
+
- '897'
|
47
|
+
Connection:
|
48
|
+
- keep-alive
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"external_id":null,"subject":"Testing the Tank again","priority":5,"locked_until":null,"description":null,"status":"open","type":"email","labels":[],"language":"de","active_at":"2013-05-13T19:20:59Z","created_at":"2013-05-13T18:13:39Z","updated_at":"2013-05-13T18:13:39Z","received_at":null,"custom_fields":{"my_new_custom_field":null,"my_new_number_field":null,"my_new_date_field":null,"my_new_boolean_field":null,"my_new_list_field":null},"_links":{"self":{"href":"/api/v2/cases/3065","class":"case"},"message":{"href":"/api/v2/cases/3065/message","class":"email"},"customer":{"href":"/api/v2/customers/86101780","class":"customer"},"assigned_user":null,"assigned_group":null,"locked_by":null,"replies":{"href":"/api/v2/cases/3065/replies","class":"reply"},"notes":{"href":"/api/v2/cases/3065/notes","class":"note"},"attachments":{"href":"/api/v2/cases/3065/attachments","class":"attachment"}}}'
|
52
|
+
http_version:
|
53
|
+
recorded_at: Sat, 07 Sep 2013 21:40:49 GMT
|
54
|
+
recorded_with: VCR 2.5.0
|
data/spec/desk_api/error_spec.rb
CHANGED
@@ -20,4 +20,15 @@ describe DeskApi::Error do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
context 'on validation error' do
|
25
|
+
it 'allows access to error hash', :vcr do
|
26
|
+
begin
|
27
|
+
subject.articles.create({ subject: 'Testing', body: 'Testing' })
|
28
|
+
rescue DeskApi::Error::UnprocessableEntity => e
|
29
|
+
e.errors.should be_an_instance_of(Hash)
|
30
|
+
e.errors.should eq({"_links" => { "topic" => ["blank"]}})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
23
34
|
end
|
@@ -3,6 +3,8 @@ require 'desk_api/request/retry'
|
|
3
3
|
|
4
4
|
describe DeskApi::Request::Retry do
|
5
5
|
before do
|
6
|
+
VCR.turn_off!
|
7
|
+
|
6
8
|
@stubs = Faraday::Adapter::Test::Stubs.new
|
7
9
|
@conn = Faraday.new do |builder|
|
8
10
|
builder.request :retry, { interval: 0 }
|
@@ -10,7 +12,11 @@ describe DeskApi::Request::Retry do
|
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
|
-
|
15
|
+
after do
|
16
|
+
VCR.turn_on!
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'retries three times' do
|
14
20
|
times_called = 0
|
15
21
|
|
16
22
|
@stubs.post('/echo') do
|
@@ -22,7 +28,7 @@ describe DeskApi::Request::Retry do
|
|
22
28
|
times_called.should eq(3)
|
23
29
|
end
|
24
30
|
|
25
|
-
it 'retries once if we have too many requests'
|
31
|
+
it 'retries once if we have too many requests' do
|
26
32
|
times_called = 0
|
27
33
|
|
28
34
|
@stubs.post('/echo') do
|
@@ -34,7 +40,7 @@ describe DeskApi::Request::Retry do
|
|
34
40
|
'status' => 429,
|
35
41
|
'x-rate-limit-limit' => '60',
|
36
42
|
'x-rate-limit-remaining' => '0',
|
37
|
-
'x-rate-limit-reset' => '
|
43
|
+
'x-rate-limit-reset' => '0',
|
38
44
|
'content-length' => '31'
|
39
45
|
}
|
40
46
|
})
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'desk_api/error/not_updateable'
|
3
|
+
require 'desk_api/resource/case'
|
4
|
+
|
5
|
+
describe DeskApi::Resource::Case do
|
6
|
+
subject do
|
7
|
+
@client ||= DeskApi::Client.new DeskApi::CONFIG
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'once closed', :vcr do
|
11
|
+
before do
|
12
|
+
@kase = subject.customers.first.cases.create({
|
13
|
+
type: 'phone',
|
14
|
+
subject: 'Phone Case Subject',
|
15
|
+
priority: 4,
|
16
|
+
status: 'closed',
|
17
|
+
message: {
|
18
|
+
direction: 'in',
|
19
|
+
body: 'Example Body'
|
20
|
+
}
|
21
|
+
})
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'can not be updated' do
|
25
|
+
lambda { @kase.update(description: 'Testing') }.should raise_error(DeskApi::Error::NotUpdateable)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -14,12 +14,12 @@ describe DeskApi::Resource::Page do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'allows to get query params from the current resource' do
|
17
|
-
@page.send(:
|
18
|
-
@page.send(:
|
17
|
+
@page.send(:query_params_include?, 'page').should eq('2')
|
18
|
+
@page.send(:query_params_include?, 'per_page').should eq('50')
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'returns nil if param not found' do
|
22
|
-
@page.send(:
|
22
|
+
@page.send(:query_params_include?, 'blup').should be_nil
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -56,9 +56,13 @@ describe DeskApi::Resource::Page do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
context '#
|
59
|
+
context '#find' do
|
60
60
|
it 'loads the requested resource', :vcr do
|
61
|
-
subject.cases.
|
61
|
+
subject.cases.find(3065).subject.should eq('Testing the Tank again')
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'has an alias by_id', :vcr do
|
65
|
+
subject.cases.find(3065).subject.should eq('Testing the Tank again')
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
@@ -138,4 +138,72 @@ describe DeskApi::Resource do
|
|
138
138
|
lambda { user.delete }.should raise_error(DeskApi::Error::MethodNotSupported)
|
139
139
|
end
|
140
140
|
end
|
141
|
+
|
142
|
+
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
|
+
it 'allows to declare embedds' do
|
149
|
+
lambda { subject.cases.embed(:assigned_user) }.should_not raise_error
|
150
|
+
lambda { subject.cases.embed(:message) }.should raise_error(DeskApi::Error::NotEmbeddable)
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'changes the url' do
|
154
|
+
subject.cases.embed(:assigned_user).get_href.should eq('/api/v2/cases?embed=assigned_user')
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'if you use embed' do
|
158
|
+
before do
|
159
|
+
VCR.turn_off! ignore_cassettes: true
|
160
|
+
|
161
|
+
@stubs ||= Faraday::Adapter::Test::Stubs.new
|
162
|
+
@client ||= DeskApi::Client.new(DeskApi::CONFIG).tap do |client|
|
163
|
+
client.middleware = Proc.new do |builder|
|
164
|
+
builder.response :mashify
|
165
|
+
builder.response :dates
|
166
|
+
builder.response :json, content_type: /application\/json/
|
167
|
+
builder.adapter :test, @stubs
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
after do
|
173
|
+
VCR.turn_on!
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'does not load the resource again' do
|
177
|
+
times_called = 0
|
178
|
+
@stubs.get('/api/v2/cases?embed=assigned_user') do
|
179
|
+
times_called += 1
|
180
|
+
[
|
181
|
+
200,
|
182
|
+
{ 'content-type' => 'application/json' },
|
183
|
+
File.open(File.join(RSpec.configuration.root_path, 'stubs', 'cases_embed_assigned_user.json')).read
|
184
|
+
]
|
185
|
+
end
|
186
|
+
|
187
|
+
first_case = @client.cases.embed(:assigned_user).first
|
188
|
+
first_case.assigned_user.name.should eq('Thomas Stachl')
|
189
|
+
first_case.assigned_user.instance_variable_get(:@loaded).should be_true
|
190
|
+
times_called.should eq(1)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'can be used in finder' do
|
194
|
+
@stubs.get('/api/v2/cases/3011?embed=customer') do
|
195
|
+
[
|
196
|
+
200,
|
197
|
+
{ 'content-type' => 'application/json' },
|
198
|
+
File.open(File.join(RSpec.configuration.root_path, 'stubs', 'case_embed_customer.json')).read
|
199
|
+
]
|
200
|
+
end
|
201
|
+
|
202
|
+
customer = @client.cases.find(3011, embed: :customer).customer
|
203
|
+
customer.first_name.should eq('Thomas')
|
204
|
+
customer = @client.cases.find(3011, embed: [:customer]).customer
|
205
|
+
customer.first_name.should eq('Thomas')
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
141
209
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,115 @@
|
|
1
|
+
{
|
2
|
+
"external_id": null,
|
3
|
+
"subject": "",
|
4
|
+
"priority": 9,
|
5
|
+
"locked_until": null,
|
6
|
+
"description": "",
|
7
|
+
"status": "open",
|
8
|
+
"type": "phone",
|
9
|
+
"labels": [],
|
10
|
+
"language": "en",
|
11
|
+
"active_at": "2013-09-07T19:38:58Z",
|
12
|
+
"created_at": "2013-05-09T17:02:16Z",
|
13
|
+
"updated_at": "2013-09-07T19:39:07Z",
|
14
|
+
"received_at": "2013-05-09T17:02:16Z",
|
15
|
+
"custom_fields": {
|
16
|
+
"my_new_custom_field": "",
|
17
|
+
"my_new_number_field": "0",
|
18
|
+
"my_new_date_field": "",
|
19
|
+
"my_new_boolean_field": "0",
|
20
|
+
"my_new_list_field": "Option 1"
|
21
|
+
},
|
22
|
+
"_links": {
|
23
|
+
"self": {
|
24
|
+
"href": "/api/v2/cases/3011",
|
25
|
+
"class": "case"
|
26
|
+
},
|
27
|
+
"message": {
|
28
|
+
"href": "/api/v2/cases/3011/message",
|
29
|
+
"class": "phone"
|
30
|
+
},
|
31
|
+
"customer": {
|
32
|
+
"href": "/api/v2/customers/37823480",
|
33
|
+
"class": "customer"
|
34
|
+
},
|
35
|
+
"assigned_user": {
|
36
|
+
"href": "/api/v2/users/16096734",
|
37
|
+
"class": "user"
|
38
|
+
},
|
39
|
+
"assigned_group": {
|
40
|
+
"href": "/api/v2/groups/171213",
|
41
|
+
"class": "group"
|
42
|
+
},
|
43
|
+
"locked_by": null,
|
44
|
+
"replies": {
|
45
|
+
"href": "/api/v2/cases/3011/replies",
|
46
|
+
"class": "reply"
|
47
|
+
},
|
48
|
+
"notes": {
|
49
|
+
"href": "/api/v2/cases/3011/notes",
|
50
|
+
"class": "note"
|
51
|
+
},
|
52
|
+
"attachments": {
|
53
|
+
"href": "/api/v2/cases/3011/attachments",
|
54
|
+
"class": "attachment"
|
55
|
+
}
|
56
|
+
},
|
57
|
+
"_embedded": {
|
58
|
+
"customer": {
|
59
|
+
"first_name": "Thomas",
|
60
|
+
"last_name": "Stachl",
|
61
|
+
"company": "stachl.me",
|
62
|
+
"title": "Master of Script Artistry",
|
63
|
+
"external_id": null,
|
64
|
+
"background": "Some Background information.",
|
65
|
+
"language": "de",
|
66
|
+
"locked_until": null,
|
67
|
+
"created_at": "2012-07-04T14:33:39Z",
|
68
|
+
"updated_at": "2013-07-15T18:10:21Z",
|
69
|
+
"custom_fields": {
|
70
|
+
"my_custom_field": "",
|
71
|
+
"my_number_field": "0",
|
72
|
+
"my_boolean_field": "0",
|
73
|
+
"my_date_field": "",
|
74
|
+
"my_list_field": "Option 1"
|
75
|
+
},
|
76
|
+
"emails": [
|
77
|
+
{
|
78
|
+
"type": "home",
|
79
|
+
"value": "thomas@stachl.me"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"type": "home",
|
83
|
+
"value": "tstachl@salesforce.com"
|
84
|
+
}
|
85
|
+
],
|
86
|
+
"phone_numbers": [
|
87
|
+
{
|
88
|
+
"type": "mobile",
|
89
|
+
"value": "4156060761"
|
90
|
+
}
|
91
|
+
],
|
92
|
+
"addresses": [
|
93
|
+
{
|
94
|
+
"type": "home",
|
95
|
+
"value": "600 William Street #526\nOakland, CA 94612"
|
96
|
+
}
|
97
|
+
],
|
98
|
+
"_links": {
|
99
|
+
"self": {
|
100
|
+
"href": "/api/v2/customers/37823480",
|
101
|
+
"class": "customer"
|
102
|
+
},
|
103
|
+
"locked_by": null,
|
104
|
+
"company": {
|
105
|
+
"href": "/api/v2/companies/373760",
|
106
|
+
"class": "company"
|
107
|
+
},
|
108
|
+
"cases": {
|
109
|
+
"href": "/api/v2/customers/37823480/cases",
|
110
|
+
"class": "case"
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|