Class: Unisms::Adapter::Kotsms
- Defined in:
- lib/unisms/adapter/kotsms.rb
Instance Method Summary collapse
- #deliver(message, to: nil, from: nil) ⇒ Object
-
#initialize(username, password, options = {}) ⇒ Kotsms
constructor
A new instance of Kotsms.
Constructor Details
#initialize(username, password, options = {}) ⇒ Kotsms
Returns a new instance of Kotsms.
6 7 8 9 |
# File 'lib/unisms/adapter/kotsms.rb', line 6 def initialize(username, password, = {}) @kotsms = ::Kotsms.new username, password @kotsms_options = end |
Instance Method Details
#deliver(message, to: nil, from: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/unisms/adapter/kotsms.rb', line 11 def deliver(, to: nil, from: nil) raise ArgumentError.new("phone number should start with '+'") unless /\A\+.*\z/ === to @kotsms.deliver to[1..-1], , @kotsms_options true rescue ArgumentError => e Unisms.logger.error "ArgumentError: #{e}" rescue SocketError => e Unisms.logger.error "Failed to send message to #{to}" false end |