top4r 0.0.39 → 0.1.0

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/README CHANGED
@@ -9,12 +9,20 @@ TOP4R封装了淘宝开发平台的接口,帮助你快速构建基于TOP的应
9
9
 
10
10
  == FEATURES/PROBLEMS:
11
11
 
12
- * 待续...
12
+ * [09/25/10] TOP API 2.0支持
13
+ * 商品
14
+ * 物流
15
+ * 店铺
16
+ * 收费
17
+ * 淘宝客
18
+ * 交易
19
+ * 用户
13
20
 
14
21
  == REQUIREMENTS:
15
22
 
16
23
  * rubygems
24
+ * json
17
25
 
18
26
  == INSTALL:
19
27
 
20
- sudo gem install nowa-top4r -s http://gems.github.com
28
+ sudo gem install top4r
@@ -75,6 +75,7 @@ class Top4R::Client
75
75
  end
76
76
 
77
77
  map = JSON.parse(response.body)
78
+ # API 1.0
78
79
  if map["error_rsp"].is_a?(Hash) and map["error_rsp"]["code"].to_s == "630"
79
80
  @@logger.info "Raising SuiteNotOrderedError..."
80
81
  raise Top4R::SuiteNotOrderedError.new(:code => map["error_rsp"]["code"],
@@ -87,6 +88,15 @@ class Top4R::Client
87
88
  :message => map["error_rsp"]["msg"],
88
89
  :error => map["error_rsp"],
89
90
  :uri => uri)
91
+ # API 2.0
92
+ elsif map["error_response"].is_a?(Hash)
93
+ @@logger.info "Raising RESTError..."
94
+ raise Top4R::RESTError.new(:code => map["error_response"]["code"],
95
+ :message => map["error_response"]["msg"],
96
+ :sub_code => map["error_response"]["sub_code"],
97
+ :sub_msg => map["error_response"]["sub_msg"],
98
+ :error => map["error_response"],
99
+ :uri => uri)
90
100
  end
91
101
  end
92
102
 
@@ -124,7 +134,7 @@ class Top4R::Client
124
134
  :format => "#{@@config.format}",
125
135
  :app_key => @app_key
126
136
  })
127
- params[:v] = "1.0" unless params[:v]
137
+ params[:v] = "2.0" unless params[:v]
128
138
  params = params.merge({
129
139
  :sign => Digest::MD5.hexdigest(params.sort {|a,b| "#{a[0]}"<=>"#{b[0]}"}.flatten.unshift(@app_secret).join).upcase
130
140
  })
@@ -146,4 +156,8 @@ class Top4R::Client
146
156
  path = (params.size > 0) ? "#{uri}?#{params.to_http_str}" : uri
147
157
  Net::HTTP::Delete.new(path, http_header)
148
158
  end
159
+
160
+ def rsp(api)
161
+ "#{api.split('.')[1..-1].join('_')}_response"
162
+ end
149
163
  end
@@ -8,9 +8,15 @@ class Top4R::Client
8
8
  options = {:q => q}.merge(options) if q
9
9
  params = {:fields => Top4R::Item.fields}.merge(options)
10
10
  response = http_connect {|conn| create_http_get_request(@@ITEM_METHODS[method], params)}
11
- items = Top4R::Item.unmarshal(JSON.parse(response.body)["rsp"]["items"])
12
- items.each {|item| bless_model(item); yield item if block_given?}
13
- @total_results = JSON.parse(response.body)["rsp"]["totalResults"].to_i
11
+ result = JSON.parse(response.body)[rsp(@@ITEM_METHODS[method])]
12
+ if result['items']
13
+ items = Top4R::Item.unmarshal(result["items"]["item"])
14
+ items.each {|item| bless_model(item); yield item if block_given?}
15
+ @total_results = result["total_results"].to_i
16
+ else
17
+ @total_results = 0
18
+ items = []
19
+ end
14
20
  items
15
21
  end
16
22
  end
@@ -4,7 +4,7 @@ class Top4R::Client
4
4
  }
5
5
 
