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,370 @@
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 TicketForms within the module {SupportOps::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.0
12
+ # @attr [Boolean] active If the form is set as active
13
+ # @attr [Array] agent_conditions Array of condition sets for agent workspaces
14
+ # @attr [String] created_at The time the ticket form was created
15
+ # @attr [Boolean] default Is the form the default form for this account
16
+ # @attr [String] display_name The name of the form that is displayed to an end user
17
+ # @attr [Array] end_user_conditions Array of condition sets for end user products
18
+ # @attr [Boolean] end_user_visible Is the form visible to the end user
19
+ # @attr [Integer] id Automatically assigned when creating ticket form
20
+ # @attr [Boolean] in_all_brands Is the form available for use in all brands on this account
21
+ # @attr [String] name The name of the form
22
+ # @attr [Integer] position The position of this form among other forms in the account, i.e. dropdown
23
+ # @attr [String] raw_display_name The dynamic content placeholder, if present, or the "display_name" value, if not.
24
+ # @attr [String] raw_name The dynamic content placeholder, if present, or the "name" value, if not
25
+ # @attr [Array] restricted_brand_ids ids of all brands that this ticket form is restricted to
26
+ # @attr [Array] ticket_field_ids ids of all ticket fields which are in this ticket form; the products use the order of the ids to show the field values in the tickets
27
+ # @attr [String] updated_at The time of the last update of the ticket form
28
+ # @todo List Ticket Form Statuses of a Ticket Form => https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#list-ticket-form-statuses-of-a-ticket-form
29
+ # @todo Create Ticket Form Statuses => https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#create-ticket-form-statuses
30
+ # @todo Bulk Update Ticket Form Statuses of a Ticket Form => https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#bulk-update-ticket-form-statuses-of-a-ticket-form
31
+ # @todo Update Ticket Form Status By Id => https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#update-ticket-form-status-by-id
32
+ class TicketForms < SupportOps::Zendesk::Base
33
+ # @!parse
34
+ # # Creates/updates a ticket form. Update will update the conditions first if changed to prevent collision update issues.
35
+ # #
36
+ # # @author Jason Colyer
37
+ # # @since 1.0.0
38
+ # # @return [Object] Instance of {SupportOps::Zendesk::TicketForms}
39
+ # # @note This is inherited from {SupportOps::Zendesk::Base#save!}
40
+ # # @see
41
+ # # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#create-ticket-form
42
+ # # Zendesk API > Ticket Forms > Create Ticket Form
43
+ # # @see
44
+ # # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#update-ticket-form
45
+ # # Zendesk API > Ticket Forms > Update Ticket Form
46
+ # # @example
47
+ # # require 'support_ops_zendesk'
48
+ # #
49
+ # # SupportOps::Zendesk::Configuration.configure do |config|
50
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
51
+ # # config.username = 'jason@example.com'
52
+ # # config.token = 'abc123'
53
+ # # end
54
+ # #
55
+ # # new_form = SupportOps::Zendesk::TicketForms.new
56
+ # # new_form.name = 'Printer Issues'
57
+ # # new_form.end_user_visible = false
58
+ # # new_form.display_name = 'Printer Issues'
59
+ # # new_form.position = 28
60
+ # # new_form.active = true
61
+ # # new_form.in_all_brands = true
62
+ # # new_form.restricted_brand_ids = []
63
+ # # new_form.ticket_field_ids = [1, 4, 8, 26]
64
+ # # new_form.agent_conditions = []
65
+ # # new_form.end_user_conditions = []
66
+ # # new_form.default = false
67
+ # #
68
+ # # new_form.save!
69
+ # #
70
+ # # pp new_form.id
71
+ # # # => 35436
72
+ # # @example
73
+ # # require 'support_ops_zendesk'
74
+ # #
75
+ # # SupportOps::Zendesk::Configuration.configure do |config|
76
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
77
+ # # config.username = 'jason@example.com'
78
+ # # config.token = 'abc123'
79
+ # # end
80
+ # #
81
+ # # existing_form = SupportOps::Zendesk::TicketForms.get!(35436)
82
+ # # existing_form.name = 'Printer/Scanner Issues'
83
+ # #
84
+ # # existing_form.save!
85
+ # #
86
+ # # pp existing_form.name
87
+ # # # => "Printer/Scanner Issues"
88
+ # def save!; end
89
+ # @!parse
90
+ # # Deletes a ticket form
91
+ # #
92
+ # # @author Jason Colyer
93
+ # # @since 1.0.0
94
+ # # @return [Boolean]
95
+ # # @note This is inherited from {SupportOps::Zendesk::Base#delete!}
96
+ # # @see
97
+ # # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#delete-ticket-form
98
+ # # Zendesk API > Ticket Forms > Delete Ticket Form
99
+ # # @example
100
+ # # require 'support_ops_zendesk'
101
+ # #
102
+ # # SupportOps::Zendesk::Configuration.configure do |config|
103
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
104
+ # # config.username = 'jason@example.com'
105
+ # # config.token = 'abc123'
106
+ # # end
107
+ # #
108
+ # # existing_form = SupportOps::Zendesk::TicketForms.get!(35436)
109
+ # #
110
+ # # existing_form.delete!
111
+ # def delete!; end
112
+ # @!parse
113
+ # # Clones a ticket form
114
+ # #
115
+ # # @author Jason Colyer
116
+ # # @since 1.0.0
117
+ # # @return [Boolean]
118
+ # # @note This is inherited from {SupportOps::Zendesk::Base#clone!}
119
+ # # @see
120
+ # # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#clone-an-already-existing-ticket-form
121
+ # # Zendesk API > Ticket Forms > Clone an Already Existing Ticket Form
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_form = SupportOps::Zendesk::TicketForms.get!(35436)
132
+ # #
133
+ # # cloned_form = existing_form.clone!
134
+ # # pp cloned_form.name
135
+ # # # => "Copy of Printer/Scanner Issues"
136
+ # def clone!; end
137
+ define_attributes :active, :agent_conditions, :created_at, :default,
138
+ :display_name, :end_user_conditions, :end_user_visible,
139
+ :id, :in_all_brands, :name, :position,
140
+ :raw_display_name, :raw_name, :restricted_brand_ids,
141
+ :ticket_field_ids, :updated_at
142
+ readonly_attributes :created_at, :id, :updated_at
143
+
144
+ ##
145
+ # Lists ticket forms in the Zendesk system
146
+ #
147
+ # @author Jason Colyer
148
+ # @since 1.0.0
149
+ # @overload list(key: value)
150
+ # @param active [Boolean optional] true returns active ticket forms;
151
+ # false returns inactive ticket forms
152
+ # @param associated_to_brand [Boolean optional] true returns the ticket
153
+ # forms of the brand specified by the url's subdomain
154
+ # @param end_user_visible [Boolean optional] true returns ticket forms
155
+ # where end_user_visible; false returns ticket forms that are not
156
+ # end-user visible
157
+ # @param fallback_to_default [Boolean optional] true returns the default
158
+ # ticket form when the criteria defined by the parameters results in a
159
+ # set without active and end-user visible ticket forms
160
+ # @return [Array]
161
+ # @see
162
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#list-ticket-forms
163
+ # Zendesk API > Ticket Forms > List Ticket Forms
164
+ # @see SupportOps::Zendesk::Configuration Setting up a client
165
+ # @example
166
+ # require 'support_ops_zendesk'
167
+ #
168
+ # SupportOps::Zendesk::Configuration.configure do |config|
169
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
170
+ # config.username = 'jason@example.com'
171
+ # config.token = 'abc123'
172
+ # end
173
+ #
174
+ # forms = SupportOps::Zendesk::TicketFormss.list(active: true)
175
+ # pp forms.count
176
+ # # => 18
177
+ # pp forms.last.name
178
+ # # => "Printer Issues"
179
+ def self.list(**args)
180
+ args[:limit] = 0 unless args[:limit]
181
+ opts = ''
182
+ opts += "&active=#{args[:active]}" unless args[:active].nil?
183
+ opts += "&associated_to_brand=#{args[:associated_to_brand]}" unless args[:associated_to_brand].nil?
184
+ opts += "&end_user_visible=#{args[:end_user_visible]}" unless args[:end_user_visible].nil?
185
+ opts += "&fallback_to_default=#{args[:fallback_to_default]}" unless args[:fallback_to_default].nil?
186
+ response = client.connection.get("ticket_forms?#{opts}")
187
+ body = Oj.load(response.body)
188
+ body['ticket_forms'].map { |t| TicketForms.new(t) }
189
+ end
190
+
191
+ ##
192
+ # Locates a specific ticket form in the Zendesk system
193
+ #
194
+ # @author Jason Colyer
195
+ # @since 1.0.0
196
+ # @see
197
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#show-ticket-form
198
+ # Zendesk API > Ticket Forms > Show Ticket Form
199
+ # @see SupportOps::Zendesk::Configuration Setting up a client
200
+ # @example
201
+ # require 'support_ops_zendesk'
202
+ #
203
+ # SupportOps::Zendesk::Configuration.configure do |config|
204
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
205
+ # config.username = 'jason@example.com'
206
+ # config.token = 'abc123'
207
+ # end
208
+ #
209
+ # form = SupportOps::Zendesk::TicketForms.get(250)
210
+ # pp form.name
211
+ # # => "I'm the 250th ticket form!"
212
+ def self.get(object)
213
+ if object.is_a? TicketForms
214
+ TicketForms.new(id: id).find
215
+ else
216
+ TicketForms.new(id: object).find
217
+ end
218
+ end
219
+
220
+ ##
221
+ ##
222
+ # Locates a specific ticket form in the Zendesk system
223
+ #
224
+ # @author Jason Colyer
225
+ # @since 1.0.0
226
+ # @see
227
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#show-ticket-form
228
+ # Zendesk API > Ticket Forms > Show Ticket Form
229
+ # @see SupportOps::Zendesk::Configuration Setting up a client
230
+ # @example
231
+ # require 'support_ops_zendesk'
232
+ #
233
+ # SupportOps::Zendesk::Configuration.configure do |config|
234
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
235
+ # config.username = 'jason@example.com'
236
+ # config.token = 'abc123'
237
+ # end
238
+ #
239
+ # form = SupportOps::Zendesk::TicketForms.get!(250)
240
+ # pp form.name
241
+ # # => "I'm the 250th ticket form!"
242
+ def self.get!(object)
243
+ if object.is_a? TicketForms
244
+ TicketForms.new(id: id).find!
245
+ else
246
+ TicketForms.new(id: object).find!
247
+ end
248
+ end
249
+
250
+ ##
251
+ # Locates up to 100 ticket forms within Zendesk.
252
+ #
253
+ # @author Jason Colyer
254
+ # @since 1.0.0
255
+ # @param ticket_form_ids [Array] The ticket IDs to find
256
+ # @return [Array]
257
+ # @see
258
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#show-many-ticket-forms
259
+ # Zendesk API > Ticket Forms > Show Many Ticket Forms
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
+ # forms = SupportOps::Zendesk::TicketForms.get_many([255, 256])
270
+ # pp forms.map { |t| t.name }
271
+ # # => ["Camera Issues", "Keyboard Issues"]
272
+ def self.get_many(ticket_form_ids)
273
+ raise 'The parameter must be an Array' unless ticket_form_ids.is_a? Array
274
+ raise 'You can only get a maximum of 100 ticket forms at a time' if ticket_form_ids.count > 100
275
+
276
+ response = client.connection.get("ticket_forms/show_many?ids=#{ticket_form_ids.join(',')}")
277
+ Oj.load(response.body)['ticket_forms'].map { |t| TicketForms.new(t) }
278
+ end
279
+
280
+ ##
281
+ # Reorders the ticket form positions in Zendesk. Must include all of them.
282
+ #
283
+ # @author Jason Colyer
284
+ # @since 1.0.0
285
+ # @param ticket_form_ids [Array] The IDs of ticket forms in the new order
286
+ # @see
287
+ # https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#reorder-ticket-forms
288
+ # Zendesk API > Ticket Forms > Reorder Ticket Forms
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::TicketForms.reorder!([25, 38, 24, 37])
300
+ # # => true
301
+ def self.reorder!(ticket_form_ids)
302
+ current_order = list.sort_by { |l| l.position }.map { |l| l.id }
303
+ raise 'You must include all ticket form IDs here' unless ticket_form_ids.count == current_order.count
304
+ raise 'You did not make any changes' if current_order == ticket_form_ids
305
+ data = { ticket_form_ids: ticket_form_ids }.to_json
306
+ response = client.connection.put('ticket_forms/reorder', data)
307
+ body = Oj.load(response.body)
308
+ raise "Unable to reorder ticket forms => #{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_forms/#{self.id}")
318
+ return nil if response.status != 200
319
+
320
+ Oj.load(response.body)['ticket_form']
321
+ end
322
+
323
+ ##
324
+ # @private
325
+ def create_record
326
+ response = self.client.connection.post("ticket_forms", { ticket_form: attributes_for_save }.to_json)
327
+ body = Oj.load(response.body)
328
+ raise "Failed to create ticket form => #{body['details']}" if response.status != 201
329
+ body['ticket_form']
330
+ end
331
+
332
+ ##
333
+ # @private
334
+ def update_record
335
+ raise "Failed to update ticket form => You didn't change anything in the object" if attributes_for_save.keys == [:id]
336
+ save_data = attributes_for_save
337
+ if save_data[:agent_conditions] || save_data[:end_user_conditions]
338
+ data_for_conditions_update = {
339
+ id: save_data[:id]
340
+ }
341
+ data_for_conditions_update[:agent_conditions] = save_data.delete(:agent_conditions)
342
+ data_for_conditions_update[:end_user_conditions] = save_data.delete(:end_user_conditions)
343
+ response = self.client.connection.put("ticket_forms/#{self.id}", { ticket_form: data_for_conditions_update }.to_json)
344
+ raise "Failed to update ticket form #{self.id} => #{body['details']}" if response.status != 200
345
+ end
346
+ response = self.client.connection.put("ticket_forms/#{self.id}", { ticket_form: save_data }.to_json)
347
+ body = Oj.load(response.body)
348
+ raise "Failed to update ticket form #{self.id} => #{body['details']}" if response.status != 200
349
+ body['ticket_form']
350
+ end
351
+
352
+ ##
353
+ # @private
354
+ def delete_record
355
+ response = self.client.connection.delete("ticket_forms/#{self.id}")
356
+ raise "Failed to delete ticket form #{self.id} => #{body['details']}" if response.status != 204
357
+ true
358
+ end
359
+
360
+ ##
361
+ # @private
362
+ def clone_record
363
+ data = { prepend_clone_title: true }.to_json
364
+ response = self.client.connection.post("ticket_forms/#{self.id}/clone", data)
365
+ raise "Failed to clone ticket form #{self.id} => #{body['details']}" if response.status != 200
366
+ TicketForms.new(Oj.load(response.body)['ticket_form'])
367
+ end
368
+ end
369
+ end
370
+ end
@@ -0,0 +1,67 @@
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 TicketUserTypes within the module {SupportOps::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.0
12
+ # @attr [Integer] id An auto-generated id
13
+ # @attr [String] name Theh name of the via type
14
+ class TicketUserTypes < SupportOps::Zendesk::Base
15
+ define_attributes :id, :name
16
+ readonly_attributes :id, :name
17
+
18
+ ##
19
+ # Lists via types
20
+ #
21
+ # @author Jason Colyer
22
+ # @since 1.0.0
23
+ # @return [Array]
24
+ # @example
25
+ # require 'support_ops_zendesk'
26
+ # types = SupportOps::Zendesk::ViaTypes.list
27
+ # pp types.first.name
28
+ # # => "Web form"
29
+ def self.list
30
+ [
31
+ { 'id' => 'agent', 'name' => 'Agent' },
32
+ { 'id' => 'end_user', 'name' => 'End User' }
33
+ ].map { |v| TicketUserTypes.new(v) }
34
+ end
35
+
36
+ ##
37
+ # Locates a ticket user type within Zendesk by name
38
+ #
39
+ # @author Jason Colyer
40
+ # @since 1.0.0
41
+ # @param name [String] The via type name to look for
42
+ # @return [Object] An instance of {SupportOps::Zendesk::ViaTypes}
43
+ # @example
44
+ # require 'support_ops_zendesk'
45
+ #
46
+ # SupportOps::Zendesk::Configuration.configure do |config|
47
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
48
+ # config.username = 'jason@example.com'
49
+ # config.token = 'abc123'
50
+ # end
51
+ #
52
+ # type = SupportOps::Zendesk::TicketUserTypes.find_by_name('End User')
53
+ # pp type.id
54
+ # # => "end_user"
55
+ def self.find_by_name(name)
56
+ type = TicketUserTypes.list.detect { |r| r.name.downcase == name.downcase }
57
+ if type.nil?
58
+ search = Search.users(query: "email:#{name}")
59
+ if search.count == 1
60
+ type = TicketUserTypes.new({ 'id' => search.first.id, 'name' => search.first.email })
61
+ end
62
+ end
63
+ type
64
+ end
65
+ end
66
+ end
67
+ end