gitlab_support_readiness 1.0.9 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b6172a8a41b139003edf771fe377bd8910f12d41c27d54456290c114cae08cb
4
- data.tar.gz: 568efc6d2b6cd4bd7c014787a70cce19927415b14944ed4e4bb7dac4f682b03a
3
+ metadata.gz: 7b80e496307fbfaa496e95ca2af86a765ec8264d08cd70c5dde730305c597d2e
4
+ data.tar.gz: 0c1b9bf16c261245a4c8d8928d581bfe08d7b8e5dde42cee7fc55129233b42c4
5
5
  SHA512:
6
- metadata.gz: 50e8b47c5a5eb3cc7b3e537c4d64c30ebc5f1461c1586b7890ca97b20783d285a8c060cf4c35dac4ad9a76e75b6645f8b1498e42c3162ca71f2d96197b4b3acb
7
- data.tar.gz: 502bee0ca7781bd1469a7551f0a40239f940e7619b083e8c148b6e81f2ba58c277d6adf8ce18f35465864df2ce16e465e93f14ede1d6b367c882c38f14a18e90
6
+ metadata.gz: 9d38234f4a29dc2965e3544eb4e8f75830992cde999619b655ea1941c63255e1debb8aacccc841d92ecf6580a8ea2faf2d2c7edfbb9064df40fa5cd88c333977
7
+ data.tar.gz: 7419e41c9dbbe22058e0e567dc79b26c5408b3d4766e9d618dc3dfbd494f6b6619cf1d6a312c14dbd2df852c230098b75cbb76161c0f03b586638505e20a107d
@@ -271,7 +271,7 @@ module Readiness
271
271
  array = []
272
272
  page = 0
273
273
  loop do
274
- response = client.connection.get "projects/#{project.id}/issues/#{issues.iid}/notes?per_page=100&page=#{page}"
274
+ response = client.connection.get "projects/#{project.id}/issues/#{issue.iid}/notes?per_page=100&page=#{page}"
275
275
  handle_request_error(0, 'GitLab', response.status) unless response.status == 200
276
276
  body = Oj.load(response.body)
277
277
  array += body
@@ -190,7 +190,7 @@ module Readiness
190
190
  # pp file
191
191
  # # => true
192
192
  def self.delete_file!(client, project, path, params)
193
- response = client.connection.delete "projects/#{project.id}/repository/files/#{CGI.escape(path)}", params.to_json
193
+ response = client.connection.delete "projects/#{project.id}/repository/files/#{CGI.escape(path)}", params
194
194
  handle_request_error(1, 'GitLab', response.status, { action: 'Delete file in repo', id: "#{project.id}" }) unless response.status == 204
195
195
  true
196
196
  end
@@ -156,7 +156,7 @@ module Readiness
156
156
  end
157
157
 
158
158
  ##
159
- # Updates an article. Will exit if unsuccessful
159
+ # Updates an article (both metadata and translation). Will exit if unsuccessful
160
160
  #
161
161
  # @author Jason Colyer
162
162
  # @since 1.0.0
@@ -177,11 +177,65 @@ module Readiness
177
177
  # pp update.body
178
178
  # # => "Use a tripod and low light approved camera"
179
179
  def self.update!(client, article)
180
+ update_article_metadata!(client, article)
181
+ update_article_translation!(client, article)
182
+ Articles.find!(client, article.id)
183
+ end
184
+
185
+ ##
186
+ # Updates an article's metadata. Will exit if unsuccessful
187
+ #
188
+ # @author Jason Colyer
189
+ # @since 1.0.10
190
+ # @param client [Object] An instance of {Readiness::Zendesk::Client}
191
+ # @param article [Object] An instance of {Readiness::Zendesk::Articles}
192
+ # @return [Object] An instance of {Readiness::Zendesk::Articles}
193
+ # @see https://developer.zendesk.com/api-reference/help_center/help-center-api/articles/#update-article Zendesk API > Articles > Update Article
194
+ # @example
195
+ # require 'support_readiness'
196
+ # config = Readiness::Zendesk::Configuration.new
197
+ # config.username = 'alice@example.com'
198
+ # config.token = 'test123abc'
199
+ # config.url = 'https://example.zendesk.com/api/v2'
200
+ # client = Readiness::Zendesk::Client.new(config)
201
+ # article = Readiness::Zendesk::Articles.find!(client, 35468)
202
+ # artricle.promoted = true
203
+ # update = Readiness::Zendesk::Articles.update_article_metadata!(client, article)
204
+ # pp update.promoted
205
+ # # => true
206
+ def self.update_article_metadata!(client, article)
180
207
  response = client.connection.put "help_center/articles/#{article.id}", to_nearly_clean_json_with_key(article, 'article', ['user_segment_id'])
181
- handle_request_error(1, 'Zendesk', response.status, { action: 'Update article', id: article.id, message: Oj.load(response.body)}) unless response.status == 200
208
+ handle_request_error(1, 'Zendesk', response.status, { action: 'Update article metadata', id: article.id, message: Oj.load(response.body)}) unless response.status == 200
182
209
  Articles.new(Oj.load(response.body)['article'])
183
210
  end
184
211
 
