gitlab_support_readiness 1.0.71 → 1.0.73
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/ticket_processor/link_tagger.rb +2 -0
- data/lib/support_readiness/zendesk/dynamic_content.rb +230 -0
- data/lib/support_readiness/zendesk/dynamic_content_variants.rb +273 -0
- data/lib/support_readiness/zendesk/locales.rb +81 -0
- data/lib/support_readiness/zendesk.rb +3 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e46aedda90f84ce671f2d8d19160f07fd95a391659bdb9141d8c3e7f2b559e04
|
4
|
+
data.tar.gz: 746d13244c25e4dc918a3b3d85f262fb4affbd4e73e1cc305ea2a1220b005acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb42a7fea9bc27b6239bb376fcc2fdaa793c5b2615b115cfec1aad97fd9072a4bb0c72d6d6e0195084e13ff4ff4ace6dede4457ce646e3b305e6e9e46c9d2a15
|
7
|
+
data.tar.gz: 33a27e8f9ed7a7b507cdfd76cfafb4c2f1ac6b2cf9e995d1737c173ee18e81baf42b2f360bfb5230eb7005b59b4a1c144c683b2bbac86dbf5267b201883b1a70
|
@@ -46,6 +46,8 @@ module Readiness
|
|
46
46
|
end
|
47
47
|
tags_to_add = []
|
48
48
|
Nokogiri::HTML(comment_to_check['html_body']).css('a').each do |p|
|
49
|
+
next if p['href'].nil? || p['href'].empty?
|
50
|
+
|
49
51
|
link = p['href'].split('?').first.split('#').first
|
50
52
|
domain = link.split('/')[2]
|
51
53
|
if domain == 'gitlab.com'
|
@@ -0,0 +1,230 @@
|
|
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 DynamicContent within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.73
|
12
|
+
class DynamicContent < Readiness::Client
|
13
|
+
attr_accessor :default_locale_id, :id, :name, :outdated, :placeholder
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Zendesk::DyanmicContent} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.73
|
20
|
+
# @param object [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Zendesk::DyanmicContent.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@default_locale_id = object['default_locale_id']
|
26
|
+
@id = object['id']
|
27
|
+
@name = object['name']
|
28
|
+
@outdated = object['outdated']
|
29
|
+
@placeholder = object['placeholder']
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Lists dynamic content.
|
34
|
+
#
|
35
|
+
# @author Jason Colyer
|
36
|
+
# @since 1.0.73
|
37
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
38
|
+
# @return [Array]
|
39
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#list-items Zendesk API > Dynamic Content Items > List items
|
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
|
+
# items = Readiness::Zendesk::DynamicContent.list(client)
|
48
|
+
# pp items.first.id
|
49
|
+
# # => 47
|
50
|
+
def self.list(client)
|
51
|
+
array = []
|
52
|
+
page = 1
|
53
|
+
loop do
|
54
|
+
response = client.connection.get("dynamic_content/items?page=#{page}")
|
55
|
+
handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
|
56
|
+
body = Oj.load(response.body)
|
57
|
+
array += body['items'].map { |i| DynamicContent.new(i) }
|
58
|
+
break if body['items'].count < 100
|
59
|
+
|
60
|
+
page += 1
|
61
|
+
end
|
62
|
+
array
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# Lists variants for a dynamic content.
|
67
|
+
#
|
68
|
+
# @author Jason Colyer
|
69
|
+
# @since 1.0.73
|
70
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
71
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DynamicContent}
|
72
|
+
# @return [Array]
|
73
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content_item_variants/#list-variants Zendesk API > Dynamic Content Item Variants > List variants
|
74
|
+
# @example
|
75
|
+
# require 'support_readiness'
|
76
|
+
# config = Readiness::Zendesk::Configuration.new
|
77
|
+
# config.username = 'alice@example.com'
|
78
|
+
# config.token = 'test123abc'
|
79
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
80
|
+
# client = Readiness::Zendesk::Client.new(config)
|
81
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
82
|
+
# variants = Readiness::Zendesk::DynamicContent.variants(client, content)
|
83
|
+
# pp variants.first.content
|
84
|
+
# # => "Bonjour"
|
85
|
+
def self.variants(client, dynamic_content)
|
86
|
+
DynamicContentVariants.list(client, dynamic_content)
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Locates a dynamic content item within Zendesk. This will not exit on error (except Authentication errors)
|
91
|
+
#
|
92
|
+
# @author Jason Colyer
|
93
|
+
# @since 1.0.73
|
94
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
95
|
+
# @param did [Integer] The dynamic content item ID to find
|
96
|
+
# @return [Hash]
|
97
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#show-item Zendesk API > Dynmaic Content Items > Show item
|
98
|
+
# @example
|
99
|
+
# require 'support_readiness'
|
100
|
+
# config = Readiness::Zendesk::Configuration.new
|
101
|
+
# config.username = 'alice@example.com'
|
102
|
+
# config.token = 'test123abc'
|
103
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
104
|
+
# client = Readiness::Zendesk::Client.new(config)
|
105
|
+
# content = Readiness::Zendesk::DynamicContent.find(client, 25)
|
106
|
+
# pp content.placeholder
|
107
|
+
# # => "{dc.subject}"
|
108
|
+
def self.find(client, did)
|
109
|
+
response = client.connection.get("dynamic_content/items/#{did}")
|
110
|
+
handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: did }) unless response.status == 200
|
111
|
+
return DynamicContent.new(Oj.load(response.body)['item']) if response.status == 200
|
112
|
+
|
113
|
+
Oj.load(response.body)
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Locates a dynamic content item within Zendesk. This will exit on error
|
118
|
+
#
|
119
|
+
# @author Jason Colyer
|
120
|
+
# @since 1.0.73
|
121
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
122
|
+
# @param did [Integer] The dynamic content item ID to find
|
123
|
+
# @return [Hash]
|
124
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#show-item Zendesk API > Dynmaic Content Items > Show item
|
125
|
+
# @example
|
126
|
+
# require 'support_readiness'
|
127
|
+
# config = Readiness::Zendesk::Configuration.new
|
128
|
+
# config.username = 'alice@example.com'
|
129
|
+
# config.token = 'test123abc'
|
130
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
131
|
+
# client = Readiness::Zendesk::Client.new(config)
|
132
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 25)
|
133
|
+
# pp content.placeholder
|
134
|
+
# # => "{dc.subject}"
|
135
|
+
def self.find!(client, did)
|
136
|
+
response = client.connection.get("dynamic_content/items/#{did}")
|
137
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Find dynamic content', id: did }) unless response.status == 200
|
138
|
+
DynamicContent.new(Oj.load(response.body)['item'])
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# Creates a dynamic content item within Zendesk. Will exit if unsuccessful
|
143
|
+
#
|
144
|
+
# @author Jason Colyer
|
145
|
+
# @since 1.0.73
|
146
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
147
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
148
|
+
# @param variants [Array] An array of {Readiness::Zendesk::DynamicContentVariants} instances
|
149
|
+
# @return [Object]
|
150
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#create-item Zendesk API > Dynmaic Content Items > Create item
|
151
|
+
# @example
|
152
|
+
# require 'support_readiness'
|
153
|
+
# config = Readiness::Zendesk::Configuration.new
|
154
|
+
# config.username = 'alice@example.com'
|
155
|
+
# config.token = 'test123abc'
|
156
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
157
|
+
# client = Readiness::Zendesk::Client.new(config)
|
158
|
+
# content = Readiness::Zendesk::DynamicContent.new
|
159
|
+
# content.default_locale_id = 1
|
160
|
+
# content.name = 'Hello'
|
161
|
+
# variant = Readiness::Zendesk::DyanmicContentVariants.new
|
162
|
+
# variant.content = 'Hello'
|
163
|
+
# variant.default = true
|
164
|
+
# variant.locale_id = 1
|
165
|
+
# create = Readiness::Zendesk::DynamicContent.create!(client, content, [variant])
|
166
|
+
# pp create.id
|
167
|
+
# # => 8
|
168
|
+
def self.create!(client, dynamic_content, variants)
|
169
|
+
object = to_hash(dynamic_content).compact
|
170
|
+
object['variants'] = variants.map { |t| to_hash(t).compact }
|
171
|
+
response = client.connection.post 'dynamic_content/items', { item: object }.to_json
|
172
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Create dynamic content', message: Oj.load(response.body)}) unless response.status == 201
|
173
|
+
DynamicContent.new(Oj.load(response.body)['item'])
|
174
|
+
end
|
175
|
+
|
176
|
+
##
|
177
|
+
# Updates a dynamic content item within Zendesk. Will exit if unsuccessful
|
178
|
+
#
|
179
|
+
# @author Jason Colyer
|
180
|
+
# @since 1.0.73
|
181
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
182
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
183
|
+
# @return [Object]
|
184
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#update-item Zendesk API > Dynmaic Content Items > Update item
|
185
|
+
# @example
|
186
|
+
# require 'support_readiness'
|
187
|
+
# config = Readiness::Zendesk::Configuration.new
|
188
|
+
# config.username = 'alice@example.com'
|
189
|
+
# config.token = 'test123abc'
|
190
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
191
|
+
# client = Readiness::Zendesk::Client.new(config)
|
192
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
193
|
+
# content.name = 'Hello 2'
|
194
|
+
# update = Readiness::Zendesk::DynamicContent.update!(client, content)
|
195
|
+
# pp create.name
|
196
|
+
# # => "Hello 2"
|
197
|
+
def self.update!(client, dynamic_content)
|
198
|
+
response = client.connection.put "dynamic_content/items/#{dynamic_content.id}", to_clean_json_with_key(dynamic_content, 'item')
|
199
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Update dynamic content', id: dynamic_content.id, message: Oj.load(response.body)}) unless response.status == 200
|
200
|
+
DynamicContent.new(Oj.load(response.body)['item'])
|
201
|
+
end
|
202
|
+
|
203
|
+
##
|
204
|
+
# Deletes a dynamic content item within Zendesk. Will exit if unsuccessful
|
205
|
+
#
|
206
|
+
# @author Jason Colyer
|
207
|
+
# @since 1.0.73
|
208
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
209
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
210
|
+
# @return [Boolean]
|
211
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#delete-item Zendesk API > Dynmaic Content Items > Delete item
|
212
|
+
# @example
|
213
|
+
# require 'support_readiness'
|
214
|
+
# config = Readiness::Zendesk::Configuration.new
|
215
|
+
# config.username = 'alice@example.com'
|
216
|
+
# config.token = 'test123abc'
|
217
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
218
|
+
# client = Readiness::Zendesk::Client.new(config)
|
219
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
220
|
+
# delete = Readiness::Zendesk::DynamicContent.delete!(client, content)
|
221
|
+
# pp delete
|
222
|
+
# # => true
|
223
|
+
def self.delete!(client, dynamic_content)
|
224
|
+
response = client.connection.delete "dynamic_content/items/#{dynamic_content.id}"
|
225
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Delete a dynamic content', id: dynamic_content.id, message: Oj.load(response.body)}) unless response.status == 204
|
226
|
+
true
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,273 @@
|
|
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 DynamicContentVariants within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.73
|
12
|
+
class DynamicContentVariants < Readiness::Client
|
13
|
+
attr_accessor :active, :content, :default, :id, :locale_id, :outdated
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Zendesk::DynamicContentVariants} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.73
|
20
|
+
# @param object [Object] An instance of {Readiness::Zendesk::DynamicContentVariants}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Zendesk::DynamicContentVariants.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@active = object['active']
|
26
|
+
@content = object['content']
|
27
|
+
@default = object['default']
|
28
|
+
@id = object['id']
|
29
|
+
@locale_id = object['locale_id']
|
30
|
+
@outdated = object['outdated']
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Lists dynamic content variants.
|
35
|
+
#
|
36
|
+
# @author Jason Colyer
|
37
|
+
# @since 1.0.73
|
38
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
39
|
+
# @return [Array]
|
40
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content/#list-items Zendesk API > Dynamic Content Items > List items
|
41
|
+
# @example
|
42
|
+
# require 'support_readiness'
|
43
|
+
# config = Readiness::Zendesk::Configuration.new
|
44
|
+
# config.username = 'alice@example.com'
|
45
|
+
# config.token = 'test123abc'
|
46
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
47
|
+
# client = Readiness::Zendesk::Client.new(config)
|
48
|
+
# items = Readiness::Zendesk::DynamicContent.list(client)
|
49
|
+
# pp items.first.id
|
50
|
+
# # => 47
|
51
|
+
def self.list(client, dynamic_content)
|
52
|
+
response = client.connection.get("dynamic_content/items/#{dynamic_content.id}/variants")
|
53
|
+
handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
|
54
|
+
body = Oj.load(response.body)
|
55
|
+
body['variants'].map { |v| DynamicContentVariants.new(v) }
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Locates a dynamic content item variant within Zendesk. This will not exit on error (except Authentication errors)
|
60
|
+
#
|
61
|
+
# @author Jason Colyer
|
62
|
+
# @since 1.0.73
|
63
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
64
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DynamicContent}
|
65
|
+
# @param vid [Integer] The ID of the dynamnic content variant
|
66
|
+
# @return [Hash]
|
67
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content_item_variants/#show-variant Zendesk API > Dynmaic Content Item Variants > Show variant
|
68
|
+
# @example
|
69
|
+
# require 'support_readiness'
|
70
|
+
# config = Readiness::Zendesk::Configuration.new
|
71
|
+
# config.username = 'alice@example.com'
|
72
|
+
# config.token = 'test123abc'
|
73
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
74
|
+
# client = Readiness::Zendesk::Client.new(config)
|
75
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
76
|
+
# variant = Readiness::Zendesk::DynamicContentVariants.find(client, content, 123456)
|
77
|
+
# pp variant.content
|
78
|
+
# # => "Bonjour"
|
79
|
+
def self.find(client, dynamic_content, vid)
|
80
|
+
response = client.connection.get("dynamic_content/items/#{dynamic_content.id}/variants/#{vid}")
|
81
|
+
handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: vid }) unless response.status == 200
|
82
|
+
return DynamicContentVariants.new(Oj.load(response.body)['variant']) if response.status == 200
|
83
|
+
|
84
|
+
Oj.load(response.body)
|
85
|
+
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# Locates a dynamic content item variant within Zendesk. This will exit on error
|
89
|
+
#
|
90
|
+
# @author Jason Colyer
|
91
|
+
# @since 1.0.73
|
92
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
93
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DynamicContent}
|
94
|
+
# @param vid [Integer] The ID of the dynamnic content variant
|
95
|
+
# @return [Hash]
|
96
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content_item_variants/#show-variant Zendesk API > Dynmaic Content Item Variants > Show variant
|
97
|
+
# @example
|
98
|
+
# require 'support_readiness'
|
99
|
+
# config = Readiness::Zendesk::Configuration.new
|
100
|
+
# config.username = 'alice@example.com'
|
101
|
+
# config.token = 'test123abc'
|
102
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
103
|
+
# client = Readiness::Zendesk::Client.new(config)
|
104
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
105
|
+
# variant = Readiness::Zendesk::DynamicContentVariants.find!(client, content, 123456)
|
106
|
+
# pp variant.content
|
107
|
+
# # => "Bonjour"
|
108
|
+
def self.find!(client, dynamic_content, vid)
|
109
|
+
response = client.connection.get("dynamic_content/items/#{dynamic_content.id}/variants/#{vid}")
|
110
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Find dynamic content variant', id: vid }) unless response.status == 200
|
111
|
+
DynamicContentVariants.new(Oj.load(response.body)['variant'])
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Creates a dynamic content item variant within Zendesk. Will exit if unsuccessful
|
116
|
+
#
|
117
|
+
# @author Jason Colyer
|
118
|
+
# @since 1.0.73
|
119
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
120
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
121
|
+
# @param variant [Object] An instance of {Readiness::Zendesk::DynamicContentVariants}
|
122
|
+
# @return [Object]
|
123
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content_item_variants/#create-variant Zendesk API > Dynmaic Content Item Vatiants > Create variant
|
124
|
+
# @example
|
125
|
+
# require 'support_readiness'
|
126
|
+
# config = Readiness::Zendesk::Configuration.new
|
127
|
+
# config.username = 'alice@example.com'
|
128
|
+
# config.token = 'test123abc'
|
129
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
130
|
+
# client = Readiness::Zendesk::Client.new(config)
|
131
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
132
|
+
# variant = Readiness::Zendesk::DyanmicContentVariants.new
|
133
|
+
# variant.content = 'Ciao'
|
134
|
+
# variant.default = true
|
135
|
+
# variant.locale_id = 26
|
136
|
+
# create = Readiness::Zendesk::DynamicContentVariants.create!(client, content, variant)
|
137
|
+
# pp create.id
|
138
|
+
# # => 123456
|
139
|
+
def self.create!(client, dynamic_content, variant)
|
140
|
+
response = client.connection.post "dynamic_content/items/#{dynamic_content.id}/variants/", to_clean_json_with_key(variant, 'variant')
|
141
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Create variant', message: Oj.load(response.body)}) unless response.status == 201
|
142
|
+
DynamicContentVariants.new(Oj.load(response.body)['variant'])
|
143
|
+
end
|
144
|
+
|
145
|
+
##
|
146
|
+
# Creates many dynamic content item variant within Zendesk. Will exit if unsuccessful
|
147
|
+
#
|
148
|
+
# @author Jason Colyer
|
149
|
+
# @since 1.0.73
|
150
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
151
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
152
|
+
# @param variants [Array] An array of {Readiness::Zendesk::DynamicContentVariants} instances
|
153
|
+
# @return [Object]
|
154
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content_item_variants/#create-many-variants Zendesk API > Dynmaic Content Item Vatiants > Create many variant
|
155
|
+
# @example
|
156
|
+
# require 'support_readiness'
|
157
|
+
# config = Readiness::Zendesk::Configuration.new
|
158
|
+
# config.username = 'alice@example.com'
|
159
|
+
# config.token = 'test123abc'
|
160
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
161
|
+
# client = Readiness::Zendesk::Client.new(config)
|
162
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
163
|
+
# variant1 = Readiness::Zendesk::DyanmicContentVariants.new
|
164
|
+
# variant1.content = 'Ciao'
|
165
|
+
# variant1.default = false
|
166
|
+
# variant1.locale_id = 26
|
167
|
+
# variant2 = Readiness::Zendesk::DyanmicContentVariants.new
|
168
|
+
# variant2.content = 'Bonjour'
|
169
|
+
# variant2.default = false
|
170
|
+
# variant2.locale_id = 27
|
171
|
+
# creates = Readiness::Zendesk::DynamicContentVariants.create_many!(client, content, [variant1, variant2])
|
172
|
+
# pp creates.map { |c| c.id }
|
173
|
+
# # => [123455, 123456]
|
174
|
+
def self.create_many!(client, dynamic_content, variants)
|
175
|
+
data = { variants: variants.map { |t| to_hash(t).compact } }.to_json
|
176
|
+
response = client.connection.put("dynamic_content/items/#{dynamic_content.id}/variants/create_many", data)
|
177
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Create many variants', message: Oj.load(response.body)}) unless response.status == 201
|
178
|
+
Oj.load(response.body)['variants'].map { |v| DynamicContentVariants.new(v) }
|
179
|
+
end
|
180
|
+
|
181
|
+
##
|
182
|
+
# Updates a dynamic content item variant within Zendesk. Will exit if unsuccessful
|
183
|
+
#
|
184
|
+
# @author Jason Colyer
|
185
|
+
# @since 1.0.73
|
186
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
187
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
188
|
+
# @param variant [Object] An instance of {Readiness::Zendesk::DynamicContentVariants}
|
189
|
+
# @return [Object]
|
190
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content_item_variants/#update-variant Zendesk API > Dynmaic Content Item Variants > Update variant
|
191
|
+
# @example
|
192
|
+
# require 'support_readiness'
|
193
|
+
# config = Readiness::Zendesk::Configuration.new
|
194
|
+
# config.username = 'alice@example.com'
|
195
|
+
# config.token = 'test123abc'
|
196
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
197
|
+
# client = Readiness::Zendesk::Client.new(config)
|
198
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
199
|
+
# variant = Readiness::Zendesk::DyanmicContentVariants.find!(client, 123456)
|
200
|
+
# variant.content = 'Ciao!'
|
201
|
+
# variant.default = true
|
202
|
+
# variant.locale_id = 26
|
203
|
+
# update = Readiness::Zendesk::DynamicContentVariants.update!(client, content, variant)
|
204
|
+
# pp update.content
|
205
|
+
# # => "Ciao!"
|
206
|
+
def self.update!(client, dynamic_content, variant)
|
207
|
+
response = client.connection.put "dynamic_content/items/#{dynamic_content.id}/variants/#{variant.id}", to_clean_json_with_key(variant, 'variant')
|
208
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Update dynamic content variant', id: variant.id, message: Oj.load(response.body)}) unless response.status == 200
|
209
|
+
DynamicContentVariants.new(Oj.load(response.body)['variant'])
|
210
|
+
end
|
211
|
+
|
212
|
+
##
|
213
|
+
# Updates amanydynamic content item variants within Zendesk. Will exit if unsuccessful
|
214
|
+
#
|
215
|
+
# @author Jason Colyer
|
216
|
+
# @since 1.0.73
|
217
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
218
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
219
|
+
# @param variants [Array] An array of {Readiness::Zendesk::DynamicContentVariants} instances
|
220
|
+
# @return [Array]
|
221
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content_item_variants/#update-many-variants Zendesk API > Dynmaic Content Item Variants > Update many variant
|
222
|
+
# @example
|
223
|
+
# require 'support_readiness'
|
224
|
+
# config = Readiness::Zendesk::Configuration.new
|
225
|
+
# config.username = 'alice@example.com'
|
226
|
+
# config.token = 'test123abc'
|
227
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
228
|
+
# client = Readiness::Zendesk::Client.new(config)
|
229
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
230
|
+
# variant1 = Readiness::Zendesk::DyanmicContentVariants.find!(client, 123456)
|
231
|
+
# variant1.content = 'Ciao!'
|
232
|
+
# variant2 = Readiness::Zendesk::DyanmicContentVariants.find!(client, 123455)
|
233
|
+
# variant2.content = 'Bonjour!'
|
234
|
+
# updates = Readiness::Zendesk::DynamicContentVariants.update_many!(client, content, [variant1, variant2])
|
235
|
+
# pp updates.map { u| u.content }
|
236
|
+
# # => ["Ciao!", "Bonjour!"]
|
237
|
+
def self.update_many!(client, dynamic_content, variants)
|
238
|
+
data = { variants: variants.map { |t| to_hash(t).compact } }.to_json
|
239
|
+
response = client.connection.put("dynamic_content/items/#{dynamic_content.id}/variants/update_many", data)
|
240
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Update many variants', message: Oj.load(response.body)}) unless response.status == 200
|
241
|
+
Oj.load(response.body)['variants'].map { |v| DynamicContentVariants.new(v) }
|
242
|
+
end
|
243
|
+
|
244
|
+
##
|
245
|
+
# Deletes a dynamic content item variant within Zendesk. Will exit if unsuccessful
|
246
|
+
#
|
247
|
+
# @author Jason Colyer
|
248
|
+
# @since 1.0.73
|
249
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
250
|
+
# @param dynamic_content [Object] An instance of {Readiness::Zendesk::DyanmicContent}
|
251
|
+
# @param variant [Object] An instance of {Readiness::Zendesk::DynamicContentVariants}
|
252
|
+
# @return [Boolean]
|
253
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/dynamic_content_item_variants/#delete-variant Zendesk API > Dynmaic Content Item Variantss > Delete variant
|
254
|
+
# @example
|
255
|
+
# require 'support_readiness'
|
256
|
+
# config = Readiness::Zendesk::Configuration.new
|
257
|
+
# config.username = 'alice@example.com'
|
258
|
+
# config.token = 'test123abc'
|
259
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
260
|
+
# client = Readiness::Zendesk::Client.new(config)
|
261
|
+
# content = Readiness::Zendesk::DynamicContent.find!(client, 8)
|
262
|
+
# variant = Readiness::Zendesk::DynamicContentVariants.find!(client, content, 123456)
|
263
|
+
# delete = Readiness::Zendesk::DynamicContentVariants.delete!(client, content, variant)
|
264
|
+
# pp delete
|
265
|
+
# # => true
|
266
|
+
def self.delete!(client, dynamic_content, variant)
|
267
|
+
response = client.connection.delete "dynamic_content/items/#{dynamic_content.id}/variants/#{variant.id}"
|
268
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Delete a dynamic content variant', id: variant.id, message: Oj.load(response.body)}) unless response.status == 204
|
269
|
+
true
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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 Locales within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.73
|
12
|
+
class Locales < Readiness::Client
|
13
|
+
attr_accessor :id, :locale, :name
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Zendesk::Locales} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.73
|
20
|
+
# @param object [Object] An instance of {Readiness::Zendesk::Locales}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Zendesk::Locales.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@id = object['id']
|
26
|
+
@locale = object['locale']
|
27
|
+
@name = object['name']
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Lists locales.
|
32
|
+
#
|
33
|
+
# @author Jason Colyer
|
34
|
+
# @since 1.0.73
|
35
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
36
|
+
# @return [Array]
|
37
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/account-configuration/locales/#list-locales Zendesk API > Locales > List locales
|
38
|
+
# @example
|
39
|
+
# require 'support_readiness'
|
40
|
+
# config = Readiness::Zendesk::Configuration.new
|
41
|
+
# config.username = 'alice@example.com'
|
42
|
+
# config.token = 'test123abc'
|
43
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
44
|
+
# client = Readiness::Zendesk::Client.new(config)
|
45
|
+
# items = Readiness::Zendesk::Locales.list(client)
|
46
|
+
# pp items.first.locale
|
47
|
+
# # => "en-US"
|
48
|
+
def self.list(client)
|
49
|
+
response = client.connection.get('locales')
|
50
|
+
handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
|
51
|
+
body = Oj.load(response.body)
|
52
|
+
body['locales'].map { |l| Locales.new(l) }
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Locates a locale within Zendesk. This will exit on error
|
57
|
+
#
|
58
|
+
# @author Jason Colyer
|
59
|
+
# @since 1.0.73
|
60
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
61
|
+
# @param lid [Integer] The locale ID to find
|
62
|
+
# @return [Object] An instance of {Readiness::Zendesk::Locales}
|
63
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/account-configuration/locales/#show-locale Zendesk API > Locales > Show locale
|
64
|
+
# @example
|
65
|
+
# require 'support_readiness'
|
66
|
+
# config = Readiness::Zendesk::Configuration.new
|
67
|
+
# config.username = 'alice@example.com'
|
68
|
+
# config.token = 'test123abc'
|
69
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
70
|
+
# client = Readiness::Zendesk::Client.new(config)
|
71
|
+
# locale = Readiness::Zendesk::Locales.find!(client, 8)
|
72
|
+
# pp automation.name
|
73
|
+
# # => "Deutsch"
|
74
|
+
def self.find!(client, lid)
|
75
|
+
response = client.connection.get("locales/#{lid}")
|
76
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Find locale', id: lid }) unless response.status == 200
|
77
|
+
Locales.new(Oj.load(response.body)['locale'])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -13,9 +13,12 @@ module Readiness
|
|
13
13
|
require "#{__dir__}/zendesk/automations"
|
14
14
|
require "#{__dir__}/zendesk/client"
|
15
15
|
require "#{__dir__}/zendesk/configuration"
|
16
|
+
require "#{__dir__}/zendesk/dynamic_content"
|
17
|
+
require "#{__dir__}/zendesk/dynamic_content_variants"
|
16
18
|
require "#{__dir__}/zendesk/group_memberships"
|
17
19
|
require "#{__dir__}/zendesk/groups"
|
18
20
|
require "#{__dir__}/zendesk/job_statuses"
|
21
|
+
require "#{__dir__}/zendesk/locales"
|
19
22
|
require "#{__dir__}/zendesk/macros"
|
20
23
|
require "#{__dir__}/zendesk/organization_fields"
|
21
24
|
require "#{__dir__}/zendesk/organization_memberships"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab_support_readiness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.73
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Colyer
|
@@ -389,9 +389,12 @@ files:
|
|
389
389
|
- lib/support_readiness/zendesk/automations.rb
|
390
390
|
- lib/support_readiness/zendesk/client.rb
|
391
391
|
- lib/support_readiness/zendesk/configuration.rb
|
392
|
+
- lib/support_readiness/zendesk/dynamic_content.rb
|
393
|
+
- lib/support_readiness/zendesk/dynamic_content_variants.rb
|
392
394
|
- lib/support_readiness/zendesk/group_memberships.rb
|
393
395
|
- lib/support_readiness/zendesk/groups.rb
|
394
396
|
- lib/support_readiness/zendesk/job_statuses.rb
|
397
|
+
- lib/support_readiness/zendesk/locales.rb
|
395
398
|
- lib/support_readiness/zendesk/macros.rb
|
396
399
|
- lib/support_readiness/zendesk/organization_fields.rb
|
397
400
|
- lib/support_readiness/zendesk/organization_memberships.rb
|