Class: Workarea::UpdatePaymentProfileEmail

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::CallbacksWorker, Sidekiq::Worker
Defined in:
app/workers/workarea/update_payment_profile_email.rb

Instance Method Summary collapse

Instance Method Details

#perform(id, changes) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/workers/workarea/update_payment_profile_email.rb', line 10

def perform(id, changes)
  if changes['email'].present? && changes['email'].first.present?
    old_email = changes['email'].first
    new_email = changes['email'].last

    user = User.find(id)
    user.email = old_email # set old email so we lookup by old email value

    Payment::Profile.update_email(PaymentReference.new(user), new_email)
  end
end