class Readiness::SupportSuperFormProcessor::GlobalIRDotcomSubscriptionsExtension

@since 1.0.42
@author Jason Colyer
Defines the class GlobalIRDotcomSubscriptionsExtension within the module {Readiness::Zendesk}.
#

def self.body

Returns:
  • (String) -

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
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 Extend an (almost) expired subscription (GitLab.com).
    </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>#{Readiness::SupportSuperFormProcessor::Shared.sfdc_account_string(sfdc_account_link)}</li>
      <li>#{Readiness::SupportSuperFormProcessor::Shared.sfdc_opportunity_string(opp_link)}</li>
      <li>GitLab.com namespace: #{@namespace.path}</li>
      <li>Plan: #{plan}</li>
      <li>Requested expiration date: #{extension_date}</li>
      <li>Subscription name: #{sub_name}</li>
      <li>Reason for extension: #{reason}</li>
    </ul>
    <p>
      Some additional context for this request is:
    </p>
    <pre>
      #{context}
    </pre>
  STRING
end

def self.company

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.company
  @company ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_COMPANY_NAME')
end

def self.contact_email

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.contact_email
  @contact_email ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_EMAIL')
end

def self.contact_name

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.contact_name
  @contact_name ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_CONTACT_NAME')
end

def self.context

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.context
  @context ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_CONTEXT')
end

def self.extension_date

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.extension_date
  @extension_date ||= ENV.fetch('SAAS_SUB_EXTENSION_EXPIRATION')
end

def self.namespace_provided

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.namespace_provided
  @namespace_provided ||= ENV.fetch('SAAS_SUB_EXTENSION_NAMESPACE')
end

def self.opp_link

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.opp_link
  @opp_link ||= ENV.fetch('SAAS_SUB_EXTENSION_SFDC_OPPORTUNITY')
end

def self.plan

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.plan
  @plan ||= ENV.fetch('SAAS_SUB_EXTENSION_SUB_PLAN')
end

def self.process!(gitlab_client, gitlab_admin_client, zendesk_client)

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.process!(gitlab_client, gitlab_admin_client, zendesk_client)
  @gitlab_client = gitlab_client
  @gitlab_admin_client = gitlab_admin_client
  @zendesk_client = zendesk_client
  requester
  zd_user
  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 = 379855863520
  ticket.submitter_id = 379855863520
  ticket.comment = { html_body: body }
  ticket.subject = 'Internal Request - GitLab.com - Extend an (almost) expired subscription'
  ticket.tags = %w[lnr_internal_request lnr_valid_request lnr_saas_subscription lnr_saas_sub_extension]
  ticket.priority = request_priority
  ticket.status = 'new'
  ticket.ticket_form_id = 360000071293
  ticket.custom_fields = [
    { id: 4414446722578, value: 'ticket_group_not_applicable' },
    { id: 360020614420,  value: 'aof_lnr' },
    { id: 360020735259,  value: 'stage-frt' },
    { id: 360018253094,  value: 'all_regions' },
    { id: 360004394559,  value: 'free_plan' },
    { id: 360005183820,  value: zd_user.name },
    { id: 360005248219,  value: zd_user.email },
    { id: 360020735319,  value: 'sev3' },
    { id: 360020288373,  value: '0' },
    { id: 360014776453,  value: 'medium' },
    { id: 6978426204828, value: 'ir_extend_saas_sub' },
    { id: 6978366086428, value: zd_user.email },
    { id: 45195248,      value: 'created_by_agent' }
  ]
  create = Readiness::Zendesk::Tickets.create!(@zendesk_client, ticket)
  puts "Ticket created: https://gitlab.zendesk.com/agent/tickets/#{create.id}"
end

def self.reason

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.reason
  @reason ||= ENV.fetch('SAAS_SUB_EXTENSION_REASON')
end

def self.request_priority

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.request_priority
  @request_priority ||= ENV.fetch('INTERNAL_REQUEST_GLOBAL_PRIORITY')
end

def self.requester

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.requester
  @requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email)
end

def self.requester_email

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.requester_email
  @requester_email ||= ENV.fetch('REQUESTER_EMAIL')
end

def self.sfdc_account_link

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.sfdc_account_link
  @sfdc_account_link ||= ENV.fetch('SAAS_SUB_EXTENSION_SFDC_ACCOUNT')
end

def self.sub_name

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.sub_name
  @sub_name ||= ENV.fetch('SAAS_SUB_EXTENSION_SUB_NAME')
end

def self.zd_user

Other tags:
    Since: - 1.0.42

Other tags:
    Author: - Jason Colyer
def self.zd_user
  @zd_user ||= Readiness::SupportSuperFormProcessor::Shared.zendesk_user_check(@zendesk_client, requester_email)
end