taobao_fu_reload 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/taobao_fu.rb +13 -3
  2. metadata +10 -5
data/lib/taobao_fu.rb CHANGED
@@ -56,7 +56,11 @@ module TaobaoFu
56
56
  else
57
57
  @response = TaobaoFu::Rest.get(@base_url, generate_query_vars(sorted_params(options)))
58
58
  end
59
- parse_result @response
59
+ if options.fetch(:method).start_with?("taobao.wangwang")
60
+ parse_result_xml @response
61
+ else
62
+ parse_result_json @response
63
+ end
60
64
  end
61
65
 
62
66
  # http://toland.github.com/patron/
@@ -70,10 +74,12 @@ module TaobaoFu
70
74
  end
71
75
 
72
76
  def sorted_params(options)
77
+ output_format = OUTPUT_FORMAT
78
+ output_format = 'xml' if options.fetch(:method).start_with?("taobao.wangwang")
73
79
  {
74
80
  :app_key => @settings['app_key'],
75
81
  :session => @settings['session'],
76
- :format => OUTPUT_FORMAT,
82
+ :format => output_format,
77
83
  :v => API_VERSION,
78
84
  :sign_method => SIGN_ALGORITHM,
79
85
  :timestamp => Time.now.strftime("%Y-%m-%d %H:%M:%S")
@@ -96,9 +102,13 @@ module TaobaoFu
96
102
  Digest::MD5.hexdigest(@settings['secret_key'] + param_string + @settings['secret_key']).upcase
97
103
  end
98
104
 
99
- def parse_result(data)
105
+ def parse_result_json(data)
100
106
  Crack::JSON.parse(data)
101
107
  end
108
+
109
+ def parse_result_xml(data)
110
+ Crack::XML.parse(data)
111
+ end
102
112
 
103
113
  end
104
114
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taobao_fu_reload
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
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: 2012-08-21 00:00:00.000000000 Z
12
+ date: 2012-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: crack
16
- requirement: &70106294689960 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 0.1.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70106294689960
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.7
25
30
  description: long live the taobao_fu!
26
31
  email: info@networking.io
27
32
  executables: []
@@ -57,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
62
  version: '0'
58
63
  requirements: []
59
64
  rubyforge_project:
60
- rubygems_version: 1.8.15
65
+ rubygems_version: 1.8.24
61
66
  signing_key:
62
67
  specification_version: 3
63
68
  summary: taobao_fu reloaded!