6
6
  @@LOGISTIC_COMPANY_METHODS = {
7
- :list => 'taobao.logisticcompanies.get'
7
+ :list => 'taobao.logistics.companies.get'
8
8
  }
9
9
 
10
10
  @@DELIVERY_METHODS = {
@@ -15,8 +15,13 @@ class Top4R::Client
15
15
  valid_method(method, @@AREA_METHODS, :area)
16
16
  params = {:fields => Top4R::Area.fields}.merge(options)
17
17
  response = http_connect {|conn| create_http_get_request(@@AREA_METHODS[method], params)}
18
- areas = Top4R::Area.unmarshal(JSON.parse(response.body)["rsp"]["areas"])
19
- areas.each {|area| bless_model(area); yield area if block_given?}
18
+ result = JSON.parse(response.body)[rsp(@@AREA_METHODS[method])]
19
+ if result["areas"]
20
+ areas = Top4R::Area.unmarshal(result["areas"]["area"])
21
+ areas.each {|area| bless_model(area); yield area if block_given?}
22
+ else
23
+ areas = []
24
+ end
20
25
  areas
21
26
  end
22
27
 
@@ -24,8 +29,13 @@ class Top4R::Client
24
29
  valid_method(method, @@LOGISTIC_COMPANY_METHODS, :logistic_company)
25
30
  params = {:fields => Top4R::LogisticCompany.fields}.merge(options)
26
31
  response = http_connect {|conn| create_http_get_request(@@LOGISTIC_COMPANY_METHODS[method], params)}
27
- logistic_companies = Top4R::LogisticCompany.unmarshal(JSON.parse(response.body)["rsp"]["logistic_companies"])
28
- logistic_companies.each {|logistic_company| bless_model(logistic_company); yield logistic_company if block_given?}
32
+ result = JSON.parse(response.body)[rsp(@@LOGISTIC_COMPANY_METHODS[method])]
33
+ if result["logistics_companies"]
34
+ logistic_companies = Top4R::LogisticCompany.unmarshal(result["logistics_companies"]["logistics_company"])
35
+ logistic_companies.each {|logistic_company| bless_model(logistic_company); yield logistic_company if block_given?}
36
+ else
37
+ logistic_companies = []
38
+ end
29
39
  logistic_companies
30
40
  end
31
41
 
@@ -40,6 +50,6 @@ class Top4R::Client
40
50
  end
41
51
  response = http_connect {|conn| create_http_get_request(@@DELIVERY_METHODS[method], params)}
42
52
  json = JSON.parse(response.body)
43
- json.is_a?(Hash) ? json["rsp"]["is_success"] : false
53
+ json.is_a?(Hash) ? json[rsp(@@DELIVERY_METHODS[method])]["shipping"]["is_success"] : false
44
54
  end
45
55
  end
@@ -9,8 +9,13 @@ class Top4R::Client
9
9
  u = u.nick if u.is_a?(Top4R::User)
10
10
  params = options.merge(:nick => u)
11
11
  response = http_connect {|conn| create_http_get_request(@@SHOP_METHODS[method], params)}
12
- seller_cats = Top4R::SellerCat.unmarshal(JSON.parse(response.body)["rsp"]["seller_cats"])
13
- seller_cats.each {|cat| bless_model(cat); yield cat if block_given?}
12
+ result = JSON.parse(response.body)[rsp(@@SHOP_METHODS[method])]
13
+ if result["seller_cats"]
14
+ seller_cats = Top4R::SellerCat.unmarshal(result["seller_cats"]["seller_cat"])
15
+ seller_cats.each {|cat| bless_model(cat); yield cat if block_given?}
16
+ else
17
+ seller_cats = []
18
+ end
14
19
  # puts "\nsuites: #{suites.inspect}"
15
20
  seller_cats
16
21
  end
@@ -20,7 +25,7 @@ class Top4R::Client
20
25
  u = u.nick if u.is_a?(Top4R::User)
21
26
  params = {:fields => Top4R::Shop.fields}.merge(options).merge(:nick => u)
22
27
  response = http_connect {|conn| create_http_get_request(@@SHOP_METHODS[method], params)}
23
- shops = Top4R::Shop.unmarshal(JSON.parse(response.body)["rsp"]["shops"])
24
- method == :shop_info ? bless_model(shops.first) : bless_models(shops)
28
+ shop = Top4R::Shop.unmarshal(JSON.parse(response.body)[rsp(@@SHOP_METHODS[method])]["shop"])
29
+ bless_model(shop)
25
30
  end
26
31
  end
@@ -8,16 +8,21 @@ class Top4R::Client
8
8
  u = u.nick if u.is_a?(Top4R::User)
9
9
  params = {:service_code => service_code}.merge(options).merge(:nick => u)
10
10
  response = http_connect {|conn| create_http_get_request(@@SUITE_METHODS[method], params)}
11
- if response.body == "{\"rsp\":{}}"
11
+ if response.body == "{\"suites_get_response\":{}}"
12
12
  raise Top4R::SuiteNotOrderedError.new(:code => 630,
13
13
  :message => "没有#{service_code}的订购记录",
14
14
  :error => "{}",
15
15
  :uri => @@SUITE_METHODS[method])
16
16
  end
17
- suites = Top4R::Suite.unmarshal(JSON.parse(response.body)["rsp"]["suites"])
18
- suites.each {|suite| bless_model(suite); yield suite if block_given?}
19
- # puts "\nsuites: #{suites.inspect}"
20
- @total_results = JSON.parse(response.body)["rsp"]["totalResults"].to_i
17
+ result = JSON.parse(response.body)[rsp(@@SUITE_METHODS[method])]
18
+ if result["suites"]
19
+ suites = Top4R::Suite.unmarshal(result["suites"]["suite"])
20
+ suites.each {|suite| bless_model(suite); yield suite if block_given?}
21
+ @total_results = result["total_results"].to_i
22
+ else
23
+ @total_results = 0
24
+ suites = []
25
+ end
21
26
  suites
22
27
  end
23
28
  end
@@ -8,10 +8,15 @@ class Top4R::Client
8
8
  options = {:keyword => q}.merge(options) if q
9
9
  params = {:fields => Top4R::TaobaokeItem.fields, :v => "2.0"}.merge(options)
10
10
  response = http_connect {|conn| create_http_get_request(@@TAOBAOKEITEM_METHODS[method], params)}
11
-
12
- items = Top4R::TaobaokeItem.unmarshal(JSON.parse(response.body)["taobaoke_items_get_response"]["taobaoke_items"]["taobaoke_item"])
13
- items.each {|item| bless_model(item); yield item if block_given?}
14
- @total_results = JSON.parse(response.body)["taobaoke_items_get_response"]["total_results"].to_i
11
+ result = JSON.parse(response.body)[rsp(@@TAOBAOKEITEM_METHODS[method])]
12
+ if result["taobaoke_items"]
13
+ items = Top4R::TaobaokeItem.unmarshal(result["taobaoke_items"]["taobaoke_item"])
14
+ items.each {|item| bless_model(item); yield item if block_given?}
15
+ @total_results = result["total_results"].to_i
16
+ else
17
+ @total_results = 0
18
+ items = []
19
+ end
15
20
  items
16
21
  end
17
22
  end
@@ -19,10 +19,15 @@ class Top4R::Client
19
19
  params = {:start_modified => (now - 24.hours).strftime("%Y-%m-%d %H:%M:%S"), :end_modified => now.strftime("%Y-%m-%d %H:%M:%S")}.merge(params)
20
20
  end
21
21
  response = http_connect {|conn| create_http_get_request(@@TRADE_METHODS[method], params)}
22
- trades = Top4R::Trade.unmarshal(JSON.parse(response.body)["rsp"]["trades"])
23
- trades.each {|trade| bless_model(trade); yield trade if block_given?}
24
- # puts "\ntrades: #{trades.inspect}"
25
- @total_results = JSON.parse(response.body)["rsp"]["totalResults"].to_i
22
+ result = JSON.parse(response.body)[rsp(@@TRADE_METHODS[method])]
23
+ if result["trades"]
24
+ trades = Top4R::Trade.unmarshal(result["trades"]["trade"])
25
+ trades.each {|trade| bless_model(trade); yield trade if block_given?}
26
+ @total_results = result["total_results"].to_i
27
+ else
28
+ @total_results = 0
29
+ trades = []
30
+ end
26
31
  trades
27
32
  end
28
33
 
@@ -34,15 +39,15 @@ class Top4R::Client
34
39
  parsed_body = JSON.parse(response.body)
35
40
 
36
41
  if [:info, :fullinfo].member?(method)
37
- trades = Top4R::Trade.unmarshal(parsed_body["rsp"]["trades"])
42
+ trades = Top4R::Trade.unmarshal(parsed_body[rsp(@@TRADE_METHODS[method])]["trade"])
38
43
  bless_model(trades.first)
39
44
  elsif method == :confirmfee
40
- confirmfees = Top4R::TradeConfirmFee.unmarshal(parsed_body["rsp"]["confirmFees"])
45
+ confirmfees = Top4R::TradeConfirmFee.unmarshal(parsed_body[rsp(@@TRADE_METHODS[method])]["trade_confirm_fee"])
41
46
  bless_models(confirmfees)
42
47
  elsif [:close, :update_memo].member?(method)
43
- parsed_body["rsp"]["modified"]
48
+ parsed_body[rsp(@@TRADE_METHODS[method])]["trade"]["modified"]
44
49
  elsif method == :add_memo
45
- parsed_body["rsp"]["created"]
50
+ parsed_body[rsp(@@TRADE_METHODS[method])]["trade"]["created"]
46
51
  end
47
52
  end
48
53
  end
@@ -24,8 +24,15 @@ class Top4R::Client
24
24
  protected
25
25
 
26
26
  def user_request(u, method, options)
27
- params = {:fields => Top4R::User.fields}.merge(options).merge(:nick => u)
27
+ @@logger.info "u: #{u}"
28
+ params = {:fields => Top4R::User.fields}.merge(options).merge((method == :info ? :nick : :nicks) => u)
28
29
  response = http_connect {|conn| create_http_get_request(@@USER_METHODS[method], params)}
29
- Top4R::User.unmarshal(JSON.parse(response.body)["rsp"]["users"])
30
+ @@logger.info "rsp: #{rsp(@@USER_METHODS[method])}"
31
+
32
+ if method == :info
33
+ return [Top4R::User.unmarshal(JSON.parse(response.body)[rsp(@@USER_METHODS[method])]["user"])]
34
+ else
35
+ return Top4R::User.unmarshal(JSON.parse(response.body)[rsp(@@USER_METHODS[method])]["users"]["user"])
36
+ end
30
37
  end
31
38
  end
data/lib/top4r/client.rb CHANGED
@@ -11,7 +11,7 @@ class Top4R::Client
11
11
  :list => 'taobao.areas.get'
12
12
  },
