Class: SpreeCmCommissioner::Sms

Inherits:
BaseInteractor show all
Defined in:
app/interactors/spree_cm_commissioner/sms.rb

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/interactors/spree_cm_commissioner/sms.rb', line 3

def call
  context.fail!(message: I18n.t('sms.to.blank')) if context.to.blank?
  context.fail!(message: I18n.t('sms.body.blank')) if context.body.blank?

  begin
    create_sms_log(sms_options)
    create_message(sms_options)
  rescue StandardError => e
    context.sms_log.error = e.message
    context.sms_log.save
    context.fail!(message: e.message)
  end
end