Class: Readiness::SupportSuperFormProcessor::GratisSupportFormerCustomer
- Inherits:
-
Client
- Object
- Client
- Readiness::SupportSuperFormProcessor::GratisSupportFormerCustomer
- Defined in:
- lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb
Overview
Defines the class GratisSupportFormerCustomer within the module Zendesk.
Class Method Summary collapse
-
.account_query ⇒ Object
Returns a SOQL query string to get Account info.
-
.checks ⇒ Object
Perform the checks for this request.
-
.determine_manager ⇒ Object
Sets the global variable customer_email.
-
.determine_sfdc_account_id ⇒ Object
Determines the SFDC Account ID based off of the link given.
-
.determine_sfdc_opportunity_id ⇒ Object
Determines the SFDC Opportunity ID based off of the link given.
-
.errors ⇒ Object
Sets the global variable errors.
-
.errors_block ⇒ Object
Returns a string for the errors block.
-
.fetch_sfdc_account ⇒ Object
Gets the SFDC Account information.
-
.fetch_sfdc_opportunity ⇒ Object
Gets the SFDC Opportunity information.
-
.justification ⇒ Object
Sets the global variable justification.
-
.manager ⇒ Object
Sets the global variable manager.
-
.manager_handle ⇒ Object
Sets the global variable manager_handle.
-
.message ⇒ Object
Returns a string for the issue body.
-
.opportunity_query ⇒ Object
Returns a SOQL query string to get Opportunity info.
-
.plan ⇒ Object
Sets the global variable plan.
-
.process!(gitlab_client, gitlab_admin_client, sfdc_client) ⇒ Object
Process a Gratis Support Former Customer request.
-
.project ⇒ Object
Sets the global variable project.
-
.requester ⇒ Object
Sets the global variable requester.
-
.requester_email ⇒ Object
Sets the global variable requester_email.
-
.sfdc_account ⇒ Object
Sets the global variable sfdc_account.
-
.sfdc_account_id ⇒ Object
Sets the global variable sfdc_account_id.
-
.sfdc_opportunity ⇒ Object
Sets the global variable sfdc_opportunity.
-
.sfdc_opportunity_id ⇒ Object
Sets the global variable sfdc_opportunity_id.
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
219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 219 def self.account_query <<~STRING SELECT Account.Account_ID_18__c, Account.Name, Account.Type FROM Account WHERE Account.Account_ID_18__c = '#{sfdc_account_id}' STRING end |
.checks ⇒ Object
Perform the checks for this request
46 47 48 49 50 51 52 53 54 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 46 def self.checks if sfdc_account.nil? errors.push('Invalid SFDC account given') else errors.push('Incorrect SFDC account type') if sfdc_account.Type != 'Former Customer' end errors.push('Invalid SFDC opportunity given') if sfdc_opportunity.nil? errors.push('Invalid manager handle given') if manager.nil? end |
.determine_manager ⇒ Object
Sets the global variable customer_email
197 198 199 200 201 202 203 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 197 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
97 98 99 100 101 102 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 97 def self.determine_sfdc_account_id link = ENV.fetch('GRATUS_SUPPORT_SFDC_ACCOUNT') return link.split('/')[-2] if link =~ /lightning/ link.split('/').last end |
.determine_sfdc_opportunity_id ⇒ Object
Determines the SFDC Opportunity ID based off of the link given
118 119 120 121 122 123 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 118 def self.determine_sfdc_opportunity_id link = ENV.fetch('GRATIS_SUPPORT_SFDC_OPPORTUNITY') return link.split('/')[-2] if link =~ /lightning/ link.split('/').last end |
.errors ⇒ Object
Sets the global variable errors
37 38 39 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 37 def self.errors @errors ||= [] end |
.errors_block ⇒ Object
Returns a string for the errors block
252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 252 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
139 140 141 142 143 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 139 def self.fetch_sfdc_account query = Readiness::Salesforce::Queries.new(account_query) results = Readiness::Salesforce::Queries.run!(@sfdc_client, query) results.first end |
.fetch_sfdc_opportunity ⇒ Object
Gets the SFDC Opportunity information
159 160 161 162 163 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 159 def self.fetch_sfdc_opportunity query = Readiness::Salesforce::Queries.new(opportunity_query) results = Readiness::Salesforce::Queries.run!(@sfdc_client, query) results.first end |
.justification ⇒ Object
Sets the global variable justification
170 171 172 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 170 def self.justification @justification ||= ENV.fetch('GRATUS_SUPPORT_JUSTIFICATION') end |
.manager ⇒ Object
Sets the global variable manager
188 189 190 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 188 def self.manager @manager ||= determine_manager end |
.manager_handle ⇒ Object
Sets the global variable manager_handle
210 211 212 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 210 def self.manager_handle @manager_handle ||= ENV.fetch('GRATUS_SUPPORT_APPROVING_MANAGER') end |
.message ⇒ Object
Returns a string for the issue body
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 271 def self. <<~STRING ## Gratis Support Request for a Former Customer - Requester: @#{requester.username} - Approver: @#{manager.nil? ? manager_handle : manager.username} - SFDC Account: #{sfdc_account.nil? ? sfdc_account_id : sfdc_account.Account_ID_18__c} - SFDC Opportunity: #{sfdc_opportunity.nil? ? sfdc_opportunity_id : sfdc_opportunity.Id} - ARR: #{sfdc_opportunity.nil? ? 'Unknown' : sfdc_opportunity.ARR__c} - Plan customer is trialing: #{plan} - 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::Former Customer" /due in 72 hours STRING end |
.opportunity_query ⇒ Object
Returns a SOQL query string to get Opportunity info
236 237 238 239 240 241 242 243 244 245 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 236 def self.opportunity_query <<~STRING SELECT Opportunity.Id, Opportunity.ARR__c FROM Opportunity WHERE Opportunity.Id = '#{sfdc_opportunity_id}' STRING end |
.plan ⇒ Object
Sets the global variable plan
179 180 181 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 179 def self.plan @plan ||= ENV.fetch('GRATIS_SUPPORT_NEW_SUB') end |
.process!(gitlab_client, gitlab_admin_client, sfdc_client) ⇒ Object
Process a Gratis Support Former Customer request
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.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 Request for a Former Customer' issue.description = 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
79 80 81 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 79 def self.project @project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 12811526) end |
.requester ⇒ Object
Sets the global variable requester
61 62 63 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 61 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
70 71 72 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 70 def self.requester_email @requester_email ||= ENV.fetch('REQUESTER_EMAIL') end |
.sfdc_account ⇒ Object
Sets the global variable sfdc_account
130 131 132 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 130 def self.sfdc_account @sfdc_account ||= fetch_sfdc_account end |
.sfdc_account_id ⇒ Object
Sets the global variable sfdc_account_id
88 89 90 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 88 def self.sfdc_account_id @sfdc_account_id ||= determine_sfdc_account_id end |
.sfdc_opportunity ⇒ Object
Sets the global variable sfdc_opportunity
150 151 152 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 150 def self.sfdc_opportunity @sfdc_opportunity ||= fetch_sfdc_opportunity end |
.sfdc_opportunity_id ⇒ Object
Sets the global variable sfdc_opportunity_id
109 110 111 |
# File 'lib/support_readiness/support_super_form_processor/gratis_support_former_customer.rb', line 109 def self.sfdc_opportunity_id @sfdc_account_id ||= determine_sfdc_opportunity_id end |