Class: Readiness::SupportSuperFormProcessor::EnableUSGov

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

Overview

Defines the class EnableUSGov 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

.accountObject

Sets the global variable account

Author:

  • Jason Colyer

Since:

  • 1.0.42



120
121
122
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 120

def self.
  @account ||= 
end

.account_idObject

Sets the global variable account_id

Author:

  • Jason Colyer

Since:

  • 1.0.42



160
161
162
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 160

def self.
  @account_id ||= ENV.fetch('ENABLE_US_GOV_SUPPORT_SFDC_ACCOUNT')
end

.account_queryObject

Returns a String to get account information

Author:

  • Jason Colyer

Since:

  • 1.0.42



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.
  <<~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 = '#{}'
  STRING
end

.checksObject

Peform validity checks for this request

Author:

  • Jason Colyer

Since:

  • 1.0.42



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: #{}") if .nil?
  errors.push("Invalid SFDC opportunity given: #{opportunity_id}") if opportunity.nil?
  return unless errors.count.zero?

  errors.push("SFDC account #{} already has the exception") if .Support_Instance__c == 'federal-support'
  errors.push("Missing US Government SKU on #{}") unless correct_sku?
end

.correct_sku?Boolean

Check the SFDC account for a US Gov SKU

Returns:

  • (Boolean)

Author:

  • Jason Colyer

Since:

  • 1.0.42



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 .Zuora__R00N40000001lGjTEAU__r.nil?

  .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

.errorsObject

Sets the global variable errors

Author:

  • Jason Colyer

Since:

  • 1.0.42



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

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

.fetch_accountObject

Run a SQOL query to get account information

Author:

  • Jason Colyer

Since:

  • 1.0.42



138
139
140
141
142
# File 'lib/support_readiness/support_super_form_processor/enable_us_government.rb', line 138

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

.fetch_opportunityObject

Run a SQOL query to get opportunity information

Author:

  • Jason Colyer

Since:

  • 1.0.42



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

.messageObject

Return the string for the issue body

Author:

  • Jason Colyer

Since:

  • 1.0.42



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.message
  <<~STRING
    ## Add US Government Support exception for #{.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_ID_18__c}](https://gitlab.lightning.force.com/lightning/r/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:
    #{.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

.opportunityObject

Sets the global variable opportunity

Author:

  • Jason Colyer

Since:

  • 1.0.42



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_idObject

Sets the global variable opportunity_id

Author:

  • Jason Colyer

Since:

  • 1.0.42



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_queryObject

Returns a String to get opportunity information

Author:

  • Jason Colyer

Since:

  • 1.0.42



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

Author:

  • Jason Colyer

Since:

  • 1.0.42



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 = message
  create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue)
  puts "Issue created: #{create.web_url}"
  exit 0
end

.projectObject

Sets the global variable project

Author:

  • Jason Colyer

Since:

  • 1.0.133



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

.requesterObject

Sets the global variable requester

Author:

  • Jason Colyer

Since:

  • 1.0.42



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_emailObject

Sets the global variable requester_email

Author:

  • Jason Colyer

Since:

  • 1.0.42



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_userObject

Sets the global variable zd_user

Author:

  • Jason Colyer

Since:

  • 1.0.42



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