gitlab_support_readiness 1.0.41 → 1.0.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/support_readiness/mailgun/client.rb +2 -1
  3. data/lib/support_readiness/mailgun/emails.rb +1 -1
  4. data/lib/support_readiness/support_super_form_processor/create_article.rb +375 -0
  5. data/lib/support_readiness/support_super_form_processor/create_macro.rb +183 -0
  6. data/lib/support_readiness/support_super_form_processor/edit_macro.rb +161 -0
  7. data/lib/support_readiness/support_super_form_processor/enable_us_government.rb +236 -0
  8. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_billing_entity_change.rb +218 -0
  9. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_extension.rb +238 -0
  10. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_investigate.rb +238 -0
  11. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_link.rb +213 -0
  12. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb +224 -0
  13. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_reset_seat_qsr.rb +194 -0
  14. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_trials_edit.rb +198 -0
  15. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_trials_extension.rb +228 -0
  16. data/lib/support_readiness/support_super_form_processor/global_ir_dotcom_trials_over_plan.rb +219 -0
  17. data/lib/support_readiness/support_super_form_processor/global_ir_hackerone_license.rb +172 -0
  18. data/lib/support_readiness/support_super_form_processor/global_ir_oem_license.rb +241 -0
  19. data/lib/support_readiness/support_super_form_processor/global_ir_order_management.rb +267 -0
  20. data/lib/support_readiness/support_super_form_processor/global_ir_other.rb +137 -0
  21. data/lib/support_readiness/support_super_form_processor/global_ir_provison_failure.rb +179 -0
  22. data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_did_not_receive.rb +191 -0
  23. data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_multiyear.rb +188 -0
  24. data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_nfr.rb +215 -0
  25. data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_resend.rb +188 -0
  26. data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_scl.rb +194 -0
  27. data/lib/support_readiness/support_super_form_processor/global_ir_sm_subscriptions_temp.rb +234 -0
  28. data/lib/support_readiness/support_super_form_processor/global_ir_sm_trials_edit.rb +203 -0
  29. data/lib/support_readiness/support_super_form_processor/global_ir_sm_trials_extension.rb +233 -0
  30. data/lib/support_readiness/support_super_form_processor/global_ir_sm_trials_new.rb +223 -0
  31. data/lib/support_readiness/support_super_form_processor/global_ir_wider_community_license.rb +247 -0
  32. data/lib/support_readiness/support_super_form_processor/global_set_collaboration_id.rb +151 -0
  33. data/lib/support_readiness/support_super_form_processor/global_set_org_ase.rb +293 -0
  34. data/lib/support_readiness/support_super_form_processor/global_toggle_escalation.rb +142 -0
  35. data/lib/support_readiness/support_super_form_processor/gratis_support_extension.rb +247 -0
  36. data/lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb +288 -0
  37. data/lib/support_readiness/support_super_form_processor/gratis_support_migration.rb +238 -0
  38. data/lib/support_readiness/support_super_form_processor/gratis_support_other.rb +221 -0
  39. data/lib/support_readiness/support_super_form_processor/gratis_support_prospect.rb +288 -0
  40. data/lib/support_readiness/support_super_form_processor/gratis_support_upgrade.rb +298 -0
  41. data/lib/support_readiness/support_super_form_processor/namespace_availability.rb +213 -0
  42. data/lib/support_readiness/support_super_form_processor/pd_shadow_modification.rb +189 -0
  43. data/lib/support_readiness/support_super_form_processor/sa_request_for_support.rb +214 -0
  44. data/lib/support_readiness/support_super_form_processor/shared.rb +518 -0
  45. data/lib/support_readiness/support_super_form_processor/team_member_license.rb +144 -0
  46. data/lib/support_readiness/support_super_form_processor/two_fa_exemption.rb +260 -0
  47. data/lib/support_readiness/support_super_form_processor/usgov_ir_order_management.rb +252 -0
  48. data/lib/support_readiness/support_super_form_processor/usgov_ir_other.rb +136 -0
  49. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_did_not_receive.rb +162 -0
  50. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_multiyear.rb +159 -0
  51. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_nfr.rb +196 -0
  52. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_resend.rb +159 -0
  53. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_scl.rb +160 -0
  54. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_subs_temp.rb +219 -0
  55. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_trials_edit.rb +189 -0
  56. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_trials_extension.rb +219 -0
  57. data/lib/support_readiness/support_super_form_processor/usgov_ir_sm_trials_new.rb +209 -0
  58. data/lib/support_readiness/support_super_form_processor/usgov_set_collaboration_id.rb +151 -0
  59. data/lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb +295 -0
  60. data/lib/support_readiness/support_super_form_processor.rb +67 -0
  61. data/lib/support_readiness.rb +1 -0
  62. metadata +59 -2
