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,11 @@
1
+ module Desk
2
+ class Client
3
+ module Brand
4
+
5
+ def brand_endpoints
6
+ [ :list, :show ]
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -2,53 +2,70 @@ module Desk
2
2
  class Client
3
3
  # Defines methods related to cases
4
4
  module Case
5
- # Returns extended information of cases
6
- #
7
- # @option options [Boolean, String, Integer]
8
- # @example Return extended information for 12345
9
- # Desk.cases(:case_id => 12345)
10
- # Desk.cases(:email => "customer@example.com", :count => 5)
11
- # Desk.cases(:since_id => 12345)
12
- # @format :json
13
- # @authenticated true
14
- # @see http://dev.desk.com/docs/api/cases/show
15
- def cases(*args)
5
+
6
+ def case_endpoints
7
+ [ :list, :search, :create, :update,
8
+ :list_replies, :show_reply, :create_reply, :update_reply,
9
+ :list_notes, :show_note, :create_note,
10
+ :list_attachments, :show_attachment, :create_attachment, :delete_attachment,
11
+ :list_history
12
+ ]
13
+ end
14
+
15
+ def show_case(case_id, *args)
16
16
  options = args.last.is_a?(Hash) ? args.pop : {}
17
- response = get("cases",options)
18
- response
19
- end
20
-
21
- # Returns extended information on a single case
22
- #
23
- # @option options [String]
24
- # @example Return extended information for 12345
25
- # Desk.case(12345)
26
- # Desk.case(12345, :by => "external_id")
27
- # @format :json
28
- # @authenticated true
29
- # @see http://dev.desk.com/docs/api/cases/show
30
- def case(id, *args)
17
+ case_id = "e-#{case_id}" if options[:by] == "external_id"
18
+ get("cases/#{case_id}")
19
+ end
20
+ alias_method :case, :show_case
21
+
22
+ def show_case_message(case_id)
23
+ get("cases/#{case_id}/message")
24
+ end
25
+ alias_method :case_message, :show_case_message
26
+
27
+ def list_case_message_attachments(case_id, *args)
31
28
  options = args.last.is_a?(Hash) ? args.pop : {}
32
- response = get("cases/#{id}",options)
33
- response.case
34
- end
35
-
36
- # Updates a single case
37
- #
38
- # @option options [String]
39
- # @example Return extended information for 12345
40
- # Desk.update_case(12345, :subject => "New Subject")
41
- # @format :json
42
- # @authenticated true
43
- # @see http://dev.desk.com/docs/api/cases/update
44
- def update_case(id, *args)
29
+ get("cases/#{case_id}/message/attachments", options)
30
+ end
31
+ alias_method :case_message_attachments, :list_case_message_attachments
32
+
33
+ def list_case_reply_attachments(case_id, reply_id, *args)
45
34
  options = args.last.is_a?(Hash) ? args.pop : {}
46
- response = put("cases/#{id}",options)
47
- response.case
35
+ get("cases/#{case_id}/replies/#{reply_id}/attachments", options)
36
+ end
37
+ alias_method :case_reply_attachments, :list_case_reply_attachments
38
+
39
+ def show_case_message_attachment(case_id, attachment_id)
40
+ get("cases/#{case_id}/message/attachments/#{attachment_id}")
41
+ end
42
+ alias_method :case_message_attachment, :show_case_message_attachment
43
+
44
+ def show_case_reply_attachment(case_id, reply_id, attachment_id)
45
+ get("cases/#{case_id}/replies/#{reply_id}/attachments/#{attachment_id}")
46
+ end
47
+ alias_method :case_reply_attachment, :show_case_reply_attachment
48
+
49
+ def create_case_message_attachment(case_id, *args)
50
+ options = args.last.is_a?(Hash) ? args.pop : {}
51
+ post("cases/#{case_id}/message/attachments", options)
52
+ end
53
+
54
+ def create_case_reply_attachment(case_id, reply_id, *args)
55
+ options = args.last.is_a?(Hash) ? args.pop : {}
56
+ post("cases/#{case_id}/replies/#{reply_id}/attachments", options)
57
+ end
58
+
59
+ def delete_case_message_attachment(case_id, attachment_id)
60
+ delete("cases/#{case_id}/message/attachments/#{attachment_id}")
61
+ end
62
+
63
+ def delete_case_reply_attachment(case_id, reply_id, attachment_id)
64
+ delete("cases/#{case_id}/replies/#{reply_id}/attachments/#{attachment_id}")
48
65
  end
49
66
 
50
- def case_url(id)
51
- "https://#{subdomain}.desk.com/agent/case/#{id}"
67
+ def case_url(case_id)
68
+ "https://#{subdomain}.desk.com/agent/case/#{case_id}"
52
69
  end
