Class: Readiness::SupportSuperFormProcessor::GratisSupportExtension

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/support_super_form_processor/gratis_support_extension.rb

Overview

Defines the class GratisSupportExtension within the module Zendesk.

Author:

  • Jason Colyer

Since:

  • 1.0.42

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

.account_query ⇒ Object

Returns a SOQL query string to get Account info

Author:

  • Jason Colyer

Since:

  • 1.0.42



183
184
185
186
187
188
189
190
191
192
193
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 183

def self.
  <<~STRING
    SELECT
      Account.Account_ID_18__c,
      Account.Name,
      Account.Type
    FROM Account
    WHERE
      Account.Account_ID_18__c = '#{}'
  STRING
end

.checks ⇒ Object

Perform the checks for this request

Author:

  • Jason Colyer

Since:

  • 1.0.42



46
47
48
49
50
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 46

def self.checks
  errors.push('Invalid previous issue given') if issue.is_a? Hash
  errors.push('Invalid SFDC account given') if .nil?
  errors.push('Invalid manager handle given') if manager.nil?
end

.determine_manager ⇒ Object

Sets the global variable customer_email

Author:

  • Jason Colyer

Since:

  • 1.0.42



93
94
95
96
97
98
99
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 93

def self.determine_manager
  user_search = Readiness::GitLab::Users.search_by_username(@gitlab_admin_client, manager_handle)
  found_user = user_search.detect { |u| u.email.downcase == manager_handle.downcase }
  return nil if found_user.nil?

  found_user
end

.determine_sfdc_account_id ⇒ Object

Determines the SFDC Account ID based off of the link given

Author:

  • Jason Colyer

Since:

  • 1.0.42



124
125
126
127
128
129
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 124

def self.
  link = ENV.fetch('GRATUS_SUPPORT_SFDC_ACCOUNT')
  return link.split('/')[-2] if link =~ /lightning/

  link.split('/').last
end

.errors ⇒ Object

Sets the global variable errors

Author:

  • Jason Colyer

Since:

  • 1.0.42



37
38
39
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 37

def self.errors
  @errors ||= []
end

.errors_block ⇒ Object

Returns a string for the errors block

Author:

  • Jason Colyer

Since:

  • 1.0.42



200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 200

def self.errors_block
  return '' if errors.count.zero?

  <<~STRING
    ## Attention @jcolyer and @#{requester.username}

    The following problems were detected in the form submission:

    #{errors.map { |e| "- #{e}" }.join("\n")}

    These will need to be corrected to proceed. Please communicate via issue comments to work this out.
  STRING
end

.fetch_sfdc_account ⇒ Object

Gets the SFDC Account information

Author:

  • Jason Colyer

Since:

  • 1.0.42



145
146
147
148
149
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 145

def self.
  query = Readiness::Salesforce::Queries.new()
  results = Readiness::Salesforce::Queries.run!(@sfdc_client, query)
  results.first
end

.issue ⇒ Object

Sets the global variable issue

Author:

  • Jason Colyer

Since:

  • 1.0.42



165
166
167
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 165

def self.issue
  @issue ||= Readiness::GitLab::Issues.find(@gitlab_client, project, issue_link.split('/').last)
end

Sets the global variable issue_link

Author:

  • Jason Colyer

Since:

  • 1.0.42



156
157
158
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 156

def self.issue_link
  @issue_link ||= ENV.fetch('GRATIS_SUPPORT_PREVIOUS_ISSUE')
end

.justification ⇒ Object

Sets the global variable justification

Author:

  • Jason Colyer

Since:

  • 1.0.42



174
175
176
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 174

def self.justification
  @justification ||= ENV.fetch('GRATUS_SUPPORT_JUSTIFICATION')
end

.manager ⇒ Object

Sets the global variable manager

Author:

  • Jason Colyer

Since:

  • 1.0.44



84
85
86
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 84

def self.manager
  @manager ||= determine_manager
end

.manager_handle ⇒ Object

Sets the global variable manager_handle