@@ -0,0 +1,223 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module Readiness.
4
+ module Readiness
5
+ # Defines the module SupportSuperFormProcessor
6
+ module SupportSuperFormProcessor
7
+ ##
8
+ # Defines the class GlobalIRSMTrialsNew within the module {Readiness::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.42
12
+ class GlobalIRSMTrialsNew < Readiness::Client
13
+ ##
14
+ # Process a Global Internal Request Self-Managed Trials New request
15
+ #
16
+ # @author Jason Colyer
17
+ # @since 1.0.42
18
+ def self.process!(gitlab_client, gitlab_admin_client, zendesk_client)
19
+ @gitlab_client = gitlab_client
20
+ @gitlab_admin_client = gitlab_admin_client
21
+ @zendesk_client = zendesk_client
22
+ requester
23
+ zd_user
24
+ ticket = Readiness::Zendesk::Tickets.new
25
+ ticket.email_cc_ids = [zd_user.id]
26
+ ticket.requester_id = 379855863520
27
+ ticket.submitter_id = 379855863520
28
+ ticket.comment = { html_body: body }
29
+ ticket.subject = 'Internal Request - SM - Problems starting a new trial'
30
+ ticket.tags = %w[lnr_internal_request lnr_valid_request lnr_sm_trial lnr_sm_trial_new]
31
+ ticket.priority = request_priority
32
+ ticket.status = 'new'
33
+ ticket.ticket_form_id = 360000071293
34
+ ticket.custom_fields = [
35
+ { id: 4414446722578, value: 'ticket_group_not_applicable' },
36
+ { id: 360020614420, value: 'aof_lnr' },
37
+ { id: 360020735259, value: 'stage-frt' },
38
+ { id: 360018253094, value: 'all_regions' },
39
+ { id: 360004394559, value: 'free_plan' },
40
+ { id: 360005183820, value: zd_user.name },
41
+ { id: 360005248219, value: zd_user.email },
42
+ { id: 360020735319, value: 'sev3' },
43
+ { id: 360020288373, value: '0' },
44
+ { id: 360014776453, value: 'medium' },
45
+ { id: 6978426204828, value: 'ir_issues_sm_trial' },
46
+ { id: 6978366086428, value: zd_user.email },
47
+ { id: 45195248, value: 'created_by_agent' }
48
+ ]
49
+ create = Readiness::Zendesk::Tickets.create!(@zendesk_client, ticket)
50
+ puts "Ticket created: https://gitlab.zendesk.com/agent/tickets/#{create.id}"
51
+ end
52
+
53
+ ##
54
+ # Sets the global variable requester
55
+ #
56
+ # @author Jason Colyer
57
+ # @since 1.0.42
58
+ def self.requester
59
+ @requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email)
60
+ end
61
+
62
+ ##
63
+ # Sets the global variable zd_user
64
+ #
65
+ # @author Jason Colyer
66
+ # @since 1.0.42
67
+ def self.zd_user
68
+ @zd_user ||= Readiness::SupportSuperFormProcessor::Shared.zendesk_user_check(@zendesk_client, requester_email)
69
+ end
70
+
71
+ ##
72
+ # Sets the global variable requester_email
73
+ #
74
+ # @author Jason Colyer
75
+ # @since 1.0.42
76
+ def self.requester_email
77
+ @requester_email ||= ENV.fetch('REQUESTER_EMAIL')
78
+ end
79
+
80
+ ##
81
+ # Sets the global variable request_priority
82
+ #
83
+ # @author Jason Colyer
84
+ # @since 1.0.42
85
+ def self.request_priority
86
+ @request_priority ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_PRIORITY')
87
+ end
88
+
89
+ ##
90
+ # Sets the global variable context
91
+ #
92
+ # @author Jason Colyer
93
+ # @since 1.0.42
94
+ def self.context
95
+ @context ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_CONTEXT')
96
+ end
97
+
98
+ ##
99
+ # Sets the global variable contact_name
100
+ #
101
+ # @author Jason Colyer
102
+ # @since 1.0.42
103
+ def self.contact_name
104
+ @contact_name ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_CONTACT_NAME')
105
+ end
106
+
107
+ ##
108
+ # Sets the global variable contact_email
109
+ #
110
+ # @author Jason Colyer
111
+ # @since 1.0.42
112
+ def self.contact_email
113
+ @contact_email ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_EMAIL')
114
+ end
115
+
116
+ ##
117
+ # Sets the global variable company
118
+ #
119
+ # @author Jason Colyer
120
+ # @since 1.0.42
121
+ def self.company
122
+ @company ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_COMPANY_NAME')
123
+ end
124
+
125
+ ##
126
+ # Sets the global variable start_date
127
+ #
128
+ # @author Jason Colyer
129
+ # @since 1.0.42
130
+ def self.start_date
131
+ @start_date ||= ENV.fetch('SM_TRIAL_NEW_START_DATE')
132
+ end
133
+
134
+ ##
135
+ # Sets the global variable end_date
136
+ #
137
+ # @author Jason Colyer
138
+ # @since 1.0.42
139
+ def self.end_date
140
+ @end_date ||= ENV.fetch('SM_TRIAL_NEW_EXPIRATION')
141
+ end
142
+
143
+ ##
144
+ # Sets the global variable current
145
+ #
146
+ # @author Jason Colyer
147
+ # @since 1.0.42
148
+ def self.current
149
+ @current ||= ENV.fetch('SM_TRIAL_NEW_SEATS')
150
+ end
151
+
152
+ ##
153
+ # Sets the global variable plan
154
+ #
155
+ # @author Jason Colyer
156
+ # @since 1.0.42
157
+ def self.plan
158
+ @plan ||= ENV.fetch('SM_TRIAL_NEW_PLAN')
159
+ end
160
+
161
+ ##
162
+ # Sets the global variable sfdc_account_link
163
+ #
164
+ # @author Jason Colyer
165
+ # @since 1.0.42
166
+ def self.sfdc_account_link
167
+ @sfdc_account_link ||= ENV.fetch('SM_TRIAL_NEW_SFDC_ACCOUNT')
168
+ end
169
+
170
+ ##
171
+ # Sets the global variable reason
172
+ #
173
+ # @author Jason Colyer
174
+ # @since 1.0.42
175
+ def self.reason
176
+ @reason ||= ENV.fetch('SM_TRIAL_NEW_REASON')
177
+ end
178
+
179
+ ##
180
+ # Returns the ticket body
181
+ #
182
+ # @author Jason Colyer
183
+ # @since 1.0.42
184
+ # @return [String]
185
+ def self.body
186
+ <<~STRING
187
+ <p>
188
+ Greetings
189
+ </p>
190
+ <p>
191
+ Please note that this is an <b>INTERNAL</b> ticket and should <b>NEVER</b> be shared with anyone. Please do not CC, BCC, forward, or anything else that can send the information from this ticket. <b>NEVER</b> add <i>anyone</i> outside of GitLab to this ticket or communications stemming from this ticket.
192
+ </p>
193
+ <p>
194
+ A request has been filed for Problems starting a new Self-managed trial .
195
+ </p>
196
+ <p>
197
+ The information for this is as follows:
198
+ </p>
199
+ <ul>
200
+ <li>Contact's name: #{contact_name}</li>
201
+ <li>
202
+ Contact's email: #{contact_email}
203
+ <a href="https://www.zuora.com/platform/apps/search?searchTerm=#{contact_email}" target='_blank'>(Zuora Search)</a>
204
+ <a href="https://customers.gitlab.com/admin/customer?model_name=customer&query=#{contact_email}" target='_blank'>(Portal Search)</a>
205
+ </li>
206
+ <li>Company: #{company}</li>
207
+ <li>Trial start date: #{start_date}</li>
208
+ <li>Desired trial end date: #{end_date}</li>
209
+ <li>Trial seat count: #{current}</li>
210
+ <li>Trial plan: #{plan}</li>
211
+ <li>Reason user cannot start a trial: #{reason}</li>
212
+ </ul>
213
+ <p>
214
+ Some additional context for this request is:
215
+ </p>
216
+ <pre>
217
+ #{context}
218
+ </pre>
219
+ STRING
220
+ end
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,247 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module Readiness.
4
+ module Readiness
5
+ # Defines the module SupportSuperFormProcessor
6
+ module SupportSuperFormProcessor
7
+ ##
8
+ # Defines the class GlobalIRWiderCommunityLicense within the module {Readiness::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.42
12
+ class GlobalIRWiderCommunityLicense < Readiness::Client
13
+ ##
14
+ # Process a Global Internal Request Provision Failure request
15
+ #
16
+ # @author Jason Colyer
17
+ # @since 1.0.42
18
+ def self.process!(gitlab_client, gitlab_admin_client, zendesk_client)
19
+ @gitlab_client = gitlab_client
20
+ @gitlab_admin_client = gitlab_admin_client
21
+ @zendesk_client = zendesk_client
22
+ requester
23
+ zd_user
24
+ if Date.parse(expiration) > (Date.today + 3.months) && requester_email == approver
25
+ Readiness::SupportSuperFormProcessor::Shared.cannot_self_approve((requester_email))
26
+ end
27
+ ticket = Readiness::Zendesk::Tickets.new
28
+ ticket.email_cc_ids = [zd_user.id]
29
+ ticket.requester_id = 379855863520
30
+ ticket.submitter_id = 379855863520
31
+ ticket.comment = { html_body: body }
32
+ ticket.subject = 'Internal Request - SM - Wider Community License'
33
+ ticket.tags = %w[lnr_internal_request lnr_valid_request lnr_community_license]
34
+ ticket.priority = request_priority
35
+ ticket.status = 'new'
36
+ ticket.ticket_form_id = 360000071293
37
+ ticket.custom_fields = [
38
+ { id: 4414446722578, value: 'ticket_group_not_applicable' },
39
+ { id: 360020614420, value: 'aof_lnr' },
40
+ { id: 360020735259, value: 'stage-frt' },
41
+ { id: 360018253094, value: 'all_regions' },
42
+ { id: 360004394559, value: 'free_plan' },
43
+ { id: 360005183820, value: zd_user.name },
44
+ { id: 360005248219, value: zd_user.email },
45
+ { id: 360020735319, value: 'sev3' },
46
+ { id: 360020288373, value: '0' },
47
+ { id: 360014776453, value: 'medium' },
48
+ { id: 6978426204828, value: 'ir_wcl' },
49
+ { id: 6978366086428, value: zd_user.email },
50
+ { id: 45195248, value: 'created_by_agent' }
51
+ ]
52
+ create = Readiness::Zendesk::Tickets.create!(@zendesk_client, ticket)
53
+ puts "Ticket created: https://gitlab.zendesk.com/agent/tickets/#{create.id}"
54
+ end
55
+
56
+ ##
57
+ # Sets the global variable requester
58
+ #
59
+ # @author Jason Colyer
60
+ # @since 1.0.42
61
+ def self.requester
62
+ @requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email)
63
+ end
64
+
65
+ ##
66
+ # Sets the global variable zd_user
67
+ #
68
+ # @author Jason Colyer
69
+ # @since 1.0.42
70
+ def self.zd_user
71
+ @zd_user ||= Readiness::SupportSuperFormProcessor::Shared.zendesk_user_check(@zendesk_client, requester_email)
72
+ end
73
+
74
+ ##
75
+ # Sets the global variable requester_email
76
+ #
77
+ # @author Jason Colyer
78
+ # @since 1.0.42
79
+ def self.requester_email
80
+ @requester_email ||= ENV.fetch('REQUESTER_EMAIL')
81
+ end
82
+
83
+ ##
84
+ # Sets the global variable request_priority
85
+ #
86
+ # @author Jason Colyer
87
+ # @since 1.0.42
88
+ def self.request_priority
89
+ @request_priority ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_PRIORITY')
90
+ end
91
+
92
+ ##
93
+ # Sets the global variable context
94
+ #
95
+ # @author Jason Colyer
96
+ # @since 1.0.42
97
+ def self.context
98
+ @context ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_CONTEXT')
99
+ end
100
+
101
+ ##
102
+ # Sets the global variable contact_name
103
+ #
104
+ # @author Jason Colyer
105
+ # @since 1.0.42
106
+ def self.contact_name
107
+ @contact_name ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_CONTACT_NAME')
108
+ end
109
+
110
+ ##
111
+ # Sets the global variable contact_email
112
+ #
113
+ # @author Jason Colyer
114
+ # @since 1.0.42
115
+ def self.contact_email
116
+ @contact_email ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_EMAIL')
117
+ end
118
+
119
+ ##
120
+ # Sets the global variable company
121
+ #
122
+ # @author Jason Colyer
123
+ # @since 1.0.42
124
+ def self.company
125
+ @company ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_COMPANY_NAME')
126
+ end
127
+
128
+ ##
129
+ # Sets the global variable current
130
+ #
131
+ # @author Jason Colyer
132
+ # @since 1.0.42
133
+ def self.current
134
+ @current ||= ENV.fetch('WIDER_COMMUNITY_LICENSE_SEATS')
135
+ end
136
+
137
+ ##
138
+ # Sets the global variable previous
139
+ #
140
+ # @author Jason Colyer
141
+ # @since 1.0.42
142
+ def self.previous
143
+ @previous ||= ENV.fetch('WIDER_COMMUNITY_LICENSE_PREVIOUS')
144
+ end
145
+
146
+ ##
147
+ # Sets the global variable trueup
148
+ #
149
+ # @author Jason Colyer
150
+ # @since 1.0.42
151
+ def self.trueup
152
+ @trueup ||= ENV.fetch('WIDER_COMMUNITY_LICENSE_TRUEUPS')
153
+ end
154
+
155
+ ##
156
+ # Sets the global variable plan
157
+ #
158
+ # @author Jason Colyer
159
+ # @since 1.0.42
160
+ def self.plan
161
+ @plan ||= ENV.fetch('WIDER_COMMUNITY_LICENSE_PLAN')
162
+ end
163
+
164
+ ##
165
+ # Sets the global variable approver
166
+ #
167
+ # @author Jason Colyer
168
+ # @since 1.0.42
169
+ def self.approver
170
+ @approver ||= ENV.fetch('WIDER_COMMUNITY_LICENSE_APPROVER')
171
+ end
172
+
173
+ ##
174
+ # Sets the global variable expiration
175
+ #
176
+ # @author Jason Colyer
177
+ # @since 1.0.42
178
+ def self.expiration
179
+ @expiration ||= ENV.fetch('WIDER_COMMUNITY_LICENSE_EXPIRATION')
180
+ end
181
+
182
+ ##
183
+ # Sets the global variable reason
184
+ #
185
+ # @author Jason Colyer
186
+ # @since 1.0.42
187
+ def self.reason
188
+ @reason ||= ENV.fetch('WIDER_COMMUNITY_LICENSE_REASON')
189
+ end
190
+
191
+ ##
192
+ # Returns the ticket body
193
+ #
194
+ # @author Jason Colyer
195
+ # @since 1.0.42
196
+ # @return [String]
197
+ def self.body
198
+ <<~STRING
199
+ <p>
200
+ Greetings,
201
+ </p>
202
+ <p>
203
+ Please note that this is an <b>INTERNAL</b> ticket and should <b>NEVER</b> be shared with anyone. Please do not CC, BCC, forward, or anything else that can send the information from this ticket. <b>NEVER</b> add <i>anyone</i> outside of GitLab to this ticket or communications stemming from this ticket.
204
+ </p>
205
+ <p>
206
+ A request has been filed for Wider Community License.
207
+ </p>
208
+ <p>
209
+ The information for this is as follows:
210
+ </p>
211
+ <ul>
212
+ <li>Contact's name: #{contact_name}</li>
213
+ <li>
214
+ Contact's email: #{contact_email}
215
+ <a href="https://www.zuora.com/platform/apps/search?searchTerm=#{contact_email}" target='_blank'>(Zuora Search)</a>
216
+ <a href="https://customers.gitlab.com/admin/customer?model_name=customer&query=#{contact_email}" target='_blank'>(Portal Search)</a>
217
+ </li>
218
+ <li>Contact's company: #{company}</li>
219
+ <li>User count: #{current}</li>
220
+ <li>Previous user count: #{previous}</li>
221
+ <li>True-up count: #{trueup}</li>
222
+ <li>Plan: #{plan}</li>
223
+ <li>Expiration date: #{expiration}</li>
224
+ <li>Approving manager email: #{approver}</li>
225
+ <li>Trial: Yes</li>
226
+ </ul>
227
+ <p>
228
+ The reason for the license being issued is:
229
+ </p>
230
+ <pre>
231
+ #{reason}
232
+ </pre>
233
+ <p>
234
+ Some additional context for this request is:
235
+ </p>
236
+ <pre>
237
+ #{context}
238
+ </pre>
239
+ <p>
240
+ You can find the workflow for this ticket
241
+ <a href='https://handbook.gitlab.com/handbook/support/license-and-renewals/workflows/self-managed/creating-wider-community-license/' target='_blank'>here</a>
242
+ </p>
243
+ STRING
244
+ end
245
+ end
246
+ end
247
+ end
@@ -0,0 +1,151 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module Readiness.
4
+ module Readiness
5
+ # Defines the module SupportSuperFormProcessor
6
+ module SupportSuperFormProcessor
7
+ ##
8
+ # Defines the class GlobalSetCollaboriationID within the module {Readiness::Zendesk}.
9
+ #
10
+ # @author Jason Colyer
11
+ # @since 1.0.42
12
+ class GlobalSetCollaboriationID < Readiness::Client
13
+ ##
14
+ # Process setting a collab ID on a Global organization
15
+ #
16
+ # @author Jason Colyer
17
+ # @since 1.0.42
18
+ def self.process!(gitlab_client, gitlab_admin_client, zendesk_client)
19
+ @gitlab_client = gitlab_client
20
+ @gitlab_admin_client = gitlab_admin_client
21
+ @zendesk_client = zendesk_client
22
+ requester
23
+ org_does_not_exist if org.is_a? Hash
24
+ new_org = Readiness::Zendesk::Organizations.new
25
+ new_org.id = org.id
26
+ new_org.custom_fields = {
27
+ "am_project_id" => collaboration_project_id
28
+ }
29
+ Readiness::Zendesk::Organizations.update!(@zendesk_client, new_org)
30
+ issue = Readiness::GitLab::Issues.new
31
+ issue.title = "Set the collaboration project ID for a Zendesk Global organization - #{org.id}"
32
+ issue.description = message
33
+ create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue)
34
+ puts "Issue created: #{create.web_url}"
35
+ exit 0
36
+ end
37
+
38
+ ##
39
+ # Create issue when organization does not exist
40
+ #
41
+ # @author Jason Colyer
42
+ # @since 1.0.42
43
+ def self.org_does_not_exist
44
+ issue = Readiness::GitLab::Issues.new
45
+ issue.title = "Invalid Request - Organization Not Found"
46
+ issue.description = org_does_not_exist_message
47
+ create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue)
48
+ puts "Issue created: #{create.web_url}"
49
+ exit 0
50
+ end
51
+
52
+ ##
53
+ # Sets the global variable requester
54
+ #
55
+ # @author Jason Colyer
56
+ # @since 1.0.42
57
+ def self.requester
58
+ @requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email)
59
+ end
60
+
61
+ ##
62
+ # Sets the global variable requester_email
63
+ #
64
+ # @author Jason Colyer
65
+ # @since 1.0.42
66
+ def self.requester_email
67
+ @requester_email ||= ENV.fetch('REQUESTER_EMAIL')
68
+ end
69
+
70
+ ##
71
+ # Sets the global variable project
72
+ #
73
+ # @author Jason Colyer
74
+ # @since 1.0.42
75
+ def self.project
76
+ @project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 12811526)
77
+ end
78
+
79
+ ##
80
+ # Sets the global variable org
81
+ #
82
+ # @author Jason Colyer
83
+ # @since 1.0.42
84
+ def self.org
85
+ @org ||= Readiness::Zendesk::Organizations.find(@zendesk_client, org_id)
86
+ end
87
+
88
+ ##
89
+ # Sets the global variable org_id
90
+ #
91
+ # @author Jason Colyer
92
+ # @since 1.0.42
93
+ def self.org_id
94
+ @org_id ||= ENV.fetch('ZENDESK_ORGANIZATION_ID')
95
+ end
96
+
97
+ ##
98
+ # Sets the global variable collaboration_project_id
99
+ #
100
+ # @author Jason Colyer
101
+ # @since 1.0.42
102
+ def self.collaboration_project_id
103
+ @collaboration_project_id ||= ENV.fetch('ZENDESK_ORG_COLLAB_ID')
104
+ end
105
+
106
+ ##
107
+ # Returns the issue description
108
+ #
109
+ # @author Jason Colyer
110
+ # @since 1.0.42
111
+ def self.message
112
+ <<~STRING
113
+ ## Set the collaboration project ID for an Zendesk Global organization - #{org.id}
114
+
115
+ Greetings @#{requester.username} !
116
+
117
+ We have set the collaboration project ID of the Zendesk Global organization to that of #{collaboration_project_id} at this time.
118
+
119
+ /label ~"AutomatedRequests::Set Org Collab ID"
120
+
121
+ /assign @#{requester.username}
122
+ STRING
123
+ end
124
+
125
+ ##
126
+ # Returns the issue description
127
+ #
128
+ # @author Jason Colyer
129
+ # @since 1.0.42
130
+ def self.org_does_not_exist_message
131
+ <<~STRING
132
+ ## Invalid Request Organization Not Found
133
+
134
+ Greetings @#{requester.username} !
135
+
136
+ We received a request from you recently, however the organization ID given #{org_id} is not a valid Zendesk Global Organization ID. As such, we are not able to proceed.
137
+
138
+ Please review the Zendesk Global organization you were wanting to use once more and file a new submission.
139
+
140
+ If you need assistance in locating the organization's ID, please ask in the Slack channel [#support_operations](https://gitlab.slack.com/archives/C018ZGZAMPD)
141
+
142
+ /label ~"AutomatedRequests::Invalid Organization"
143
+
144
+ /label ~"Invalid Zendesk Global organization given"
145
+
146
+ /assign @#{requester.username}
147
+ STRING
148
+ end
149
+ end
150
+ end
151
+ end