class BabySMS::Adapters::NexmoAdapter
Public Class Methods
new(api_key:, api_secret:, from:)
click to toggle source
Calls superclass method
BabySMS::Adapter::new
# File lib/babysms/adapters/nexmo_adapter.rb, line 8 def initialize(api_key:, api_secret:, from:) super(from: from) self.client = Nexmo::Client.new(api_key: api_key, api_secret: api_secret) end
Public Instance Methods
deliver(message)
click to toggle source
# File lib/babysms/adapters/nexmo_adapter.rb, line 14 def deliver(message) # Thanks for being weird, Nexmo. Rejects numbers starting with "+" response = client.sms.send(from: from.gsub(/\A\+/, ''), to: message.to, text: message.contents) if response.messages.first.status != '0' raise BabySMS::FailedDelivery.new(response.messages.first.error_text, adapter: self) end response.messages.first.message_id end