Sha256: 97f5093f2a9f04f88ae515c85c67163e53b43bc616971045e86e4b5a4a719824
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 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" @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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
globalsms-0.1.0 | lib/globalsms/sms.rb |