13
13
  :logistic_company => {
14
- :list => 'taobao.logisticcompanies.get'
14
+ :list => 'taobao.logistics.companies.get'
15
15
  },
16
16
  :shop => {
17
17
  :cats_list => 'taobao.sellercats.list.get',
data/lib/top4r/config.rb CHANGED
@@ -66,7 +66,7 @@ module Top4R
66
66
  :application_key => '12000224',
67
67
  :application_secret => '2f26cb1a99570aa72daee12a1db88e63',
68
68
  :application_version => Top4R::Version.to_version,
69
- :application_url => 'http://top4r.nowa.me',
69
+ :application_url => 'http://top4r.labs.nowa.me',
70
70
  :user_agent => 'default',
71
71
  :source => 'top4r',
72
72
  :logger => nil,
data/lib/top4r/core.rb CHANGED
@@ -33,7 +33,7 @@ module Top4R
33
33
 
34
34
  class RESTError < RuntimeError
35
35
  include ClassUtilMixin
36
- @@ATTRIBUTES = [:code, :message, :uri, :error]
36
+ @@ATTRIBUTES = [:code, :message, :uri, :error, :sub_code, :sub_msg]
37
37
  attr_accessor *@@ATTRIBUTES
38
38
 
39
39
  # Returns string in following format:
@@ -41,7 +41,7 @@ module Top4R
41
41
  # For example,
42
42
  # "HTTP 404: Resource Not Found at /i_am_crap.json"
43
43
  def to_s
44
- "HTTP #{@code}: #{@message} at #{@uri}"
44
+ "HTTP #{@code}: #{@message} at #{@uri}, sub_code: #{@sub_code}, sub_msg: #{@sub_msg}"
45
45
  end
46
46
  end # RESTError
47
47
 
@@ -2,7 +2,7 @@ module Top4R
2
2
  # ItemImg Model
3
3
  class ItemImg
4
4
  include ModelMixin
5
- @@ATTRIBUTES = [:id, :url, :position]
5
+ @@ATTRIBUTES = [:id, :url, :position, :created]
6
6
  attr_accessor *@@ATTRIBUTES
7
7
 
8
8
  class << self
@@ -13,7 +13,7 @@ module Top4R
13
13
  # PropImg Model
14
14
  class PropImg
15
15
  include ModelMixin
16
- @@ATTRIBUTES = [:id, :url, :properties, :position]
16
+ @@ATTRIBUTES = [:id, :url, :properties, :position, :created]
17
17
  attr_accessor *@@ATTRIBUTES
18
18
 
19
19
  class << self
@@ -39,7 +39,7 @@ module Top4R
39
39
  # Video Model
40
40
  class Video
41
41
  include ModelMixin
42
- @@ATTRIBUTES = [:id, :video_id, :url, :created, :modified]
42
+ @@ATTRIBUTES = [:id, :video_id, :url, :created, :modified, :iid, :num_iid]
43
43
  attr_accessor *@@ATTRIBUTES
44
44
 
45
45
  class << self
@@ -54,9 +54,10 @@ module Top4R
54
54
  :seller_cids, :props, :input_pids, :input_str, :desc, :pic_path, :num, :valid_thru,
55
55
  :list_time, :delist_time, :stuff_status, :location, :price, :post_fee, :express_fee,
56
56
  :ems_fee, :has_discount, :freight_payer, :has_invoice, :has_warranty, :has_showcase,
57
- :modified, :increment, :auto_repost, :approve_status, :postage_id, :product_id, :auction_point,
57
+ :modified, :increment, :approve_status, :postage_id, :product_id, :auction_point,
58
58
  :property_alias, :item_imgs, :prop_imgs, :skus, :outer_id, :is_virtual, :is_taobao,
59
- :is_ex, :videos, :is_3D, :score, :volume, :one_station]
59
+ :is_ex, :is_timing, :videos, :is_3D, :score, :volume, :one_station, :second_kill,
60
+ :auto_fill, :props_name, :violation, :created, :is_prepay, :ww_status, :promoted_service]
60
61
  attr_accessor *@@ATTRIBUTES
