ruby_desk 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -24,15 +24,28 @@ module RubyDesk
24
24
 
25
25
  # Sign the given parameters and returns the signature
26
26
  def sign(params)
27
- RubyDesk.logger.info "Params to sign: #{params.inspect}"
27
+ RubyDesk.logger.debug {"Params to sign: #{params.inspect}"}
28
28
  # sort parameters by its names (keys)
29
29
  sorted_params = params.sort { |a, b| a.to_s <=> b.to_s}
30
30
 
31
+ RubyDesk.logger.debug {"Sorted params: #{sorted_params.inspect}"}
32
+
33
+ # Unescape escaped params
34
+ sorted_params.map! do |k, v|
35
+ [k, URI.unescape(v)]
36
+ end
37
+
31
38
  # concatenate secret with names, values
32
39
  concatenated = @api_secret + sorted_params.to_s
33
40
 
41
+ RubyDesk.logger.debug {"concatenated: #{concatenated}"}
42
+
34
43
  # Calculate and return md5 of concatenated string
35
- Digest::MD5.hexdigest(concatenated)
44
+ md5 = Digest::MD5.hexdigest(concatenated)
45
+
46
+ RubyDesk.logger.debug {"md5: #{md5}"}
47
+
48
+ return md5
36
49
  end
37
50
 
38
51
  # Returns the correct URL to go to to invoke the given api
@@ -20,7 +20,7 @@ class RubyDesk::TimeReport
20
20
  #
21
21
  # Allowed values for options are
22
22
  # :select
23
- # :condition
23
+ # :conditions
24
24
  # Here is the limited support for the where clause.
25
25
  # Fields
26
26
  # * Name
@@ -76,7 +76,7 @@ class RubyDesk::TimeReport
76
76
  gds_query = ""
77
77
  gds_query << "SELECT " << (options[:select].respond_to?(:join)?
78
78
  options[:select].join(",") : options[:select])
79
- if options[:conditions]
79
+ if options[:conditions] && options[:conditions].any?
80
80
  gds_query << " WHERE "
81
81
  combined = options[:conditions].map do |field, condition|
82
82
  "(" +
@@ -5,7 +5,7 @@ class TestRubyDesk < Test::Unit::TestCase
5
5
 
6
6
  def dummy_connector(result_filename)
7
7
  connector = RubyDesk::Connector.new('824d225a889aca186c55ac49a6b23957',
8
- '984aa36db13fff5c')
8
+ '984aa36db13fff5c', 'fffff')
9
9
  connector.instance_variable_set '@result_filename', result_filename
10
10
  def connector.invoke_api_call(*args)
11
11
  File.read(File.join(File.dirname(__FILE__), @result_filename))
@@ -22,11 +22,20 @@ class TestRubyDesk < Test::Unit::TestCase
22
22
  :api_token=>'ffffffffffffffffffffffffffffffff')
23
23
  end
24
24
 
25
- def test_api_call
25
+ def test_sign_escaped_params
26
26
  connector = RubyDesk::Connector.new('824d225a889aca186c55ac49a6b23957',
27
27
  '984aa36db13fff5c')
28
+ assert_equal 'dc30357f7c6b62aadf99e5313ac93365',
29
+ connector.sign(:online=>'a%6C%6C', :tz=>'mine',
30
+ :api_key=>'824d225a889aca186c55ac49a6b23957',
31
+ :api_token=>'ffffffffffffffffffffffffffffffff')
32
+ end
33
+
34
+ def test_api_call
35
+ connector = RubyDesk::Connector.new('824d225a889aca186c55ac49a6b23957',
36
+ '984aa36db13fff5c', 'fff')
28
37
  api_call = connector.prepare_api_call('auth/v1/keys/tokens',
29
- :params=>{:frob=>@frob, :api_key=>@api_key},
38
+ :params=>{:frob=>'342423', :api_key=>@api_key},
30
39
  :method=>:post, :format=>'json')
31
40
  assert api_call[:url].index('.json')
32
41
  assert api_call[:url].index('/api/auth/v1/keys/tokens')
@@ -35,7 +44,7 @@ class TestRubyDesk < Test::Unit::TestCase
35
44
 
36
45
  def test_gds_api_call
37
46
  connector = RubyDesk::Connector.new('824d225a889aca186c55ac49a6b23957',
38
- '984aa36db13fff5c')
47
+ '984aa36db13fff5c', 'ff')
39
48
  api_call = connector.prepare_api_call('timereports/v1/companies/1',
40
49
  :method=>:post, :base_url=>RubyDesk::Connector::ODESK_GDS_URL)
41
50
  assert api_call[:url].index('/gds/timereports/v1/companies/1')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_desk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmed ElDawy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-21 00:00:00 +02:00
12
+ date: 2010-02-23 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency