gitlab-customer-support-operations_zendesk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/lib/support_ops_zendesk/packages.rb +89 -0
  3. data/lib/support_ops_zendesk/zendesk/app_installations.rb +62 -0
  4. data/lib/support_ops_zendesk/zendesk/app_job_statuses.rb +157 -0
  5. data/lib/support_ops_zendesk/zendesk/apps.rb +476 -0
  6. data/lib/support_ops_zendesk/zendesk/articles.rb +362 -0
  7. data/lib/support_ops_zendesk/zendesk/audit_logs.rb +166 -0
  8. data/lib/support_ops_zendesk/zendesk/automations.rb +390 -0
  9. data/lib/support_ops_zendesk/zendesk/base.rb +472 -0
  10. data/lib/support_ops_zendesk/zendesk/brands.rb +172 -0
  11. data/lib/support_ops_zendesk/zendesk/client.rb +91 -0
  12. data/lib/support_ops_zendesk/zendesk/comments.rb +37 -0
  13. data/lib/support_ops_zendesk/zendesk/configuration.rb +138 -0
  14. data/lib/support_ops_zendesk/zendesk/custom_roles.rb +224 -0
  15. data/lib/support_ops_zendesk/zendesk/dynamic_content.rb +297 -0
  16. data/lib/support_ops_zendesk/zendesk/dynamic_content_variants.rb +309 -0
  17. data/lib/support_ops_zendesk/zendesk/group_memberships.rb +337 -0
  18. data/lib/support_ops_zendesk/zendesk/groups.rb +385 -0
  19. data/lib/support_ops_zendesk/zendesk/help_center_categories.rb +332 -0
  20. data/lib/support_ops_zendesk/zendesk/help_center_content_tags.rb +237 -0
  21. data/lib/support_ops_zendesk/zendesk/help_center_management_permission_groups.rb +271 -0
  22. data/lib/support_ops_zendesk/zendesk/help_center_sections.rb +378 -0
  23. data/lib/support_ops_zendesk/zendesk/help_center_topics.rb +274 -0
  24. data/lib/support_ops_zendesk/zendesk/help_center_user_segments.rb +279 -0
  25. data/lib/support_ops_zendesk/zendesk/job_statuses.rb +231 -0
  26. data/lib/support_ops_zendesk/zendesk/locales.rb +326 -0
  27. data/lib/support_ops_zendesk/zendesk/macros.rb +407 -0
  28. data/lib/support_ops_zendesk/zendesk/oauth_clients.rb +186 -0
  29. data/lib/support_ops_zendesk/zendesk/oauth_tokens.rb +114 -0
  30. data/lib/support_ops_zendesk/zendesk/organization_fields.rb +282 -0
  31. data/lib/support_ops_zendesk/zendesk/organization_memberships.rb +336 -0
  32. data/lib/support_ops_zendesk/zendesk/organizations.rb +568 -0
  33. data/lib/support_ops_zendesk/zendesk/requester_roles.rb +58 -0
  34. data/lib/support_ops_zendesk/zendesk/satisfaction_reasons.rb +161 -0
  35. data/lib/support_ops_zendesk/zendesk/schedule_holidays.rb +27 -0
  36. data/lib/support_ops_zendesk/zendesk/schedules.rb +192 -0
  37. data/lib/support_ops_zendesk/zendesk/search.rb +185 -0
  38. data/lib/support_ops_zendesk/zendesk/sla_policies.rb +302 -0
  39. data/lib/support_ops_zendesk/zendesk/targets.rb +96 -0
  40. data/lib/support_ops_zendesk/zendesk/theme_job_statuses.rb +154 -0
  41. data/lib/support_ops_zendesk/zendesk/themes.rb +328 -0
  42. data/lib/support_ops_zendesk/zendesk/ticket_field_options.rb +154 -0
  43. data/lib/support_ops_zendesk/zendesk/ticket_fields.rb +357 -0
  44. data/lib/support_ops_zendesk/zendesk/ticket_forms.rb +370 -0
  45. data/lib/support_ops_zendesk/zendesk/ticket_user_types.rb +67 -0
  46. data/lib/support_ops_zendesk/zendesk/tickets.rb +837 -0
  47. data/lib/support_ops_zendesk/zendesk/translations.rb +310 -0
  48. data/lib/support_ops_zendesk/zendesk/trigger_categories.rb +275 -0
  49. data/lib/support_ops_zendesk/zendesk/triggers.rb +427 -0
  50. data/lib/support_ops_zendesk/zendesk/user_field_options.rb +153 -0
  51. data/lib/support_ops_zendesk/zendesk/user_fields.rb +312 -0
  52. data/lib/support_ops_zendesk/zendesk/users.rb +889 -0
  53. data/lib/support_ops_zendesk/zendesk/via_types.rb +137 -0
  54. data/lib/support_ops_zendesk/zendesk/views.rb +636 -0
  55. data/lib/support_ops_zendesk/zendesk/webhooks.rb +206 -0
  56. data/lib/support_ops_zendesk/zendesk.rb +66 -0
  57. data/lib/support_ops_zendesk.rb +29 -0
  58. metadata +274 -0
