desk 0.3.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +7 -0
  2. data/README.mkd +305 -106
  3. data/TRANSITION.mkd +133 -0
  4. data/desk.gemspec +1 -1
  5. data/lib/desk.rb +1 -1
  6. data/lib/desk/api.rb +5 -1
  7. data/lib/desk/client.rb +184 -10
  8. data/lib/desk/client/article.rb +4 -83
  9. data/lib/desk/client/brand.rb +11 -0
  10. data/lib/desk/client/case.rb +59 -42
  11. data/lib/desk/client/company.rb +11 -0
  12. data/lib/desk/client/custom_field.rb +10 -0
  13. data/lib/desk/client/customer.rb +26 -124
  14. data/lib/desk/client/facebook_user.rb +11 -0
  15. data/lib/desk/client/filter.rb +11 -0
  16. data/lib/desk/client/group.rb +3 -29
  17. data/lib/desk/client/insight.rb +17 -0
  18. data/lib/desk/client/integration_url.rb +11 -0
  19. data/lib/desk/client/job.rb +11 -0
  20. data/lib/desk/client/label.rb +11 -0
  21. data/lib/desk/client/macro.rb +3 -133
  22. data/lib/desk/client/mailbox.rb +26 -0
  23. data/lib/desk/client/rule.rb +14 -0
  24. data/lib/desk/client/site_setting.rb +11 -0
  25. data/lib/desk/client/system_message.rb +16 -0
  26. data/lib/desk/client/topic.rb +4 -81
  27. data/lib/desk/client/twitter_account.rb +11 -0
  28. data/lib/desk/client/twitter_user.rb +11 -0
  29. data/lib/desk/client/user.rb +3 -30
  30. data/lib/desk/configuration.rb +1 -1
  31. data/lib/desk/connection.rb +2 -1
  32. data/lib/desk/deash.rb +100 -0
  33. data/lib/desk/request.rb +33 -20
  34. data/lib/desk/version.rb +1 -1
  35. data/lib/faraday/request/oauth.rb +6 -3
  36. data/lib/faraday/response/deashify.rb +23 -0
  37. data/spec/desk/client/article_spec.rb +62 -117
  38. data/spec/desk/client/brand_spec.rb +18 -0
  39. data/spec/desk/client/case_spec.rb +182 -66
  40. data/spec/desk/client/companies_spec.rb +26 -0
  41. data/spec/desk/client/custom_fields_spec.rb +18 -0
  42. data/spec/desk/client/customer_spec.rb +16 -145
  43. data/spec/desk/client/facebook_users_spec.rb +17 -0
  44. data/spec/desk/client/filter_spec.rb +28 -0
  45. data/spec/desk/client/group_spec.rb +32 -49
  46. data/spec/desk/client/inbound_mailboxes_spec.rb +70 -0
  47. data/spec/desk/client/integration_url_spec.rb +28 -0
  48. data/spec/desk/client/job_spec.rb +32 -0
  49. data/spec/desk/client/label_spec.rb +31 -0
  50. data/spec/desk/client/macro_spec.rb +22 -185
  51. data/spec/desk/client/rule_spec.rb +18 -0
  52. data/spec/desk/client/site_setting_spec.rb +18 -0
  53. data/spec/desk/client/system_message_spec.rb +42 -0
  54. data/spec/desk/client/topic_spec.rb +31 -112
  55. data/spec/desk/client/twitter_account_spec.rb +32 -0
  56. data/spec/desk/client/twitter_user_spec.rb +27 -0
  57. data/spec/desk/client/user_spec.rb +19 -42
  58. data/spec/desk_spec.rb +2 -2
  59. data/spec/faraday/response_spec.rb +3 -6
  60. data/spec/fixtures/article +50 -0
  61. data/spec/fixtures/article_create +50 -0
  62. data/spec/fixtures/article_translation +29 -0
  63. data/spec/fixtures/article_translation_create +29 -0
  64. data/spec/fixtures/article_translation_update +29 -0
  65. data/spec/fixtures/article_translations +81 -0
  66. data/spec/fixtures/article_update +50 -0
  67. data/spec/fixtures/articles +123 -0
  68. data/spec/fixtures/articles_search +124 -0
  69. data/spec/fixtures/brand +11 -0
  70. data/spec/fixtures/brands +45 -0
  71. data/spec/fixtures/case +44 -0
  72. data/spec/fixtures/case_attachment +19 -0
  73. data/spec/fixtures/case_attachment_create +19 -0
  74. data/spec/fixtures/case_attachments +61 -0
  75. data/spec/fixtures/case_create +51 -0
  76. data/spec/fixtures/case_message +26 -0
  77. data/spec/fixtures/case_note +21 -0
  78. data/spec/fixtures/case_note_create +26 -0
  79. data/spec/fixtures/case_notes +65 -0
  80. data/spec/fixtures/case_replies +75 -0
  81. data/spec/fixtures/case_reply +26 -0
  82. data/spec/fixtures/case_reply_create +26 -0
  83. data/spec/fixtures/case_reply_update +26 -0
  84. data/spec/fixtures/case_update +49 -0
  85. data/spec/fixtures/cases +111 -0
  86. data/spec/fixtures/cases_search +113 -0
  87. data/spec/fixtures/companies +75 -0
  88. data/spec/fixtures/companies_search +76 -0
  89. data/spec/fixtures/company +26 -0
  90. data/spec/fixtures/company_create +26 -0
  91. data/spec/fixtures/company_search +76 -0
  92. data/spec/fixtures/company_update +27 -0
  93. data/spec/fixtures/custom_field +15 -0
  94. data/spec/fixtures/custom_fields +58 -0
  95. data/spec/fixtures/customer +60 -0
  96. data/spec/fixtures/customer_create +54 -0
  97. data/spec/fixtures/customer_update +60 -0
  98. data/spec/fixtures/customers +143 -0
  99. data/spec/fixtures/customers_search +143 -0
  100. data/spec/fixtures/facebook_user +16 -0
  101. data/spec/fixtures/facebook_users +55 -0
  102. data/spec/fixtures/filter +16 -0
  103. data/spec/fixtures/filter_cases +111 -0
  104. data/spec/fixtures/filters +55 -0
  105. data/spec/fixtures/group +9 -0
  106. data/spec/fixtures/group_filters +55 -0
  107. data/spec/fixtures/group_users +63 -0
  108. data/spec/fixtures/groups +42 -0
  109. data/spec/fixtures/inbound_mailbox +32 -0
  110. data/spec/fixtures/inbound_mailboxes +87 -0
  111. data/spec/fixtures/integration_url +15 -0
  112. data/spec/fixtures/integration_url_create +15 -0
  113. data/spec/fixtures/integration_url_update +15 -0
  114. data/spec/fixtures/integration_urls +54 -0
  115. data/spec/fixtures/job +17 -0
  116. data/spec/fixtures/job_create +17 -0
  117. data/spec/fixtures/jobs +57 -0
  118. data/spec/fixtures/label +17 -0
  119. data/spec/fixtures/label_create +17 -0
  120. data/spec/fixtures/label_update +17 -0
  121. data/spec/fixtures/labels +57 -0
  122. data/spec/fixtures/macro +20 -0
  123. data/spec/fixtures/macro_action +17 -0
  124. data/spec/fixtures/macro_action_update +17 -0
  125. data/spec/fixtures/macro_actions +57 -0
  126. data/spec/fixtures/macro_create +20 -0
  127. data/spec/fixtures/macro_update +20 -0
  128. data/spec/fixtures/macros +63 -0
  129. data/spec/fixtures/rule +13 -0
  130. data/spec/fixtures/rules +49 -0
  131. data/spec/fixtures/site_setting +10 -0
  132. data/spec/fixtures/site_settings +43 -0
  133. data/spec/fixtures/system_message +4 -0
  134. data/spec/fixtures/topic +23 -0
  135. data/spec/fixtures/topic_create +23 -0
  136. data/spec/fixtures/topic_translation +12 -0
  137. data/spec/fixtures/topic_translation_create +12 -0
  138. data/spec/fixtures/topic_translation_update +12 -0
  139. data/spec/fixtures/topic_translations +47 -0
  140. data/spec/fixtures/topic_update +23 -0
  141. data/spec/fixtures/topics +69 -0
  142. data/spec/fixtures/twitter_account +14 -0
  143. data/spec/fixtures/twitter_account_tweet +20 -0
  144. data/spec/fixtures/twitter_account_tweet_create +20 -0
  145. data/spec/fixtures/twitter_account_tweets +63 -0
  146. data/spec/fixtures/twitter_accounts +51 -0
  147. data/spec/fixtures/twitter_user +18 -0
  148. data/spec/fixtures/twitter_user_create +18 -0
  149. data/spec/fixtures/twitter_users +59 -0
  150. data/spec/fixtures/user +20 -0
  151. data/spec/fixtures/user_preference +18 -0
  152. data/spec/fixtures/user_preference_update +14 -0
  153. data/spec/fixtures/user_preferences +223 -0
  154. data/spec/fixtures/users +63 -0
  155. data/spec/helper.rb +12 -0
  156. data/spec/shared_context.rb +16 -0
  157. data/spec/shared_examples.rb +312 -0
  158. metadata +247 -181
  159. data/lib/desk/client/interaction.rb +0 -75
  160. data/spec/desk/client/interaction_spec.rb +0 -191
  161. data/spec/fixtures/article.json +0 -50
  162. data/spec/fixtures/article_create.json +0 -54
  163. data/spec/fixtures/article_destroy.json +0 -3
  164. data/spec/fixtures/article_update.json +0 -54
  165. data/spec/fixtures/articles.json +0 -58
  166. data/spec/fixtures/case.json +0 -59
  167. data/spec/fixtures/case_update.json +0 -59
  168. data/spec/fixtures/cases.json +0 -182
  169. data/spec/fixtures/customer.json +0 -58
  170. data/spec/fixtures/customer_create.json +0 -56
  171. data/spec/fixtures/customer_create_email.json +0 -15
  172. data/spec/fixtures/customer_update.json +0 -47
  173. data/spec/fixtures/customer_update_email.json +0 -15
  174. data/spec/fixtures/customers.json +0 -98
  175. data/spec/fixtures/group.json +0 -8
  176. data/spec/fixtures/groups.json +0 -23
  177. data/spec/fixtures/interaction_create.json +0 -126
  178. data/spec/fixtures/interactions.json +0 -139
  179. data/spec/fixtures/macro.json +0 -8
  180. data/spec/fixtures/macro_action.json +0 -9
  181. data/spec/fixtures/macro_action_update.json +0 -12
  182. data/spec/fixtures/macro_actions.json +0 -69
  183. data/spec/fixtures/macro_create.json +0 -13
  184. data/spec/fixtures/macro_destroy.json +0 -3
  185. data/spec/fixtures/macro_update.json +0 -13
  186. data/spec/fixtures/macros.json +0 -24
  187. data/spec/fixtures/topic.json +0 -9
  188. data/spec/fixtures/topic_create.json +0 -14
  189. data/spec/fixtures/topic_destroy.json +0 -3
  190. data/spec/fixtures/topic_update.json +0 -14
  191. data/spec/fixtures/topics.json +0 -35
  192. data/spec/fixtures/user.json +0 -15
  193. data/spec/fixtures/users.json +0 -24
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA512:
3
+ data.tar.gz: f5707b5b210f15d2441f5601fc18344b89046e2d6b79aef3f86dc0b8aba22fe0eb7e2e1de36b867dd72c6b4b84549e3097de6067f8cf9c25fa34ae4878b15963
4
+ metadata.gz: 9ec58c7e7f4a6b0ea44dd9ae678a81777923e3e0a64ca75a088959088247c54552eb18427c1a8f42777ca9020d215d587d95953a7de167d46c5df1eb2305f684
5
+ SHA1:
6
+ data.tar.gz: c5c8e13964633c35df237320f14a3c2dd3dc6af5
7
+ metadata.gz: 47e3d104d111e35c853d8ffcd0dfb8a7c95900ce
data/README.mkd CHANGED
@@ -6,23 +6,130 @@ Installation
6
6
  ------------