61
62
 
62
63
  class << self
@@ -80,16 +81,16 @@ module Top4R
80
81
  else
81
82
  @location = nil
82
83
  end
83
- if @item_imgs.is_a?(Array) && @item_imgs.size > 0
84
- @item_imgs.map {|img| ItemImg.new(img)}
85
- else
86
- @item_imgs = []
87
- end
88
- if @prop_imgs.is_a?(Array) && @prop_imgs.size > 0
89
- @prop_imgs.map {|img| PropImg.new(img)}
90
- else
91
- @prop_imgs = []
92
- end
84
+ # if @item_imgs.is_a?(Array) && @item_imgs.size > 0
85
+ # @item_imgs.map {|img| ItemImg.new(img)}
86
+ # else
87
+ # @item_imgs = []
88
+ # end
89
+ # if @prop_imgs.is_a?(Array) && @prop_imgs.size > 0
90
+ # @prop_imgs.map {|img| PropImg.new(img)}
91
+ # else
92
+ # @prop_imgs = []
93
+ # end
93
94
 
94
95
  self
95
96
  end
@@ -2,41 +2,31 @@ module Top4R
2
2
  # Area model
3
3
  class Area
4
4
  include ModelMixin
5
- @@ATTRIBUTES = [:id, :area_id, :area_type, :area_name, :parent_id, :zip]
5
+ @@ATTRIBUTES = [:id, :type, :name, :parent_id, :zip]
6
6
  attr_accessor *@@ATTRIBUTES
