Class: BabySMS::Adapters::TwilioAdapter
- Inherits:
-
BabySMS::Adapter
- Object
- BabySMS::Adapter
- BabySMS::Adapters::TwilioAdapter
- Defined in:
- lib/babysms/adapters/twilio_adapter.rb
Defined Under Namespace
Classes: WebHook
Instance Attribute Summary
Attributes inherited from BabySMS::Adapter
Instance Method Summary collapse
- #deliver(message) ⇒ Object
-
#initialize(account_sid:, auth_token:, from:) ⇒ TwilioAdapter
constructor
A new instance of TwilioAdapter.
Methods inherited from BabySMS::Adapter
#adapter_id, adapter_name, #adapter_name, for_adapter_id, for_number, #web_hook, #web_hook?, #web_hook_class
Constructor Details
#initialize(account_sid:, auth_token:, from:) ⇒ TwilioAdapter
Returns a new instance of TwilioAdapter.
8 9 10 11 12 |
# File 'lib/babysms/adapters/twilio_adapter.rb', line 8 def initialize(account_sid:, auth_token:, from:) super(from: from) self.client = Twilio::REST::Client.new(account_sid, auth_token) end |
Instance Method Details
#deliver(message) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/babysms/adapters/twilio_adapter.rb', line 14 def deliver() result = client.api.account..create(from: from, to: .to, body: .contents, status_callback: web_hook.end_point) result.sid rescue Twilio::REST::TwilioError => e raise BabySMS::FailedDelivery.new(e., adapter: self) end |