Class: Xip::Services::Twilio::MessageHandler
- Inherits:
-
BaseMessageHandler
- Object
- BaseMessageHandler
- Xip::Services::Twilio::MessageHandler
- Defined in:
- lib/xip/services/twilio/message_handler.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#service_message ⇒ Object
readonly
Returns the value of attribute service_message.
Instance Method Summary collapse
- #coordinate ⇒ Object
-
#initialize(params:, headers:) ⇒ MessageHandler
constructor
A new instance of MessageHandler.
- #process ⇒ Object
Constructor Details
#initialize(params:, headers:) ⇒ MessageHandler
Returns a new instance of MessageHandler.
9 10 11 12 |
# File 'lib/xip/services/twilio/message_handler.rb', line 9 def initialize(params:, headers:) @params = params @headers = headers end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/xip/services/twilio/message_handler.rb', line 7 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/xip/services/twilio/message_handler.rb', line 7 def params @params end |
#service_message ⇒ Object (readonly)
Returns the value of attribute service_message.
7 8 9 |
# File 'lib/xip/services/twilio/message_handler.rb', line 7 def end |
Instance Method Details
#coordinate ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/xip/services/twilio/message_handler.rb', line 14 def coordinate Xip::Services::HandleMessageJob.perform_async( 'twilio', params, headers ) # Relay our acceptance [204, 'No Content'] end |
#process ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/xip/services/twilio/message_handler.rb', line 25 def process = ServiceMessage.new(service: 'twilio') .sender_id = params['From'] .target_id = params['To'] . = params['Body'] # Check for media attachments = params['NumMedia'].to_i .times do |i| . << { type: params["MediaContentType#{i}"], url: params["MediaUrl#{i}"] } end end |