top4r 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.2.2 / 2013-01-09
2
+
3
+ Add: taobao.items.list.get 的支持
4
+ Fix: 当不需要session的时候还带有空session参数导致出错的bug
5
+
1
6
  === 0.2.1 / 2013-01-05
2
7
 
3
8
  Add: taobao.itemcats.get 的支持
@@ -129,11 +129,14 @@ class Top4R::Client
129
129
 
130
130
  def append_top_params(params)
131
131
  params = params.merge({
132
- :session => @session,
132
+ # :session => @session,
133
133
  :timestamp => Time.now.strftime("%Y-%m-%d %H:%M:%S"),
134
134
  :format => "#{@@config.format}",
135
135
  :app_key => @app_key
136
136
  })
137
+ if !@session.nil? and !@session.blank?
138
+ params[:session] = @session
139
+ end
137
140
  params[:v] = "2.0" unless params[:v]
138
141
  params = params.merge({
139
142
  :sign => Digest::MD5.hexdigest(params.sort {|a,b| "#{a[0]}"<=>"#{b[0]}"}.flatten.unshift(@app_secret).join).upcase
@@ -31,7 +31,26 @@ class Top4R::Client
31
31
  options = {:num_iid => iid}.merge(options) if iid
32
32
  params = {:fields => Top4R::Item.fields}.merge(options)
33
33
  response = http_connect {|conn| create_http_get_request(@@ITEM_METHODS[method], params)}
34
- item = Top4R::Item.unmarshal(JSON.parse(response.body)[rsp(@@SHOP_METHODS[method])]["item"])
34
+ item = Top4R::Item.unmarshal(JSON.parse(response.body)[rsp(@@ITEM_METHODS[method])]["item"])
35
35
  bless_model(item)
36
36
  end
37
+
38
+ def items_info(iid = nil, options = {}, &block)
39
+ method = :items_info
40
+ valid_method(method, @@ITEM_METHODS, :item)
41
+ iid = [iid] if !iid.is_a?(Array)
42
+ options = {:num_iids => iid}.merge(options) if iid
43
+ params = {:fields => Top4R::Item.fields}.merge(options)
44
+ response = http_connect {|conn| create_http_get_request(@@ITEM_METHODS[method], params)}
45
+ result = JSON.parse(response.body)[rsp(@@ITEM_METHODS[method])]
46
+ if result.is_a?(Hash) and result['items']
47
+ items = Top4R::Item.unmarshal(result["items"]["item"])
48
+ items.each {|item| bless_model(item); yield item if block_given?}
49
+ @total_results = items.size
50
+ else
51
+ @total_results = 0
52
+ items = []
53
+ end
54
+ items
55
+ end
37
56
  end
data/lib/top4r/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  module Top4R::Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- REVISION = 1
5
+ REVISION = 2
6
6
 
7
7
  class << self
8
8
  # Returns X.Y.Z formatted version string
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: top4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-05 00:00:00.000000000 Z
12
+ date: 2013-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json