Class: Readiness::SupportSuperFormProcessor::GratisRequest

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

Overview

Defines the class GratisRequest within the module Zendesk.

Author:

  • Jason Colyer

Since:

  • 1.0.51

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

.bodyObject

Returns the body to use for a ticket

Author:

  • Jason Colyer

Since:

  • 1.0.51



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 198

def self.body
  <<~STRING
    <p>
      Greetings #{customer_name} !
    </p>
    <p>
      We have been notified you are in need of some assistance. The context we were provided is as follows:
    </p>
    <pre>
      #{context}
    </pre>
    <p>
      Our Support team will review this request, but please feel free to reply back with any further information that may assist us in assisting you.
    </p>
    <p>
      In addition to reply by email, you can manage this request by logging in with your account at
      <a href='https://support.gitlab.com'>https://support.gitlab.com</a>.
      If you didn't previously have an account, one was created for you. You can access it by sending a request to 
      <a href='https://support.gitlab.com/hc/en-us/articles/11626501035292-Support-Portal#reset-your-password'>reset your password</a>.
    </p>
    <p>
      Thank you,
    </p>
    <p>
      GitLab Support
    </p>
  STRING
end

.contextObject

Sets the global variable context

Author:

  • Jason Colyer

Since:

  • 1.0.51



132
133
134
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 132

def self.context
  @context ||= ENV.fetch('TICKET_BODY')
end

.customer_emailObject

Sets the global variable customer_email

Author:

  • Jason Colyer

Since:

  • 1.0.51



96
97
98
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 96

def self.customer_email
  @customer_email ||= ENV.fetch('CONTACT_EMAIL')
end

.customer_nameObject

Sets the global variable customer_name

Author:

  • Jason Colyer

Since:

  • 1.0.51



105
106
107
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 105

def self.customer_name
  @customer_name ||= ENV.fetch('CONTACT_NAME')
end

.fetch_sfdc_opportunityObject

Gets the SFDC Opportunity information

Author:

  • Jason Colyer

Since:

  • 1.0.51



159
160
161
162
163
164
165
166
# File 'lib/support_readiness/support_super_form_processor/gratis_request.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
rescue Restforce::ErrorCode::InvalidQueryFilterOperator
  puts 'Invalid SFDC opp link provided'
  Readiness::SupportSuperFormProcessor::Shared.invalid_opportunity_link(requester, opportunity_link)
end

Sets the global variable opportunity_link

Author:

  • Jason Colyer

Since:

  • 1.0.51



114
115
116
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 114

def self.opportunity_link
  @opportunity_link ||= ENV.fetch('SFDC_OPPORTUNITY')
end

.opportunity_queryObject

Returns a SOQL query string to get Opportunity info

Author:

  • Jason Colyer

Since:

  • 1.0.51



173
174
175
176
177
178
179
180
181
182
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 173

def self.opportunity_query
  <<~STRING
    SELECT
      Opportunity.Id,
      Opportunity.ARR__c
    FROM Opportunity
    WHERE
      Opportunity.Id = '#{opportunity_link.split('/')[-2]}'
  STRING
end

.process!(sfdc_client, zendesk_client, sandbox = false) ⇒ Object

Process a Gratis Request request

Author:

  • Jason Colyer

Since:

  • 1.0.51



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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 18

def self.process!(sfdc_client, zendesk_client, sandbox = false)
  @sfdc_client = sfdc_client
  @zendesk_client = zendesk_client
  @ticket_forms = Readiness::Zendesk::TicketForms.list(@zendesk_client)
  @ticket_fields = Readiness::Zendesk::TicketFields.list(@zendesk_client)
  @support_ir_form = Readiness::Zendesk::TicketForms.find_by_name(@zendesk_client, 'Support Internal Request', @ticket_forms)
  @area_of_focus_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Area of Focus', @ticket_fields)
  @ticket_stage_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Ticket Stage', @ticket_fields)
  @prfs_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Preferred Region for Support', @ticket_fields)
  @plan_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'GitLab Plan', @ticket_fields)
  @sales_name_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Sales contact name', @ticket_fields)
  @sales_email_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Sales contact email', @ticket_fields)
  @severity_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Customer Severity (maps to priority, do not change)', @ticket_fields)
  @arr_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Ticket ARR', @ticket_fields)
  @priority_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Customer Priority', @ticket_fields)
  @channel_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Channel (Received at email)', @ticket_fields)
  @ir_sfdc_id_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'IR SFDC ID', @ticket_fields)        
  zd_user
  ticket = Readiness::Zendesk::Tickets.new
  ticket.email_ccs = [
    { user_id: zd_user.id }
  ]
  ticket.requester = { name: customer_name, email: customer_email }
  ticket.comment = { html_body: body }
  ticket.subject = ticket_subject
  ticket.tags = %w[support_gratis_request manual_support_upgrade]
  ticket.priority = 'medium'
  ticket.status = 'new'
  ticket.ticket_form_id = @support_ir_form.id
  ticket.custom_fields = [
    { id: @area_of_focus_field.id,  value: 'aof_other' },
    { id: @ticket_stage_field.id,  value: 'stage-frt' },
    { id: @plan_field.id,  value: 'free_plan' },
    { id: @sales_name_field.id,  value: zd_user.name },
    { id: @sales_email_field.id,  value: zd_user.email },
    { id: @severity_field.id,  value: 'medium' },
    { id: @arr_field.id,  value: ticket_arr },
    { id: @priority_field.id,  value: 'medium' },
    { id: @channel_field.id,      value: 'created_by_agent' },
    { id: @prfs_field.id,  value: region },
    { id: @ir_sfdc_id_field.id, value: opportunity_link.split('/')[-2] }          
  ]
  create = Readiness::Zendesk::Tickets.create!(@zendesk_client, ticket)
  puts "Ticket created: #{create.id}"
end

.regionObject

Sets the global variable region

Author:

  • Jason Colyer

Since:

  • 1.0.51



141
142
143
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 141

def self.region
  @region ||= ENV.fetch('PREFERRED_REGION')
end

.requesterObject

Sets the global variable requester

Author:

  • Jason Colyer

Since:

  • 1.0.51



69
70
71
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 69

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.51



78
79
80
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 78

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

.sfdc_opportunityObject

Sets the global variable sfdc_opportunity

Author:

  • Jason Colyer

Since:

  • 1.0.51



150
151
152
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 150

def self.sfdc_opportunity
  @sfdc_opportunity ||= fetch_sfdc_opportunity
end

.ticket_arrObject

Returns the ARR to use for a ticket

Author:

  • Jason Colyer

Since:

  • 1.0.51



189
190
191
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 189

def self.ticket_arr
  (sfdc_opportunity.nil? ? 0 : sfdc_opportunity.ARR__c.to_i)
end

.ticket_subjectObject

Sets the global variable ticket_subject

Author:

  • Jason Colyer

Since:

  • 1.0.86



123
124
125
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 123

def self.ticket_subject
  @ticket_subject ||= ENV.fetch('TICKET_SUBJECT', 'Gratis Support Request')
end

.zd_userObject

Sets the global variable zd_user

Author:

  • Jason Colyer

Since:

  • 1.0.51



87
88
89
# File 'lib/support_readiness/support_super_form_processor/gratis_request.rb', line 87

def self.zd_user
  @zd_user ||= Readiness::SupportSuperFormProcessor::Shared.zendesk_user_check(@zendesk_client, requester_email)
end