7
7
  gem install desk
8
8
 
9
- What's new in 0.3.3?
10
- ------------------
11
- @mtchavez bumped faraday_middleware to 0.9.0
9
+ What's new in 1.0.0?
10
+ --------------------
12
11
 
13
- What's new in 0.3.2?
14
- ------------------
15
- @tstachl added support for groups and max requests
12
+ Completely rewritten for Desk.com API v2
16
13
 
17
- What's new in 0.3.0?
18
- ------------------
19
- Renamed to Desk
20
- Newer faraday, faraday_middleware and hashie
14
+ For those upgrading from API v2 (Desk gem v0.3.x), check out the [transition
15
+ guide](TRANSITION.mkd)
21
16
 
22
17
  Help! I'm getting: "Did not recognize your engine specification. Please specify either a symbol or a class. (RuntimeError)"
23
18
  ---------------------------------------------------------------------------------------------------------------------------
24
19
 
25
- You'll need to explicitly require a JSON library. We recommend [yajl-ruby](http://github.com/brianmario/yajl-ruby).
20
+ You'll need to explicitly require a JSON library.
21
+ We recommend [yajl-ruby](http://github.com/brianmario/yajl-ruby).
22
+
23
+ Overview
24
+ --------------
25
+
26
+ Desk.com's API v2 follows a standard structure for (almost) every endpoint (see
27
+ the last section of the examples for the irregularities). Each endpoint
28
+ impliments some, or all, of the following actions: list, search, show, create,
29
+ update and delete. Additionally, some endpoints impliment sub-endpoints that
30
+ utilize the same list of actions.
31
+
32
+ The endpoint actions, and sub-endpoint actions, are implimented as methods in
33
+ the following way:
34
+
35
+ [action]_[endpoint] or [action]_[endpoint]_[sub-endpoint]
36
+
37
+ http://dev.desk.com/API/cases
38
+ The cases endpoint is a great example. It impliments the list, search, show,
39
+ create and updated actions. It additionally impliments sub-endpoints for
40
+ messages, replies, notes and attachments related to cases.
41
+ See the above link for more information.
42
+
43
+ For the Case endpoint, the create action would look like:
44
+
45
+ Desk.create_case(args)
46
+
47
+ For the Reply sub-endpoint under Cases, the update action would look like:
48
+
49
+ Desk.update_case_reply(case_id, reply_id, args)
50
+
51
+ Take note, as reflected in the Desk.com API documentation, that the list and
52
+ search actions change the plurality of the endpoint or sub-endpoint. Such as:
53
+
54
+ Desk.search_cases
55
+ Desk.list_case_replies(case_id)
56
+
57
+ Aliases
58
+ -------------
59
+
60
+ For ease of use, the list and show endpoint and sub-endpoint methods have
61
+ aliases that drop the action. These translate as follows:
62
+
63
+ list_[endpoint plural] => [endpoint plural]
64
+ show_[endpoint] => [endpoint]
65
+
66
+ list_[endpoint]_[sub-endpoint pluaral] => [endpoint]_[sub-endpoint plural]
67
+ show_[endpoint]_[sub-endpoint] => [endpoint]_[sub-endpoint]
68
+
69
+ For the Case endpoint and Reply sub-endpoint that would look like:
70
+
71
+ Desk.cases
72
+ Desk.case(case_id)
73
+ Desk.case_replies(case_id)
74
+ Desk.case_reply(case_id, reply_id)
75
+
76
+ Additionally, for endpoints that impliment the search action, the list and list
77
+ alias will intelligently use the correct API action for the provided arguments.
78
+ Meaning, all of the following are valid:
79
+
80
+ Desk.cases
81
+ Desk.cases(:page => 2)
82
+ Desk.cases(:status => "new,open")
83
+ Desk.cases(:status => "new,open", :page => 2, :per_page => 10)
84
+
85
+ Responses
86
+ --------------
87
+
88
+ While the raw API responses are available (see below), results are by default
89
+ translated into cleaner, more accessible Ruby objects, allowing the following:
90
+
91
+ cases = Desk.cases
92
+ cases.each do |c|
93
+ puts c.priority
94
+ puts c.status
95
+ end
96
+
97
+ For actions like show, create and update the endpoint fields are accessible in
98
+ the object root, such as:
99
+
100
+ c = Desk.case(case_id)
101
+ puts c.priority
102
+ puts c.status
103
+
104
+ Additionally, the new "\_links" in API v2 are easily accessible in this way as
105
+ well. Because each link (like self, first, next, etc) contain a fully formated
106
+ API callback, we're able to directly load the results of that link and return
107
+ the resulting object. This allows for clean, simple code like the following to
108
+ page though all the avaiable cases:
109
+
110
+ cases = Desk.list_cases
111
+ while cases
112
+ cases.each do |c|
113
+ # do something with each case
114
+ end
115
+ cases = cases.next
116
+ end
117
+
118
+ Or to easily access a case's assigned user and assigned group:
119
+
120
+ c = Desk.show_case(case_id)
121
+ user_object = c.assigned_user
122
+ group_object = c.assigned_group
123
+
124
+ Raw Responses
125
+ --------------
126
+
127
+ While almost all of the Desk.com API results are accessible, in some form, using
128
+ the simple object keys above the raw results are still avaiable via the "raw" key.
129
+ This allows for:
130
+
131
+ c = Desk.show_case(case_id)
132
+ puts c.raw["_links"]["self"]["class"]
26
133
 