7
7
 
8
8
  class << self
9
9
  def attributes; @@ATTRIBUTES; end
10
10
 
11
11
  def default_public_fields
12
- ["area_id", "area_type", "area_name", "parent_id", "zip"]
12
+ ["id", "type", "name", "parent_id", "zip"]
13
13
  end
14
14
  end
15
-
16
- def unmarshal_other_attrs
17
- @id = @area_id
18
- self
19
- end
20
15
  end
21
16
 
22
17
  # LogisticCompany model
23
18
  class LogisticCompany
24
19
  include ModelMixin
25
- @@ATTRIBUTES = [:id, :company_id, :company_code, :company_name]
20
+ @@ATTRIBUTES = [:id, :code, :name]
26
21
  attr_accessor *@@ATTRIBUTES
27
22
 
28
23
  class << self
29
24
  def attributes; @@ATTRIBUTES; end
30
25
 
31
26
  def default_public_fields
32
- ["company_id", "company_code", "company_name"]
27
+ ["id", "code", "name"]
33
28
  end
34
29
  end
35
-
36
- def unmarshal_other_attrs
37
- @id = @company_id
38
- self
39
- end
40
30
  end
41
31
 
42
32
  # Delivery model
@@ -56,7 +46,7 @@ module Top4R
56
46
  include ModelMixin
