Class: Smsc::Sms

Inherits:
Object
  • Object
show all
Defined in:
lib/smsc.rb

Instance Method Summary collapse

Constructor Details

#initialize(login, password, charset = 'utf-8') ⇒ Sms

Returns a new instance of Sms.



7
8
9
10
11
12
13
14
15
16
# File 'lib/smsc.rb', line 7

def initialize(, password, charset = 'utf-8')
  @login = 
  @password = Digest::MD5.hexdigest(password.to_s)
  @charset = charset
  @connection = Faraday.new(url: 'https://smsc.ru') do |i|
    i.request  :url_encoded
    i.response :logger
    i.adapter  Faraday.default_adapter
  end
end

Instance Method Details

#message(message, phones, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/smsc.rb', line 18

def message(message, phones, options = {})
  params = {
    login: @login,
    psw: @password,
    phones: phones.join(','),
    mes: message,
    charset: @charset,
    sender: options[:sender]
  }

  @connection.post '/sys/send.php', params
end