Sha256: 8035236fc007f11ee972d4bfa12db373c8fb5905a4878a9e2011da1edb7e22e1
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module MuthofunApi class SmsAccount def self.send_sms(phone_number, body) @sms_sender = self.new.send_sms(phone_number, body) end def send_sms(phone_number, body) request(path: 'sendsms.jsp', method: 'get', params: {'sms' => body, 'mobiles' => phone_number}) @result = MuthofunApi::Result.new(response) yield(@result) if block_given? && @result.success? @result rescue => e p e.message end def response @response end private def request(path:, method: 'get', params: ) MuthofunApi.check_credentials! conn = ::Faraday.new(:url => "http://clients.muthofun.com:8901/esmsgw/#{path}") response = conn.send(method.to_sym) do |req| req.params['user'] = MuthofunApi.configuration.client_id req.params['password'] = MuthofunApi.configuration.secret_key req.params['unicode'] = 1 req.params.merge!(params) end @response = response.body.gsub(/[\r\n\t]+/m, "").strip end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
muthofun_api-0.1.3 | lib/muthofun_api/sms_account.rb |