57
47
  @@ATTRIBUTES = [:id, :tid, :seller_nick, :buyer_nick, :delivery_start, :delivery_end,
58
48
  :out_sid, :item_title, :receiver_name, :receiver_phone, :receiver_mobile, :receiver_location,
59
- :status, :type, :freight_payer, :seller_confirm, :company_name]
49
+ :status, :type, :freight_payer, :seller_confirm, :company_name, :is_success, :created, :modified]
60
50
  attr_accessor *@@ATTRIBUTES
61
51
 
62
52
  class << self
@@ -2,7 +2,7 @@ module Top4R
2
2
  # SellerCat Model
3
3
  class SellerCat
4
4
  include ModelMixin
5
- @@ATTRIBUTES = [:id, :cid, :parent_cid, :name, :pict_url, :sort_order]
5
+ @@ATTRIBUTES = [:id, :cid, :parent_cid, :name, :pict_url, :sort_order, :created, :modified]
6
6
  attr_accessor *@@ATTRIBUTES
7
7
 
8
8
  class << self
@@ -15,10 +15,26 @@ module Top4R
15
15
  end
16
16
  end
17
17
 
18
+ # ShopScore Model
19
+ class ShopScore
20
+ include ModelMixin
21
+ @@ATTRIBUTES = [:item_score, :service_score, :delivery_score]
22
+ attr_accessor *@@ATTRIBUTES
23
+
24
+ class << self
25
+ def attributes; @@ATTRIBUTES; end
26
+ end
27
+
28
+ def unmarshal_other_attrs
29
+ @id = 0
30
+ self
31
+ end
32
+ end
33
+
18
34
  # Shop Model
19
35
  class Shop
20
36
  include ModelMixin
21
- @@ATTRIBUTES = [:id, :sid, :cid, :nick, :title, :desc, :bulletin, :pic_path, :created, :modified]
37
+ @@ATTRIBUTES = [:id, :sid, :cid, :nick, :title, :desc, :bulletin, :pic_path, :created, :modified, :shop_score, :remain_count]
22
38
  attr_accessor *@@ATTRIBUTES
23
39
 
24
40
  class << self
@@ -31,6 +47,13 @@ module Top4R
31
47
 
32
48
  def unmarshal_other_attrs
33
49
  @id = @sid
