desk 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.mkd +305 -106
- data/TRANSITION.mkd +133 -0
- data/desk.gemspec +1 -1
- data/lib/desk.rb +1 -1
- data/lib/desk/api.rb +5 -1
- data/lib/desk/client.rb +184 -10
- data/lib/desk/client/article.rb +4 -83
- data/lib/desk/client/brand.rb +11 -0
- data/lib/desk/client/case.rb +59 -42
- data/lib/desk/client/company.rb +11 -0
- data/lib/desk/client/custom_field.rb +10 -0
- data/lib/desk/client/customer.rb +26 -124
- data/lib/desk/client/facebook_user.rb +11 -0
- data/lib/desk/client/filter.rb +11 -0
- data/lib/desk/client/group.rb +3 -29
- data/lib/desk/client/insight.rb +17 -0
- data/lib/desk/client/integration_url.rb +11 -0
- data/lib/desk/client/job.rb +11 -0
- data/lib/desk/client/label.rb +11 -0
- data/lib/desk/client/macro.rb +3 -133
- data/lib/desk/client/mailbox.rb +26 -0
- data/lib/desk/client/rule.rb +14 -0
- data/lib/desk/client/site_setting.rb +11 -0
- data/lib/desk/client/system_message.rb +16 -0
- data/lib/desk/client/topic.rb +4 -81
- data/lib/desk/client/twitter_account.rb +11 -0
- data/lib/desk/client/twitter_user.rb +11 -0
- data/lib/desk/client/user.rb +3 -30
- data/lib/desk/configuration.rb +1 -1
- data/lib/desk/connection.rb +2 -1
- data/lib/desk/deash.rb +100 -0
- data/lib/desk/request.rb +33 -20
- data/lib/desk/version.rb +1 -1
- data/lib/faraday/request/oauth.rb +6 -3
- data/lib/faraday/response/deashify.rb +23 -0
- data/spec/desk/client/article_spec.rb +62 -117
- data/spec/desk/client/brand_spec.rb +18 -0
- data/spec/desk/client/case_spec.rb +182 -66
- data/spec/desk/client/companies_spec.rb +26 -0
- data/spec/desk/client/custom_fields_spec.rb +18 -0
- data/spec/desk/client/customer_spec.rb +16 -145
- data/spec/desk/client/facebook_users_spec.rb +17 -0
- data/spec/desk/client/filter_spec.rb +28 -0
- data/spec/desk/client/group_spec.rb +32 -49
- data/spec/desk/client/inbound_mailboxes_spec.rb +70 -0
- data/spec/desk/client/integration_url_spec.rb +28 -0
- data/spec/desk/client/job_spec.rb +32 -0
- data/spec/desk/client/label_spec.rb +31 -0
- data/spec/desk/client/macro_spec.rb +22 -185
- data/spec/desk/client/rule_spec.rb +18 -0
- data/spec/desk/client/site_setting_spec.rb +18 -0
- data/spec/desk/client/system_message_spec.rb +42 -0
- data/spec/desk/client/topic_spec.rb +31 -112
- data/spec/desk/client/twitter_account_spec.rb +32 -0
- data/spec/desk/client/twitter_user_spec.rb +27 -0
- data/spec/desk/client/user_spec.rb +19 -42
- data/spec/desk_spec.rb +2 -2
- data/spec/faraday/response_spec.rb +3 -6
- data/spec/fixtures/article +50 -0
- data/spec/fixtures/article_create +50 -0
- data/spec/fixtures/article_translation +29 -0
- data/spec/fixtures/article_translation_create +29 -0
- data/spec/fixtures/article_translation_update +29 -0
- data/spec/fixtures/article_translations +81 -0
- data/spec/fixtures/article_update +50 -0
- data/spec/fixtures/articles +123 -0
- data/spec/fixtures/articles_search +124 -0
- data/spec/fixtures/brand +11 -0
- data/spec/fixtures/brands +45 -0
- data/spec/fixtures/case +44 -0
- data/spec/fixtures/case_attachment +19 -0
- data/spec/fixtures/case_attachment_create +19 -0
- data/spec/fixtures/case_attachments +61 -0
- data/spec/fixtures/case_create +51 -0
- data/spec/fixtures/case_message +26 -0
- data/spec/fixtures/case_note +21 -0
- data/spec/fixtures/case_note_create +26 -0
- data/spec/fixtures/case_notes +65 -0
- data/spec/fixtures/case_replies +75 -0
- data/spec/fixtures/case_reply +26 -0
- data/spec/fixtures/case_reply_create +26 -0
- data/spec/fixtures/case_reply_update +26 -0
- data/spec/fixtures/case_update +49 -0
- data/spec/fixtures/cases +111 -0
- data/spec/fixtures/cases_search +113 -0
- data/spec/fixtures/companies +75 -0
- data/spec/fixtures/companies_search +76 -0
- data/spec/fixtures/company +26 -0
- data/spec/fixtures/company_create +26 -0
- data/spec/fixtures/company_search +76 -0
- data/spec/fixtures/company_update +27 -0
- data/spec/fixtures/custom_field +15 -0
- data/spec/fixtures/custom_fields +58 -0
- data/spec/fixtures/customer +60 -0
- data/spec/fixtures/customer_create +54 -0
- data/spec/fixtures/customer_update +60 -0
- data/spec/fixtures/customers +143 -0
- data/spec/fixtures/customers_search +143 -0
- data/spec/fixtures/facebook_user +16 -0
- data/spec/fixtures/facebook_users +55 -0
- data/spec/fixtures/filter +16 -0
- data/spec/fixtures/filter_cases +111 -0
- data/spec/fixtures/filters +55 -0
- data/spec/fixtures/group +9 -0
- data/spec/fixtures/group_filters +55 -0
- data/spec/fixtures/group_users +63 -0
- data/spec/fixtures/groups +42 -0
- data/spec/fixtures/inbound_mailbox +32 -0
- data/spec/fixtures/inbound_mailboxes +87 -0
- data/spec/fixtures/integration_url +15 -0
- data/spec/fixtures/integration_url_create +15 -0
- data/spec/fixtures/integration_url_update +15 -0
- data/spec/fixtures/integration_urls +54 -0
- data/spec/fixtures/job +17 -0
- data/spec/fixtures/job_create +17 -0
- data/spec/fixtures/jobs +57 -0
- data/spec/fixtures/label +17 -0
- data/spec/fixtures/label_create +17 -0
- data/spec/fixtures/label_update +17 -0
- data/spec/fixtures/labels +57 -0
- data/spec/fixtures/macro +20 -0
- data/spec/fixtures/macro_action +17 -0
- data/spec/fixtures/macro_action_update +17 -0
- data/spec/fixtures/macro_actions +57 -0
- data/spec/fixtures/macro_create +20 -0
- data/spec/fixtures/macro_update +20 -0
- data/spec/fixtures/macros +63 -0
- data/spec/fixtures/rule +13 -0
- data/spec/fixtures/rules +49 -0
- data/spec/fixtures/site_setting +10 -0
- data/spec/fixtures/site_settings +43 -0
- data/spec/fixtures/system_message +4 -0
- data/spec/fixtures/topic +23 -0
- data/spec/fixtures/topic_create +23 -0
- data/spec/fixtures/topic_translation +12 -0
- data/spec/fixtures/topic_translation_create +12 -0
- data/spec/fixtures/topic_translation_update +12 -0
- data/spec/fixtures/topic_translations +47 -0
- data/spec/fixtures/topic_update +23 -0
- data/spec/fixtures/topics +69 -0
- data/spec/fixtures/twitter_account +14 -0
- data/spec/fixtures/twitter_account_tweet +20 -0
- data/spec/fixtures/twitter_account_tweet_create +20 -0
- data/spec/fixtures/twitter_account_tweets +63 -0
- data/spec/fixtures/twitter_accounts +51 -0
- data/spec/fixtures/twitter_user +18 -0
- data/spec/fixtures/twitter_user_create +18 -0
- data/spec/fixtures/twitter_users +59 -0
- data/spec/fixtures/user +20 -0
- data/spec/fixtures/user_preference +18 -0
- data/spec/fixtures/user_preference_update +14 -0
- data/spec/fixtures/user_preferences +223 -0
- data/spec/fixtures/users +63 -0
- data/spec/helper.rb +12 -0
- data/spec/shared_context.rb +16 -0
- data/spec/shared_examples.rb +312 -0
- metadata +247 -181
- data/lib/desk/client/interaction.rb +0 -75
- data/spec/desk/client/interaction_spec.rb +0 -191
- data/spec/fixtures/article.json +0 -50
- data/spec/fixtures/article_create.json +0 -54
- data/spec/fixtures/article_destroy.json +0 -3
- data/spec/fixtures/article_update.json +0 -54
- data/spec/fixtures/articles.json +0 -58
- data/spec/fixtures/case.json +0 -59
- data/spec/fixtures/case_update.json +0 -59
- data/spec/fixtures/cases.json +0 -182
- data/spec/fixtures/customer.json +0 -58
- data/spec/fixtures/customer_create.json +0 -56
- data/spec/fixtures/customer_create_email.json +0 -15
- data/spec/fixtures/customer_update.json +0 -47
- data/spec/fixtures/customer_update_email.json +0 -15
- data/spec/fixtures/customers.json +0 -98
- data/spec/fixtures/group.json +0 -8
- data/spec/fixtures/groups.json +0 -23
- data/spec/fixtures/interaction_create.json +0 -126
- data/spec/fixtures/interactions.json +0 -139
- data/spec/fixtures/macro.json +0 -8
- data/spec/fixtures/macro_action.json +0 -9
- data/spec/fixtures/macro_action_update.json +0 -12
- data/spec/fixtures/macro_actions.json +0 -69
- data/spec/fixtures/macro_create.json +0 -13
- data/spec/fixtures/macro_destroy.json +0 -3
- data/spec/fixtures/macro_update.json +0 -13
- data/spec/fixtures/macros.json +0 -24
- data/spec/fixtures/topic.json +0 -9
- data/spec/fixtures/topic_create.json +0 -14
- data/spec/fixtures/topic_destroy.json +0 -3
- data/spec/fixtures/topic_update.json +0 -14
- data/spec/fixtures/topics.json +0 -35
- data/spec/fixtures/user.json +0 -15
- data/spec/fixtures/users.json +0 -24
checksums.yaml
ADDED
@@ -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.
|
10
|
-
|
11
|
-
@mtchavez bumped faraday_middleware to 0.9.0
|
9
|
+
What's new in 1.0.0?
|
10
|
+
--------------------
|
12
11
|
|
13
|
-
|
14
|
-
------------------
|
15
|
-
@tstachl added support for groups and max requests
|
12
|
+
Completely rewritten for Desk.com API v2
|
16
13
|
|
17
|
-
|
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.
|
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
|
-
#
|
151
|
+
# List examples
|
45
152
|
######
|
46
153
|
|
47
154
|
# List cases
|
48
155
|
Desk.cases
|
49
|
-
Desk.cases(:since_id => 12345)
|
50
156
|
|
51
|
-
#
|
52
|
-
Desk.
|
157
|
+
# List customers
|
158
|
+
Desk.customers
|
53
159
|
|
54
|
-
#
|
55
|
-
Desk.
|
160
|
+
# List site settings
|
161
|
+
Desk.site_settings
|
56
162
|
|
57
|
-
#
|
58
|
-
Desk.
|
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
|
-
#
|
173
|
+
# Search examples
|
62
174
|
######
|
63
175
|
|
64
|
-
#
|
65
|
-
Desk.
|
66
|
-
Desk.customers(:since_id => 12345, :count => 5)
|
176
|
+
# Search articles
|
177
|
+
Desk.articles(:text => "happy", :topic_ids => "1,2,4")
|
67
178
|
|
68
|
-
#
|
69
|
-
Desk.
|
179
|
+
# Search cases
|
180
|
+
Desk.cases(:since_id => 12345)
|
70
181
|
|
71
|
-
#
|
72
|
-
Desk.
|
182
|
+
# Search companies
|
183
|
+
Desk.companies(:q => "acme")
|
73
184
|
|
74
|
-
#
|
75
|
-
Desk.
|
185
|
+
# Search customers
|
186
|
+
Desk.customers(:last_name => "Smith", :custom_field => "IS 5416")
|
76
187
|
|
77
|
-
|
78
|
-
|
79
|
-
|
188
|
+
######
|
189
|
+
# Show examples
|
190
|
+
######
|
80
191
|
|
81
|
-
#
|
82
|
-
Desk.
|
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
|
-
#
|
86
|
-
Desk.
|
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
|
-
#
|
90
|
-
Desk.
|
91
|
-
|
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
|
-
#
|
205
|
+
# Create examples
|
95
206
|
######
|
96
207
|
|
97
|
-
#
|
98
|
-
Desk.
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|
-
#
|
259
|
+
# Update examples
|
119
260
|
######
|
120
261
|
|
121
|
-
#
|
122
|
-
Desk.
|
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
|
-
#
|
125
|
-
Desk.
|
275
|
+
# Update a macro
|
276
|
+
Desk.update_macro(5, :name => "Macro 5")
|
126
277
|
|
127
278
|
######
|
128
|
-
#
|
279
|
+
# Delete examples
|
129
280
|
######
|
130
281
|
|
131
|
-
#
|
132
|
-
Desk.
|
282
|
+
# Delete a case
|
283
|
+
Desk.delete_case(12345)
|
133
284
|
|
134
|
-
#
|
135
|
-
Desk.
|
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
|
-
#
|
141
|
-
Desk.
|
142
|
-
|
143
|
-
# Delete a topic
|
144
|
-
Desk.delete_topic(12345)
|
288
|
+
# Delete a macro
|
289
|
+
Desk.delete_macro(10)
|
145
290
|
|
146
291
|
######
|
147
|
-
#
|
292
|
+
# Sub-endpoint examples
|
148
293
|
######
|
149
294
|
|
150
|
-
#
|
151
|
-
Desk.
|
295
|
+
# Get the original message for a specific case
|
296
|
+
Desk.case_message(12345)
|
152
297
|
|
153
|
-
# Get a
|
154
|
-
Desk.
|
298
|
+
# Get the cases for a specifc filter
|
299
|
+
Desk.filter_cases(8)
|
155
300
|
|
156
|
-
#
|
157
|
-
Desk.
|
301
|
+
# Output all replies for a specific case
|
302
|
+
Desk.case_replies(12345).each { |r| puts r.body }
|
158
303
|
|
159
|
-
# Update
|
160
|
-
Desk.
|
304
|
+
# Update the translation for a specific topic
|
305
|
+
Desk.update_topic_translation(1, "ja", :name => "The Japanese Translation")
|
161
306
|
|
162
|
-
# Delete
|
163
|
-
Desk.
|
307
|
+
# Delete a specifc attachment for a specific case
|
308
|
+
Desk.delete_case_attachment(12345, 10)
|
164
309
|
|
165
310
|
######
|
166
|
-
#
|
311
|
+
# _link helper examples
|
167
312
|
######
|
168
313
|
|
169
|
-
#
|
170
|
-
Desk.
|
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
|
-
#
|
173
|
-
Desk.
|
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
|
-
#
|
176
|
-
|
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
|
-
|
179
|
-
|
334
|
+
######
|
335
|
+
# Helper methods
|
336
|
+
######
|
180
337
|
|
181
|
-
#
|
182
|
-
|
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
|
-
|
185
|
-
|
365
|
+
######
|
366
|
+
# "non-standard" examples
|
367
|
+
######
|
186
368
|
|
187
|
-
#
|
188
|
-
Desk.
|
369
|
+
# Get a case url
|
370
|
+
Desk.case_url(12345)
|
189
371
|
|
190
|
-
#
|
191
|
-
Desk.
|
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
|
------------
|