Class: Readiness::SupportSuperFormProcessor::GlobalIRDotcomSubscriptionsNFR

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

Overview

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

.bodyString

Returns the ticket body

Returns:

  • (String)

Author:

  • Jason Colyer

Since:

  • 1.0.42



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 204

def self.body
  <<~STRING
    <p>
      Greetings,
    </p>
    <p>
      Please note that this is an <b>INTERNAL</b> ticket and should <b>NEVER</b> be shared with anyone. Please do not CC, BCC, forward, or anything else that can send the information from this ticket. <b>NEVER</b> add <i>anyone</i> outside of GitLab to this ticket or communications stemming from this ticket.
    </p>
    <p>
      A request has been filed for GitLab.com NFR license request.
    </p>
    <p>
      The information for this is as follows:
    </p>
    <ul>
      <li>Customer's name: #{contact_name}</li>
      <li>
        Contact's email: #{contact_email}
        <a href="https://www.zuora.com/platform/apps/search?searchTerm=#{contact_email}" target='_blank'>(Zuora Search)</a>
        <a href="https://customers.gitlab.com/admin/customer?model_name=customer&query=#{contact_email}" target='_blank'>(Portal Search)</a>
      </li>
      <li>Customer's company: #{company}</li>
      <li>GitLab.com namespace: #{@namespace.path}</li>
      <li>Subscription start date: #{sub_start_date}</li>
      <li>Subscription end date: #{sub_end_date}</li>
      <li>#{Readiness::SupportSuperFormProcessor::Shared.()}</li>
      <li>Seats needed: #{seats}</li>
    </ul>
    <p>
      Some additional context for this request is:
    </p>
    <pre>
      #{context}
    </pre>
  STRING
end

.companyObject

Sets the global variable company

Author:

  • Jason Colyer

Since:

  • 1.0.42



149
150
151
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 149

def self.company
  @company ||= ENV.fetch('COMPANY')
end

.contact_emailObject

Sets the global variable contact_email

Author:

  • Jason Colyer

Since:

  • 1.0.42



140
141
142
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 140

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

.contact_nameObject

Sets the global variable contact_name

Author:

  • Jason Colyer

Since:

  • 1.0.42



131
132
133
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 131

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

.contextObject

Sets the global variable context

Author:

  • Jason Colyer

Since:

  • 1.0.42



122
123
124
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 122

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

.namespace_providedObject

Sets the global variable namespace_provided

Author:

  • Jason Colyer

Since:

  • 1.0.42



158
159
160
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 158

def self.namespace_provided
  @namespace_provided ||= ENV.fetch('NAMESPACE')
end

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

Process a Global Internal Request GitLab.com Subscriptions NFR 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 18

def self.process!(gitlab_client, gitlab_admin_client, zendesk_client)
  @gitlab_client = gitlab_client
  @gitlab_admin_client = gitlab_admin_client
  @zendesk_client = zendesk_client
  @ticket_forms = Readiness::Zendesk::TicketForms.list(@zendesk_client)
  @ticket_fields = Readiness::Zendesk::TicketFields.list(@zendesk_client)
  @lnr_form = Readiness::Zendesk::TicketForms.find_by_name(@zendesk_client, 'L&R', @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)
  @ir_category_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'IR Category', @ticket_fields)
  @ir_submitter_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'IR Submitter', @ticket_fields)
  @channel_field = Readiness::Zendesk::TicketFields.find_by_name(@zendesk_client, 'Channel (Received at email)', @ticket_fields)
  search = Readiness::Zendesk::Users.find_many(@zendesk_client, [379855863520, 12816218763676])
  end_user = search.detect { |s| s.email == 'gitlab_support@example.com' }        
  requester
  zd_user
  unless zd_user.tags.include? 'partner_support_agent'
    Readiness::SupportSuperFormProcessor::Shared.not_partner_support_member(requester_email)
  end
  if seats.to_i > 25 || Date.parse(sub_end_date) > (Date.today + 1.years)
    Readiness::SupportSuperFormProcessor::Shared.invalid_nfr_request(requester_email)
  end
  unless Readiness::SupportSuperFormProcessor::Shared.namespace_exists?(@gitlab_admin_client, namespace_provided)
    Readiness::SupportSuperFormProcessor::Shared.invalid_namespace(requester_email, namespace_provided)
  end
  @namespace = Readiness::GitLab::Namespaces.find!(@gitlab_admin_client, namespace_provided)
  ticket = Readiness::Zendesk::Tickets.new
  ticket.email_ccs = [
    { user_id: zd_user.id }
  ]
  ticket.requester_id = end_user.id
  ticket.submitter_id = end_user.id
  ticket.comment = { html_body: body }
  ticket.subject = 'Internal Request - GitLab.com - NFR license request'
  ticket.tags = %w[lnr_internal_request lnr_valid_request lnr_saas_nfr]
  ticket.priority = request_priority
  ticket.status = 'new'
  ticket.ticket_form_id = @lnr_form.id
  ticket.custom_fields = [
    { id: @area_of_focus_field.id, value: 'aof_lnr' },
    { id: @ticket_stage_field.id, value: 'stage-frt' },
    { id: @prfs_field.id, value: 'all_regions' },
    { 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: 'sev3' },
    { id: @arr_field.id, value: '0' },
    { id: @priority_field.id, value: 'medium' },
    { id: @ir_category_field.id, value: 'ir_saas_nfr' },
    { id: @ir_submitter_field.id, value: zd_user.email },
    { id: @channel_field.id, value: 'created_by_agent' }          
  ]
  create = Readiness::Zendesk::Tickets.create!(@zendesk_client, ticket)
  puts "Ticket created: #{create.id}"
end

.request_priorityObject

Sets the global variable request_priority

Author:

  • Jason Colyer

Since:

  • 1.0.42



113
114
115
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 113

def self.request_priority
  @request_priority ||= ENV.fetch('PRIORITY')
end

.requesterObject

Sets the global variable requester

Author:

  • Jason Colyer

Since:

  • 1.0.42



86
87
88
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 86

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



104
105
106
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 104

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

.seatsObject

Sets the global variable seats

Author:

  • Jason Colyer

Since:

  • 1.0.42



194
195
196
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 194

def self.seats
  @seats ||= ENV.fetch('SEAT_COUNT')
end

Sets the global variable sfdc_account_link

Author:

  • Jason Colyer

Since:

  • 1.0.42



185
186
187
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 185

def self.
  @sfdc_account_link ||= ENV.fetch('SFDC_ACCOUNT')
end

.sub_end_dateObject

Sets the global variable sub_end_date

Author:

  • Jason Colyer

Since:

  • 1.0.42



176
177
178
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 176

def self.sub_end_date
  @sub_end_date ||= ENV.fetch('EXPIRATION_DATE')
end

.sub_start_dateObject

Sets the global variable sub_start_date

Author:

  • Jason Colyer

Since:

  • 1.0.42



167
168
169
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 167

def self.sub_start_date
  @sub_start_date ||= ENV.fetch('START_DATE')
end

.zd_userObject

Sets the global variable zd_user

Author:

  • Jason Colyer

Since:

  • 1.0.42



95
96
97
# File 'lib/support_readiness/support_super_form_processor/global_ir_dotcom_subscriptions_nfr.rb', line 95

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