Class: OauthCredentialMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/oauth_credential_mailer.rb

Overview

Alerts the responsible owner when an outbound OAuth credential's token can
no longer be refreshed automatically and needs a manual reconnect.

Instance Method Summary collapse

Methods inherited from ApplicationMailer

#null_mail

Instance Method Details

#refresh_failed(credential) ⇒ Object

Parameters:



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/mailers/oauth_credential_mailer.rb', line 9

def refresh_failed(credential)
  @provider      = credential.provider.titleize
  @error         = credential.&.dig('last_refresh_error')
  @failing_since = credential.&.dig('refresh_failing_since')
  @reconnect_url = credential.reconnect_url
  @user_facing   = (credential.owner || credential.)&.employee.present?

  mail(
    to:      credential.alert_recipient_email,
    subject: "[Heatwave] #{@provider} integration needs reconnecting"
  )
end