gitlab_support_readiness 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/support_readiness/calendly/client.rb +64 -0
- data/lib/support_readiness/calendly/configuration.rb +45 -0
- data/lib/support_readiness/calendly/organization_memberships.rb +67 -0
- data/lib/support_readiness/calendly/organizations.rb +123 -0
- data/lib/support_readiness/calendly/users.rb +105 -0
- data/lib/support_readiness/calendly.rb +16 -0
- data/lib/support_readiness/client.rb +88 -1
- data/lib/support_readiness/dates.rb +90 -0
- data/lib/support_readiness/gitlab/configuration.rb +0 -1
- data/lib/support_readiness/gitlab/groups.rb +35 -0
- data/lib/support_readiness/gitlab/markdown.rb +37 -0
- data/lib/support_readiness/gitlab/merge_requests.rb +127 -0
- data/lib/support_readiness/gitlab/namespaces.rb +22 -0
- data/lib/support_readiness/gitlab/projects.rb +36 -1
- data/lib/support_readiness/gitlab/repositories.rb +174 -0
- data/lib/support_readiness/gitlab/users.rb +24 -0
- data/lib/support_readiness/gitlab.rb +2 -0
- data/lib/support_readiness/google_calendar/client.rb +59 -0
- data/lib/support_readiness/google_calendar/configuration.rb +39 -0
- data/lib/support_readiness/google_calendar/events.rb +169 -0
- data/lib/support_readiness/google_calendar.rb +14 -0
- data/lib/support_readiness/mailgun/bounces.rb +103 -0
- data/lib/support_readiness/mailgun/client.rb +65 -0
- data/lib/support_readiness/mailgun/configuration.rb +46 -0
- data/lib/support_readiness/mailgun/emails.rb +95 -0
- data/lib/support_readiness/mailgun.rb +15 -0
- data/lib/support_readiness/pagerduty/escalation_policies.rb +1 -1
- data/lib/support_readiness/pagerduty/schedules.rb +27 -3
- data/lib/support_readiness/pagerduty/services.rb +1 -1
- data/lib/support_readiness/pagerduty/users.rb +197 -0
- data/lib/support_readiness/pagerduty.rb +1 -0
- data/lib/support_readiness/repos/articles.rb +335 -0
- data/lib/support_readiness/repos/automations.rb +247 -0
- data/lib/support_readiness/repos/groups.rb +188 -0
- data/lib/support_readiness/repos/macros.rb +224 -0
- data/lib/support_readiness/repos/organization_fields.rb +193 -0
- data/lib/support_readiness/repos/sla_policies.rb +192 -0
- data/lib/support_readiness/repos/ticket_fields.rb +200 -0
- data/lib/support_readiness/repos/ticket_forms.rb +200 -0
- data/lib/support_readiness/repos/triggers.rb +255 -0
- data/lib/support_readiness/repos/user_fields.rb +201 -0
- data/lib/support_readiness/repos/views.rb +362 -0
- data/lib/support_readiness/repos.rb +22 -0
- data/lib/support_readiness/salesforce/accounts.rb +109 -0
- data/lib/support_readiness/salesforce/cases.rb +109 -0
- data/lib/support_readiness/salesforce/client.rb +64 -0
- data/lib/support_readiness/salesforce/configuration.rb +49 -0
- data/lib/support_readiness/salesforce/queries.rb +62 -0
- data/lib/support_readiness/salesforce.rb +16 -0
- data/lib/support_readiness/slack/client.rb +63 -0
- data/lib/support_readiness/slack/configuration.rb +43 -0
- data/lib/support_readiness/slack/messages.rb +37 -0
- data/lib/support_readiness/slack.rb +14 -0
- data/lib/support_readiness/zendesk/app_job_statuses.rb +140 -0
- data/lib/support_readiness/zendesk/apps.rb +209 -0
- data/lib/support_readiness/zendesk/automations.rb +1 -2
- data/lib/support_readiness/zendesk/macros.rb +1 -3
- data/lib/support_readiness/zendesk/organization_fields.rb +1 -1
- data/lib/support_readiness/zendesk/theme_job_statuses.rb +136 -0
- data/lib/support_readiness/zendesk/themes.rb +303 -0
- data/lib/support_readiness/zendesk/ticket_field_options.rb +110 -0
- data/lib/support_readiness/zendesk/ticket_fields.rb +85 -16
- data/lib/support_readiness/zendesk/ticket_forms.rb +65 -2
- data/lib/support_readiness/zendesk/tickets.rb +77 -0
- data/lib/support_readiness/zendesk/triggers.rb +1 -2
- data/lib/support_readiness/zendesk/user_field_options.rb +110 -0
- data/lib/support_readiness/zendesk/user_fields.rb +257 -0
- data/lib/support_readiness/zendesk/views.rb +49 -2
- data/lib/support_readiness/zendesk.rb +7 -0
- data/lib/support_readiness.rb +16 -0
- metadata +120 -2
@@ -9,11 +9,6 @@ module Readiness
|
|
9
9
|
#
|
10
10
|
# @author Jason Colyer
|
11
11
|
# @since 1.0.0
|
12
|
-
# @todo List ticket field options
|
13
|
-
# @todo Show ticket field option
|
14
|
-
# @todo Create or update ticket field option
|
15
|
-
# @todo Delete ticket field option
|
16
|
-
# @todo Reorder ticket fields
|
17
12
|
class TicketFields < Readiness::Client
|
18
13
|
attr_accessor :active, :agent_description, :collapsed_for_agents, :custom_field_options, :description, :editable_in_portal, :id, :key, :position, :regexp_for_validation, :removable, :required, :system_field_options, :tag, :title, :title_in_portal, :type, :visible_in_portal
|
19
14
|
|
@@ -22,15 +17,21 @@ module Readiness
|
|
22
17
|
#
|
23
18
|
# @author Jason Colyer
|
24
19
|
# @since 1.0.0
|
20
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
25
21
|
# @param object [Object] An instance of {Readiness::Zendesk::TicketFields}
|
26
22
|
# @example
|
27
23
|
# require 'support_readiness'
|
28
|
-
# Readiness::Zendesk::
|
29
|
-
|
24
|
+
# config = Readiness::Zendesk::Configuration.new
|
25
|
+
# config.username = 'alice@example.com'
|
26
|
+
# config.token = 'test123abc'
|
27
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
28
|
+
# client = Readiness::Zendesk::Client.new(config)
|
29
|
+
# Readiness::Zendesk::TicketFields.new(client)
|
30
|
+
def initialize(client, object = {})
|
30
31
|
@active = object['active']
|
31
32
|
@agent_description = object['agent_description']
|
32
33
|
@collapsed_for_agents = object['collapsed_for_agents']
|
33
|
-
@custom_field_options = object
|
34
|
+
@custom_field_options = ticket_field_options(client, object)
|
34
35
|
@description = object['description']
|
35
36
|
@editable_in_portal = object['editable_in_portal']
|
36
37
|
@id = object['id']
|
@@ -47,6 +48,24 @@ module Readiness
|
|
47
48
|
@visible_in_portal = object['visible_in_portal']
|
48
49
|
end
|
49
50
|
|
51
|
+
##
|
52
|
+
# Gets the ticket field options for a ticket field
|
53
|
+
#
|
54
|
+
# @author Jason Colyer
|
55
|
+
# @since 1.0.12
|
56
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
57
|
+
# @param object [Varies] Either a Hash from JSON or a {Readiness::Zendesk::TicketFields} instance
|
58
|
+
# @return [Array]
|
59
|
+
def ticket_field_options(client, object)
|
60
|
+
return nil unless %w[tagger multiselect].include? object['type']
|
61
|
+
|
62
|
+
# Handles when the position value is nil
|
63
|
+
object['custom_field_options'].each do |c|
|
64
|
+
c['position'] = object['custom_field_options'].index(c)
|
65
|
+
end
|
66
|
+
object['custom_field_options'].map { |c| TicketFieldOptions.new(c) }
|
67
|
+
end
|
68
|
+
|
50
69
|
##
|
51
70
|
# Lists all ticket fields.
|
52
71
|
#
|
@@ -72,7 +91,7 @@ module Readiness
|
|
72
91
|
response = client.connection.get("ticket_fields?#{opts}")
|
73
92
|
handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
|
74
93
|
body = Oj.load(response.body)
|
75
|
-
array += body['ticket_fields'].map { |f| TicketFields.new(f) }
|
94
|
+
array += body['ticket_fields'].map { |f| TicketFields.new(client, f) }
|
76
95
|
break if limit != 0 && array.count >= (limit * 100)
|
77
96
|
break unless body['meta']['has_more']
|
78
97
|
|
@@ -103,7 +122,7 @@ module Readiness
|
|
103
122
|
def self.find(client, fid)
|
104
123
|
response = client.connection.get("ticket_fields/#{fid}")
|
105
124
|
handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: fid }) unless response.status == 200
|
106
|
-
return TicketFields.new(Oj.load(response.body)['ticket_field']) if response.status == 200
|
125
|
+
return TicketFields.new(client, Oj.load(response.body)['ticket_field']) if response.status == 200
|
107
126
|
|
108
127
|
Oj.load(response.body)
|
109
128
|
end
|
@@ -130,11 +149,59 @@ module Readiness
|
|
130
149
|
def self.find!(client, fid)
|
131
150
|
response = client.connection.get("ticket_fields/#{fid}")
|
132
151
|
handle_request_error(1, 'Zendesk', response.status, { action: 'Find ticket field', id: fid }) unless response.status == 200
|
133
|
-
TicketFields.new(Oj.load(response.body)['ticket_field'])
|
152
|
+
TicketFields.new(client, Oj.load(response.body)['ticket_field'])
|
153
|
+
end
|
154
|
+
|
155
|
+
##
|
156
|
+
# Locates a ticket field within Zendesk by name. This will not exit on error (except Authentication errors)
|
157
|
+
#
|
158
|
+
# @author Jason Colyer
|
159
|
+
# @since 1.0.12
|
160
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
161
|
+
# @param name [String] The ticket field name to look for
|
162
|
+
# @return [Object] An instance of {Readiness::Zendesk::TicketFields}
|
163
|
+
# @example
|
164
|
+
# require 'support_readiness'
|
165
|
+
# config = Readiness::Zendesk::Configuration.new
|
166
|
+
# config.username = 'alice@example.com'
|
167
|
+
# config.token = 'test123abc'
|
168
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
169
|
+
# client = Readiness::Zendesk::Client.new(config)
|
170
|
+
# field = Readiness::Zendesk::TicketFields.find_by_name(client, 'Age')
|
171
|
+
# pp field.id
|
172
|
+
# # => 89
|
173
|
+
def self.find_by_name(client, name)
|
174
|
+
fields = TicketFields.list(client)
|
175
|
+
fields.detect { |f| f.title == name }
|
176
|
+
end
|
177
|
+
|
178
|
+
##
|
179
|
+
# Locates a ticket field within Zendesk by name. This will exit on error
|
180
|
+
#
|
181
|
+
# @author Jason Colyer
|
182
|
+
# @since 1.0.12
|
183
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
184
|
+
# @param name [String] The ticket field name to look for
|
185
|
+
# @return [Object] An instance of {Readiness::Zendesk::TicketFields}
|
186
|
+
# @example
|
187
|
+
# require 'support_readiness'
|
188
|
+
# config = Readiness::Zendesk::Configuration.new
|
189
|
+
# config.username = 'alice@example.com'
|
190
|
+
# config.token = 'test123abc'
|
191
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
192
|
+
# client = Readiness::Zendesk::Client.new(config)
|
193
|
+
# field = Readiness::Zendesk::TicketFields.find_by_name!(client, 'Age')
|
194
|
+
# pp field.id
|
195
|
+
# # => 89
|
196
|
+
def self.find_by_name!(client, name)
|
197
|
+
fields = TicketFields.list(client)
|
198
|
+
field = fields.detect { |f| f.title == name }
|
199
|
+
handle_request_error(1, 'Zendesk', 404, { action: 'Find ticket field', id: name }) if field.nil?
|
200
|
+
field
|
134
201
|
end
|
135
202
|
|
136
203
|
##
|
137
|
-
# Creates a ticket field. Will exit if unsuccessful
|
204
|
+
# Creates a ticket field. Will exit if unsuccessful. Note that this does not not create ticket field options. Use {Readiness::Zendesk::TicketFieldOptions} for that.
|
138
205
|
#
|
139
206
|
# @author Jason Colyer
|
140
207
|
# @since 1.0.0
|
@@ -149,20 +216,21 @@ module Readiness
|
|
149
216
|
# config.token = 'test123abc'
|
150
217
|
# config.url = 'https://example.zendesk.com/api/v2'
|
151
218
|
# client = Readiness::Zendesk::Client.new(config)
|
152
|
-
# field = Readiness::Zendesk::TicketFields.new
|
219
|
+
# field = Readiness::Zendesk::TicketFields.new(client)
|
153
220
|
# field.type = 'text'
|
154
221
|
# field.title = 'Age'
|
155
222
|
# create = Readiness::Zendesk::TicketFields.create!(client, field)
|
156
223
|
# pp create.id
|
157
224
|
# # => 89
|
158
225
|
def self.create!(client, field)
|
226
|
+
field.custom_field_options = nil
|
159
227
|
response = client.connection.post 'ticket_fields', to_clean_json_with_key(field, 'ticket_field')
|
160
228
|
handle_request_error(1, 'Zendesk', response.status, { action: 'Create ticket field', message: Oj.load(response.body)}) unless response.status == 201
|
161
|
-
TicketFields.new(Oj.load(response.body)['ticket_field'])
|
229
|
+
TicketFields.new(client, Oj.load(response.body)['ticket_field'])
|
162
230
|
end
|
163
231
|
|
164
232
|
##
|
165
|
-
# Updates a ticket field. Will exit if unsuccessful
|
233
|
+
# Updates a ticket field. Will exit if unsuccessful. Note that this does not not update ticket field options. Use {Readiness::Zendesk::TicketFieldOptions} for that.
|
166
234
|
#
|
167
235
|
# @author Jason Colyer
|
168
236
|
# @since 1.0.0
|
@@ -187,9 +255,10 @@ module Readiness
|
|
187
255
|
# pp update.title
|
188
256
|
# # => "Pies"
|
189
257
|
def self.update!(client, field)
|
258
|
+
field.custom_field_options = nil
|
190
259
|
response = client.connection.put "ticket_fields/#{field.id}", to_clean_json_with_key(field, 'ticket_field')
|
191
260
|
handle_request_error(1, 'Zendesk', response.status, { action: 'Update ticket field', message: Oj.load(response.body)}) unless response.status == 200
|
192
|
-
TicketFields.new(Oj.load(response.body)['ticket_field'])
|
261
|
+
TicketFields.new(client, Oj.load(response.body)['ticket_field'])
|
193
262
|
end
|
194
263
|
|
195
264
|
##
|
@@ -23,10 +23,10 @@ module Readiness
|
|
23
23
|
# Readiness::Zendesk::TicketForms.new
|
24
24
|
def initialize(object = {})
|
25
25
|
@active = object['active']
|
26
|
-
@agent_conditions = object['agent_conditions']
|
26
|
+
@agent_conditions = clean_conditions(object['agent_conditions'])
|
27
27
|
@default = object['default']
|
28
28
|
@display_name = object['display_name']
|
29
|
-
@end_user_conditions = object['end_user_conditions']
|
29
|
+
@end_user_conditions = clean_conditions(object['end_user_conditions'])
|
30
30
|
@end_user_visible = object['end_user_visible']
|
31
31
|
@id = object['id']
|
32
32
|
@in_all_brands = object['in_all_brands']
|
@@ -36,6 +36,21 @@ module Readiness
|
|
36
36
|
@ticket_field_ids = object['ticket_field_ids']
|
37
37
|
end
|
38
38
|
|
39
|
+
##
|
40
|
+
# Removes unneeded values from the conditions variable on a {Readiness::Zendesk::TicketForms} object
|
41
|
+
#
|
42
|
+
# @author Jason Colyer
|
43
|
+
# @since 1.0.12
|
44
|
+
# @param conditions [Hash]
|
45
|
+
# @return [Hash]
|
46
|
+
def clean_conditions(conditions)
|
47
|
+
return nil if conditions.nil?
|
48
|
+
return [] if conditions.count.zero?
|
49
|
+
|
50
|
+
conditions.map { |c| c.delete('parent_field_type') }
|
51
|
+
conditions
|
52
|
+
end
|
53
|
+
|
39
54
|
##
|
40
55
|
# Lists the first 100 ticket forms
|
41
56
|
#
|
@@ -137,6 +152,54 @@ module Readiness
|
|
137
152
|
Oj.load(response.body)['ticket_forms'].map { |f| TicketForms.new(f) }
|
138
153
|
end
|
139
154
|
|
155
|
+
##
|
156
|
+
# Locates a ticket form within Zendesk by name. This will not exit on error (except Authentication errors)
|
157
|
+
#
|
158
|
+
# @author Jason Colyer
|
159
|
+
# @since 1.0.12
|
160
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
161
|
+
# @param name [String] The ticket form name to look for
|
162
|
+
# @return [Object] An instance of {Readiness::Zendesk::TicketForms}
|
163
|
+
# @example
|
164
|
+
# require 'support_readiness'
|
165
|
+
# config = Readiness::Zendesk::Configuration.new
|
166
|
+
# config.username = 'alice@example.com'
|
167
|
+
# config.token = 'test123abc'
|
168
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
169
|
+
# client = Readiness::Zendesk::Client.new(config)
|
170
|
+
# form = Readiness::Zendesk::TicketForms.find_by_name(client, 'Snowboard Problem')
|
171
|
+
# pp form.id
|
172
|
+
# # => 47
|
173
|
+
def self.find_by_name(client, name)
|
174
|
+
forms = TicketForms.list(client)
|
175
|
+
forms.detect { |f| f.name == name }
|
176
|
+
end
|
177
|
+
|
178
|
+
##
|
179
|
+
# Locates a ticket field within Zendesk by name. This will exit on error
|
180
|
+
#
|
181
|
+
# @author Jason Colyer
|
182
|
+
# @since 1.0.12
|
183
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
184
|
+
# @param name [String] The ticket field name to look for
|
185
|
+
# @return [Object] An instance of {Readiness::Zendesk::TicketForms}
|
186
|
+
# @example
|
187
|
+
# require 'support_readiness'
|
188
|
+
# config = Readiness::Zendesk::Configuration.new
|
189
|
+
# config.username = 'alice@example.com'
|
190
|
+
# config.token = 'test123abc'
|
191
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
192
|
+
# client = Readiness::Zendesk::Client.new(config)
|
193
|
+
# form = Readiness::Zendesk::TicketForms.find_by_name!(client, 'Snowboard Problem')
|
194
|
+
# pp form.id
|
195
|
+
# # => 47
|
196
|
+
def self.find_by_name!(client, name)
|
197
|
+
forms = TicketForms.list(client)
|
198
|
+
form = forms.detect { |f| f.name == name }
|
199
|
+
handle_request_error(1, 'Zendesk', 404, { action: 'Find ticket form', id: name }) if form.nil?
|
200
|
+
form
|
201
|
+
end
|
202
|
+
|
140
203
|
##
|
141
204
|
# Creates a ticket form. Will exit if unsuccessful
|
142
205
|
#
|
@@ -846,6 +846,83 @@ module Readiness
|
|
846
846
|
handle_request_error(1, 'Zendesk', response.status, { action: 'Delete many suspended ticket', id: sids }) unless response.status == 200
|
847
847
|
true
|
848
848
|
end
|
849
|
+
|
850
|
+
##
|
851
|
+
# Redacts all attachments (inline and external) within a ticket. This will not exit on error (except Authentication errors)
|
852
|
+
#
|
853
|
+
# @author Jason Colyer
|
854
|
+
# @since 1.0.12
|
855
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
856
|
+
# @param ticket [Object] An instance of {Readiness::Zendesk::Tickets}
|
857
|
+
# @return [Boolean]
|
858
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/#redact-ticket-comment-in-agent-workspace Zendesk API > Ticket Comments > Redact Ticket Comment In Agent Workspace
|
859
|
+
# @example
|
860
|
+
# require 'support_readiness'
|
861
|
+
# config = Readiness::Zendesk::Configuration.new
|
862
|
+
# config.username = 'alice@example.com'
|
863
|
+
# config.token = 'test123abc'
|
864
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
865
|
+
# client = Readiness::Zendesk::Client.new(config)
|
866
|
+
# ticket = Readiness::Zendesk::Tickets.find!(client, 141)
|
867
|
+
# redaction = Readiness::Zendesk::Tickets.redact_attachments!(client, ticket)
|
868
|
+
# pp redaction
|
869
|
+
# # => true
|
870
|
+
def self.redact_attachments(client, ticket)
|
871
|
+
redactions = []
|
872
|
+
Tickets.comments(client, ticket).each do |c|
|
873
|
+
object = {
|
874
|
+
id: c['id'],
|
875
|
+
redaction: { ticket_id: ticket.id }
|
876
|
+
}
|
877
|
+
object[:redaction][:external_attachment_urls] = c['attachments'].map { |a| a['content_url'] } unless c['attachments'].count.zero?
|
878
|
+
object[:redaction][:html_body] = c['html_body'].gsub('<img', '<img redact') if c['html_body'] =~ /<img/
|
879
|
+
redactions.push(object) unless object[:redaction][:external_attachment_urls].nil? && object[:redaction][:html_body].nil?
|
880
|
+
end
|
881
|
+
redactions.each do |r|
|
882
|
+
response = client.connection.put "comment_redactions/#{r[:id]}", r[:redaction].to_json
|
883
|
+
handle_request_error(0, 'Zendesk', response.status, { action: 'Redact attachments', id: "tickets/#{ticket.id}/comments/#{r[:id]}" }) unless response.status == 200
|
884
|
+
return false
|
885
|
+
end
|
886
|
+
true
|
887
|
+
end
|
888
|
+
|
889
|
+
##
|
890
|
+
# Redacts all attachments (inline and external) within a ticket. This will exit on error
|
891
|
+
#
|
892
|
+
# @author Jason Colyer
|
893
|
+
# @since 1.0.12
|
894
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
895
|
+
# @param ticket [Object] An instance of {Readiness::Zendesk::Tickets}
|
896
|
+
# @return [Boolean]
|
897
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/#redact-ticket-comment-in-agent-workspace Zendesk API > Ticket Comments > Redact Ticket Comment In Agent Workspace
|
898
|
+
# @example
|
899
|
+
# require 'support_readiness'
|
900
|
+
# config = Readiness::Zendesk::Configuration.new
|
901
|
+
# config.username = 'alice@example.com'
|
902
|
+
# config.token = 'test123abc'
|
903
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
904
|
+
# client = Readiness::Zendesk::Client.new(config)
|
905
|
+
# ticket = Readiness::Zendesk::Tickets.find!(client, 141)
|
906
|
+
# redaction = Readiness::Zendesk::Tickets.redact_attachments!(client, ticket)
|
907
|
+
# pp redaction
|
908
|
+
# # => true
|
909
|
+
def self.redact_attachments!(client, ticket)
|
910
|
+
redactions = []
|
911
|
+
Tickets.comments(client, ticket).each do |c|
|
912
|
+
object = {
|
913
|
+
id: c['id'],
|
914
|
+
redaction: { ticket_id: ticket.id }
|
915
|
+
}
|
916
|
+
object[:redaction][:external_attachment_urls] = c['attachments'].map { |a| a['content_url'] } unless c['attachments'].count.zero?
|
917
|
+
object[:redaction][:html_body] = c['html_body'].gsub('<img', '<img redact') if c['html_body'] =~ /<img/
|
918
|
+
redactions.push(object) unless object[:redaction][:external_attachment_urls].nil? && object[:redaction][:html_body].nil?
|
919
|
+
end
|
920
|
+
redactions.each do |r|
|
921
|
+
response = client.connection.put "comment_redactions/#{r[:id]}", r[:redaction].to_json
|
922
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Redact attachments', id: "tickets/#{ticket.id}/comments/#{r[:id]}" }) unless response.status == 200
|
923
|
+
end
|
924
|
+
true
|
925
|
+
end
|
849
926
|
end
|
850
927
|
end
|
851
928
|
end
|
@@ -10,7 +10,7 @@ module Readiness
|
|
10
10
|
# @author Jason Colyer
|
11
11
|
# @since 1.0.0
|
12
12
|
class Triggers < Readiness::Client
|
13
|
-
attr_accessor :actions, :active, :category_id, :conditions, :
|
13
|
+
attr_accessor :actions, :active, :category_id, :conditions, :description, :id, :position, :title
|
14
14
|
|
15
15
|
##
|
16
16
|
# Creates a new {Readiness::Zendesk::Triggers} instance
|
@@ -26,7 +26,6 @@ module Readiness
|
|
26
26
|
@active = object['active']
|
27
27
|
@category_id = object['category_id']
|
28
28
|
@conditions = object['conditions']
|
29
|
-
@default = object['default']
|
30
29
|
@description = object['description']
|
31
30
|
@id = object['id']
|
32
31
|
@position = object['position']
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Zendesk
|
6
|
+
module Zendesk
|
7
|
+
##
|
8
|
+
# Defines the class UserFieldOptions within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class UserFieldOptions < Readiness::Client
|
13
|
+
attr_accessor :id, :name, :position, :value
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Zendesk::UserFieldOptions} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param object [Object] An instance of {Readiness::Zendesk::UserFieldOptions}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Zendesk::TicketFieldOptions.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@id = object['id']
|
26
|
+
@name = object['name']
|
27
|
+
@position = object['position']
|
28
|
+
@value = object['value']
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Lists all user fields options for a specific user field.
|
33
|
+
#
|
34
|
+
# @author Jason Colyer
|
35
|
+
# @since 1.0.12
|
36
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
37
|
+
# @param fid [Integer] The field ID to get the field options for
|
38
|
+
# @return [Array]
|
39
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#list-user-field-options Zendesk API > User Fields > List User Field Options
|
40
|
+
# @example
|
41
|
+
# require 'support_readiness'
|
42
|
+
# config = Readiness::Zendesk::Configuration.new
|
43
|
+
# config.username = 'alice@example.com'
|
44
|
+
# config.token = 'test123abc'
|
45
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
46
|
+
# client = Readiness::Zendesk::Client.new(config)
|
47
|
+
# options = Readiness::Zendesk::UserFieldOptions.list(client, 123)
|
48
|
+
# pp fields.count
|
49
|
+
# # => 5
|
50
|
+
def self.list(client, fid)
|
51
|
+
array = []
|
52
|
+
page = 1
|
53
|
+
loop do
|
54
|
+
response = client.connection.get("user_fields/#{fid}/options?page=#{page}")
|
55
|
+
handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
|
56
|
+
body = Oj.load(response.body)
|
57
|
+
array += body['custom_field_options'].map { |f| UserFieldOptions.new(f) }
|
58
|
+
break unless body['custom_field_options'].count == 100
|
59
|
+
|
60
|
+
page += 1
|
61
|
+
end
|
62
|
+
array
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# Creates or updates an user field option. This will exit on error.
|
67
|
+
#
|
68
|
+
# @author Jason Colyer
|
69
|
+
# @since 1.0.12
|
70
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
71
|
+
# @param field [Object] An instance of {Readiness::Zendesk::UserFields}
|
72
|
+
# @param option [Object] An instance of {Readiness::Zendesk::UserFieldOptions}
|
73
|
+
# @return [Object]
|
74
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#create-or-update-a-user-field-option Zendesk API > User Fields > Create or Update a User Field Option
|
75
|
+
def self.create_or_update!(client, field, option)
|
76
|
+
response = client.connection.post "user_fields/#{field.id}/options", to_clean_json_with_key(option, 'custom_field_option')
|
77
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Create/update user field option', message: Oj.load(response.body)}) unless [200, 201].include?(response.status)
|
78
|
+
UserFieldOptions.new(Oj.load(response.body)['custom_field_option'])
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Deletes aan user field option. Will exit if unsuccessful
|
83
|
+
#
|
84
|
+
# @author Jason Colyer
|
85
|
+
# @since 1.0.12
|
86
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
87
|
+
# @param field [Object] An instance of {Readiness::Zendesk::UserFields}
|
88
|
+
# @param option [Object] An instance of {Readiness::Zendesk::UserFieldOptions}
|
89
|
+
# @return [Boolean]
|
90
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#delete-user-field-option Zendesk API > USer Fields > Delete User Field Option
|
91
|
+
# @example
|
92
|
+
# require 'support_readiness'
|
93
|
+
# config = Readiness::Zendesk::Configuration.new
|
94
|
+
# config.username = 'alice@example.com'
|
95
|
+
# config.token = 'test123abc'
|
96
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
97
|
+
# client = Readiness::Zendesk::Client.new(config)
|
98
|
+
# field = Readiness::Zendesk::UserFields.find!(client, 75)
|
99
|
+
# option = field.custom_field_options.last
|
100
|
+
# delete = Readiness::Zendesk::UserFieldOptions.delete!(client, field, option)
|
101
|
+
# pp delete
|
102
|
+
# # => true
|
103
|
+
def self.delete!(client, field, option)
|
104
|
+
response = client.connection.delete "user_fields/#{field.id}/options/#{option.id}"
|
105
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Delete a user field option', id: "user_fields/#{field.id}/options/#{option.id}", message: Oj.load(response.body)}) unless response.status == 204
|
106
|
+
true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|