53
70
  end
54
71
  end
@@ -0,0 +1,11 @@
1
+ module Desk
2
+ class Client
3
+ module Company
4
+
5
+ def company_endpoints
6
+ [ :list, :show, :create, :update, :search, :list_cases ]
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module Desk
2
+ class Client
3
+ module CustomField
4
+
5
+ def custom_field_endpoints
6
+ [ :list, :show ]
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,146 +1,48 @@
1
1
  module Desk
2
2
  class Client
3
- # Defines methods related to customers
4
3
  module Customer
5
- # Returns extended information of customers
6
- #
7
- # @option options [Boolean, String, Integer]
8
- # @example Return extended information for customers
9
- # Desk.customers
10
- # Desk.customers(:since_id => 12345, :count => 5)
11
- # @format :json
12
- # @authenticated true
13
- # @see http://dev.desk.com/docs/api/customers
14
- def customers(*args)
15
- options = args.last.is_a?(Hash) ? args.pop : {}
16
- response = get("customers",options)
17
- response
4
+
5
+ def customer_endpoints
6
+ [ :list, :show, :create, :update, :search ]
18
7
  end
19
8
 
20
- # Returns extended information on a single customer
21
- #
22
- # @option options [String]
23
- # @example Return extended information for customer 12345
24
- # Desk.customer(12345)
25
- # @format :json
26
- # @authenticated true
27
- # @see http://dev.desk.com/docs/api/customers/show
28
- def customer(id)
29
- response = get("customers/#{id}")
30
- response.customer
9
+ def customer_add_key(key, customer, value, type)
10
+ customer.send(key) << {:value => value, :type => type}
11
+ customer = Desk.update_customer(customer.id, {key.to_sym => customer.send(key)})
31
12
  end
32
13
 
33
- # Create a new customer
34
- #
35
- # @option options [String]
36
- # @example Return extended information for 12345
37
- # Desk.create_customer(:name => "Chris Warren", :twitter => "cdwarren")
38
- # @format :json
39
- # @authenticated true
40
- # @see http://dev.desk.com/docs/api/customers/create
41
- def create_customer(*args)
42
- options = args.last.is_a?(Hash) ? args.pop : {}
43
- response = post("customers",options)
44
- if response['success']
45
- return response['results']['customer']
46
- else
47
- return response
14
+ def customer_delete_key(key, customer, *args)
15
+ a = args.last.is_a?(Array) ? args.pop : args
16
+ customer.send(key).delete_if do |item|
17
+ a.include?(item.type) || a.include?(item.value)
48
18
  end
19
+ customer = Desk.update_customer(customer.id, {key.to_sym => customer.send(key)})
49
20
  end
50
21
 
51
- # Update a customer
52
- #
53
- # @option options [String]
54
- # @example Return extended information for 12345
55
- # Desk.update_customer(12345, :name => "Christopher Warren")
56
- # @format :json
57
- # @authenticated true
58
- # @see http://dev.desk.com/docs/api/customers/update
59
- def update_customer(id, *args)
60
- options = args.last.is_a?(Hash) ? args.pop : {}
61
- response = put("customers/#{id}",options)
62
- if response['success']
63
- return response['results']['customer']
64
- else
65
- return response
66
- end
22
+ def customer_add_address(customer, address, type = "home")
23
+ customer_add_key("addresses", customer, address, type)
67
24
  end
68
25
 
69
- # Create a new customer email
70
- #
71
- # @option options [String]
72
- # @example Return extended information for 12345
73
- # Desk.create_customer_email(12345, "foo@example.com")
74
- # @format :json
75
- # @authenticated true
76
- # @see http://dev.desk.com/docs/api/customers/emails/create
77
- def create_customer_email(id, email, *args)
78
- options = args.last.is_a?(Hash) ? args.pop : {}
79
- options.merge!({:email => email})
80
- response = post("customers/#{id}/emails",options)
81
- if response['success']
82
- return response['results']['email']
83
- else
84
- return response
85
- end
26
+ def customer_delete_address(customer, *args)
27
+ customer_delete_key("addresses", customer, args)
86
28
  end
87
29
 
88
- # Update a customer's email
89
- #
90
- # @option options [String]
91
- # @example Return extended information for 12345
92
- # Desk.update_customer_email(12345, 12345, :email => "foo@example.com")
93
- # Desk.update_customer_email(12345, 12345, :customer_contact_type => "work")
94
- # @format :json
95
- # @authenticated true
96
- # @see http://dev.desk.com/docs/api/customers/emails/update
97
- def update_customer_email(id, email_id, *args)
98
- options = args.last.is_a?(Hash) ? args.pop : {}
99
- response = put("customers/#{id}/emails/#{email_id}",options)
100
- if response['success']
101
- return response['results']['email']
102
- else
103
- return response
104
- end
30
+ def customer_add_email(customer, email, type = "home")
31
+ customer_add_key("emails", customer, email, type)
105
32
  end
