module SerwerSMS
Constants
- VERSION
Public Class Methods
api_addr()
click to toggle source
# File lib/serwer_sms.rb, line 7 def self.api_addr "https://api2.serwersms.pl/" end
req(action, params = {})
click to toggle source
# File lib/serwer_sms.rb, line 19 def self.req(action, params = {}) req_params = { 'username' => username, 'password' => password, 'details' => details }.merge(params) uri = URI.parse("#{api_addr}messages/send_sms") https = Net::HTTP.new(uri.host,uri.port) https.use_ssl = true req = Net::HTTP::Post.new(uri.path,{'Content-Type' => 'application/json'}) req.body = req_params.to_json res = https.request(req) JSON.parse(res.body) end
send(number, body)
click to toggle source
# File lib/serwer_sms.rb, line 11 def self.send(number, body) params = { 'phone' => number, 'text' => body } req('messages/send_sms', params) end