Class: Stealth::Services::Twilio::MessageHandler
- Inherits:
-
BaseMessageHandler
- Object
- BaseMessageHandler
- Stealth::Services::Twilio::MessageHandler
- Defined in:
- lib/stealth/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.
10 11 12 13 |
# File 'lib/stealth/services/twilio/message_handler.rb', line 10 def initialize(params:, headers:) @params = params @headers = headers end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/stealth/services/twilio/message_handler.rb', line 8 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/stealth/services/twilio/message_handler.rb', line 8 def params @params end |
#service_message ⇒ Object (readonly)
Returns the value of attribute service_message.
8 9 10 |
# File 'lib/stealth/services/twilio/message_handler.rb', line 8 def @service_message end |
Instance Method Details
#coordinate ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/stealth/services/twilio/message_handler.rb', line 15 def coordinate Stealth::Services::HandleMessageJob.perform_async( 'twilio', params, headers ) # Relay our acceptance [204, 'No Content'] end |
#process ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/stealth/services/twilio/message_handler.rb', line 26 def process @service_message = 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 |