gitlab_support_readiness 1.0.116 → 1.0.118

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e23c1f8ff61d3f65049356c43811a965f9bbe12adcf59521f7a791fe6ca1c41d
4
- data.tar.gz: 7f955a7330e1206f7da3daaf55d16a1e39ecf0f6283e92520a209da187b2022f
3
+ metadata.gz: 9f0bcf366ba1eb4cf4cb4db3bd2c12f1813d2cfcb1354e270f4ad06e4597bfe5
4
+ data.tar.gz: 3fb6cafe83120494ba4dae58e319ef2f76631ec3160ea119dfd42d75bd4f21aa
5
5
  SHA512:
6
- metadata.gz: 5e7650d5e50d31d9f330aab54d5d8892ff2fbc356aaa32b32a4eec158eb75f91fe6b5494533948b4ab96862722c68e3f90c4220c38eb5e8f69673670cc798f87
7
- data.tar.gz: f83d87bd5ce911651308c694b2ccddd9453fcfb5b6bfa11976aee4fd46e4a4287b37c0b61ab51edc6008a433adea8640b32ad689ef7f008e7731ee9bf63419fd
6
+ metadata.gz: d660ad4f9ec5cc6d97a44dd816a53784f8a786bde8c7a53cbe69f9d0d009784c2315544ff38ade8fb7f3aa5fdbdbe52604f2ff9a5ca2e6b1ac84501e52e1f0b6
7
+ data.tar.gz: 825c5a0c2e0cc70024f0991a9ca5fcc2ce65602c226b662a2a4aeb449a49c25e61d4dbcfe0f443bc361bf328d4fb1d547a5eee73fde23c236a728eac40b71622
@@ -403,5 +403,118 @@ module Readiness
403
403
  end
404
404
  object
405
405
  end
406
+
407
+ ##
408
+ # Convert user friendly Strings into Zendesk values for view objects
409
+ #
410
+ # @author Jason Colyer
411
+ # @since 1.0.117
412
+ # @param object [Object] The object to parse
413
+ def self.convert_view_names_to_ids(object)
414
+ new_object = convert_conditions(object)
415
+ convert_view_restrictions(new_object)
416
+ end
417
+
418
+ ##
419
+ # Convert user friendly Strings within restrictions into Zendesk values for view objects
420
+ #
421
+ # @author Jason Colyer
422
+ # @since 1.0.117
423
+ # @param object [Object] The object to parse
424
+ def self.convert_view_restrictions(object)
425
+ return object if object['restriction'].nil?
426
+
427
+ if object['restriction']['type'] == 'Group'
428
+ group = Readiness::Zendesk::Groups.find_by_name(@zendesk_client, object['restriction']['id'], @groups)
429
+ object['restriction']['id'] = group.id unless group.nil?
430
+ object['restriction']['ids'] = object['restriction']['ids'].map do |i|
431
+ group = Readiness::Zendesk::Groups.find_by_name(@zendesk_client, i, @groups)
432
+ group.nil? ? i : group.id
433
+ end
434
+ elsif object['restriction']['type'] == 'User'
435
+ search = Readiness::Zendesk::Search.users(@zendesk_client, "email:#{object['restriction']['id']}")
436
+ if search.count == 1
437
+ object['restriction']['id'] = search.first.id
438
+ end
439
+ end
440
+ object
441
+ end
442
+
443
+ ##
444
+ # Convert user friendly Strings into Zendesk values for ticket form objects
445
+ #
446
+ # @author Jason Colyer
447
+ # @since 1.0.118
448
+ # @param object [Object] The object to parse
449
+ def self.convert_ticket_form_names_to_ids(object)
450
+ new_object = covert_ticket_form_field_ids(object)
451
+ new_object = convert_ticket_form_end_user_conditions(new_object)
452
+ new_object = convert_ticket_form_agent_conditions(new_object)
453
+ convert_ticket_form_brands(new_object)
454
+ end
455
+
456
+ ##
457
+ # Convert user friendly Strings into Zendesk values for ticket form field IDs
458
+ #
459
+ # @author Jason Colyer
460
+ # @since 1.0.118
461
+ # @param object [Object] The ticket form to parse
462
+ def self.covert_ticket_form_field_ids(object)
463
+ object['ticket_field_ids'] = object['ticket_field_ids'].map do |f|
464
+ field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, f, @ticket_fields)
465
+ field.nil? ? f : field.id
466
+ end
467
+ object
468
+ end
469
+
470
+ ##
471
+ # Convert user friendly Strings into Zendesk values for ticket form end_user conditions
472
+ #
473
+ # @author Jason Colyer
474
+ # @since 1.0.118
475
+ # @param object [Object] The ticket form to parse
476
+ def self.convert_ticket_form_end_user_conditions(object)
477
+ object['end_user_conditions'].each_with_index do |c, ci|
478
+ parent_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, c['parent_field_id'], @ticket_fields)
479
+ object['end_user_conditions'][ci]['parent_field_id'] = parent_field.id unless parent_field.nil?
480
+ c['child_fields'].each_with_index do |cf, cfi|
481
+ child_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, cf['id'], @ticket_fields)
482
+ object['end_user_conditions'][ci]['child_fields'][cfi]['id'] = child_field.id unless child_field.nil?
483
+ end
484
+ end
485
+ object
486
+ end
487
+
488
+ ##
489
+ # Convert user friendly Strings into Zendesk values for ticket form agent conditions
490
+ #
491
+ # @author Jason Colyer
492
+ # @since 1.0.118
493
+ # @param object [Object] The ticket form to parse
494
+ def self.convert_ticket_form_agent_conditions(object)
495
+ object['agent_conditions'].each_with_index do |c, ci|
496
+ parent_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, c['parent_field_id'], @ticket_fields)
497
+ object['agent_conditions'][ci]['parent_field_id'] = parent_field.id unless parent_field.nil?
498
+ c['child_fields'].each_with_index do |cf, cfi|
499
+ child_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, cf['id'], @ticket_fields)
500
+ object['agent_conditions'][ci]['child_fields'][cfi]['id'] = child_field.id unless child_field.nil?
501
+ end
502
+ end
503
+ object
504
+ end
505
+
506
+ ##
507
+ # Convert user friendly Strings into Zendesk values for ticket form brands
508
+ #
509
+ # @author Jason Colyer
510
+ # @since 1.0.118
511
+ # @param object [Object] The ticket form to parse
512
+ def self.convert_ticket_form_brands(object)
513
+ object['restricted_brand_ids'] = object['restricted_brand_ids'].map do |b|
514
+ brand = Readiness::Zendesk::Brands.find_by_name(@zendesk_client, b, @brands)
515
+ brand.nil? ? b : brand.id
516
+ end
517
+ object
518
+ end
406
519
  end
