topsdk 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -23,12 +23,12 @@ Create a config/taobao.yml
23
23
  <<: *default
24
24
 
25
25
  production:
26
+ <<: *default
26
27
  secret_key: 42ab2d12a5bea25d1bc06ccd23123121daf
27
28
  auth_url: https://oauth.taobao.com/authorize
28
29
  token_url: https://oauth.taobao.com/token
29
30
  rest_url: http://gw.api.taobao.com/router/rest
30
31
  callback_url: http://yourdomain.com/auth/callback
31
- <<: *default
32
32
 
33
33
  == Usage
34
34
 
@@ -1,21 +1,24 @@
1
- default: &default
1
+ prod: &prod
2
2
  api_key: 12012322
3
- secret_key: sandbox2a5bea25d1bc06ccd23123121daf
3
+ secret_key: 42ab2d12a5bea25d1bc06ccd23123121daf
4
+ auth_url: https://oauth.taobao.com/authorize
5
+ token_url: https://oauth.taobao.com/token
6
+ rest_url: http://gw.api.taobao.com/router/rest
7
+ callback_url: http://yourdomain.com/auth/callback
8
+
9
+ sandbox: &sandbox
10
+ <<: *prod
11
+ secret_key: sandbox9ffd79873a7ae0e01fefed97c
4
12
  auth_url: https://oauth.tbsandbox.com/authorize
5
13
  token_url: https://oauth.tbsandbox.com/token
6
14
  rest_url: http://gw.api.tbsandbox.com/router/rest
7
15
  callback_url: http://0.0.0.0:3000/auth/callback
8
16
 
9
17
  development:
10
- <<: *default
18
+ <<: *sandbox
11
19
 
12
20
  test:
13
- <<: *default
21
+ <<: *sandbox
14
22
 
15
23
  production:
16
- secret_key: 42ab2d12a5bea25d1bc06ccd23123121daf
17
- auth_url: https://oauth.taobao.com/authorize
18
- token_url: https://oauth.taobao.com/token
19
- rest_url: http://gw.api.taobao.com/router/rest
20
- callback_url: http://yourdomain.com/auth/callback
21
- <<: *default
24
+ <<: *prod
data/lib/topsdk/client.rb CHANGED
@@ -20,12 +20,16 @@ module Topsdk
20
20
  end
21
21
 
22
22
  def get(url=ENV['TAOBAO_REST_URL'])
23
- @result = Nestful::Request.new(url, ({:method => :get, :format => :json, :params => @params})).execute
23
+ request = Nestful::Request.new(url, ({:method => :get, :format => :json, :params => @params}))
24
+ @result = request.execute
24
25
  parse
25
26
  end
26
27
 
27
28
  def post(url=ENV['TAOBAO_REST_URL'])
28
- @result = Nestful::Request.new(url, ({:method => :post, :format => :form, :params => @params})).execute
29
+ request = Nestful::Request.new(url, ({:method => :post, :format => :form, :params => @params}))
30
+ pp request.to_s
31
+ pp @params.to_s
32
+ @result = request.execute
29
33
  @result = JSON.parse(@result)
30
34
  parse
31
35
  end
@@ -34,8 +38,8 @@ module Topsdk
34
38
  return false unless @result.is_a?(Hash)
35
39
  case
36
40
  when @result.has_key?(response_key)
41
+ pp response_key if DEBUG
37
42
  result = @result[response_key]
38
- result[root_key] if result.has_key?(root_key)
39
43
  when @result.has_key?('error_response')
40
44
  @result['error_response']['msg']
41
45
  else
@@ -1,3 +1,3 @@
1
1
  module Topsdk
2
- VERSION = "0.0.2"
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/topsdk.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "topsdk/version"
2
- require "topsdk/client"
1
+ require 'topsdk/version'
2
+ require 'topsdk/client'
3
3
 
4
4
  RAILS_ENV = PADRINO_ENV if defined?(PADRINO_ENV)
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-30 00:00:00.000000000Z
12
+ date: 2011-10-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nestful
16
- requirement: &70339835765280 !ruby/object:Gem::Requirement
16
+ requirement: &70275679541760 !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: :runtime
23
23
  prerelease: false
24
- version_requirements: *70339835765280
24
+ version_requirements: *70275679541760
25
25
  description: Simple Taobao API client for Ruby
26
26
  email:
27
27
  - howl.wong@gmail.com
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project: topsdk
63
- rubygems_version: 1.8.10
63
+ rubygems_version: 1.8.11
64
64
  signing_key:
65
65
  specification_version: 3
66
66
  summary: Taobao API client