Class: Stealth::Services::Bandwidth::MessageHandler
- Inherits:
-
Stealth::Services::BaseMessageHandler
- Object
- Stealth::Services::BaseMessageHandler
- Stealth::Services::Bandwidth::MessageHandler
- Defined in:
- lib/stealth/services/bandwidth/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/stealth/services/bandwidth/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/stealth/services/bandwidth/message_handler.rb', line 7 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/stealth/services/bandwidth/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/stealth/services/bandwidth/message_handler.rb', line 7 def @service_message end |
Instance Method Details
#coordinate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/stealth/services/bandwidth/message_handler.rb', line 14 def coordinate case params.dig('message', 'direction') when "in" Stealth::Services::HandleMessageJob.perform_async( 'bandwidth', params, headers ) when "out" # Ignoring outbound messages end # Relay our acceptance [202, 'Accepted'] end |
#process ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/stealth/services/bandwidth/message_handler.rb', line 30 def process @service_message = ServiceMessage.new(service: 'bandwidth') .sender_id = params.dig('message', 'from') .target_id = params.dig('message', 'to') . = params.dig('message', 'text') . = params.dig('message', 'time') params.dig('message', 'media')&.each do || . << { url: } end end |