edm 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/edm.rb +11 -8
  2. data/lib/edm/version.rb +1 -1
  3. metadata +3 -3
data/lib/edm.rb CHANGED
@@ -1,30 +1,33 @@
1
1
  require "edm/version"
2
2
  require "net/http"
3
-
4
3
  module Edm
5
4
  class EdmClient
6
- def initialize(account, key)
5
+ DOMAIN = 'http://edm.demohour.com'
6
+ def initialize(account, secret)
7
7
  @account = account
8
- @key = key
8
+ @secret = secret
9
9
  end
10
10
 
11
- attr_accessor :account, :key
11
+ attr_accessor :account, :secret
12
12
 
13
- def api_request(url, http_method, options = {})
13
+ def request(url, http_method, options = {})
14
14
  sign = generate_sign(options)
15
- options["sign"] = sign
16
- result = remote_request(http_method, 'http://edm.demohour.com' + url, options)
15
+ options[:sign] = sign
16
+ options[:account_key] = self.account
17
+ result = remote_request(http_method, url, options)
17
18
  return result.body
18
19
  end
19
20
 
20
21
  def generate_sign(options = {})
21
22
  if options.length > 0
23
+ secret = self.secret
22
24
  str = options.to_a.sort.map { |c| "#{c[0]}=#{c[1]}" }.join('&')
23
- sign = Digest::SHA1.hexdigest("#{str}#{key}")
25
+ sign = Digest::SHA1.hexdigest("#{str}#{secret}")
24
26
  end
25
27
  end
26
28
 
27
29
  def remote_request(http_method, url, options = {})
30
+ url = DOMAIN + url
28
31
  case http_method
29
32
  when 'post'
30
33
  Net::HTTP.post_form(URI.parse(url), options)
data/lib/edm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Edm
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spec
16
- requirement: &70232421145860 !ruby/object:Gem::Requirement
16
+ requirement: &70245374460660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70232421145860
24
+ version_requirements: *70245374460660
25
25
  description: demohour edm api
26
26
  email:
27
27
  - lijiping@demohour.com