Class: Readiness::TicketProcessor::OrganizationNotes
- Inherits:
-
Client
- Object
- Client
- Readiness::TicketProcessor::OrganizationNotes
show all
- Defined in:
- lib/support_readiness/ticket_processor/organization_notes.rb
Overview
Defines the class OrganizationNotes within the module Zendesk.
Class Method Summary
collapse
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Class Method Details
.addons_message ⇒ Object
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 355
def self.addons_message
addons = []
addons.push('GitLab Duo Premium') if @organization.organization_fields['sub_consumption_duo_premium']
addons.push('GitLab Duo Enterprise') if @organization.organization_fields['sub_consumption_duo_enterprise']
addons.push('GitLab Duo with Amazon Q') if @organization.organization_fields['sub_consumption_duo_amazon_q']
addons.push('Success Advanced') if @organization.organization_fields['sub_ss_success_growth']
addons.push('Success Signature') if @organization.organization_fields['sub_ss_success_enterprise']
addons.push('Consumption (CI/CD Minutes)') if @organization.organization_fields['sub_consumption_cicd_minutes']
addons.push('Consumption (Storage)') if @organization.organization_fields['sub_consumption_storage']
addons.push('Enterprise Agile Planning') if @organization.organization_fields['sub_consumption_eap']
addons.push('Professional Services') if @organization.organization_fields['sub_proserv']
addons.push('Assigned Support Engineer') if @organization.organization_fields['sub_ss_ase']
addons
return '' if addons.count.zero?
<<~STRING
## This organization has the following active addons:
#{addons.map { |s| "- #{s}" }.join("\n")}
STRING
end
|
.cmp_string ⇒ Object
256
257
258
259
260
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 256
def self.cmp_string
return nil if @organization.organization_fields['cmp_id'].nil?
"### This organization is using a contact management project!"
end
|
.collab_project_string ⇒ Object
234
235
236
237
238
239
240
241
242
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 234
def self.collab_project_string
return '' if @organization.organization_fields['am_project_id'].nil?
<<~STRING
---
## NOTE: This organization has an AM Collaboration project!
STRING
end
|
.create_notes_file ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 125
def self.create_notes_file
return nil if @sandbox_mode
content_string = "---\nid: #{@organization.id}\nname: \"#{@organization.name}\"\nnotes:\ndetails:\n"
commit_params = {
branch: 'master',
commit_message: 'Creating default org note file',
actions: [
{
action: 'create',
file_path: "organizations/#{@organization.id}.yaml",
content: content_string
}
]
}
Readiness::GitLab::Repositories.create_commit!(@gitlab_client, @project, commit_params)
YAML.safe_load(content_string)
end
|
.determine_within_grace_period ⇒ Object
119
120
121
122
123
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 119
def self.determine_within_grace_period
Date.today < (Date.parse(@organization.organization_fields['expiration_date']) + 15.days)
rescue TypeError
true
end
|
.emergencies_list ⇒ Object
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 216
def self.emergencies_list
org_tickets = Readiness::Zendesk::Organizations.tickets(@zendesk_client, @organization)
list = org_tickets.select { |t| t.ticket_form_id == 360001264259 }
emergencies = list.reject { |t| t.id == @ticket.id }
return '' if emergencies.count.zero?
output = []
emergencies.each do |e|
string = "- [#{e.subject}](https://gitlab.zendesk.com/agent/tickets/#{e.id}) - created #{e.created_at}"
output.push(string)
end
<<~STRING
## Recent Emergencies
#{output.join("\n")}
STRING
end
|
.escalated_string ⇒ Object
204
205
206
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 204
def self.escalated_string
"---\n\n## NOTE: This organization is in an escalated state.\n\n"
end
|
.expired_message ⇒ Object
326
327
328
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 326
def self.expired_message
'## NOTE: This account is showing as expired. Please confirm manually before proceeding!'
end
|
377
378
379
380
381
382
383
384
385
386
387
388
389
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 377
def self.
<<~STRING
## :information_source: Important Information about this Ticket
This is a [GitLab Dedicated](https://docs.gitlab.com/ee/subscriptions/gitlab_dedicated/) customer.
- **Logs**: :warning: Do **not** request GitLab logs from the customer.
- **Configuration**:
- Customers **can** access and make changes in the **Admin Area**.
- :warning: Do **not** request `gitlab.rb`, `values.yaml` or other GitLab configuration files from this customer.
- :question: Not sure what to do?: Check the [GitLab Dedicated Handbook](https://handbook.gitlab.com/handbook/support/workflows/dedicated_logs/) for information on how to handle :ticket: Dedicated tickets including information on [working with logs](https://handbook.gitlab.com/handbook/support/workflows/dedicated_logs/#working-with-logs).
STRING
end
|
.grace_period ⇒ Object
113
114
115
116
117
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 113
def self.grace_period
Date.parse(@organization.organization_fields['expiration_date']) + 15.days
rescue TypeError
Date.parse('9999-12-31')
end
|
.org_details_string ⇒ Object
272
273
274
275
276
277
278
279
280
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 272
def self.org_details_string
return nil if @organization.details.to_s == ''
<<~STRING
### Support Readiness Details about this Organizations
#{@organization.details}
STRING
end
|
.org_notes_string ⇒ Object
262
263
264
265
266
267
268
269
270
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 262
def self.org_notes_string
return nil if @organization.notes.to_s == ''
<<~STRING
### Support Readiness Notes about this Organizations
#{@organization.notes}
STRING
end
|
310
311
312
313
314
315
316
317
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 310
def self.
return expired_message if @organization.organization_fields['support_level'] == 'Expired'
return prospect_message if @organization.tags.include? 'priority_prospect'
<<~STRING
#{subscriptions_message}
#{addons_message}
STRING
end
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 144
def self.
if @sandbox_mode
note_file_contents = 'Being in the Sandbox, there is no organization notes file to use'
else
note_file_contents = @notes_file['notes']
end
<<~STRING
#{@organization.organization_fields['org_in_escalated_state'] ? escalated_string : ''}
## Organization Notes
#{note_file_contents}
Manage this organization note via https://gitlab.com/gitlab-com/support/zendesk-global/organizations/-/blob/master/organizations/#{@organization.id}.yaml
#{partner_troubleshooting_string}
---
## Organization Info
- Account type: #{@organization.organization_fields['account_type'].to_s.capitalize}
- Sales Segmentation: #{@organization.organization_fields['sales_segmentation'].to_s.capitalize}
- Account Owner: #{@organization.organization_fields['account_owner']}
- Customer Success Manager: #{@organization.organization_fields['technical_account_manager']}
- Solutions Architect: #{@organization.organization_fields['solutions_architect']}
- Expiration/Next Renewal Date: #{@organization.organization_fields['expiration_date']}
- Salesforce: [#{@organization.organization_fields['salesforce_id']}](https://gitlab.lightning.force.com/lightning/r/Account/#{@organization.organization_fields['salesforce_id']}/view)
#{emergencies_list}
#{collab_project_string}
#{readiness_string}
STRING
end
|
.partner_troubleshooting_string ⇒ Object
208
209
210
211
212
213
214
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 208
def self.partner_troubleshooting_string
field = @ticket.custom_fields.detect { |t| t['id'] == 360012194220 }
return '' if field.nil?
return '' if field['value'].nil?
"---\n\n## Partner Troubleshooting\n\n#{field['value']}\n\n"
end
|
.process_global!(zendesk_client, gitlab_client, ticket_id, sandbox_mode = false) ⇒ Object
Process an Organization Notes request for Zendesk Global
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 55
def self.process_global!(zendesk_client, gitlab_client, ticket_id, sandbox_mode = false)
@zendesk_client = zendesk_client
@gitlab_client = gitlab_client
@ticket_id = ticket_id
@sandbox_mode = sandbox_mode
@ticket = Readiness::Zendesk::Tickets.find(@zendesk_client, @ticket_id)
puts 'No ticket found, so no org notes to add' if @ticket.is_a? Hash
exit 0 if @ticket.is_a? Hash
puts 'Ticket is closed, so no org notes to add' if @ticket.status == 'closed'
exit 0 if @ticket.status == 'closed'
puts 'No organization, so no org notes to add' if @ticket.organization_id.nil?
exit 0 if @ticket.organization_id.nil?
@organization = Readiness::Zendesk::Organizations.find!(@zendesk_client, @ticket.organization_id)
@project = Readiness::GitLab::Projects.find!(@gitlab_client, 27675679)
file = Readiness::GitLab::Repositories.raw_file(@gitlab_client, @project, "organizations/#{@organization.id}.yaml", 'master')
yaml = YAML.safe_load(file)
@notes_file = if yaml['message']
create_notes_file
else
yaml
end
print 'Making organization info comment...'
new_ticket = Readiness::Zendesk::Tickets.new
new_ticket.id = @ticket.id
new_ticket. = { body: .gsub("\n\n\n\n", "\n\n").strip, public: false }
Readiness::Zendesk::Tickets.update!(zendesk_client, new_ticket)
puts 'done'
sleep 3
print 'Making organization entitlement info comment...'
new_ticket. = { body: .gsub("\n\n\n\n", "\n\n").strip, public: false }
Readiness::Zendesk::Tickets.update!(zendesk_client, new_ticket)
puts 'done'
if @organization.organization_fields['sub_gitlab_dedicated']
sleep 3
print 'Making GitLab Dedicated note...'
new_ticket. = { body: .gsub("\n\n\n\n", "\n\n").strip, public: false }
Readiness::Zendesk::Tickets.update!(zendesk_client, new_ticket)
puts 'done'
end
if @organization.organization_fields['support_level'] == 'Expired' && within_grace_period?
sleep 3
print 'Adding within_grace_period tag...'
@ticket = Readiness::Zendesk::Tickets.find(@zendesk_client, @ticket_id)
new_ticket = Readiness::Zendesk::Tickets.new
new_ticket.id = @ticket.id
new_ticket.tags = @ticket.tags + ['within_grace_period']
Readiness::Zendesk::Tickets.update!(zendesk_client, new_ticket)
puts 'done'
end
end
|
.process_usgov!(zendesk_client, ticket_id) ⇒ Object
Process an Organization Notes request for Zendesk US Government
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 18
def self.process_usgov!(zendesk_client, ticket_id)
@zendesk_client = zendesk_client
@ticket_id = ticket_id
@ticket = Readiness::Zendesk::Tickets.find(@zendesk_client, @ticket_id)
puts 'No ticket found, so no org notes to add' if @ticket.is_a? Hash
exit 0 if @ticket.is_a? Hash
puts 'Ticket is closed, so no org notes to add' if @ticket.status == 'closed'
exit 0 if @ticket.status == 'closed'
puts 'No organization, so no org notes to add' if @ticket.organization_id.nil?
exit 0 if @ticket.organization_id.nil?
@organization = Readiness::Zendesk::Organizations.find!(@zendesk_client, @ticket.organization_id)
print 'Making organization info comment...'
new_ticket = Readiness::Zendesk::Tickets.new
new_ticket.id = @ticket.id
new_ticket. = { body: .gsub("\n\n\n\n", "\n\n").strip, public: false }
Readiness::Zendesk::Tickets.update!(zendesk_client, new_ticket)
puts 'done'
sleep 3
print 'Making organization entitlement info comment...'
new_ticket. = { body: .gsub("\n\n\n\n", "\n\n").strip, public: false }
Readiness::Zendesk::Tickets.update!(zendesk_client, new_ticket)
puts 'done'
sleep 3
print 'Making organization support hours info comment...'
new_ticket. = { body: .gsub("\n\n\n\n", "\n\n").strip, public: false }
Readiness::Zendesk::Tickets.update!(zendesk_client, new_ticket)
puts 'done'
end
|
.prospect_message ⇒ Object
330
331
332
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 330
def self.prospect_message
'## NOTE: This is a priority prospect and is eligible for support.'
end
|
.readiness_string ⇒ Object
244
245
246
247
248
249
250
251
252
253
254
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 244
def self.readiness_string
output = [
cmp_string,
org_notes_string,
org_details_string,
shared_org_string
].compact
<<~STRING
#{output.join("\n\n")}
STRING
end
|
.shared_org_string ⇒ Object
302
303
304
305
306
307
308
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 302
def self.shared_org_string
return nil unless @organization.shared_tickets
return "### This organization has shared org permissions (read only)" unless @organization.
"### This organization has shared org permissions (read+write)"
end
|
.subscriptions_message ⇒ Object
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 334
def self.subscriptions_message
subs = []
subs.push('Community (unidentified type)') if @organization.organization_fields['sub_community_other']
subs.push('GitLab.com Premium') if @organization.organization_fields['sub_dotcom_premium']
subs.push('GitLab.com Ultimate') if @organization.organization_fields['sub_dotcom_ultimate']
subs.push('Community (EDU)') if @organization.organization_fields['sub_edu']
subs.push('GitLab Dedicated') if @organization.organization_fields['sub_gitlab_dedicated']
subs.push('Community (OSS)') if @organization.organization_fields['sub_oss']
subs.push('Self-Managed Premium') if @organization.organization_fields['sub_sm_premium']
subs.push('Self-Managed Starter') if @organization.organization_fields['sub_sm_starter']
subs.push('Self-Managed Ultimate') if @organization.organization_fields['sub_sm_ultimate']
subs
return '' if subs.count.zero?
<<~STRING
## This organization has the following active subscription types:
#{subs.map { |s| "- #{s}" }.join("\n")}
STRING
end
|
.usgov_org_details_string ⇒ Object
292
293
294
295
296
297
298
299
300
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 292
def self.usgov_org_details_string
return nil if @organization.details.to_s == ''
<<~STRING
## Organization Details
#{@organization.details}
STRING
end
|
.usgov_org_notes_string ⇒ Object
282
283
284
285
286
287
288
289
290
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 282
def self.usgov_org_notes_string
return nil if @organization.notes.to_s == ''
<<~STRING
## Organization Notes
#{@organization.notes}
STRING
end
|
319
320
321
322
323
324
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 319
def self.
<<~STRING
#{subscriptions_message}
#{addons_message}
STRING
end
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 180
def self.
<<~STRING
#{@organization.organization_fields['org_in_escalated_state'] ? escalated_string : ''}
#{usgov_org_notes_string}
#{usgov_org_details_string}
## Organization Info
- Account type: #{@organization.organization_fields['account_type'].to_s.capitalize}
- Sales Segmentation: #{@organization.organization_fields['sales_segmentation'].to_s.capitalize}
- Account Owner: #{@organization.organization_fields['account_owner']}
- Customer Success Manager: #{@organization.organization_fields['technical_account_manager']}
- Solutions Architect: #{@organization.organization_fields['solutions_architect']}
- Expiration/Next Renewal Date: #{@organization.organization_fields['expiration_date']}
- Salesforce: [#{@organization.organization_fields['salesforce_id']}](https://gitlab.lightning.force.com/lightning/r/Account/#{@organization.organization_fields['salesforce_id']}/view)
#{emergencies_list}
#{collab_project_string}
STRING
end
|
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 391
def self.
type = if @organization.tags.include?('24x7_emergency_support_manual') || @organization.organization_fields['emergency_support_24x7']
'24x7'
else
'12x5'
end
hours = if @ticket.ticket_form_id == 360001421112 || @ticket.ticket_form_id == '360001421112'
'0500-1700 Pacific Time, 7 days a week'
elsif type == '24x7' && %w[high urgent].include?(@ticket.priority)
'24x7'
else
'Monday through Friday, 0500-1700 Pacific Time'
end
<<~STRING
## Support Hours
This customer is currently entitled to #{type} support.
As this ticket has a priority of #{@ticket.priority}, this means the hours of SLA for this customer are #{hours}.
Please ensure reply times follow the above information.
STRING
end
|
.within_grace_period? ⇒ Boolean
109
110
111
|
# File 'lib/support_readiness/ticket_processor/organization_notes.rb', line 109
def self.within_grace_period?
Date.today < grace_period
end
|