50
+
51
+ if @shop_score && @shop_score.size > 0
52
+ @shop_score = ShopScore.new(@shop_score)
53
+ else
54
+ @shop_score = nil
55
+ end
56
+
34
57
  self
35
58
  end
36
59
  end
@@ -3,9 +3,10 @@ module Top4R
3
3
  class Order
4
4
  include ModelMixin
5
5
  @@ATTRIBUTES = [:id, :iid, :sku_id, :sku_properties_name, :item_meal_name, :num, :title,
6
- :price, :pic_path, :seller_nick, :buyer_nick, :type, :created, :refund_status, :tid,
6
+ :price, :pic_path, :seller_nick, :buyer_nick, :type, :created, :refund_status, :oid,
7
7
  :outer_iid, :outer_sku_id, :total_fee, :payment, :discount_fee, :adjust_fee, :status,
8
- :snapshot_url, :timeout_action_time]
8
+ :snapshot_url, :snapshot, :timeout_action_time, :buyer_rate, :seller_rate, :refund_id,
9
+ :seller_type, :modified, :num_iid]
9
10
  attr_accessor *@@ATTRIBUTES
10
11
 
11
12
  class << self
@@ -30,7 +31,7 @@ module Top4R
30
31
  # TradeConfirmFee model
31
32
  class TradeConfirmFee
32
33
  include ModelMixin
33
- @@ATTRIBUTES = [:id, :confirm_fee, :confirm_post_fee, :is_last_detail_order]
34
+ @@ATTRIBUTES = [:id, :confirm_fee, :confirm_post_fee, :is_last_order]
34
35
  attr_accessor *@@ATTRIBUTES
35
36
 
36
37
  class << self
@@ -43,18 +44,30 @@ module Top4R
43
44
  end
44
45
  end
45
46
 
47
+ # PromotionDetail model
48
+ class PromotionDetail
49
+ include ModelMixin
50
+ @@ATTRIBUTES = [:id, :promotion_name, :discount_fee]
51
+ attr_accessor *@@ATTRIBUTES
52
+
53
+ class << self
54
+ def attributes; @@ATTRIBUTES; end
55
+ end
56
+ end
57
+
46
58
  # Trade model
47
59
  class Trade
48
60
  include ModelMixin
49
61
  @@ATTRIBUTES = [:id, :seller_nick, :buyer_nick, :title, :type, :created, :iid, :price,
50
- :pic_path, :num, :tid, :buyer_message, :sid, :shipping_type, :alipay_no, :payment,
51
- :discount_fee, :adjust_fee, :snapshot_url, :status, :seller_rate, :buyer_rate,
52
- :buyer_memo, :seller_memo, :pay_time, :end_time, :modified, :buyer_obtain_point_fee,
62
+ :pic_path, :num, :tid, :buyer_message, :shipping_type, :alipay_no, :payment,
63
+ :discount_fee, :adjust_fee, :snapshot_url, :snapshot, :status, :seller_rate, :buyer_rate,
64
+ :buyer_memo, :seller_memo, :trade_memo, :pay_time, :end_time, :modified, :buyer_obtain_point_fee,
53
65
  :point_fee, :real_point_fee, :total_fee, :post_fee, :buyer_alipay_no, :receiver_name,
54
66
  :receiver_state, :receiver_city, :receiver_district, :receiver_address, :receiver_zip,
55
67
  :receiver_mobile, :receiver_phone, :consign_time, :buyer_email, :commission_fee,
56
68
  :seller_alipay_no, :seller_mobile, :seller_phone, :seller_name, :seller_email,
57
- :available_confirm_fee, :has_postFee, :received_payment, :cod_fee, :timeout_action_time, :orders]
69
+ :available_confirm_fee, :has_post_fee, :received_payment, :cod_fee, :timeout_action_time,
70
+ :is_3D, :buyer_flag, :seller_flag, :num_iid, :promotion, :promotion_details, :invoice_name, :orders]
58
71
  attr_accessor *@@ATTRIBUTES
59
72
 
60
73
  class << self
@@ -94,8 +107,8 @@ module Top4R
94
107
 
