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,114 @@
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 OAuthTokens within the module {SupportOps::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.0
12
+ # @attr [Integer] client_id The id of the client this token belongs to
13
+ # @attr [String] created_at The time the token was created
14
+ # @attr [String] expires_at The time the token will expire
15
+ # @attr [Integer] id Automatically assigned upon creation
16
+ # @attr [String] refresh_token The refresh token, if generated
17
+ # @attr [Array] scopes An array of the valid scopes for this token.
18
+ # @attr [String] token The access token
19
+ # @attr [String] used_at The latest time this token was used for authentication
20
+ # @attr [Integer] user_id The id of the user this token authenticates as
21
+ # @todo List Tokens => https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#list-tokens
22
+ # @todo Show Token => https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#show-token
23
+ class OAuthTokens < SupportOps::Zendesk::Base
24
+ # @!parse
25
+ # # Creates an OAuth Token
26
+ # #
27
+ # # @author Jason Colyer
28
+ # # @since 1.0.0
29
+ # # @return [Object] Instance of {SupportOps::Zendesk::OAuthTokens}
30
+ # # @note This is inherited from {SupportOps::Zendesk::Base#save!}
31
+ # # @see
32
+ # # https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#create-token
33
+ # # Zendesk API > OAuth Tokens > Create Token
34
+ # # @example
35
+ # # require 'support_ops_zendesk'
36
+ # #
37
+ # # SupportOps::Zendesk::Configuration.configure do |config|
38
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
39
+ # # config.username = 'jason@example.com'
40
+ # # config.token = 'abc123'
41
+ # # end
42
+ # #
43
+ # # new_token = SupportOps::Zendesk::OAuthTokens.new
44
+ # # new_token.client_id = 1234
45
+ # # new_token.scopes = [
46
+ # # 'impersonate',
47
+ # # 'write'
48
+ # # ]
49
+ # #
50
+ # # new_token.save!
51
+ # #
52
+ # # pp new_token.full_token
53
+ # # # => "JskoTAaEACYey4pix43GDTEc4QQoHictFgHP79AH8s2XznVKtXHdj8YmoRbzcNiZ"
54
+ # @!parse
55
+ # # Revokes an OAuth token
56
+ # #
57
+ # # @author Jason Colyer
58
+ # # @since 1.0.0
59
+ # # @return [Boolean]
60
+ # # @note This is inherited from {SupportOps::Zendesk::Base#delete!}
61
+ # # @see
62
+ # # https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#revoke-token
63
+ # # Zendesk API > OAuth Tokens > Revoke Token
64
+ # # @example
65
+ # # require 'support_ops_zendesk'
66
+ # #
67
+ # # SupportOps::Zendesk::Configuration.configure do |config|
68
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
69
+ # # config.username = 'jason@example.com'
70
+ # # config.token = 'abc123'
71
+ # # end
72
+ # #
73
+ # # new_token = SupportOps::Zendesk::OAuthTokens.new
74
+ # # new_token.client_id = 1234
75
+ # # new_token.scopes = [
76
+ # # 'impersonate',
77
+ # # 'write'
78
+ # # ]
79
+ # #
80
+ # # new_token.save!
81
+ # # new_token.delete!
82
+ # def delete!; end
83
+ define_attributes :client_id, :created_at, :expires_at, :id,
84
+ :refresh_token, :scopes, :token, :used_at, :user_id
85
+ readonly_attributes :client_id, :created_at, :expires_at, :id,
86
+ :refresh_token, :scopes, :token, :used_at, :user_id
87
+
88
+ private
89
+
90
+ ##
91
+ # @private
92
+ def create_record
93
+ data = {
94
+ 'token' => {
95
+ 'client_id' => self.client_id,
96
+ 'scopes' => self.scopes
97
+ }
98
+ }.to_json
99
+ response = self.client.connection.post('oauth/tokens', data)
100
+ body = Oj.load(response.body)
101
+ raise "Failed to create OAuth token => #{body}" unless [200, 201].include?(response.status)
102
+ body['token']
103
+ end
104
+
105
+ ##
106
+ # @private
107
+ def delete_record
108
+ response = self.client.connection.delete("oauth/tokens/#{self.id}")
109
+ raise "Failed to delete OAuth token => #{body}" if response.status != 204
110
+ true
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,282 @@
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 OrganizationFields within the module {SupportOps::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.0
12
+ # @attr [Boolean] active If true, this field is available for use
13
+ # @attr [String] created_at The time of the last update of the ticket field
14
+ # @attr [Array] custom_field_options Required and presented for a custom field of type "dropdown", each option is represented by an object with a name and value property
15
+ # @attr [String] description User-defined description of this field's purpose
16
+ # @attr [Integer] id Automatically assigned upon creation
17
+ # @attr [String] key A unique key that identifies this custom field; this is used for updating the field and referencing in placeholders; the key must consist of only letters, numbers, and underscores; it can't be only numbers
18
+ # @attr [Integer] position Ordering of the field relative to other fields
19
+ # @attr [String] raw_description The dynamic content placeholder, if present, or the description value, if not
20
+ # @attr [String] raw_title The dynamic content placeholder, if present, or the title value, if not
21
+ # @attr [String] regexp_for_validation The validation pattern for a field value to be deemed valid
22
+ # @attr [Hash] relationship_filter A filter definition that allows your autocomplete to filter down results
23
+ # @attr [String] relationship_target_type A representation of what type of object the field references; options are "zen:user", "zen:organization", "zen:ticket", and "zen:custom_object:{key}" where key is a custom object key (for example "zen:custom_object:apartment")
24
+ # @attr [Boolean] system If true, only active and position values of this field can be changed
25
+ # @attr [String] tag Optional for custom field of type "checkbox"; not presented otherwise
26
+ # @attr [String] title The title of the custom field
27
+ # @attr [String] type The custom field type: "checkbox", "date", "decimal", "dropdown", "integer", "lookup", "multiselect", "regexp", "text", or "textarea"
28
+ # @attr [String] updated_at The time of the last update of the ticket field
29
+ class OrganizationFields < SupportOps::Zendesk::Base
30
+ # @!parse
31
+ # # Creates/updates an organization field
32
+ # #
33
+ # # @author Jason Colyer
34
+ # # @since 1.0.0
35
+ # # @return [Object] Instance of {SupportOps::Zendesk::OrganizationFields}
36
+ # # @note This is inherited from {SupportOps::Zendesk::Base#save!}
37
+ # # @see
38
+ # # https://developer.zendesk.com/api-reference/ticketing/organizations/organization_fields/#create-organization-field
39
+ # # Zendesk API > Organization Fields > Create Organization Field
40
+ # # @see
41
+ # # https://developer.zendesk.com/api-reference/ticketing/organizations/organization_fields/#update-organization-field
42
+ # # Zendesk API > Organization Fields > Update Organization Field
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
+ # # new_field = SupportOps::Zendesk::OrganizationFields.new
53
+ # # new_field.title = 'Support description'
54
+ # # new_field.type = 'text'
55
+ # # new_field.description = 'This field describes the support plan this organization has'
56
+ # # new_field.key = 'support_description'
57
+ # #
58
+ # # new_field.save!
59
+ # #
60
+ # # pp new_field.id
61
+ # # # => 23409462
62
+ # # @example
63
+ # # require 'support_ops_zendesk'
64
+ # #
65
+ # # SupportOps::Zendesk::Configuration.configure do |config|
66
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
67
+ # # config.username = 'jason@example.com'
68
+ # # config.token = 'abc123'
69
+ # # end
70
+ # #
71
+ # # existing_field = SupportOps::Zendesk::OrganizationFields.get!(23409462)
72
+ # # existing_field.title = 'Support description (text)'
73
+ # #
74
+ # # existing_field.save!
75
+ # #
76
+ # # pp existing_field.title
77
+ # # # => "Support description (text)"
78
+ # def save!; end
79
+ # @!parse
80
+ # # Deletes an organization field
81
+ # #
82
+ # # @author Jason Colyer
83
+ # # @since 1.0.0
84
+ # # @return [Boolean]
85
+ # # @note This is inherited from {SupportOps::Zendesk::Base#delete!}
86
+ # # @see
87
+ # # https://developer.zendesk.com/api-reference/ticketing/organizations/organization_fields/#delete-organization-field
88
+ # # Zendesk API > Organization Fields > Update Organization Field
89
+ # # @example
90
+ # # require 'support_ops_zendesk'
91
+ # #
92
+ # # SupportOps::Zendesk::Configuration.configure do |config|
93
+ # # config.url = 'https://gitlab.zendesk.com/api/v2'
94
+ # # config.username = 'jason@example.com'
95
+ # # config.token = 'abc123'
96
+ # # end
97
+ # #
98
+ # # existing_field = SupportOps::Zendesk::OrganizationFields.get!(23409462)
99
+ # # existing_field.delete!
100
+ # def delete!; end
101
+ define_attributes :active, :created_at, :custom_field_options,
102
+ :description, :id, :key, :position, :raw_description,
103
+ :raw_title, :regexp_for_validation,
104
+ :relationship_filter, :relationship_target_type,
105
+ :system, :tag, :title, :type, :updated_at
106
+ readonly_attributes :created_at, :id, :system, :updated_at
107
+
108
+ ##
109
+ # Lists organization fields in the Zendesk system
110
+ #
111
+ # @author Jason Colyer
112
+ # @since 1.0.0
113
+ # @overload list(key: value)
114
+ # @param limit [Integer optional] The limit to the number of
115
+ # organization fields returned. Default to 0 (i.e. no limit)
116
+ # @return [Array]
117
+ # @see
118
+ # https://developer.zendesk.com/api-reference/ticketing/organizations/organization_fields/#list-organization-fields
119
+ # Zendesk API > Organization Fields > List Organization Fields
120
+ # @see SupportOps::Zendesk::Configuration Setting up a client
121
+ # @example
122
+ # require 'support_ops_zendesk'
123
+ #
124
+ # SupportOps::Zendesk::Configuration.configure do |config|
125
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
126
+ # config.username = 'jason@example.com'
127
+ # config.token = 'abc123'
128
+ # end
129
+ #
130
+ # fields = SupportOps::Zendesk::OrganizationFields.list(limit: 10)
131
+ # pp fields.count
132
+ # # => 10
133
+ # pp fields.last.title
134
+ # # => "I'm the 10th organization field"
135
+ def self.list(**args)
136
+ args[:limit] = 0 unless args[:limit]
137
+ array = []
138
+ opts = 'page[size]=100'
139
+ loop do
140
+ response = client.connection.get("organization_fields?#{opts}")
141
+ body = Oj.load(response.body)
142
+ array += body['organization_fields'].map { |o| OrganizationFields.new(o) }
143
+ break if args[:limit].to_i.positive? && array.count >= args[:limit].to_i
144
+ break unless body['meta']['has_more']
145
+
146
+ opts = body['links']['next'].split('?').last
147
+ end
148
+ return array if args[:limit].to_i.zero?
149
+
150
+ array.first(args[:limit].to_i)
151
+ end
152
+
153
+ ##
154
+ # Locates a specific organization field in the Zendesk system
155
+ #
156
+ # @author Jason Colyer
157
+ # @since 1.0.0
158
+ # @see
159
+ # https://developer.zendesk.com/api-reference/ticketing/organizations/organization_fields/#show-organization-field
160
+ # Zendesk API > Organization Field > Show Organization Field
161
+ # @see SupportOps::Zendesk::Configuration Setting up a client
162
+ # @example
163
+ # require 'support_ops_zendesk'
164
+ #
165
+ # SupportOps::Zendesk::Configuration.configure do |config|
166
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
167
+ # config.username = 'jason@example.com'
168
+ # config.token = 'abc123'
169
+ # end
170
+ #
171
+ # field = SupportOps::Zendesk::OrganizationFields.get(25)
172
+ # pp field.title
173
+ # # => "I'm the 25th organization field"
174
+ def self.get(object)
175
+ if object.is_a? OrganizationFields
176
+ OrganizationFields.new(id: id).find
177
+ else
178
+ OrganizationFields.new(id: object).find
179
+ end
180
+ end
181
+
182
+ ##
183
+ # Locates a specific organization field in the Zendesk system
184
+ #
185
+ # @author Jason Colyer
186
+ # @since 1.0.0
187
+ # @see
188
+ # https://developer.zendesk.com/api-reference/ticketing/organizations/organization_fields/#show-organization-field
189
+ # Zendesk API > Organization Field > Show Organization Field
190
+ # @see SupportOps::Zendesk::Configuration Setting up a client
191
+ # @example
192
+ # require 'support_ops_zendesk'
193
+ #
194
+ # SupportOps::Zendesk::Configuration.configure do |config|
195
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
196
+ # config.username = 'jason@example.com'
197
+ # config.token = 'abc123'
198
+ # end
199
+ #
200
+ # field = SupportOps::Zendesk::OrganizationFields.get!(25)
201
+ # pp field.title
202
+ # # => "I'm the 25th organization field"
203
+ def self.get!(object)
204
+ if object.is_a? OrganizationFields
205
+ OrganizationFields.new(id: id).find!
206
+ else
207
+ OrganizationFields.new(id: object).find!
208
+ end
209
+ end
210
+
211
+ ##
212
+ # Reorders the organization field positions in Zendesk. Must include all of them.
213
+ #
214
+ # @author Jason Colyer
215
+ # @since 1.0.0
216
+ # @param field_ids [Array] The IDs of organization fields in the new order
217
+ # @see
218
+ # https://developer.zendesk.com/api-reference/ticketing/organizations/organization_fields/#reorder-organization-field
219
+ # Zendesk API > Organization Fields > Reorder Organization Field
220
+ # @see SupportOps::Zendesk::Configuration Setting up a client
221
+ # @example
222
+ # require 'support_ops_zendesk'
223
+ #
224
+ # SupportOps::Zendesk::Configuration.configure do |config|
225
+ # config.url = 'https://gitlab.zendesk.com/api/v2'
226
+ # config.username = 'jason@example.com'
227
+ # config.token = 'abc123'
228
+ # end
229
+ #
230
+ # pp SupportOps::Zendesk::OrganizationFields.reorder!([25, 38, 24, 37])
231
+ # # => true
232
+ def self.reorder!(field_ids)
233
+ current_order = list.sort_by { |l| l.position }.map { |l| l.id }
234
+ raise 'You must include all organization field IDs here' unless field_ids.count == current_order.count
235
+ raise 'You did not make any changes' if current_order == field_ids
236
+ data = { organization_field_ids: field_ids }.to_json
237
+ response = client.connection.put('organization_fields/reorder', data)
238
+ body = Oj.load(response.body)
239
+ raise "Unable to reorder organization fields => #{body}" if response.status != 200
240
+ true
241
+ end
242
+
243
+ private
244
+
245
+ ##
246
+ # @private
247
+ def get_record
248
+ response = self.client.connection.get("organization_fields/#{self.id}")
249
+ return nil if response.status != 200
250
+
251
+ Oj.load(response.body)['organization_field']
252
+ end
253
+
254
+ ##
255
+ # @private
256
+ def create_record
257
+ response = self.client.connection.post("organization_fields", { organization_field: attributes_for_save }.to_json)
258
+ body = Oj.load(response.body)
259
+ raise "Failed to create organization field => #{body['details']}" if response.status != 201
260
+ body['organization_field']
261
+ end
262
+
263
+ ##
264
+ # @private
265
+ def update_record
266
+ raise "Failed to update automation => You didn't change anything in the object" if attributes_for_save.keys == [:id]
267
+ response = self.client.connection.put("organization_fields/#{self.id}", { organization_field: attributes_for_save }.to_json)
268
+ body = Oj.load(response.body)
269
+ raise "Failed to update organization field #{self.id} => #{body['details']}" if response.status != 200
270
+ body['organization_field']
271
+ end
272
+
273
+ ##
274
+ # @private
275
+ def delete_record
276
+ response = self.client.connection.delete("organization_fields/#{self.id}")
277
+ raise "Failed to delete organization field => #{body['details']}" if response.status != 204
278
+ true
279
+ end
280
+ end
281
+ end
282
+ end