27
134
  Usage Examples
28
135
  --------------
@@ -41,154 +148,246 @@ Usage Examples
41
148
  end
42
149
 
43
150
  ######
44
- # Cases
151
+ # List examples
45
152
  ######
46
153
 
47
154
  # List cases
48
155
  Desk.cases
49
- Desk.cases(:since_id => 12345)
50
156
 
51
- # Get a specific case
52
- Desk.case(12345)
157
+ # List customers
158
+ Desk.customers
53
159
 
54
- # Update a specific case
55
- Desk.update_case(12345, :subject => "Something Else")
160
+ # List site settings
161
+ Desk.site_settings
56
162
 
57
- # Get a case url
58
- Desk.case_url(12345)
163
+ # List twitter users
164
+ Desk.twitter_users
165
+
166
+ # List article translations
167
+ Desk.article_translations(1)
168
+
169
+ # List case notes
170
+ Desk.case_notes(12345)
59
171
 
60
172
  ######
61
- # Customers
173
+ # Search examples
62
174
  ######
63
175
 
64
- # List customers
65
- Desk.customers
66
- Desk.customers(:since_id => 12345, :count => 5)
176
+ # Search articles
177
+ Desk.articles(:text => "happy", :topic_ids => "1,2,4")
67
178
 
68
- # Get a specific customer
69
- Desk.customer(12345)
179
+ # Search cases
180
+ Desk.cases(:since_id => 12345)
70
181
 