95
108
  def unmarshal_other_attrs
96
109
  @id = @tid
97
- if @orders.is_a?(Array)
98
- @orders = @orders.map{|order| Order.new(order)}
110
+ if @orders.is_a?(Hash)
111
+ @orders = @orders["order"].map{|order| Order.new(order)}
99
112
  end
100
113
  self
101
114
  end
@@ -13,8 +13,12 @@ module Top4R
13
13
  @client.items_onsale(q, :onsale_list, options)
14
14
  end
15
15
 
16
- def cats
17
- @client.seller_cats(self.nick)
16
+ def cats(options = {})
17
+ @client.seller_cats(self.nick, :cats_list, options)
18
+ end
19
+
20
+ def shop(options = {})
21
+ @client.shop(self.nick, :shop_info, options)
18
22
  end
19
23
  end
20
24
 
@@ -46,6 +50,17 @@ module Top4R
46
50
  def attributes; @@ATTRIBUTES; end
47
51
  end
48
52
  end # UserCredit model
53
+
54
+ # UserSubscribe Model
55
+ class UserSubscribe
56
+ include ModelMixin
57
+ @@ATTRIBUTES = [:status, :start_date, :end_date, :version_no]
58
+ attr_accessor *@@ATTRIBUTES
59
+
60
+ class << self
61
+ def attributes; @@ATTRIBUTES; end
62
+ end
63
+ end # UserCredit model
49
64
 
50
65
  # User Model
51
66
  class User
@@ -53,7 +68,7 @@ module Top4R
53
68
  @@ATTRIBUTES = [:id, :user_id, :nick, :sex, :buyer_credit, :seller_credit, :location,
54
69
  :created, :last_visit, :birthday, :type, :has_more_pic, :item_img_num, :item_img_size,
55
70
  :prop_img_num, :prop_img_size, :auto_repost, :promoted_type, :status, :alipay_bind,
56
- :consumer_protection, :other_attrs]
71
+ :consumer_protection, :alipay_account, :alipay_no, :email, :magazine_subscribe, :vertical_market]
57
72
  attr_accessor *@@ATTRIBUTES
58
73
 
59
74
  class << self
data/lib/top4r/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Top4R::Version
2
2
  MAJOR = 0
3
- MINOR = 0
4
- REVISION = 39
3
+ MINOR = 1
4
+ REVISION = 0
5
5
 
6
6
  class << self
7
7
  # Returns X.Y.Z formatted version string
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: top4r
3
3
  version: !ruby/object:Gem::Version
4
- hash: 81
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 39
10
- version: 0.0.39
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nowa Zhu
14
- autorequire:
14
+ autorequire: top4r
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-02 00:00:00 +08:00
18
+ date: 2010-09-25 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -36,8 +36,8 @@ dependencies:
36
36
  version_requirements: *id001
37
37
  description:
38
38
  email: nowazhu@gmail.com
39
- executables:
40
- - top4rsh
39
+ executables: []
40
+
41
41
  extensions: []
42
42
 
43
43
  extra_rdoc_files:
@@ -76,7 +76,6 @@ files:
76
76
  - CHANGES
77
77
  - TODO
78
78
  - MIT-LICENSE
79
- - bin/top4rsh
80
79
  has_rdoc: true
81
80
  homepage: http://top4r.labs.nowa.me
82
81
  licenses: []
@@ -91,10 +90,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
90
  requirements:
92
91
  - - ">="
93
92
  - !ruby/object:Gem::Version
94
- hash: 3
93
+ hash: 51
95
94
  segments:
96
- - 0
97
- version: "0"
95
+ - 1
96
+ - 8
97
+ - 2
98
+ version: 1.8.2
98
99
  required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  none: false
100
101
  requirements:
@@ -104,8 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  segments:
105
106
  - 0
106
107
  version: "0"
107
- requirements: []
108
-
108
+ requirements:
109
+ - Ruby 1.8.4+
109
110
  rubyforge_project: top4r
110
111
  rubygems_version: 1.3.7
111
112
  signing_key:
data/bin/top4rsh DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env ruby
2
-