top4r 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.2.1 / 2013-01-05
2
+
3
+ Add: taobao.itemcats.get 的支持
4
+ Fix: TaokeItemDetail的public fields出错的bug
5
+
1
6
  === 0.1.9 / 2011-12-28
2
7
 
3
8
  Add: taobao.item.get, taobao.items.list.get的支持
@@ -0,0 +1,23 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class Top4R::Client
3
+ @@ITEMCAT_METHODS = {
4
+ :cats_info => 'taobao.itemcats.get',
5
+ }
6
+
7
+ def itemcats(cids, options = {}, &block)
8
+ method = :cats_info
9
+ valid_method(method, @@ITEMCAT_METHODS, :item_cat)
10
+ cids = [cids] if !cids.is_a?(Array)
11
+ params = {:cids => cids.join(',')}.merge(options)
12
+ response = http_connect {|conn| create_http_get_request(@@ITEMCAT_METHODS[method], params)}
13
+ result = JSON.parse(response.body)[rsp(@@ITEMCAT_METHODS[method])]
14
+ if result.is_a?(Hash) and result["item_cats"]
15
+ item_cats = Top4R::ItemCat.unmarshal(result["item_cats"]["item_cat"])
16
+ item_cats.each {|cat| bless_model(cat); yield cat if block_given?}
17
+ else
18
+ item_cats = []
19
+ end
20
+ # puts "\nsuites: #{suites.inspect}"
21
+ item_cats
22
+ end
23
+ end
@@ -28,7 +28,7 @@ class Top4R::Client
28
28
  method = :taobaoke_items_detail_get
29
29
  valid_method(method, @@TAOBAOKEITEM_METHODS, :taobaoke_item)
30
30
  options = {:num_iids => num_iids.join(',')}.merge(options) if num_iids
31
- params = {:fields => Top4R::TaobaokeItem.fields, :v => "2.0"}.merge(options)
31
+ params = {:fields => Top4R::TaobaokeItemDetail.fields, :v => "2.0"}.merge(options)
32
32
  response = http_connect {|conn| create_http_get_request(@@TAOBAOKEITEM_METHODS[method], params)}
33
33
  result = JSON.parse(response.body)[rsp(@@TAOBAOKEITEM_METHODS[method])]
34
34
  if result.is_a?(Hash) and result["taobaoke_item_details"]
data/lib/top4r/client.rb CHANGED
@@ -29,6 +29,9 @@ class Top4R::Client
29
29
  :taobaoke_items_detail_get => 'taobao.taobaoke.items.detail.get',
30
30
  :taobaoke_items_convert => 'taobao.taobaoke.items.convert',
31
31
  :taobaoke_shops_convert => 'taobao.taobaoke.shops.convert'
32
+ },
33
+ :item_cat => {
34
+ :cats_info => 'taobao.itemcats.get'
32
35
  }
33
36
  }
34
37
  end
@@ -41,3 +44,4 @@ require 'top4r/client/suite'
41
44
  require 'top4r/client/item'
42
45
  require 'top4r/client/shop'
43
46
  require 'top4r/client/taobaokeitem'
47
+ require 'top4r/client/itemcat'
@@ -0,0 +1,21 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Top4R
3
+ # ItemCat model
4
+ class ItemCat
5
+ include ModelMixin
6
+ @@ATTRIBUTES = [:cid, :parent_cid, :name, :is_parent, :status, :sort_order]
7
+ attr_accessor *@@ATTRIBUTES
8
+
9
+ class << self
10
+ def attributes; @@ATTRIBUTES; end
11
+
12
+ def default_public_fields
13
+ ["cid", "name", "parent_cid", "is_parent"]
14
+ end
15
+ end
16
+
17
+ def unmarshal_other_attrs
18
+ self
19
+ end
20
+ end
21
+ end
@@ -53,7 +53,7 @@ module Top4R
53
53
  def attributes; @@ATTRIBUTES; end
54
54
 
55
55
  def default_public_fields
56
- ["item.title", "item.num_iid", "item.pic_url", "item.price", "item.nick", "item.item_imgs", :click_url, :shop_click_url, :seller_credit_score]
56
+ [:title, :num_iid, :cid, :pic_url, :price, :nick, :item_imgs, :desc, :click_url, :shop_click_url, :seller_credit_score]
57
57
  end
58
58
  end
59
59
  end
data/lib/top4r/model.rb CHANGED
@@ -113,3 +113,4 @@ require 'top4r/model/suite'
113
113
  require 'top4r/model/item'
114
114
  require 'top4r/model/shop'
115
115
  require 'top4r/model/taobaokeitem'
116
+ require 'top4r/model/itemcat'
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 = 0
5
+ REVISION = 1
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.0
4
+ version: 0.2.1
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: 2012-12-08 00:00:00.000000000 Z
12
+ date: 2013-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -44,6 +44,7 @@ files:
44
44
  - lib/top4r/client/shop.rb
45
45
  - lib/top4r/client/suite.rb
46
46
  - lib/top4r/client/taobaokeitem.rb
47
+ - lib/top4r/client/itemcat.rb
47
48
  - lib/top4r/client/trade.rb
48
49
  - lib/top4r/client/user.rb
49
50
  - lib/top4r/client.rb
@@ -59,6 +60,7 @@ files:
59
60
  - lib/top4r/model/shop.rb
60
61
  - lib/top4r/model/suite.rb
61
62
  - lib/top4r/model/taobaokeitem.rb
63
+ - lib/top4r/model/itemcat.rb
62
64
  - lib/top4r/model/trade.rb
63
65
  - lib/top4r/model/user.rb
64
66
  - lib/top4r/model.rb