Class: Outbox::Bandwidth::Client
- Inherits:
-
Clients::Base
- Object
- Clients::Base
- Outbox::Bandwidth::Client
- Includes:
- Bandwidth::Messaging
- Defined in:
- lib/outbox/bandwidth/client.rb
Overview
Uses Bandwidth’s official Ruby API client (bandwidth) to deliver SMS messages.
dev.bandwidth.com/sdks/ruby.html
sms = Outbox::Messages::SMS.new(
to: '+15552224444',
from: '+15551115555',
body: 'Hello World'
)
sms.deliver
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
Instance Method Summary collapse
- #deliver(sms) ⇒ Object
-
#initialize(settings = nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(settings = nil) ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/outbox/bandwidth/client.rb', line 22 def initialize(settings = nil) super = @settings.dup bandwidth_client_settings = .slice( :messaging_basic_auth_user_name, :messaging_basic_auth_password, :voice_basic_auth_user_name, :voice_basic_auth_password, :two_factor_auth_basic_auth_user_name, :two_factor_auth_basic_auth_password, :environment, :base_url ) @account_id = [:subaccount_id] || [:account_id] @application_id = [:application_id] @api_client = ::Bandwidth::Client.new( bandwidth_client_settings ) end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
19 20 21 |
# File 'lib/outbox/bandwidth/client.rb', line 19 def api_client @api_client end |
Instance Method Details
#deliver(sms) ⇒ Object
42 43 44 45 46 |
# File 'lib/outbox/bandwidth/client.rb', line 42 def deliver(sms) messaging_client = @api_client.messaging_client.client body = (sms) messaging_client.(account_id(sms), body: body) end |