106
33
 
107
- # Create a new customer phone number
108
- #
109
- # @option options [String]
110
- # @example Return extended information for 12345
111
- # Desk.create_customer_phone(12345, "555-368-7147")
112
- # @format :json
113
- # @authenticated true
114
- # @see http://dev.desk.com/docs/api/customers/phones/create
115
- def create_customer_phone(id, phone, *args)
116
- options = args.last.is_a?(Hash) ? args.pop : {}
117
- options.merge!({:phone => phone})
118
- response = post("customers/#{id}/phones",options)
119
- if response['success']
120
- return response['results']['phone']
121
- else
122
- return response
123
- end
34
+ def customer_delete_email(customer, *args)
35
+ customer_delete_key("emails", customer, args)
124
36
  end
125
37
 
126
- # Update a customer's phone number
127
- #
128
- # @option options [String]
129
- # @example Return extended information for 12345
130
- # Desk.update_customer_phone(12345, 12345, :phone => "555-368-7147")
131
- # Desk.update_customer_phone(12345, 12345, :customer_contact_type => "work")
132
- # @format :json
133
- # @authenticated true
134
- # @see http://dev.desk.com/docs/api/customers/phones/update
135
- def update_customer_phone(id, phone_id, *args)
136
- options = args.last.is_a?(Hash) ? args.pop : {}
137
- response = put("customers/#{id}/phones/#{phone_id}",options)
138
- if response['success']
139
- return response['results']['phone']
140
- else
141
- return response
142
- end
38
+ def customer_add_phone_number(customer, phone_number, type = "home")
39
+ customer_add_key("phone_numbers", customer, phone_number, type)
40
+ end
41
+
42
+ def customer_delete_phone_number(customer, *args)
43
+ customer_delete_key("phone_numbers", customer, args)
143
44
  end
45
+
144
46
  end
145
47
  end
146
48
  end
@@ -0,0 +1,11 @@
1
+ module Desk
2
+ class Client
3
+ module FacebookUser
4
+
5
+ def facebook_user_endpoints
6
+ [ :list, :show ]
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Desk
2
+ class Client
3
+ module Filter
4
+
5
+ def filter_endpoints
6
+ [ :list, :show, :list_cases ]
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -1,37 +1,11 @@
1
1
  module Desk
2
2
  class Client
3
- # Defines methods related to groups
4
3
  module Group
5
- # Returns extended information of groups
6
- #
7
- # @option options [Boolean, String, Integer]
8
- # @example Return extended information for 12345
9
- # Desk.groups
10
- # Desk.groups(:count => 5)
11
- # Desk.groups(:count => 5, :page => 3)
12
- # @format :json
13
- # @authenticated true
14
- # @see http://dev.desk.com/docs/api/groups
15
- def groups(*args)
16
- options = args.last.is_a?(Hash) ? args.pop : {}
17
- response = get("groups",options)
18
- response
19
- end
20
4
 
21
- # Returns extended information on a single group
22
- #
23
- # @param id [Integer] a group ID
24
- # @option options [Hash]
25
- # @example Return extended information for 12345
26
- # Desk.group(12345)
27
- # @format :json
28
- # @authenticated true
29
- # @see http://dev.desk.com/docs/api/groups/show
30
- def group(id)
31
- response = get("groups/#{id}")
32
- response.group
5
+ def group_endpoints
6
+ [ :list, :show, :list_filters, :list_users ]
33
7
  end
34
8
 
35
9
  end
36
10
  end
37
- end
11
+ end
@@ -0,0 +1,17 @@
1
+ module Desk
2
+ class Client
3
+ module Insight
4
+
5
+ def show_insights_meta
6
+ get("insights/meta")
7
+ end
8
+ alias_method :insights_meta, :show_insights_meta
9
+
10
+ def create_insights_report(*args)
11
+ options = args.last.is_a?(Hash) ? args.pop : {}
12
+ post("insights/reports", options)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Desk
2
+ class Client
3
+ module IntegrationUrl
4
+
5
+ def integration_url_endpoints
6
+ [ :list, :show, :create, :update, :delete ]
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Desk
2
+ class Client
3
+ module Job
4
+
5
+ def job_endpoints
6
+ [ :list, :show, :create ]
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Desk
2
+ class Client
3
+ module Label
4
+
5
+ def label_endpoints
6
+ [ :list, :show, :create, :update, :delete ]
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -1,140 +1,10 @@
1
1
  module Desk
2
2
  class Client
