lib/smsc.rb in smsc-0.0.3 vs lib/smsc.rb in smsc-0.0.4

- old
+ new

@@ -1,22 +1,23 @@ require 'digest/md5' -require 'httparty' +require 'faraday' -require "smsc/sender" -require "smsc/version" - module Smsc class Sms - attr_reader :login, :password, :charset def initialize(login, password, charset = 'utf-8') @login = 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 def message(message, phones) - phones = phones.join(",") - Smsc::Sender.post('https://smsc.ru/sys/send.php', :query => { :login => login, :psw => password, :phones => phones, :mes => message, :charset => charset }) + @connection.post '/sys/send.php', { login: @login, psw: @password, phones: phones.join(','), mes: message, charset: @charset } end + end end