Sha256: c01b38c7e78b7fe5dea2128a6d0036cb555d4c70537d698e24aeed1fe6107ace
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require "globalsms/version" require 'httpclient' require 'json' module GlobalSMS class SMS def initialize(api_key, api_secret) @api_base_url = "http://api.globalhaberlesme.com" #TODO: DEFAULTS a çıkart @api_key = api_key @api_secret = api_secret end def single_send(argv) argv = { time: "now", turkish_character: "1" }.merge(argv) body = "data=#{argv.to_json.to_s}" uri = "#{@api_base_url}/sms/send/single?key=#{@api_key}&secret=#{@api_secret}" c = HTTPClient.new return JSON.parse(c.post(uri, body).body) end def bulk_send(argv) argv = { time: "now", turkish_character: "1" }.merge(argv) body = "data=#{argv.to_json.to_s}" uri = "#{@api_base_url}/sms/send/single?key=#{@api_key}&secret=#{@api_secret}" c = HTTPClient.new return JSON.parse(c.post(uri, body).body) end def multi_send(argv) argv_def = { time: "now", turkish_character: "1" } argv_array = argv.map { |arg| argv_def.merge(arg) } body = "data=#{argv_array.to_json.to_s}" uri = "#{@api_base_url}/sms/send/multi?key=#{@api_key}&secret=#{@api_secret}" c = HTTPClient.new return JSON.parse(c.post(uri, body).body) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
globalsms-0.3.0 | lib/globalsms/sms.rb |
globalsms-0.2.0 | lib/globalsms/sms.rb |