Class: SmsSafe::Interceptors::Nexmo

Inherits:
SmsSafe::Interceptor show all
Defined in:
lib/sms_safe/interceptors/nexmo.rb

Instance Method Summary collapse

Methods inherited from SmsSafe::Interceptor

#discard, #email, #email_recipient, #intercept_message!, #intercept_message?, #process_message, #redirect_phone_number, #redirect_text

Instance Method Details

#convert_message(message) ⇒ Message

Converts a hash of params (Nexmo doesn't use a class to represent their messages) into Message


14
15
16
# File 'lib/sms_safe/interceptors/nexmo.rb', line 14

def convert_message(message)
  SmsSafe::Message.new(from: message[:from], to: message[:to], text: message[:text], original_message: message)
end

#redirect(message) ⇒ Hash

Returns a modified version of the original message with new recipient and text,

to give back to the texter gem to send.

23
24
25
26
27
28
# File 'lib/sms_safe/interceptors/nexmo.rb', line 23

def redirect(message)
  original_message = message.original_message
  original_message[:to] = redirect_phone_number(message)
  original_message[:text] = redirect_text(message)
  original_message
end