Sha256: 813dbd3091e69f3ca2335c8c211d242100932d5f29db18f81524f677050e5516
Contents?: true
Size: 871 Bytes
Versions: 1
Compression:
Stored size: 871 Bytes
Contents
require "edm/version" require "net/http" module Edm class EdmClient def initialize(account, key) @account = account @key = key end attr_accessor :account, :key def api_request(url, http_method, options = {}) sign = generate_sign(options) options["sign"] = sign result = remote_request(http_method, 'http://edm.demohour.com' + url, options) return result.body end def generate_sign(options = {}) if options.length > 0 str = options.to_a.sort.map { |c| "#{c[0]}=#{c[1]}" }.join('&') sign = Digest::SHA1.hexdigest("#{str}#{key}") end end def remote_request(http_method, url, options = {}) case http_method when 'post' Net::HTTP.post_form(URI.parse(url), options) when 'get' Net::HTTP.get(URI.parse(url)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
edm-0.0.5 | lib/edm.rb |