Method: CentralMail::Service#upload

Defined in:
lib/central_mail/service.rb

#upload(body) ⇒ Object

rubocop:disable Metrics/MethodLength



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