@@ -0,0 +1,357 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module SupportOps.
4
+ module SupportOps
5
+ # Defines the module Zendesk
6
+ module Zendesk
7
+ ##
8
+ # Defines the class TicketFields within the module {SupportOps::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.0
12
+ # @attr [Boolean] active Whether this field is available
13
+ # @attr [Boolean] agent_can_edit Whether this field is editable by agents
14
+ # @attr [String] agent_description A description of the ticket field that only agents can see
15
+ # @attr [Boolean] collapsed_for_agents If true, the field is shown to agents by default; if false, the field is hidden alongside infrequently used fields
16
+ # @attr [String] created_at The time the custom ticket field was created
17
+ # @attr [String] creator_app_name Name of the app that created the ticket field, or a null value if no app created the ticket field
18
+ # @attr [Integer] creator_user_id The id of the user that created the ticket field, or a value of "-1" if an app created the ticket field
19
+ # @attr [Array] custom_field_options equired and presented for a custom ticket field of type "multiselect" or "tagger"
20
+ # @attr [Array] custom_statuses List of customized ticket statuses; only presented for a system ticket field of type "custom_status"
21
+ # @attr [String] description Describes the purpose of the ticket field to users
22
+ # @attr [Boolean] editable_in_portal Whether this field is editable by end users in Help Center
23
+ # @attr [Integer] id Automatically assigned when created
24
+ # @attr [Integer] position The relative position of the ticket field on a ticket
25
+ # @attr [String] raw_description The dynamic content placeholder if present, or the description value if not
26
+ # @attr [String] raw_title The dynamic content placeholder if present, or the title value if not
27
+ # @attr [String] raw_title_in_portal The dynamic content placeholder if present, or the "title_in_portal" value if not
28
+ # @attr [String] regexp_for_validaition For "regexp" fields only; the validation pattern for a field value to be deemed valid
29
+ # @attr [Hash] relationship_filter A filter definition that allows your autocomplete to filter down results
30
+ # @attr [String] relationship_target_type A representation of what type of object the field references; options are "zen:user", "zen:organization", "zen:ticket", or "zen:custom_object:{key}" where key is a custom object key
31
+ # @attr [Boolean] removable If false, this field is a system field that must be present on all tickets
32
+ # @attr [Boolean] required If true, agents must enter a value in the field to change the ticket status to solved
33
+ # @attr [Boolean] required_in_portal If true, end users must enter a value in the field to create the request
34
+ # @attr [Integer] sub_type_id For system ticket fields of type "priority" and "status"; defaults to 0; a "priority" sub type of 1 removes the "Low" and "Urgent" options; a "status" sub type of 1 adds the "On-Hold" option
35
+ # @attr [Array] system_field_options Presented for a system ticket field of type "tickettype", "priority" or "status"
36
+ # @attr [String] tag For "checkbox" fields only; a tag added to tickets when the checkbox field is selected
37
+ # @attr [String] title The title of the ticket field
38
+ # @attr [String] title_in_portal The title of the ticket field for end users in Help Center
39
+ # @attr [String] type System or custom field type; editable for custom field types and only on creation
40
+ # @attr [String] updated_at The time the custom ticket field was last updated
41
+ # @attr [Boolean] visibile_in_portal Whether this field is visible to end users in Help Center
42
+ class TicketFields < SupportOps::Zendesk::Base
43
+ # @!parse
44
+ # # Creates/updates a ticket field
45
+ # #
46
+ # # @author Jason Colyer
47
+ # # @since 1.0.0
48
+ # # @return [Object] Instance of {SupportOps::Zendesk::TicketFields}
49
+ # # @note This is inherited from {SupportOps::Zendesk::Base#save!}
50
+ # # @see
51
+ # # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#create-ticket-field
52
+ # # Zendesk API > Ticket Fields > Create Ticket Field
53
+ # # @see
54
+ # # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#update-ticket-field
55
+ # # Zendesk API > Ticket Fields > Update Ticket Field
56
+ # # @example
57
+ # # require 'support_ops_zendesk'
58
+ # #
59
+ # # SupportOps::Zendesk::Configuration.configure do |config|
60
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
61
+ # # config.username = 'jason@example.com'
62
+ # # config.token = 'abc123'
63
+ # # end
64
+ # #
65
+ # # new_field = SupportOps::Zendesk::TicketFields.new
66
+ # # new_field.title = 'Support description'
67
+ # # new_field.type = 'text'
68
+ # #
69
+ # # new_field.save!
70
+ # #
71
+ # # pp new_field.id
72
+ # # # => 23409462
73
+ # # @example
74
+ # # require 'support_ops_zendesk'
75
+ # #
76
+ # # SupportOps::Zendesk::Configuration.configure do |config|
77
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
78
+ # # config.username = 'jason@example.com'
79
+ # # config.token = 'abc123'
80
+ # # end
81
+ # #
82
+ # # existing_field = SupportOps::Zendesk::TicketFields.get!(23409462)
83
+ # # existing_field.title = 'Support description (text)'
84
+ # #
85
+ # # existing_field.save!
86
+ # #
87
+ # # pp existing_field.title
88
+ # # # => "Support description (text)"
89
+ # def save!; end
90
+ # @!parse
91
+ # # Deletes a ticket field
92
+ # #
93
+ # # @author Jason Colyer
94
+ # # @since 1.0.0
95
+ # # @return [Boolean]
96
+ # # @note This is inherited from {SupportOps::Zendesk::Base#delete!}
97
+ # # @see
98
+ # # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#delete-ticket-field
99
+ # # Zendesk API > Ticket Fields > Delete Ticket Field
100
+ # # @example
101
+ # # require 'support_ops_zendesk'
102
+ # #
103
+ # # SupportOps::Zendesk::Configuration.configure do |config|
104
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
105
+ # # config.username = 'jason@example.com'
106
+ # # config.token = 'abc123'
107
+ # # end
108
+ # #
109
+ # # existing_field = SupportOps::Zendesk::TicketFields.get!(23409462)
110
+ # # existing_field.delete!
111
+ # def delete!; end
112
+ # @!parse
113
+ # # Lists field options for a ticket field
114
+ # #
115
+ # # @author Jason Colyer
116
+ # # @since 1.0.0
117
+ # # @return [Boolean]
118
+ # # @note This is inherited from {SupportOps::Zendesk::Base#field_options}
119
+ # # @see
120
+ # # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#list-ticket-field-options
121
+ # # Zendesk API > Ticket Fields > List Ticket Field Options
122
+ # # @example
123
+ # # require 'support_ops_zendesk'
124
+ # #
125
+ # # SupportOps::Zendesk::Configuration.configure do |config|
126
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
127
+ # # config.username = 'jason@example.com'
128
+ # # config.token = 'abc123'
129
+ # # end
130
+ # #
131
+ # # existing_field = SupportOps::Zendesk::TicketFields.get!(23409462)
132
+ # # options = existing_field.field_options
133
+ # # pp options.count
134
+ # # # => 5
135
+ # def field_options; end
136
+ define_attributes :active, :agent_can_edit, :agent_description,
137
+ :collapsed_for_agents, :created_at, :creator_app_name,
138
+ :creator_user_id, :custom_field_options,
139
+ :custom_statuses, :description, :editable_in_portal,
140
+ :id, :position, :raw_description, :raw_title,
141
+ :raw_title_in_portal, :regexp_for_validaition,
142
+ :relationship_filter, :relationship_target_type,
143
+ :removable, :required, :required_in_portal,
144
+ :sub_type_id, :system_field_options, :tag, :title,
145
+ :title_in_portal, :type, :updated_at,
146
+ :visibile_in_portal
147
+ readonly_attributes :agent_can_edit, :created_at, :custom_statuses, :id,
148
+ :removable, :system_field_options, :updated_at
149
+
150
+ ##
151
+ # Lists ticket fields in the Zendesk system
152
+ #
153
+ # @author Jason Colyer
154
+ # @since 1.0.0
155
+ # @overload list(key: value)
156
+ # @param limit [Integer optional] The limit to the number of ticket
157
+ # fields returned. Default to 0 (i.e. no limit)
158
+ # @return [Array]
159
+ # @see
160
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#list-ticket-fields
161
+ # Zendesk API > Ticket Fields > List Ticket Fields
162
+ # @see SupportOps::Zendesk::Configuration Setting up a client
163
+ # @example
164
+ # require 'support_ops_zendesk'
165
+ #
166
+ # SupportOps::Zendesk::Configuration.configure do |config|
167
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
168
+ # config.username = 'jason@example.com'
169
+ # config.token = 'abc123'
170
+ # end
171
+ #
172
+ # fields = SupportOps::Zendesk::TicketFields.list(limit: 10)
173
+ # pp fields.count
174
+ # # => 10
175
+ # pp fields.last.title
176
+ # # => "I'm the 10th ticket field"
177
+ def self.list(**args)
178
+ args[:limit] = 0 unless args[:limit]
179
+ array = []
180
+ opts = 'page[size]=100'
181
+ loop do
182
+ response = client.connection.get("ticket_fields?#{opts}")
183
+ body = Oj.load(response.body)
184
+ array += body['ticket_fields'].map { |t| TicketFields.new(t) }
185
+ break if args[:limit].to_i.positive? && array.count >= args[:limit].to_i
186
+ break unless body['meta']['has_more']
187
+
188
+ opts = body['links']['next'].split('?').last
189
+ end
190
+ return array if args[:limit].to_i.zero?
191
+
192
+ array.first(args[:limit].to_i)
193
+ end
194
+
195
+ ##
196
+ # Returns an approximate count of ticket fields in the account. If the count exceeds 100,000, it is updated every 24 hours.
197
+ #
198
+ # @author Jason Colyer
199
+ # @since 1.0.0
200
+ # @return [Hash]
201
+ # @see
202
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#count-ticket-fields
203
+ # Zendesk API > Ticket Fields > Count Ticket Fields
204
+ # @see SupportOps::Zendesk::Configuration Setting up a client
205
+ # @example
206
+ # require 'support_ops_zendesk'
207
+ #
208
+ # SupportOps::Zendesk::Configuration.configure do |config|
209
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
210
+ # config.username = 'jason@example.com'
211
+ # config.token = 'abc123'
212
+ # end
213
+ #
214
+ # fields = SupportOps::Zendesk::TicketFields.count
215
+ # pp fields['value']
216
+ # # => 102
217
+ def self.count
218
+ response = client.connection.get('ticket_fields/count')
219
+ Oj.load(response.body)['count']
220
+ end
221
+
222
+ ##
223
+ # Locates a specific ticket field in the Zendesk system
224
+ #
225
+ # @author Jason Colyer
226
+ # @since 1.0.0
227
+ # @see
228
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#show-ticket-field
229
+ # Zendesk API > Ticket Fields > Show Ticket Field
230
+ # @see SupportOps::Zendesk::Configuration Setting up a client
231
+ # @example
232
+ # require 'support_ops_zendesk'
233
+ #
234
+ # SupportOps::Zendesk::Configuration.configure do |config|
235
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
236
+ # config.username = 'jason@example.com'
237
+ # config.token = 'abc123'
238
+ # end
239
+ #
240
+ # field = SupportOps::Zendesk::TicketFields.get(25)
241
+ # pp field.title
242
+ # # => "I'm the 25th ticket field"
243
+ def self.get(object)
244
+ if object.is_a? TicketFields
245
+ TicketFields.new(id: id).find
246
+ else
247
+ TicketFields.new(id: object).find
248
+ end
249
+ end
250
+
251
+ ##
252
+ # Locates a specific ticket field in the Zendesk system
253
+ #
254
+ # @author Jason Colyer
255
+ # @since 1.0.0
256
+ # @see
257
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#show-ticket-field
258
+ # Zendesk API > Ticket Fields > Show Ticket Field
259
+ # @see SupportOps::Zendesk::Configuration Setting up a client
260
+ # @example
261
+ # require 'support_ops_zendesk'
262
+ #
263
+ # SupportOps::Zendesk::Configuration.configure do |config|
264
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
265
+ # config.username = 'jason@example.com'
266
+ # config.token = 'abc123'
267
+ # end
268
+ #
269
+ # field = SupportOps::Zendesk::TicketFields.get!(25)
270
+ # pp field.title
271
+ # # => "I'm the 25th ticket field"
272
+ def self.get!(object)
273
+ if object.is_a? TicketFields
274
+ TicketFields.new(id: id).find!
275
+ else
276
+ TicketFields.new(id: object).find!
277
+ end
278
+ end
279
+
280
+ ##
281
+ # Reorders the ticket field positions in Zendesk. Must include all of them.
282
+ #
283
+ # @author Jason Colyer
284
+ # @since 1.0.0
285
+ # @param field_ids [Array] The IDs of user fields in the new order
286
+ # @see
287
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#reorder-ticket-fields
288
+ # Zendesk API > Ticket Fields > Reorder Ticket Field
289
+ # @see SupportOps::Zendesk::Configuration Setting up a client
290
+ # @example
291
+ # require 'support_ops_zendesk'
292
+ #
293
+ # SupportOps::Zendesk::Configuration.configure do |config|
294
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
295
+ # config.username = 'jason@example.com'
296
+ # config.token = 'abc123'
297
+ # end
298
+ #
299
+ # pp SupportOps::Zendesk::TicketFields.reorder!([25, 38, 24, 37])
300
+ # # => true
301
+ def self.reorder!(field_ids)
302
+ current_order = list.sort_by { |l| l.position }.map { |l| l.id }
303
+ raise 'You must include all ticket field IDs here' unless field_ids.count == current_order.count
304
+ raise 'You did not make any changes' if current_order == field_ids
305
+ data = { organization_field_ids: field_ids }.to_json
306
+ response = client.connection.put('ticket_fields/reorder', data)
307
+ body = Oj.load(response.body)
308
+ raise "Unable to reorder ticket fields => #{body}" if response.status != 200
309
+ true
310
+ end
311
+
312
+ private
313
+
314
+ ##
315
+ # @private
316
+ def get_record
317
+ response = self.client.connection.get("ticket_fields/#{self.id}")
318
+ return nil if response.status != 200
319
+
320
+ Oj.load(response.body)['ticket_field']
321
+ end
322
+
323
+ ##
324
+ # @private
325
+ def create_record
326
+ response = self.client.connection.post("ticket_fields", { ticket_field: attributes_for_save }.to_json)
327
+ body = Oj.load(response.body)
328
+ raise "Failed to create ticket field => #{body}" if response.status != 201
329
+ body['ticket_field']
330
+ end
331
+
332
+ ##
333
+ # @private
334
+ def update_record
335
+ raise "Failed to update user field => You didn't change anything in the object" if attributes_for_save.keys == [:id]
336
+ response = self.client.connection.put("ticket_fields/#{self.id}", { ticket_field: attributes_for_save }.to_json)
337
+ body = Oj.load(response.body)
338
+ raise "Failed to update ticket field #{self.id} => #{body}" if response.status != 200
339
+ body['ticket_field']
340
+ end
341
+
342
+ ##
343
+ # @private
344
+ def delete_record
345
+ response = self.client.connection.delete("ticket_fields/#{self.id}")
346
+ raise "Failed to delete ticket field => #{body['details']}" if response.status != 204
347
+ true
348
+ end
349
+
350
+ ##
351
+ # @private
352
+ def field_options_record
353
+ TicketFieldOptions.list(ticket_field_id: self.id)
354
+ end
355
+ end
356
+ end
357
+ end