71
- # Create a customer
72
- Desk.create_customer(:name => "Chris Warren", :twitter => "cdwarren")
182
+ # Search companies
183
+ Desk.companies(:q => "acme")
73
184
 
74
- # Update a customer
75
- Desk.update_customer(12345, :name => "Christopher Warren")
185
+ # Search customers
186
+ Desk.customers(:last_name => "Smith", :custom_field => "IS 5416")
76
187
 
77
- # Add a customer email
78
- Desk.create_customer_email(12345, "foo@example.com")
79
- Desk.create_customer_email(12345, "foo@example.com", :customer_contact_type => "work")
188
+ ######
189
+ # Show examples
190
+ ######
80
191
 
81
- # Update a customer email
82
- Desk.update_customer_email(12345, 54321, :email => "foo@example.com")
83
- Desk.update_customer_email(12345, 54321, :customer_contact_type => "work")
192
+ # Get a specific custom field
193
+ Desk.custom_field(1)
84
194
 
85
- # Add a customer phone number
86
- Desk.create_customer_phone(12345, "555-368-7147")
87
- Desk.create_customer_phone(12345, "555-368-7147", :customer_contact_type => "work")
195
+ # Get a specific facebook user
196
+ Desk.facebook_user(1234)
88
197
 
89
- # Update a customer phone number
90
- Desk.update_customer_phone(12345, 54321, :phone => "555-368-7147")
91
- Desk.update_customer_phone(12345, 54321, :customer_contact_type => "work")
198
+ # Get a specific case
199
+ Desk.case(12345)
200
+
201
+ # Get a specific twitter account
202
+ Desk.twitter_account(2)
92
203
 