212
+ ##
213
+ # Updates an article's translation. Will exit if unsuccessful
214
+ #
215
+ # @author Jason Colyer
216
+ # @since 1.0.10
217
+ # @param client [Object] An instance of {Readiness::Zendesk::Client}
218
+ # @param article [Object] An instance of {Readiness::Zendesk::Articles}
219
+ # @return [Object] An instance of {Readiness::Zendesk::Articles}
220
+ # @see https://developer.zendesk.com/api-reference/help_center/help-center-api/translations/#update-translation Zendesk API > Translations > Update Translation
221
+ # @example
222
+ # require 'support_readiness'
223
+ # config = Readiness::Zendesk::Configuration.new
224
+ # config.username = 'alice@example.com'
225
+ # config.token = 'test123abc'
226
+ # config.url = 'https://example.zendesk.com/api/v2'
227
+ # client = Readiness::Zendesk::Client.new(config)
228
+ # article = Readiness::Zendesk::Articles.find!(client, 35468)
229
+ # artricle.body = 'Contact support'
230
+ # update = Readiness::Zendesk::Articles.update_article_translation!(client, article)
231
+ # pp update.body
232
+ # # => "Contact support"
233
+ def self.update_article_translation!(client, article)
234
+ response = client.connection.put "help_center/articles/#{article.id}/translations/#{article.locale}", to_nearly_clean_json_with_key(article, 'translation', ['user_segment_id'])
235
+ handle_request_error(1, 'Zendesk', response.status, { action: 'Update article translation', id: article.id, message: Oj.load(response.body)}) unless response.status == 200
236
+ Oj.load(response.body)['translation']
237
+ end
238
+
185
239
  ##
186
240
  # Archives an article. Will exit if unsuccessful
187
241
  #
@@ -248,7 +248,7 @@ module Readiness
248
248
  # deletes = Readiness::Zendesk::Macros.delete_many!(client, [25, 26])
249
249
  # pp deletes
250
250
  # # => true
251
- def self.delete_many(client, mids)
251
+ def self.delete_many!(client, mids)
252
252
  response = client.connection.delete("macros/destroy_many?ids=#{mids.join(',')}")
253
253
  handle_request_error(1, 'Zendesk', response.status, { action: 'Delete many macros', message: Oj.load(response.body)}) unless response.status == 204
254
254
  true
@@ -478,7 +478,7 @@ module Readiness
478
478
  # @param client [Object] An instance of {Readiness::Zendesk::Client}
479
479
  # @param tid [Integer] The deleted ticket's ID
480
480
  # @return [Object] A {Readiness::Zendesk::JobStatuses} instance
481
- # @see https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket-permanentlyt Zendesk API > Tickets > Delete Ticket Permanently
481
+ # @see https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket-permanently Zendesk API > Tickets > Delete Ticket Permanently
482
482
  # @example
483
483
  # require 'support_readiness'
484
484
  # config = Readiness::Zendesk::Configuration.new
@@ -517,7 +517,7 @@ module Readiness
517
517
  # # => [33, 34]
518
518
  def self.incidents(client, ticket)
519
519
  array = []
520
- opts = "page[size]=100&sort=#{sort}"
520
+ opts = "page[size]=100"
521
521
  loop do
522
522
  response = client.connection.get("tickets/#{ticket.id}/incidents?#{opts}")
523
523
  handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
@@ -550,9 +550,9 @@ module Readiness
550
550
  # # => [33, 34]
551
551
  def self.problems(client)
552
552
  array = []
553
- opts = "page[size]=100&sort=#{sort}"
553
+ opts = "page[size]=100"
554
554
  loop do
555
- response = client.connection.get("tickets/problems?#{opts}")
555
+ response = client.connection.get("problems?#{opts}")
556
556
  handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
557
557
  body = Oj.load(response.body)
558
558
  array += body['tickets'].map { |t| Tickets.new(t) }
@@ -734,7 +734,7 @@ module Readiness
734
734
  # # => 18
735
735
  def self.list_suspended(client)
736
736
  array = []
737
- opts = "page[size]=100&sort=#{sort}"
737
+ opts = "page[size]=100"
738
738
  loop do
739
739
  response = client.connection.get("suspended_tickets?#{opts}")
740
740
  handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
@@ -827,7 +827,6 @@ module Readiness
827
827
  handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
828
828
  body = Oj.load(response.body)
829
829
  array += body['organization_memberships'].map { |o| OrganizationMemberships.new(o) }
830
- break if limit != 0 && array.count >= (limit * 100)
831
830
  break unless body['meta']['has_more']
832
831
 
833
832
  opts = body['links'] ['next'].split('?').last
@@ -336,12 +336,10 @@ module Readiness
336
336
  def self.preview!(client, view)
337
337
  converted = create_or_update_object(view)
338
338
  data = {
339
- view: {
340
- all: converted['all'],
341
- any: converted['any'],
342
- output: converted['output']
343
- }
344
- }.compact.to_json
339
+ all: converted[:all],
340
+ any: converted[:any],
341
+ output: converted[:output]
342
+ }.compact
345
343
  response = client.connection.post 'views/preview', { view: data }.to_json
346
344
  handle_request_error(1, 'Zendesk', response.status, { action: 'Preview a view', message: Oj.load(response.body)}) unless response.status == 200
347
345
  Oj.load(response.body)
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.9
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Colyer