Sha256: 00811033ffe0e3fb5311b66fee30aafd120acf1fbad6fcb5e629b44e44ef77cf
Contents?: true
Size: 1.29 KB
Versions: 1
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: "0" }.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: "0" }.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: "0" } 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
globalsms-0.3.1 | lib/globalsms/sms.rb |