appoxy_api 0.0.8 → 0.0.9

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/api/client.rb +12 -17
  2. data/lib/api/signatures.rb +1 -1
  3. metadata +3 -3
data/lib/api/client.rb CHANGED
@@ -14,8 +14,7 @@ module Appoxy
14
14
  @@logger
15
15
  end
16
16
 
17
- attr_accessor :host, :access_key, :secret_key
18
-
17
+ attr_accessor :host, :access_key, :secret_key, :version
19
18
 
20
19
  def initialize(host, access_key, secret_key, options={})
21
20
  @host = host
@@ -73,27 +72,23 @@ module Appoxy
73
72
  url
74
73
  end
75
74
 
76
- # old way
75
+
77
76
  def add_params(command_path, hash)
78
- ts = Appoxy::Api::Signatures.generate_timestamp(Time.now.gmtime)
77
+ v = version||"0.1"
78
+ ts = Appoxy::Api::Signatures.generate_timestamp(Time.now.gmtime)
79
79
  # puts 'timestamp = ' + ts
80
- sig = Appoxy::Api::Signatures.generate_signature(command_path, ts, secret_key)
81
-
82
- extra_params = {'sigv'=>"0.1", 'sig' => sig, 'timestamp' => ts, 'access_key' => access_key}
80
+ sig = case v
81
+ when "0.2"
82
+ Appoxy::Api::Signatures.generate_signature(command_path + Appoxy::Api::Signatures.hash_to_s(hash), ts, secret_key)
83
+ when "0.1"
84
+ Appoxy::Api::Signatures.generate_signature(command_path, ts, secret_key)
85
+ end
86
+
87
+ extra_params = {'sigv'=>v, 'sig' => sig, 'timestamp' => ts, 'access_key' => access_key}
83
88
  hash.merge!(extra_params)
84
89
 
85
90
  end
86
91
 
87
- # new way
88
- # def add_params(command_path, hash)
89
- # ts = Appoxy::Api::Signatures.generate_timestamp(Time.now.gmtime)
90
- # #p "hash_to s" + command_path + Appoxy::Api::Signatures.hash_to_s(hash)
91
- # sig = Appoxy::Api::Signatures.generate_signature(command_path + Appoxy::Api::Signatures.hash_to_s(hash), ts, secret_key)
92
- # extra_params = {'sigv'=>"0.2", 'sig' => sig, 'timestamp' => ts, 'access_key' => access_key}
93
- # hash.merge!(extra_params)
94
- #
95
- # end
96
-
97
92
 
98
93
  def append_params(host, params)
99
94
  host += "?"
@@ -17,7 +17,7 @@ module Appoxy
17
17
 
18
18
  def self.hash_to_s(hash)
19
19
  str = ""
20
- hash.each_pair { |key, value| str+= "#{key}#{value}" }
20
+ hash.sort.each { |a| str+= "#{a[0]}#{a[1]}" }
21
21
  #removing all characters that could differ after parsing with rails
22
22
  return str.delete "\"\/:{}[]\' T"
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appoxy_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
17
- requirement: &26585748 !ruby/object:Gem::Requirement
17
+ requirement: &27110040 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *26585748
25
+ version_requirements: *27110040
26
26
  description: Appoxy API Helper gem description...
27
27
  email: travis@appoxy.com
28
28
  executables: []