3
- # Defines methods related to macros
4
3
  module Macro
5
- # Returns extended information of macros
6
- #
7
- # @option options [Boolean, String, Integer]
8
- # @example Return extended information for 12345
9
- # Desk.macros
10
- # Desk.macros(:count => 5)
11
- # Desk.macros(:count => 5, :page => 3)
12
- # @format :json
13
- # @authenticated true
14
- # @see http://dev.desk.com/docs/api/macros
15
- def macros(*args)
16
- options = args.last.is_a?(Hash) ? args.pop : {}
17
- response = get("macros",options)
18
- response
19
- end
20
-
21
- # Returns extended information on a single macro
22
- #
23
- # @param id [Integer] a macro ID
24
- # @option options [Hash]
25
- # @example Return extended information for 12345
26
- # Desk.macro(12345)
27
- # @format :json
28
- # @authenticated true
29
- # @see http://dev.desk.com/docs/api/macros/show
30
- def macro(id)
31
- response = get("macros/#{id}")
32
- response.macro
33
- end
34
-
35
- # Creates a new macro
36
- #
37
- # @param name [String] A macro name
38
- # @option options [Hash]
39
- # @example Creates a new macro
40
- # Desk.create_macro("name")
41
- # Desk.create_macro("name")
42
- # @format :json
43
- # @authenticated true
44
- # @see http://dev.desk.com/docs/api/macros/create
45
- def create_macro(name, *args)
46
- options = args.last.is_a?(Hash) ? args.pop : {}
47
- response = post("macros",options)
48
- if response['success']
49
- return response['results']['macro']
50
- else
51
- return response
52
- end
53
- end
54
-
55
- # Updates a single macro
56
- #
57
- # @param id [Integer] a macro ID
58
- # @option options [String]
59
- # @example Updates information for macro 12345
60
- # Desk.update_macro(12345, :subject => "New Subject")
61
- # @format :json
62
- # @authenticated true
63
- # @see http://dev.desk.com/docs/api/macros/update
64
- def update_macro(id, *args)
65
- options = args.last.is_a?(Hash) ? args.pop : {}
66
- response = put("macros/#{id}",options)
67
- if response['success']
68
- return response['results']['macro']
69
- else
70
- return response
71
- end
72
- end
73
-
74
- # Deletes a single macro
75
- #
76
- # @param id [Integer] a macro ID
77
- # @example Deletes macro 12345
78
- # Desk.update_macro(12345, :subject => "New Subject")
79
- # @format :json
80
- # @authenticated true
81
- # @see http://dev.desk.com/docs/api/macros/update
82
- def delete_macro(id)
83
- response = delete("macros/#{id}")
84
- response
85
- end
86
-
87
- ##########
88
- # Macro Actions
89
- ##########
90
-
91
- # Returns extended information of macros
92
- #
93
- # @option options [Boolean, String, Integer]
94
- # @example Return extended information for 12345
95
- # Desk.macro_actions(1)
96
- # Desk.macro_actions(1, :count => 5)
97
- # Desk.macro_actions(1, :count => 5, :page => 3)
98
- # @format :json
99
- # @authenticated true
100
- # @see http://dev.desk.com/docs/api/macros/actions
101
- def macro_actions(id, *args)
102
- options = args.last.is_a?(Hash) ? args.pop : {}
103
- response = get("macros/#{id}/actions",options)
104
- response['results']
105
- end
106
-
107
- # Returns extended information on a single macro
108
- #
109
- # @param id [Integer] a macro ID
110
- # @option options [Hash]
111
- # @example Return extended information for 12345
112
- # Desk.macro_action(12345, "set-case-description")
113
- # @format :json
114
- # @authenticated true
115
- # @see http://dev.desk.com/docs/api/macros/actions/show
116
- def macro_action(id, slug)
117
- response = get("macros/#{id}/actions/#{slug}")
118
- response['action']
119
- end
120
4
 
121
- # Updates a single macro action
122
- #
123
- # @param id [Integer] a macro ID
124
- # @option options [String]
125
- # @example Updates information for macro 12345
126
- # Desk.update_macro_action(12345, "set-case-description", :value => "New Subject")
127
- # @format :json
128
- # @authenticated true
129
- # @see http://dev.desk.com/docs/api/macros/actions/update
130
- def update_macro_action(id, slug, *args)
131
- options = args.last.is_a?(Hash) ? args.pop : {}
132
- response = put("macros/#{id}/actions/#{slug}",options)
133
- if response['success']
134
- return response['results']['action']
135
- else
136
- return response
137
- end
5
+ def macro_endpoints
6
+ [ :list, :show, :create, :update, :delete,
7
+ :list_actions, :show_action, :update_action ]
138
8
  end
139
9
 
140
10
  end