-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd72f4f
commit 646c2ae
Showing
2 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Stealth | ||
module Services | ||
module Bandwidth | ||
|
||
class ServiceMessage < Stealth::ServiceMessage | ||
attr_reader :params, :headers | ||
|
||
def initialize(params:, headers:) | ||
super(service: 'bandwidth') | ||
@params = params | ||
@headers = headers | ||
end | ||
|
||
def process | ||
self.sender_id = params.dig('message', 'from') | ||
self.target_id = params.dig('to') | ||
self.message = params.dig('message', 'text') | ||
self.event_type = params.dig('type') | ||
self.timestamp = params.dig('time') | ||
|
||
# Handle attachments if any | ||
params.dig('message', 'media')&.each do |attachment_url| | ||
service_message.attachments << { | ||
url: attachment_url | ||
} | ||
end | ||
|
||
self | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |