Class: Readiness::SupportSuperFormProcessor::EnableUSGov
- Defined in:
- lib/support_readiness/support_super_form_processor/enable_us_government.rb
Overview
Defines the class EnableUSGov within the module Zendesk.
Class Method Summary collapse
-
.account ⇒ Object
Sets the global variable account.
-
.account_id ⇒ Object
Sets the global variable account_id.
-
.account_query ⇒ Object
Returns a String to get account information.
-
.checks ⇒ Object
Peform validity checks for this request.
-
.correct_sku? ⇒ Boolean
Check the SFDC account for a US Gov SKU.
-
.errors ⇒ Object
Sets the global variable errors.
-
.fetch_account ⇒ Object
Run a SQOL query to get account information.
-
.fetch_opportunity ⇒ Object
Run a SQOL query to get opportunity information.
-
.message ⇒ Object
Return the string for the issue body.
-
.opportunity ⇒ Object
Sets the global variable opportunity.
-
.opportunity_id ⇒ Object
Sets the global variable opportunity_id.
-
.opportunity_query ⇒ Object
Returns a String to get opportunity information.
-
.process!(gitlab_client, gitlab_admin_client, zendesk_client, sfdc_client, sandbox = false) ⇒ Object
Process a Enable US Government request.
-
.project ⇒ Object
Sets the global variable project.
-
.requester ⇒ Object
Sets the global variable requester.
-
.requester_email ⇒ Object
Sets the global variable requester_email.
-
.zd_user ⇒ Object
Sets the global variable zd_user.
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 ⇒ Object
Sets the global variable account
120 121 122 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 120 def self.account @account ||= fetch_account end |
.account_id ⇒ Object
Sets the global variable account_id
160 161 162 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 160 def self.account_id @account_id ||= ENV.fetch('ENABLE_US_GOV_SUPPORT_SFDC_ACCOUNT') end |
.account_query ⇒ Object
Returns a String to get account information
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 178 def self.account_query <<~STRING SELECT Account_ID_18__c, Name, Ultimate_Parent_Sales_Segment_Employees__c, Account_Owner_Calc__c, Technical_Account_Manager_Name__c, GS_Health_Score_Color__c, Restricted_Account__c, Solutions_Architect_Lookup__r.Name, Support_Hold__c, Support_Instance__c, ( SELECT Id, Name, Zuora__ProductName__c, Zuora__EffectiveEndDate__c, Zuora__Quantity__c, Zuora__TotalContractValue__c, Subscription_Status__c FROM Zuora__R00N40000001lGjTEAU__r ) FROM Account WHERE Id = '#{account_id}' STRING end |
.checks ⇒ Object
Peform validity checks for this request
55 56 57 58 59 60 61 62 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 55 def self.checks errors.push("Invalid SFDC account given: #{account_id}") if account.nil? errors.push("Invalid SFDC opportunity given: #{opportunity_id}") if opportunity.nil? return unless errors.count.zero? errors.push("SFDC account #{account_id} already has the exception") if account.Support_Instance__c == 'federal-support' errors.push("Missing US Government SKU on #{account_id}") unless correct_sku? end |
.correct_sku? ⇒ Boolean
Check the SFDC account for a US Gov SKU
69 70 71 72 73 74 75 76 77 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 69 def self.correct_sku? return false if account.Zuora__R00N40000001lGjTEAU__r.nil? account.Zuora__R00N40000001lGjTEAU__r.map { |r| r.Name }.each do |name| return true if Readiness::Salesforce::SubscriptionDefinitions.usgov_12x5.include? name return true if Readiness::Salesforce::SubscriptionDefinitions.usgov_24x7.include? name end false end |
.errors ⇒ Object
Sets the global variable errors
84 85 86 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 84 def self.errors @errors ||= [] end |
.fetch_account ⇒ Object
Run a SQOL query to get account information
138 139 140 141 142 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 138 def self.fetch_account query = Readiness::Salesforce::Queries.new(account_query) results = Readiness::Salesforce::Queries.run!(@sfdc_client, query) results.first end |
.fetch_opportunity ⇒ Object
Run a SQOL query to get opportunity information
149 150 151 152 153 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 149 def self.fetch_opportunity query = Readiness::Salesforce::Queries.new(opportunity_query) results = Readiness::Salesforce::Queries.run!(@sfdc_client, query) results.first end |
.message ⇒ Object
Return the string for the issue body
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 228 def self. <<~STRING ## Add US Government Support exception for #{account.Account_ID_18__c} A request has been filed to add the US Government Support exception for a SFDC account. The details are as follows: - Requester: @#{requester.username} - SFDC Account: [#{account.Account_ID_18__c}](https://gitlab.lightning.force.com/lightning/r/Account/#{account.Account_ID_18__c}/view) - SFDC Opportunity: [#{opportunity.Id}](https://gitlab.lightning.force.com/lightning/r/Opportunity/#{opportunity.Id}/view) - Product Charges on SFDC account: #{account.Zuora__R00N40000001lGjTEAU__r.map { |r| " - #{r.Name}" }.join("\n")} #### Readiness TODO list - [ ] Review above information - [ ] Follow the process detailed in [this handbook page](https://handbook.gitlab.com/handbook/support/readiness/operations/docs/policies/us_gov_support_exceptions) /assign @#{requester.username} @jcolyer @secole @lyle /label ~"Stage::Development" ~p4 ~zendesk ~administrative ~"Customer::Field" cc @jscarborough @leeeee-gtlb @ktague STRING end |
.opportunity ⇒ Object
Sets the global variable opportunity
129 130 131 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 129 def self.opportunity @opportunity ||= fetch_opportunity end |
.opportunity_id ⇒ Object
Sets the global variable opportunity_id
169 170 171 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 169 def self.opportunity_id @opportunity_id ||= ENV.fetch('ENABLE_US_GOV_SUPPORT_SFDC_OPP') end |
.opportunity_query ⇒ Object
Returns a String to get opportunity information
213 214 215 216 217 218 219 220 221 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 213 def self.opportunity_query <<~STRING SELECT Id FROM Opportunity WHERE Id = '#{opportunity_id}' STRING end |
.process!(gitlab_client, gitlab_admin_client, zendesk_client, sfdc_client, sandbox = false) ⇒ Object
Process a Enable US Government request
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 18 def self.process!(gitlab_client, gitlab_admin_client, zendesk_client, sfdc_client, sandbox = false) @gitlab_client = gitlab_client @gitlab_admin_client = gitlab_admin_client @zendesk_client = zendesk_client @sfdc_client = sfdc_client requester zd_user checks unless errors.count.zero? Readiness::SupportSuperFormProcessor::Shared.invalid_enable_usgov(requester, errors) end issue = Readiness::GitLab::Issues.new if sandbox issue.title = '[SANDBOX REQUEST] Add US Government Support exception' else issue.title = 'Add US Government Support exception' end 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
46 47 48 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 46 def self.project @project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 68534119) end |
.requester ⇒ Object
Sets the global variable requester
93 94 95 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 93 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
111 112 113 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 111 def self.requester_email @requester_email ||= ENV.fetch('REQUESTER_EMAIL') end |
.zd_user ⇒ Object
Sets the global variable zd_user
102 103 104 |
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 102 def self.zd_user @zd_user ||= Readiness::SupportSuperFormProcessor::Shared.zendesk_user_check(@zendesk_client, requester_email) end |