Class: Unisms::Adapter::Kotsms

Inherits:
Base
  • Object
show all
Defined in:
lib/unisms/adapter/kotsms.rb

Instance Method Summary collapse

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, options = {})
	@kotsms = ::Kotsms.new username, password
	@kotsms_options = 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(message, to: nil, from: nil)
	raise ArgumentError.new("phone number should start with '+'") unless /\A\+.*\z/ === to
	@kotsms.deliver to[1..-1], message, @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