Class: CentralMail::Service

Inherits:
Common::Client::Base show all
Includes:
Common::Client::Concerns::Monitoring
Defined in:
lib/central_mail/service.rb

Constant Summary collapse

STATSD_KEY_PREFIX =

Please do not use this module. It has been superceded by the # Lighthouse::BenefitsIntake::Service module: #

                                                           #
https://github.com/department-of-veterans-affairs/vets-api/blob/94f88d1bb55d961e036d6fed3117735d6b9074cd/lib/lighthouse/benefits_intake/service.rb

The above-linked module sends submissions to Central Mail # Processing through the Lighthouse Benefits Intake API #

#

Additionally, it is the responsibility of any team sending # submissions to Lighthouse to monitor those submissions. See # here for more details: #

#

depo-platform-documentation.scrollhelp.site/developer-docs/endpoint-monitoring

'api.central_mail'

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common::Client::Concerns::Monitoring

#increment, #increment_failure, #increment_total, #with_monitoring

Methods inherited from Common::Client::Base

#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Class Method Details

.current_breaker_outage?Boolean

Returns:

  • (Boolean)
[View source] [View on GitHub]

73
74
75
76
77
78
79
80
# File 'lib/central_mail/service.rb', line 73

def self.current_breaker_outage?
  last_cm_outage = Breakers::Outage.find_latest(service: CentralMail::Configuration.instance.breakers_service)
  if last_cm_outage.present? && last_cm_outage.end_time.blank?
    return CentralMail::Service.new.status('').try(:status) != 200
  end

  false
end

Instance Method Details

#status(uuid_or_list) ⇒ Object

rubocop:enable Metrics/MethodLength

[View source] [View on GitHub]

60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/central_mail/service.rb', line 60

def status(uuid_or_list)
  body = {
    token: Settings.central_mail.upload.token,
    uuid: [*uuid_or_list].to_json
  }

  request(
    :post,
    'getStatus',
    body
  )
end

#upload(body) ⇒ Object

rubocop:disable Metrics/MethodLength

[View source] [View on GitHub]

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
# File 'lib/central_mail/service.rb', line 31

def upload(body)
  Sentry.set_extras(
    request: {
      metadata: body['metadata']
    }
  )
  body['token'] = Settings.central_mail.upload.token

  response = with_monitoring do
    request(
      :post,
      'upload',
      body
    )
  end

  Sentry.set_extras(
    response: {
      status: response.status,
      body: response.body
    }
  )

  StatsD.increment("#{STATSD_KEY_PREFIX}.upload.fail") unless response.success?

  response
end