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 +10 -2
- data/lib/top4r/client/base.rb +15 -1
- data/lib/top4r/client/item.rb +9 -3
- data/lib/top4r/client/shipping.rb +16 -6
- data/lib/top4r/client/shop.rb +9 -4
- data/lib/top4r/client/suite.rb +10 -5
- data/lib/top4r/client/taobaokeitem.rb +9 -4
- data/lib/top4r/client/trade.rb +13 -8
- data/lib/top4r/client/user.rb +9 -2
- data/lib/top4r/client.rb +1 -1
- data/lib/top4r/config.rb +1 -1
- data/lib/top4r/core.rb +2 -2
- data/lib/top4r/model/item.rb +16 -15
- data/lib/top4r/model/shipping.rb +5 -15
- data/lib/top4r/model/shop.rb +25 -2
- data/lib/top4r/model/trade.rb +22 -9
- data/lib/top4r/model/user.rb +18 -3
- data/lib/top4r/version.rb +2 -2
- metadata +14 -13
- data/bin/top4rsh +0 -2
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
|
28
|
+
sudo gem install top4r
|
data/lib/top4r/client/base.rb
CHANGED
@@ -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] = "
|
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
|
data/lib/top4r/client/item.rb
CHANGED
@@ -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
|
-
|
12
|
-
|
13
|
-
|
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.
|
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
|
-
|
19
|
-
|
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
|
-
|
28
|
-
|
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[
|
53
|
+
json.is_a?(Hash) ? json[rsp(@@DELIVERY_METHODS[method])]["shipping"]["is_success"] : false
|
44
54
|
end
|
45
55
|
end
|
data/lib/top4r/client/shop.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
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
|
-
|
24
|
-
|
28
|
+
shop = Top4R::Shop.unmarshal(JSON.parse(response.body)[rsp(@@SHOP_METHODS[method])]["shop"])
|
29
|
+
bless_model(shop)
|
25
30
|
end
|
26
31
|
end
|
data/lib/top4r/client/suite.rb
CHANGED
@@ -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 == "{\"
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
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
|
data/lib/top4r/client/trade.rb
CHANGED
@@ -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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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[
|
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[
|
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[
|
48
|
+
parsed_body[rsp(@@TRADE_METHODS[method])]["trade"]["modified"]
|
44
49
|
elsif method == :add_memo
|
45
|
-
parsed_body[
|
50
|
+
parsed_body[rsp(@@TRADE_METHODS[method])]["trade"]["created"]
|
46
51
|
end
|
47
52
|
end
|
48
53
|
end
|
data/lib/top4r/client/user.rb
CHANGED
@@ -24,8 +24,15 @@ class Top4R::Client
|
|
24
24
|
protected
|
25
25
|
|
26
26
|
def user_request(u, method, options)
|
27
|
-
|
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
|
-
|
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
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
|
|
data/lib/top4r/model/item.rb
CHANGED
@@ -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, :
|
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
|
-
|
85
|
-
else
|
86
|
-
|
87
|
-
end
|
88
|
-
if @prop_imgs.is_a?(Array) && @prop_imgs.size > 0
|
89
|
-
|
90
|
-
else
|
91
|
-
|
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
|
data/lib/top4r/model/shipping.rb
CHANGED
@@ -2,41 +2,31 @@ module Top4R
|
|
2
2
|
# Area model
|
3
3
|
class Area
|
4
4
|
include ModelMixin
|
5
|
-
@@ATTRIBUTES = [:id, :
|
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
|
-
["
|
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, :
|
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
|
-
["
|
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
|
data/lib/top4r/model/shop.rb
CHANGED
@@ -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
|
data/lib/top4r/model/trade.rb
CHANGED
@@ -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, :
|
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, :
|
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, :
|
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, :
|
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?(
|
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
|
data/lib/top4r/model/user.rb
CHANGED
@@ -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, :
|
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
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
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-
|
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
|
-
|
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:
|
93
|
+
hash: 51
|
95
94
|
segments:
|
96
|
-
-
|
97
|
-
|
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