Class: SmsBroker::Client::Twilio
- Defined in:
- lib/sms_broker/client/twilio.rb
Instance Attribute Summary
Attributes inherited from Base
#client, #name, #phone_number, #sender_id
Instance Method Summary collapse
-
#initialize(options) ⇒ Twilio
constructor
A new instance of Twilio.
- #send_message(message) ⇒ Object
- #send_voice_message(_message) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options) ⇒ Twilio
Returns a new instance of Twilio.
4 5 6 7 8 9 10 11 |
# File 'lib/sms_broker/client/twilio.rb', line 4 def initialize() client = ::Twilio::REST::Client.new( [:account_sid], [:auth_token] ) super :Twilio, client, end |
Instance Method Details
#send_message(message) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sms_broker/client/twilio.rb', line 13 def () response = client..create \ body: [:text], from: [:from], to: serialize_to_number([:to]) return Response::TwilioSuccess.new(response) \ if success_response?(response) Response::TwilioError.new(response) rescue ::Twilio::REST::RequestError => exception Response::TwilioError.new(exception) end |
#send_voice_message(_message) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/sms_broker/client/twilio.rb', line 27 def () = 'twillio voice message integration is not implemented' exception = \ Exceptions::NotImplemented.new() raise exception end |