93
204
  ######
94
- # Interactions
205
+ # Create examples
95
206
  ######
96
207
 
97
- # List interactions
98
- Desk.interactions
99
- Desk.interactions(:since_id => 12345)
100
- Desk.interactions(:since_id => 12345, :count => 5)
101
-
102
- # Create an inbound interaction
103
- Desk.create_interaction(:interaction_subject => "help me", :customer_email => "foo@example.com", :interaction_body => "You're my only hope.")
104
- Desk.create_inbound_interaction(:interaction_subject => "help me", :customer_email => "foo@example.com", :interaction_body => "You're my only hope.")
208
+ # Create a new phone case
209
+ Desk.create_case(
210
+ :type => "phone",
211
+ :subject => "Creating a case via the API",
212
+ :priority => 4,
213
+ :status => "open",
214
+ :labels => [ "Spam", "Ignore" ],
215
+ :_links => {
216
+ :customer => {
217
+ :href => "/api/v2/customers/1",
218
+ :class => "customer"
219
+ },
220
+ :assigned_user => {
221
+ :href => "/api/v2/users/1",
222
+ :class => "user"
223
+ },
224
+ :assigned_group => {
225
+ :href => "/api/v2/groups/1",
226
+ :class => "group"
227
+ },
228
+ :locked_by => {
229
+ :href => "/api/v2/users/1",
230
+ :class => "user"
231
+ },
232
+ :entered_by => {
233
+ :href => "/api/v2/users/1",
234
+ :class => "user"
235
+ }
236
+ },
237
+ :message => {
238
+ :direction => "out",
239
+ :body => "Please assist me with this case",
240
+ }
241
+ )
242
+
243
+ # Create a new label
244
+ Desk.create_label(
245
+ :name => "MyLabel",
246
+ :description => "A Test Label",
247
+ :types => [ "case", "macro" ],
248
+ :color => "blue"
249
+ )
105
250
 
