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.
- checksums.yaml +7 -0
- data/lib/support_ops_zendesk/packages.rb +89 -0
- data/lib/support_ops_zendesk/zendesk/app_installations.rb +62 -0
- data/lib/support_ops_zendesk/zendesk/app_job_statuses.rb +157 -0
- data/lib/support_ops_zendesk/zendesk/apps.rb +476 -0
- data/lib/support_ops_zendesk/zendesk/articles.rb +362 -0
- data/lib/support_ops_zendesk/zendesk/audit_logs.rb +166 -0
- data/lib/support_ops_zendesk/zendesk/automations.rb +390 -0
- data/lib/support_ops_zendesk/zendesk/base.rb +472 -0
- data/lib/support_ops_zendesk/zendesk/brands.rb +172 -0
- data/lib/support_ops_zendesk/zendesk/client.rb +91 -0
- data/lib/support_ops_zendesk/zendesk/comments.rb +37 -0
- data/lib/support_ops_zendesk/zendesk/configuration.rb +138 -0
- data/lib/support_ops_zendesk/zendesk/custom_roles.rb +224 -0
- data/lib/support_ops_zendesk/zendesk/dynamic_content.rb +297 -0
- data/lib/support_ops_zendesk/zendesk/dynamic_content_variants.rb +309 -0
- data/lib/support_ops_zendesk/zendesk/group_memberships.rb +337 -0
- data/lib/support_ops_zendesk/zendesk/groups.rb +385 -0
- data/lib/support_ops_zendesk/zendesk/help_center_categories.rb +332 -0
- data/lib/support_ops_zendesk/zendesk/help_center_content_tags.rb +237 -0
- data/lib/support_ops_zendesk/zendesk/help_center_management_permission_groups.rb +271 -0
- data/lib/support_ops_zendesk/zendesk/help_center_sections.rb +378 -0
- data/lib/support_ops_zendesk/zendesk/help_center_topics.rb +274 -0
- data/lib/support_ops_zendesk/zendesk/help_center_user_segments.rb +279 -0
- data/lib/support_ops_zendesk/zendesk/job_statuses.rb +231 -0
- data/lib/support_ops_zendesk/zendesk/locales.rb +326 -0
- data/lib/support_ops_zendesk/zendesk/macros.rb +407 -0
- data/lib/support_ops_zendesk/zendesk/oauth_clients.rb +186 -0
- data/lib/support_ops_zendesk/zendesk/oauth_tokens.rb +114 -0
- data/lib/support_ops_zendesk/zendesk/organization_fields.rb +282 -0
- data/lib/support_ops_zendesk/zendesk/organization_memberships.rb +336 -0
- data/lib/support_ops_zendesk/zendesk/organizations.rb +568 -0
- data/lib/support_ops_zendesk/zendesk/requester_roles.rb +58 -0
- data/lib/support_ops_zendesk/zendesk/satisfaction_reasons.rb +161 -0
- data/lib/support_ops_zendesk/zendesk/schedule_holidays.rb +27 -0
- data/lib/support_ops_zendesk/zendesk/schedules.rb +192 -0
- data/lib/support_ops_zendesk/zendesk/search.rb +185 -0
- data/lib/support_ops_zendesk/zendesk/sla_policies.rb +302 -0
- data/lib/support_ops_zendesk/zendesk/targets.rb +96 -0
- data/lib/support_ops_zendesk/zendesk/theme_job_statuses.rb +154 -0
- data/lib/support_ops_zendesk/zendesk/themes.rb +328 -0
- data/lib/support_ops_zendesk/zendesk/ticket_field_options.rb +154 -0
- data/lib/support_ops_zendesk/zendesk/ticket_fields.rb +357 -0
- data/lib/support_ops_zendesk/zendesk/ticket_forms.rb +370 -0
- data/lib/support_ops_zendesk/zendesk/ticket_user_types.rb +67 -0
- data/lib/support_ops_zendesk/zendesk/tickets.rb +837 -0
- data/lib/support_ops_zendesk/zendesk/translations.rb +310 -0
- data/lib/support_ops_zendesk/zendesk/trigger_categories.rb +275 -0
- data/lib/support_ops_zendesk/zendesk/triggers.rb +427 -0
- data/lib/support_ops_zendesk/zendesk/user_field_options.rb +153 -0
- data/lib/support_ops_zendesk/zendesk/user_fields.rb +312 -0
- data/lib/support_ops_zendesk/zendesk/users.rb +889 -0
- data/lib/support_ops_zendesk/zendesk/via_types.rb +137 -0
- data/lib/support_ops_zendesk/zendesk/views.rb +636 -0
- data/lib/support_ops_zendesk/zendesk/webhooks.rb +206 -0
- data/lib/support_ops_zendesk/zendesk.rb +66 -0
- data/lib/support_ops_zendesk.rb +29 -0
- metadata +274 -0
@@ -0,0 +1,476 @@
|
|
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 Apps within the module {SupportOps::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.0
|
12
|
+
# @attr [Object] app_organization Organization that submitted the app to the Zendesk Marketplace
|
13
|
+
# @attr [String] author_email The app author's email
|
14
|
+
# @attr [String] author_name The app author's name
|
15
|
+
# @attr [String] author_url The app author's URL
|
16
|
+
# @attr [Array] categories Zendesk Marketplace categories to which the app belongs
|
17
|
+
# @attr [Array] collections Zendesk Marketplace collections to which the app belongs
|
18
|
+
# @attr [String] created_at When the app was created
|
19
|
+
# @attr [String] date_published When the app was published on the Zendesk Marketplace
|
20
|
+
# @attr [String] default_locale The default locale for translations for the app
|
21
|
+
# @attr [Boolean] deprecated If true, the app is deprecated
|
22
|
+
# @attr [String] feature_color Hexadecimal color value used to feature the app on the Zendesk Marketplace
|
23
|
+
# @attr [Boolean] featured Whether or not the app is featured in the Zendesk Marketplace
|
24
|
+
# @attr [String] framework_version The app framework version for which the app was written
|
25
|
+
# @attr [String] google_analytics_code Universal Google Analytics ("UA-") tracking id for the app's detail page on the Zendesk Marketplace
|
26
|
+
# @attr [Integer] id The id of the app
|
27
|
+
# @attr [Boolean] installable Whether or not the app can be installed
|
28
|
+
# @attr [Integer] installation_count Current number of installations of the app
|
29
|
+
# @attr [String] installation_instructions Instructions for installing the app
|
30
|
+
# @attr [String] large_icon The large icon url for an app
|
31
|
+
# @attr [Array] locations Location ids for the app
|
32
|
+
# @attr [String] long_description The app's long description in the Zendesk Marketplace
|
33
|
+
# @attr [Boolean] marketing_only If true, the app is an integration app
|
34
|
+
# @attr [String] name The name of the app
|
35
|
+
# @attr [Boolean] obsolete If true, the app is obsolete
|
36
|
+
# @attr [Integer] owner_id The app developer id corresponding to the app
|
37
|
+
# @attr [Boolean] paid If true, the app is a paid app
|
38
|
+
# @attr [Array] parameters The parameters for the app
|
39
|
+
# @attr [Array] plans Payment plans for the app
|
40
|
+
# @attr [Array] products Zendesk products supported by the app
|
41
|
+
# @attr [Boolean] promoted Whether or not the app is a promoted app in the Zendesk Marketplace
|
42
|
+
# @attr [Object] rating The ratings of the app
|
43
|
+
# @attr [String] raw_installation_instructions The raw installation instructions
|
44
|
+
# @attr [String] raw_long_description The raw long description for the app in the Zendesk Marketplace
|
45
|
+
# @attr [String] remote_installation_url URL for the app's installation instructions
|
46
|
+
# @attr [Array] screenshots Screenshots for the app when displayed in the Zendesk Marketplace
|
47
|
+
# @attr [String] short_description The short description of the app in the Zendesk Marketplace
|
48
|
+
# @attr [Boolean] single_install Whether or not this app can only be installed once
|
49
|
+
# @attr [String] small_icon The url for the small logo for the app
|
50
|
+
# @attr [String] state Publication state for the app on the Zendesk Marketplace
|
51
|
+
# @attr [String] stripe_publishable_key Publishable key for the app developer's Stripe account
|
52
|
+
# @attr [String] terms_conditions_url URL for the app's terms and conditions
|
53
|
+
# @attr [Object] third_party_pricing Third-party pricing information for the app
|
54
|
+
# @attr [String] updated_at When the app was last updated
|
55
|
+
# @attr [String] version The version of the app
|
56
|
+
# @attr [String] visibility The app is a private app, which is only visible to your account, or a public app
|
57
|
+
class Apps < SupportOps::Zendesk::Base
|
58
|
+
# @!parse
|
59
|
+
# # Creates/updates an app
|
60
|
+
# #
|
61
|
+
# # @author Jason Colyer
|
62
|
+
# # @since 1.0.0
|
63
|
+
# # @see SupportOps::Zendesk::Configuration Setting up a client
|
64
|
+
# # @return [Object] Instance of {SupportOps::Zendesk::Apps}
|
65
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#save!}
|
66
|
+
# # @example
|
67
|
+
# # require 'support_ops_zendesk'
|
68
|
+
# #
|
69
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
70
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
71
|
+
# # config.username = 'jason@example.com'
|
72
|
+
# # config.token = 'abc123'
|
73
|
+
# # config.connection_type = 'upload'
|
74
|
+
# # end
|
75
|
+
# #
|
76
|
+
# # new_app = SupportOps::Zendesk::Apps.new
|
77
|
+
# # new_app.name = 'New app'
|
78
|
+
# # new_app.zipfile = SupportOps::Zendesk::Apps.package!('data/new_app')
|
79
|
+
# #
|
80
|
+
# # new_app.save!
|
81
|
+
# #
|
82
|
+
# # pp new_app.id
|
83
|
+
# # # => 123456
|
84
|
+
# # @example
|
85
|
+
# # require 'support_ops_zendesk'
|
86
|
+
# #
|
87
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
88
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
89
|
+
# # config.username = 'jason@example.com'
|
90
|
+
# # config.token = 'abc123'
|
91
|
+
# # config.connection_type = 'upload'
|
92
|
+
# # end
|
93
|
+
# #
|
94
|
+
# # existing_app = SupportOps::Zendesk::Apps.get!(123456)
|
95
|
+
# # existing_app.zipfile = SupportOps::Zendesk::Apps.package!('data/modified_app')
|
96
|
+
# #
|
97
|
+
# # existing_app.save!
|
98
|
+
# #
|
99
|
+
# # pp existing_app.id
|
100
|
+
# # # => 123456
|
101
|
+
# def save!; end
|
102
|
+
# @!parse
|
103
|
+
# # Reveals the app's public key in PEM format
|
104
|
+
# #
|
105
|
+
# # @author Jason Colyer
|
106
|
+
# # @since 1.0.0
|
107
|
+
# # @return [Boolean]
|
108
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#public_key!}
|
109
|
+
# # @see
|
110
|
+
# # https://developer.zendesk.com/api-reference/ticketing/apps/apps/#get-app-public-key
|
111
|
+
# # Zendesk API > Apps > Get App Public Key
|
112
|
+
# # @example
|
113
|
+
# # require 'support_ops_zendesk'
|
114
|
+
# #
|
115
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
116
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
117
|
+
# # config.username = 'jason@example.com'
|
118
|
+
# # config.token = 'abc123'
|
119
|
+
# # end
|
120
|
+
# #
|
121
|
+
# # existing_app = SupportOps::Zendesk::Apps.get!(123456)
|
122
|
+
# # key = existing_app.public_key
|
123
|
+
# # pp key
|
124
|
+
# # # => "-----BEGIN PUBLIC KEY-----\nPEM_formatted_string_goes_here\n-----END PUBLIC KEY-----\n"
|
125
|
+
# def public_key; end
|
126
|
+
# @!parse
|
127
|
+
# # Deletes an app
|
128
|
+
# #
|
129
|
+
# # @author Jason Colyer
|
130
|
+
# # @since 1.0.0
|
131
|
+
# # @return [Boolean]
|
132
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#delete!}
|
133
|
+
# # @see
|
134
|
+
# # https://developer.zendesk.com/api-reference/ticketing/apps/apps/#delete-app
|
135
|
+
# # Zendesk API > Apps > Delete App
|
136
|
+
# # @example
|
137
|
+
# # require 'support_ops_zendesk'
|
138
|
+
# #
|
139
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
140
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
141
|
+
# # config.username = 'jason@example.com'
|
142
|
+
# # config.token = 'abc123'
|
143
|
+
# # end
|
144
|
+
# #
|
145
|
+
# # existing_app = SupportOps::Zendesk::Apps.get!(123456)
|
146
|
+
# # existing_app.delete!
|
147
|
+
# def delete!; end
|
148
|
+
define_attributes :app_organization, :author_email, :author_name,
|
149
|
+
:author_url, :categories, :collections, :created_at,
|
150
|
+
:date_published, :default_locale, :deprecated,
|
151
|
+
:feature_color, :featured, :framework_version,
|
152
|
+
:google_analytics_code, :id, :installable,
|
153
|
+
:installation_count, :installation_instructions,
|
154
|
+
:large_icon, :locations, :long_description,
|
155
|
+
:marketing_only, :name, :obsolete, :owner_id, :paid,
|
156
|
+
:parameters, :plans, :products, :promoted, :rating,
|
157
|
+
:raw_installation_instructions, :raw_long_description,
|
158
|
+
:remote_installation_url, :screenshots,
|
159
|
+
:short_description, :single_install, :small_icon,
|
160
|
+
:state, :stripe_publishable_key, :terms_conditions_url,
|
161
|
+
:third_party_pricing, :updated_at, :version,
|
162
|
+
:visibility, :zipfile
|
163
|
+
readonly_attributes :app_organization, :author_email, :author_name,
|
164
|
+
:author_url, :categories, :collections, :created_at,
|
165
|
+
:date_published, :default_locale, :deprecated,
|
166
|
+
:feature_color, :featured, :framework_version,
|
167
|
+
:google_analytics_code, :id, :installable,
|
168
|
+
:installation_count, :installation_instructions,
|
169
|
+
:large_icon, :locations, :long_description,
|
170
|
+
:marketing_only, :name, :obsolete, :owner_id, :paid,
|
171
|
+
:parameters, :plans, :products, :promoted, :rating,
|
172
|
+
:raw_installation_instructions, :raw_long_description,
|
173
|
+
:remote_installation_url, :screenshots,
|
174
|
+
:short_description, :single_install, :small_icon,
|
175
|
+
:state, :stripe_publishable_key, :terms_conditions_url,
|
176
|
+
:third_party_pricing, :updated_at, :version,
|
177
|
+
:visibility
|
178
|
+
|
179
|
+
##
|
180
|
+
# Lists apps in the Zendesk system
|
181
|
+
#
|
182
|
+
# @author Jason Colyer
|
183
|
+
# @since 1.0.0
|
184
|
+
# @return [Array]
|
185
|
+
# @see
|
186
|
+
# https://developer.zendesk.com/api-reference/ticketing/apps/apps/#list-all-apps
|
187
|
+
# Zendesk API > Apps > List All Apps
|
188
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
189
|
+
# @example
|
190
|
+
# require 'support_ops_zendesk'
|
191
|
+
#
|
192
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
193
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
194
|
+
# config.username = 'jason@example.com'
|
195
|
+
# config.token = 'abc123'
|
196
|
+
# config.connection_type = 'upload'
|
197
|
+
# end
|
198
|
+
#
|
199
|
+
# apps = SupportOps::Zendesk::Apps.list
|
200
|
+
# pp apps.count
|
201
|
+
# # => 12
|
202
|
+
def self.list
|
203
|
+
response = client.connection.get('apps')
|
204
|
+
body = Oj.load(response.body)
|
205
|
+
body['apps'].map { |a| Apps.new(a) }
|
206
|
+
end
|
207
|
+
|
208
|
+
##
|
209
|
+
# Lists apps owned by the current account in the Zendesk system
|
210
|
+
#
|
211
|
+
# @author Jason Colyer
|
212
|
+
# @since 1.0.0
|
213
|
+
# @return [Array]
|
214
|
+
# @see
|
215
|
+
# https://developer.zendesk.com/api-reference/ticketing/apps/apps/#list-owned-apps
|
216
|
+
# Zendesk API > Apps > List Owned Apps
|
217
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
218
|
+
# @example
|
219
|
+
# require 'support_ops_zendesk'
|
220
|
+
#
|
221
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
222
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
223
|
+
# config.username = 'jason@example.com'
|
224
|
+
# config.token = 'abc123'
|
225
|
+
# config.connection_type = 'upload'
|
226
|
+
# end
|
227
|
+
#
|
228
|
+
# apps = SupportOps::Zendesk::Apps.list_owned
|
229
|
+
# pp apps.count
|
230
|
+
# # => 10
|
231
|
+
def self.list_owned
|
232
|
+
response = client.connection.get('apps/owned')
|
233
|
+
body = Oj.load(response.body)
|
234
|
+
body['apps'].map { |a| Apps.new(a) }
|
235
|
+
end
|
236
|
+
|
237
|
+
##
|
238
|
+
# Locates an app within Zendesk by name. Can utilize a cache for quicker results
|
239
|
+
#
|
240
|
+
# @author Jason Colyer
|
241
|
+
# @since 1.0.0
|
242
|
+
# @overload find_by_name(key: value)
|
243
|
+
# @param name [String required] The name to search for
|
244
|
+
# @param cache [Array] An Array of SupportOps::Zendesk::Apps to use as a cache
|
245
|
+
# @return [Object] An instance of {SupportOps::Zendesk::Apps}
|
246
|
+
# @example
|
247
|
+
# require 'support_ops_zendesk'
|
248
|
+
#
|
249
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
250
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
251
|
+
# config.username = 'jason@example.com'
|
252
|
+
# config.token = 'abc123'
|
253
|
+
# config.connection_type = 'upload'
|
254
|
+
# end
|
255
|
+
#
|
256
|
+
# apps = SupportOps::Zendesk::Apps.list
|
257
|
+
# app = SupportOps::Zendesk::Apps.find_by_name(name: 'QuickSearch', cache: apps)
|
258
|
+
# pp app.name
|
259
|
+
# # => "QuickSearch"
|
260
|
+
# pp app.id
|
261
|
+
# # => 123456
|
262
|
+
def self.find_by_name(**args)
|
263
|
+
raise 'You have to provide a name' unless args[:name]
|
264
|
+
if args[:cache]
|
265
|
+
raise 'Provided cache is not an Array' unless args[:cache].is_a? Array
|
266
|
+
apps = args[:cache]
|
267
|
+
else
|
268
|
+
apps = list
|
269
|
+
end
|
270
|
+
apps.detect { |c| c.name.downcase == args[:name].to_s.downcase }
|
271
|
+
end
|
272
|
+
|
273
|
+
##
|
274
|
+
# Locates a specific app in the Zendesk system
|
275
|
+
#
|
276
|
+
# @author Jason Colyer
|
277
|
+
# @since 1.0.0
|
278
|
+
# @see
|
279
|
+
# https://developer.zendesk.com/api-reference/ticketing/apps/apps/#get-information-about-app
|
280
|
+
# Zendesk API > Apps > Show Information About App
|
281
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
282
|
+
# @example
|
283
|
+
# require 'support_ops_zendesk'
|
284
|
+
#
|
285
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
286
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
287
|
+
# config.username = 'jason@example.com'
|
288
|
+
# config.token = 'abc123'
|
289
|
+
# config.connection_type = 'upload'
|
290
|
+
# end
|
291
|
+
#
|
292
|
+
# app = SupportOps::Zendesk::Apps.get(123456)
|
293
|
+
# pp app.name
|
294
|
+
# # => "QuickSearch"
|
295
|
+
def self.get(object)
|
296
|
+
if object.is_a? Apps
|
297
|
+
Apps.new(id: id).find
|
298
|
+
else
|
299
|
+
Apps.new(id: object).find
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
##
|
304
|
+
# Locates a specific app in the Zendesk system
|
305
|
+
#
|
306
|
+
# @author Jason Colyer
|
307
|
+
# @since 1.0.0
|
308
|
+
# @see
|
309
|
+
# https://developer.zendesk.com/api-reference/ticketing/apps/apps/#get-information-about-app
|
310
|
+
# Zendesk API > Apps > Show Information About App
|
311
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
312
|
+
# @example
|
313
|
+
# require 'support_ops_zendesk'
|
314
|
+
#
|
315
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
316
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
317
|
+
# config.username = 'jason@example.com'
|
318
|
+
# config.token = 'abc123'
|
319
|
+
# config.connection_type = 'upload'
|
320
|
+
# end
|
321
|
+
#
|
322
|
+
# app = SupportOps::Zendesk::Apps.get!(123456)
|
323
|
+
# pp app.name
|
324
|
+
# # => "QuickSearch"
|
325
|
+
def self.get!(object)
|
326
|
+
if object.is_a? Apps
|
327
|
+
Apps.new(id: id).find!
|
328
|
+
else
|
329
|
+
Apps.new(id: object).find!
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
##
|
334
|
+
# Sends a notification to a specific app in the Zendesk system
|
335
|
+
#
|
336
|
+
# @author Jason Colyer
|
337
|
+
# @since 1.0.0
|
338
|
+
# @overload notify!(key: value)
|
339
|
+
# @param app_id [Integer] The id of the app you want to send the message
|
340
|
+
# to
|
341
|
+
# @param event [String] The name of the event you want to fire in your
|
342
|
+
# app
|
343
|
+
# @param body [String optional] If it's valid JSON, it's passed to your
|
344
|
+
# app as a JavaScript object.
|
345
|
+
# @param agent_id [Integer optional] Send the notification to only one
|
346
|
+
# agent
|
347
|
+
# @see
|
348
|
+
# https://developer.zendesk.com/api-reference/ticketing/apps/apps/#send-notification-to-app
|
349
|
+
# Zendesk API > Apps > Send Notification to App
|
350
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
351
|
+
# @example
|
352
|
+
# require 'support_ops_zendesk'
|
353
|
+
#
|
354
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
355
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
356
|
+
# config.username = 'jason@example.com'
|
357
|
+
# config.token = 'abc123'
|
358
|
+
# end
|
359
|
+
#
|
360
|
+
# result = SupportOps::Zendesk::Apps.notify!(app_id: 123456, event: 'updateUsersPhoneNumber', agent_id: 534, body: '+123456789')
|
361
|
+
# pp result
|
362
|
+
# # => true
|
363
|
+
def self.notify!(**args)
|
364
|
+
raise 'You must specify the app via "app_id:xxx" for this to work' unless args[:app_id]
|
365
|
+
raise 'You must specify the event via "event:xxx" for this to work' unless args[:event]
|
366
|
+
data = {
|
367
|
+
'app_id' => args[:app_id],
|
368
|
+
'event' => args[:event],
|
369
|
+
}
|
370
|
+
get!(args[:app_id])
|
371
|
+
data['body'] = args[:body] if args[:body]
|
372
|
+
data['agent_id'] = args[:agent_id] if args[:agent_id]
|
373
|
+
response = client.connection.post('apps/notify', data.to_json)
|
374
|
+
body = Oj.load(response.body)
|
375
|
+
raise "Unable to notify app #{args[:app_id]} => #{body}" unless response.status == 200
|
376
|
+
true
|
377
|
+
end
|
378
|
+
|
379
|
+
##
|
380
|
+
# Creates a zipfile for the app
|
381
|
+
#
|
382
|
+
# @author Jason Colyer
|
383
|
+
# @since 1.0.0
|
384
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
385
|
+
# @param base_folder [String optional] The path to the folder the app
|
386
|
+
# files are located in; defaults to './'
|
387
|
+
# @example
|
388
|
+
# require 'support_ops_zendesk'
|
389
|
+
#
|
390
|
+
# file = SupportOps::Zendesk::Apps.package!('data/new_app')
|
391
|
+
# pp file
|
392
|
+
# # => "data/20250409124436282.zip"
|
393
|
+
def self.package!(base_folder = '')
|
394
|
+
list = %w[ assets translations manifest.json ]
|
395
|
+
SupportOps::Packages.create_zipfile!(item_list: list, input_dir: base_folder)
|
396
|
+
end
|
397
|
+
|
398
|
+
private
|
399
|
+
|
400
|
+
##
|
401
|
+
# @private
|
402
|
+
def get_record
|
403
|
+
response = self.client.connection.get("apps/#{self.id}")
|
404
|
+
return nil if response.status != 200
|
405
|
+
|
406
|
+
Oj.load(response.body)
|
407
|
+
end
|
408
|
+
|
409
|
+
##
|
410
|
+
# @private
|
411
|
+
def public_key_record
|
412
|
+
response = self.client.connection.get("apps/#{self.id}/public_key")
|
413
|
+
return nil if response.status != 200
|
414
|
+
|
415
|
+
Oj.load(response.body)
|
416
|
+
end
|
417
|
+
|
418
|
+
##
|
419
|
+
# @private
|
420
|
+
def create_record
|
421
|
+
raise 'No zipfile specified' if self.zipfile.nil?
|
422
|
+
data = {
|
423
|
+
'uploaded_data' => ::Faraday::UploadIO.new(self.zipfile, 'application.zip')
|
424
|
+
}
|
425
|
+
response = self.client.connection.post('apps/uploads', data)
|
426
|
+
body = Oj.load(response.body)
|
427
|
+
raise "Unable to create app (upload) => #{body}" unless response.status == 201
|
428
|
+
data = {
|
429
|
+
'upload_id' => body['id']
|
430
|
+
}
|
431
|
+
response = self.client.connection.post('apps', data)
|
432
|
+
body = Oj.load(response.body)
|
433
|
+
raise "Unable to update app #{self.id} => #{body}" unless response.status == 202
|
434
|
+
job_id = body['job_id']
|
435
|
+
job = AppJobStatuses.get!(job_id)
|
436
|
+
job.wait_for_completetion
|
437
|
+
response = client.connection.get('apps/owned')
|
438
|
+
body = Oj.load(response.body)
|
439
|
+
body['apps'].detect { |t| t['name'] == self.name }
|
440
|
+
end
|
441
|
+
|
442
|
+
##
|
443
|
+
# @private
|
444
|
+
def update_record
|
445
|
+
raise 'No zipfile specified' if self.zipfile.nil?
|
446
|
+
data = {
|
447
|
+
'uploaded_data' => ::Faraday::UploadIO.new(self.zipfile, 'application.zip')
|
448
|
+
}
|
449
|
+
response = self.client.connection.post('apps/uploads', data)
|
450
|
+
body = Oj.load(response.body)
|
451
|
+
raise "Unable to update app #{self.id} (upload) => #{body}" unless response.status == 201
|
452
|
+
data = {
|
453
|
+
'upload_id' => body['id']
|
454
|
+
}
|
455
|
+
response = self.client.connection.put("apps/#{self.id}", data)
|
456
|
+
body = Oj.load(response.body)
|
457
|
+
raise "Unable to update app #{self.id} => #{body}" unless response.status == 202
|
458
|
+
job_id = body['job_id']
|
459
|
+
job = AppJobStatuses.get!(job_id)
|
460
|
+
job.wait_for_completetion
|
461
|
+
response = client.connection.get('apps/owned')
|
462
|
+
body = Oj.load(response.body)
|
463
|
+
body['apps'].detect { |t| t['name'] == self.name }
|
464
|
+
end
|
465
|
+
|
466
|
+
##
|
467
|
+
# @private
|
468
|
+
def delete_record
|
469
|
+
response = self.client.connection.delete("apps/#{self.id}")
|
470
|
+
raise "Failed to delete app => #{body}" if response.status != 204
|
471
|
+
true
|
472
|
+
end
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
#save!
|