Class: Unisms::Adapter::Nexmo
Instance Method Summary collapse
- #deliver(message, to: nil, from: nil) ⇒ Object
-
#initialize(key, secret) ⇒ Nexmo
constructor
A new instance of Nexmo.
Constructor Details
#initialize(key, secret) ⇒ Nexmo
Returns a new instance of Nexmo.
6 7 8 |
# File 'lib/unisms/adapter/nexmo.rb', line 6 def initialize(key, secret) @nexmo = ::Nexmo::Client.new key: key, secret: secret end |
Instance Method Details
#deliver(message, to: nil, from: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/unisms/adapter/nexmo.rb', line 10 def deliver(, to: nil, from: nil) raise ArgumentError.new "'from' is required in Nexmo" if from.nil? response = @nexmo.(text: , to: to, from: from, type: 'unicode') Unisms.logger.debug response true rescue ArgumentError => e Unisms.logger.error "ArgumentError: #{e}" false rescue SocketError => e Unisms.logger.error "Failed to send message to #{to}" false end |