106
- # Create an outbound interaction
107
- # Desk.com's API doesn't support creating outbound communications, so we do this over email with a BCC back to Desk and customer headers.
108
- # Desk.support_email must be set to your Desk.com email address so that the email can be sent to the account and give the customer someone to respond to.
109
- #
110
- # Read more at http://support.desk.com/customer/portal/articles/4180
111
- # Additional headers can be passed as well http://support.desk.com/customer/portal/articles/6728
112
- #
113
- # Email is sent using Pony https://github.com/benprew/pony
114
- Desk.create_interaction(:interaction_subject => "Missed Your Call", :customer_email => "foo@example.com", :interaction_body => "Sorry we missed yoru call. What's up?", :direction => "outbound")
115
- Desk.create_outbound_interaction("foo@example.com", "Missed Your Call", "Sorry we missed yoru call. What's up?")
251
+ # Create a new topic
252
+ Desk.create_topic(
253
+ :name => "Social Media",
254
+ :allow_questions => true,
255
+ :in_support_center => true
256
+ )
116
257
 
117
258
  ######
118
- # Users
259
+ # Update examples
119
260
  ######
120
261
 
121
- # List users
122
- Desk.users
262
+ # Update a customer
263
+ Desk.update_customer(123,
264
+ :first_name => "Johnny",
265
+ :emails => {
266
+ { :type => "work", :value => "johnny@acme.com" },
267
+ { :type => "other", :value => "johnny@other.com" }
268
+ },
269
+ :custom_fields => { :level => "super" }
270
+ )
271
+
272
+ # Update an integration URL
273
+ Desk.update_integration_url(10, :enabled => false)
123
274
 
124
- # Get a specific user
125
- Desk.user(12345)
275
+ # Update a macro
276
+ Desk.update_macro(5, :name => "Macro 5")
126
277
 
127
278
  ######
128
- # Topics
279
+ # Delete examples
129
280
  ######
130
281
 
131
- # List Topics
132
- Desk.topics
282
+ # Delete a case
283
+ Desk.delete_case(12345)
133
284
 
134
- # Get a specific topic
135
- Desk.topic(12345)
136
-
137
- # Create a new topic
138
- Desk.create_topic("name", :description => "description")
285
+ # Delete a label
286
+ Desk.delete_label(2)
139
287
 
140
- # Update a topic
141
- Desk.update_topic(12345, :subject => "Updated")
142
-
143
- # Delete a topic
144
- Desk.delete_topic(12345)
288
+ # Delete a macro
289
+ Desk.delete_macro(10)
145
290
 
146
291
  ######
147
- # Articles
292
+ # Sub-endpoint examples
148
293
  ######
149
294
 
150
- # List articles for a topic
151
- Desk.articles(1)
295
+ # Get the original message for a specific case
296
+ Desk.case_message(12345)
152
297
 
153
- # Get a specific article
154
- Desk.article(12345)
298
+ # Get the cases for a specifc filter
299
+ Desk.filter_cases(8)
155
300
 
156
- # Create a new article within a topic
157
- Desk.create_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
301
+ # Output all replies for a specific case
302
+ Desk.case_replies(12345).each { |r| puts r.body }
158
303
 