Author:

  • Jason Colyer

Since:

  • 1.0.44



106
107
108
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 106

def self.manager_handle
  @manager_handle ||= ENV.fetch('GRATUS_SUPPORT_APPROVING_MANAGER')
end

.message ⇒ Object

Returns a string for the issue body

Author:

  • Jason Colyer

Since:

  • 1.0.42



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 219

def self.message
  <<~STRING
    ## Gratis Support Extension Request

    - Requester: @#{requester.username}
    - Approver: @#{manager.nil? ? manager_handle : manager.username}
    - SFDC Account: #{.nil? ?  : .Account_ID_18__c}
    - Previous Gratis Support issue: #{issue.is_a?(Hash) ? issue_link : issue.web_url}
    - Justification:
    
    ```
    #{justification}
    ```
    
    #{errors_block}

    ## @#{requester.username} TODO

    - [ ] Look over the issue and confirm all data is correct
    - [ ] Work with the approver on their TODO section

    ## @#{manager.nil? ? manager_handle : manager.username} TODO

    - [ ] Review the request and check this box to approve the request
      - If you are not approving it, please add a comment explaining why and close the issue.
    - [ ] Add a comment signaling your approval (this let's the assignees know the issue is ready to proceed).
      - Please note your comment must explicitly say that you approve this request. If that is not explict, you may be asked to state the approval explicitly.

    ## Support Readiness TODO

    - [ ] Review the above information for accuracy
    - [ ] Review [our documentation](https://handbook.gitlab.com/handbook/support/readiness/operations/docs/policies/gratis_support/#extensions) for this and ensure it passes all required checks/validations
    - [ ] Ensure the approver has checked the above box to signal approval
    - [ ] Implement this as per [our documentation](https://handbook.gitlab.com/handbook/support/readiness/operations/docs/policies/gratis_support/#extensions)

    /assign @jcolyer

    /cc @#{requester.username} @#{manager.nil? ? manager_handle : manager.username}

    /label ~"Readiness Priority::Current Quarter" ~"Readiness::Consulting" ~"Zendesk::Global" ~"Support-Ops-Category::Orgs and Users" ~"Gratis Support Request::Extension"

    /due in 72 hours
  STRING
end

.process!(gitlab_client, gitlab_admin_client, sfdc_client) ⇒ Object

Process a Gratis Support Extension request

Author:

  • Jason Colyer

Since:

  • 1.0.42



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 18

def self.process!(gitlab_client, gitlab_admin_client, sfdc_client)
  @gitlab_client = gitlab_client
  @gitlab_admin_client = gitlab_admin_client
  @sfdc_client = sfdc_client
  requester
  checks
  issue = Readiness::GitLab::Issues.new
  issue.title = 'Gratis Support Extension Request'
  issue.description = message
  create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue)
  puts "Issue created: #{create.web_url}"
  exit 0
end

.project ⇒ Object

Sets the global variable project

Author:

  • Jason Colyer

Since:

  • 1.0.42



75
76
77
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 75

def self.project
  @project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 12811526)
end

.requester ⇒ Object

Sets the global variable requester

Author:

  • Jason Colyer

Since:

  • 1.0.42



57
58
59
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 57

def self.requester
  @requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email)
end

.requester_email ⇒ Object

Sets the global variable requester_email

Author:

  • Jason Colyer

Since:

  • 1.0.42



66
67
68
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 66

def self.requester_email
  @requester_email ||= ENV.fetch('REQUESTER_EMAIL')
end

.sfdc_account ⇒ Object

Sets the global variable sfdc_account

Author:

  • Jason Colyer

Since:

  • 1.0.42



136
137
138
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 136

def self.
  @sfdc_account ||= 
end

.sfdc_account_id ⇒ Object

Sets the global variable sfdc_account_id

Author:

  • Jason Colyer

Since:

  • 1.0.42



115
116
117
# File 'lib/support_readiness/support_super_form_processor/gratis_support_extension.rb', line 115

def self.
  @sfdc_account_id ||= 
end