Class: Stealth::Services::Bandwidth::EventHandler
- Inherits:
-
Stealth::ServiceEvent
- Object
- Stealth::ServiceEvent
- Stealth::Services::Bandwidth::EventHandler
- Defined in:
- lib/stealth/services/bandwidth/event_handler.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#event ⇒ Object
Returns the value of attribute event.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#message ⇒ Object
Returns the value of attribute message.
-
#nlp_result ⇒ Object
Returns the value of attribute nlp_result.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#previous_message ⇒ Object
Returns the value of attribute previous_message.
-
#selected_option ⇒ Object
Returns the value of attribute selected_option.
-
#sender_id ⇒ Object
Returns the value of attribute sender_id.
-
#target_id ⇒ Object
Returns the value of attribute target_id.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #coordinate ⇒ Object
-
#initialize(params:, headers:) ⇒ EventHandler
constructor
A new instance of EventHandler.
- #process ⇒ Object
Constructor Details
#initialize(params:, headers:) ⇒ EventHandler
Returns a new instance of EventHandler.
9 10 11 12 13 14 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 9 def initialize(params:, headers:) super(service: 'bandwidth') @params = parse(params) @headers = headers = [] end |
Instance Attribute Details
#attachments ⇒ Object
Returns the value of attribute attachments.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def end |
#event ⇒ Object
Returns the value of attribute event.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def event @event end |
#event_type ⇒ Object
Returns the value of attribute event_type.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def event_type @event_type end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 6 def headers @headers end |
#message ⇒ Object
Returns the value of attribute message.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def end |
#nlp_result ⇒ Object
Returns the value of attribute nlp_result.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def nlp_result @nlp_result end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 6 def params @params end |
#previous_message ⇒ Object
Returns the value of attribute previous_message.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def end |
#selected_option ⇒ Object
Returns the value of attribute selected_option.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def selected_option @selected_option end |
#sender_id ⇒ Object
Returns the value of attribute sender_id.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def sender_id @sender_id end |
#target_id ⇒ Object
Returns the value of attribute target_id.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def target_id @target_id end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 7 def end |
Instance Method Details
#coordinate ⇒ Object
16 17 18 19 20 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 16 def coordinate return [202, 'Accepted'] if should_ignore_event?(params) Stealth::Services::HandleEventJob.perform_async('bandwidth', params, headers) [202, 'Accepted'] end |
#process ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/stealth/services/bandwidth/event_handler.rb', line 23 def process self.sender_id = params.dig('message', 'from') self.target_id = params.dig('message', 'to').first self. = params.dig('message', 'text') self. = params.dig('message', 'time') params.dig('message', 'media')&.each do || self. << { url: } end mapped_event = map_event_type self.event_type = mapped_event[:event_type] self.event = mapped_event[:event] self end |