159
- # Update an article
160
- Desk.update_article(12345, :subject => "Updated API Tips")
304
+ # Update the translation for a specific topic
305
+ Desk.update_topic_translation(1, "ja", :name => "The Japanese Translation")
161
306
 
162
- # Delete an article
163
- Desk.delete_article(12345)
307
+ # Delete a specifc attachment for a specific case
308
+ Desk.delete_case_attachment(12345, 10)
164
309
 
165
310
  ######
166
- # Macros
311
+ # _link helper examples
167
312
  ######
168
313
 
169
- # List Macros
170
- Desk.macros
314
+ # Output the original message and all replies using the _link helpers
315
+ c = Desk.case(12345)
316
+ puts c.message.body
317
+ c.replies.each { |r| puts r.body }
171
318
 
172
- # Get a specific macro
173
- Desk.macro(12345)
319
+ # Output all article subjects, who created them and who last updated them
320
+ Desk.articles.each do |a|
321
+ puts a.subject
322
+ puts "Created at: #{a.created_at} by #{a.created_by.public_name}"
323
+ puts "Updated at: #{a.updated_at} by #{a.updated_by.public_name}"
324
+ end
174
325
 
175
- # Create a new macro
176
- Desk.create_macro("name", :labels => "escalated")
326
+ # For all customers who have been created since 01/01/2013, output the
327
+ # original message for all cases for those customers
328
+ Desk.customers(:since_created_at => 1385856000).each do |customer|
329
+ customer.cases.each do |c|
330
+ puts c.message.body
331
+ end
332
+ end
177
333
 
178
- # Update a macro
179
- Desk.update_macro(12345, :name => "Updated Name")
334
+ ######
335
+ # Helper methods
336
+ ######
180
337
 
181
- # Delete a macro
182
- Desk.delete_macro(12345)
338
+ # Add an address, email and phone
339
+ # number to an existing customer
340
+ customer = Desk.customer(12345)
341
+ customer_add_address(customer, "12545 Riata Vista Cir, Austin, TX 78727", "work")
342
+ customer_add_email(customer, "ruby@desk.com")
343
+ customer_add_phone_number(customer, "123-456-7890", "other")
344
+
345
+ # Delete a specific address, email and
346
+ # phone number from an existing customer
347
+ customer = Desk.customer(12345)
348
+ customer_delete_address(customer, "12545 Riata Vista Cir, Austin, TX 78727")
349
+ customer_delete_email(customer, "ruby@desk.com")
350
+ customer_delete_phone_number(customer, "123-456-7890")
351
+
352
+ # Delete all addresses and phone
353
+ # numbers of a specific type
354
+ customer = Desk.customer(12345)
355
+ customer_delete_address(customer, "work")
356
+ customer_delete_phone_number(customer, "other")
357
+
358
+ # The delete helpers also support mixing
359
+ # and matching multiple items
360
+ customer = Desk.customer(12345)
361
+ customer_delete_address(customer, "work", "other", " "12545 Riata Vista Cir, Austin, TX 78727")
362
+ customer_delete_email(customer, "ruby@desk.com", "gem@desk.com")
363
+ customer_delete_phone_number(customer, "work", "123-456-7890", "908-456-321")
183
364
 
184
- # Macro Actions
185
- Desk.macro_actions(12345)
365
+ ######
366
+ # "non-standard" examples
367
+ ######
186
368
 
187
- # Macro Action
188
- Desk.macro_action(12345, "set-case-description")
369
+ # Get a case url
370
+ Desk.case_url(12345)
189
371
 
190
- # Update Macro Action
191
- Desk.update_macro_action(12345, "set-case-description", :value => "New Subject")
372
+ # Get the history for a sepcific case
373
+ Desk.case_history(12345)
374
+
375
+ # Show insights meta data
376
+ Desk.insights_meta
377
+
378
+ # Create insights report
379
+ Desk.create_insights_report(
380
+ :resolution => "days",
381
+ :min_date => "2013-12-01",
382
+ :max_date => "2013-12-16",
383
+ :dimension1_name => "*",
384
+ :dimension1_values => "*",
385
+ :dimension2_name => "*",
386
+ :dimension2_values => "*"
387
+ )
388
+
389
+ # Show the daily system message
390
+ Desk.system_message
192
391
 
193
392
  Contributing
194
393
  ------------