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 +5 -0
- data/lib/top4r/client/base.rb +4 -1
- data/lib/top4r/client/item.rb +20 -1
- data/lib/top4r/version.rb +1 -1
- metadata +2 -2
data/CHANGES
CHANGED
data/lib/top4r/client/base.rb
CHANGED
@@ -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
|
data/lib/top4r/client/item.rb
CHANGED
@@ -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(@@
|
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
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.
|
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-
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|