407
520
  end
@@ -48,6 +48,7 @@ module Readiness
48
48
  # pp diffs[:updates.count]
49
49
  # # => 1
50
50
  def self.compare(zendesk_client, location = 'data', verbose = false)
51
+ @zendesk_client = zendesk_client
51
52
  diffs = {
52
53
  updates: [],
53
54
  creates: []
@@ -138,11 +139,14 @@ module Readiness
138
139
  # pp repo.count
139
140
  # # => 35
140
141
  def self.gather(location = 'data')
142
+ @brands = Readiness::Zendesk::Brands.list(@zendesk_client)
143
+ @ticket_fields = Readiness::Zendesk::TicketFields.list(@zendesk_client)
141
144
  @errors = []
142
145
  @location = location
143
146
  array = []
144
147
  Dir["#{@location}/**/*.yaml"].each do |f|
145
148
  object = YAML.safe_load_file(f)
149
+ object = convert_ticket_form_names_to_ids(object)
146
150
  validity_check(f, object)
147
151
  object['id'] = nil
148
152
  array.push(Zendesk::TicketForms.new(object))
@@ -49,6 +49,7 @@ module Readiness
49
49
  # pp diffs[:updates.count]
50
50
  # # => 1
51
51
  def self.compare(config, zendesk_client, location = 'data', verbose = false)
52
+ @zendesk_client = zendesk_client
52
53
  diffs = {
53
54
  updates: [],
54
55
  creates: []
@@ -135,12 +136,18 @@ module Readiness
135
136
  # pp repo.count
136
137
  # # => 35
137
138
  def self.gather(config, location = 'data')
139
+ @groups = Readiness::Zendesk::Groups.list(@zendesk_client)
140
+ @schedules = Readiness::Zendesk::Schedules.list(@zendesk_client)
141
+ @satisfaction_reasons = Readiness::Zendesk::SatisfactionReasons.list(@zendesk_client)
142
+ @ticket_fields = Readiness::Zendesk::TicketFields.list(@zendesk_client)
143
+ @ticket_forms = Readiness::Zendesk::TicketForms.list(@zendesk_client)
138
144
  @errors = []
139
145
  @location = location
140
146
  array = []
141
147
  Dir["#{@location}/{active,inactive}/*.yaml"].each do |f|
142
148
  object = YAML.safe_load_file(f)
143
149
  object = convert_managed_content(config, object)
150
+ object = convert_view_names_to_ids(object)
144
151
  validity_check(f, object)
145
152
  object['id'] = nil
146
153
  array.push(Zendesk::Views.new(object))
@@ -0,0 +1,102 @@
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 Brands within the module {Readiness::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.118
12
+ # @todo find
13
+ # @todo find!
14
+ # @todo Create
15
+ # @todo Update
16
+ # @todo Delete
17
+ # @todo Check Host Mapping Validity
18
+ # @todo Check Host Mapping Validity for an Existing Brand
19
+ class Brands < Readiness::Client
20
+ attr_accessor :active, :brand_url, :created_at, :default, :has_help_center, :help_center_state, :host_mapping, :id, :logo, :name, :signature_template, :subdomain, :ticket_form_ids, :updated_at
21
+
22
+ ##
23
+ # Creates a new {Readiness::Zendesk::Brands} instance
24
+ #
25
+ # @author Jason Colyer
26
+ # @since 1.0.118
27
+ # @param object [Object] An instance of {Readiness::Zendesk::Brands}
28
+ # @example
29
+ # require 'support_readiness'
30
+ # Readiness::Zendesk::Brands.new
31
+ def initialize(object = {})
32
+ @active = object['active']
33
+ @brand_url = object['brand_url']
34
+ @created_at = object['created_at']
35
+ @default = object['default']
36
+ @has_help_center = object['has_help_center']
37
+ @help_center_state = object['help_center_state']
38
+ @host_mapping = object['host_mapping']
39
+ @id = object['id']
40
+ @logo = object['logo']
41
+ @name = object['name']
42
+ @signature_template = object['signature_template']
43
+ @subdomain = object['subdomain']
44
+ @ticket_form_ids = object['ticket_form_ids']
45
+ @updated_at = object['updated_at']
46
+ end
47
+
48
+ ##
49
+ # Lists all brands.
50
+ #
51
+ # @author Jason Colyer
52
+ # @since 1.0.118
53
+ # @param client [Object] An instance of {Readiness::Zendesk::Client}
54
+ # @return [Array]
55
+ # @see https://developer.zendesk.com/api-reference/ticketing/account-configuration/brands/#list-brands Zendesk API > Brands > List Brands
56
+ # @example
57
+ # require 'support_readiness'
58
+ # config = Readiness::Zendesk::Configuration.new
59
+ # config.username = 'alice@example.com'
60
+ # config.token = 'test123abc'
61
+ # config.url = 'https://example.zendesk.com/api/v2'
62
+ # client = Readiness::Zendesk::Client.new(config)
63
+ # brands = Readiness::Zendesk::Brands.list(client)
64
+ # pp brands.count
65
+ # # => 2
66
+ def self.list(client)
67
+ response = client.connection.get 'brands'
68
+ handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
69
+ body = Oj.load(response.body)
70
+ body['brands'].map { |b| Brands.new(b) }
71
+ end
72
+
73
+ ##
74
+ # Locates a brand within Zendesk by name. Can utilize a cacheh for quicker results
75
+ #
76
+ # @author Jason Colyer
77
+ # @since 1.0.118
78
+ # @param client [Object] An instance of {Readiness::Zendesk::Client}
79
+ # @param name [String] The brand name to look for
80
+ # @param cache [Array] The results of {Readiness::Zendesk::Brands#list}
81
+ # @return [Object] An instance of {Readiness::Zendesk::Brands}
82
+ # @example
83
+ # require 'support_readiness'
84
+ # config = Readiness::Zendesk::Configuration.new
85
+ # config.username = 'alice@example.com'
86
+ # config.token = 'test123abc'
87
+ # config.url = 'https://example.zendesk.com/api/v2'
88
+ # client = Readiness::Zendesk::Client.new(config)
89
+ # brand = Readiness::Zendesk::Brands.find_by_name(client, 'Brand 1')
90
+ # pp brand.id
91
+ # # => 360002783572
92
+ def self.find_by_name(client, name, cache = nil)
93
+ brands = if cache.nil?
94
+ Brands.list(client)
95
+ else
96
+ cache
97
+ end
98
+ brands.detect { |f| f.name == name }
99
+ end
100
+ end
101
+ end
102
+ end
@@ -11,6 +11,7 @@ module Readiness
11
11
  require "#{__dir__}/zendesk/apps"
12
12
  require "#{__dir__}/zendesk/articles"
13
13
  require "#{__dir__}/zendesk/automations"
14
+ require "#{__dir__}/zendesk/brands"
14
15
  require "#{__dir__}/zendesk/client"
15
16
  require "#{__dir__}/zendesk/configuration"
16
17
  require "#{__dir__}/zendesk/dynamic_content"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_support_readiness
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.116
4
+ version: 1.0.118
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Colyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-07 00:00:00.000000000 Z
11
+ date: 2025-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -405,6 +405,7 @@ files:
405
405
  - lib/support_readiness/zendesk/apps.rb
406
406
  - lib/support_readiness/zendesk/articles.rb
407
407
  - lib/support_readiness/zendesk/automations.rb
408
+ - lib/support_readiness/zendesk/brands.rb
408
409
  - lib/support_readiness/zendesk/client.rb
409
410
  - lib/support_readiness/zendesk/configuration.rb
410
411
  - lib/support_readiness/zendesk/dynamic_content.rb