nitroapi 0.0.7 → 0.0.8
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/Gemfile.lock +1 -1
- data/lib/nitro_api.rb +8 -0
- data/lib/nitro_api/site_calls.rb +13 -12
- data/lib/nitro_api/user_calls.rb +7 -6
- data/lib/nitro_api/version.rb +1 -1
- data/spec/nitro_api_spec.rb +17 -17
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/nitro_api.rb
CHANGED
@@ -173,5 +173,13 @@ module NitroApi
|
|
173
173
|
def to_query params
|
174
174
|
URI.escape(params.map { |k,v| "#{k.to_s}=#{v.to_s}" }.join("&"))
|
175
175
|
end
|
176
|
+
|
177
|
+
def symbolize_keys h
|
178
|
+
result = {}
|
179
|
+
h.keys.each do |key|
|
180
|
+
result[(key.to_sym rescue key) || key] = h[key]
|
181
|
+
end
|
182
|
+
result
|
183
|
+
end
|
176
184
|
end
|
177
185
|
end
|
data/lib/nitro_api/site_calls.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module NitroApi
|
2
2
|
module SiteCalls
|
3
3
|
def make_points_leaders_call opts
|
4
|
+
opts = symbolize_keys opts
|
4
5
|
params = {
|
5
6
|
:method => 'site.getPointsLeaders'
|
6
7
|
}
|
@@ -10,18 +11,18 @@ module NitroApi
|
|
10
11
|
params[:sessionKey] = @session if @session
|
11
12
|
|
12
13
|
opts_list = {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
criteria: 'criteria',
|
15
|
+
point_category: 'pointCategory',
|
16
|
+
return_count: 'returnCount',
|
17
|
+
start: 'start',
|
18
|
+
duration: 'duration',
|
19
|
+
user_ids: 'userIds',
|
20
|
+
tags: 'tags',
|
21
|
+
tags_operator: 'tagsOperator',
|
22
|
+
group_name: 'groupName',
|
23
|
+
with_rank: 'withRank',
|
24
|
+
with_surrounding_users: 'withSurroundingUsers',
|
25
|
+
preferences: 'preferences'
|
25
26
|
}
|
26
27
|
|
27
28
|
opts.each do |key,value|
|
data/lib/nitro_api/user_calls.rb
CHANGED
@@ -129,6 +129,7 @@ module NitroApi
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def make_get_points_balance_call opts={}
|
132
|
+
opts = symbolize_keys opts
|
132
133
|
params = {
|
133
134
|
:method => 'user.getPointsBalance'
|
134
135
|
}
|
@@ -138,12 +139,12 @@ module NitroApi
|
|
138
139
|
params[:sessionKey] = @session if @session
|
139
140
|
|
140
141
|
opts_list = {
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
142
|
+
criteria: 'criteria',
|
143
|
+
point_category: 'pointCategory',
|
144
|
+
start: 'start',
|
145
|
+
end: 'end',
|
146
|
+
user_id: 'userId',
|
147
|
+
tags: 'tags',
|
147
148
|
}
|
148
149
|
|
149
150
|
opts.each do |key,value|
|
data/lib/nitro_api/version.rb
CHANGED
data/spec/nitro_api_spec.rb
CHANGED
@@ -245,12 +245,12 @@ describe NitroApi do
|
|
245
245
|
|
246
246
|
it "passes through all the expected parameters" do
|
247
247
|
options = {
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
248
|
+
point_category: 'other_points',
|
249
|
+
criteria: 'BALANCE',
|
250
|
+
start: '1354636962',
|
251
|
+
end: '1354637015',
|
252
|
+
tags: 'beans,rice',
|
253
|
+
user_id: 'another_user',
|
254
254
|
}
|
255
255
|
url = @nitro.base_url + '?criteria=BALANCE&end=1354637015&method=user.getPointsBalance&pointCategory=other_points&sessionKey=1&start=1354636962&tags=beans,rice&userId=another_user'
|
256
256
|
stub_http_request(:get, url).
|
@@ -261,13 +261,13 @@ describe NitroApi do
|
|
261
261
|
|
262
262
|
it "passes through only the expected parameters" do
|
263
263
|
options = {
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
264
|
+
point_category: 'other_points',
|
265
|
+
criteria: 'BALANCE',
|
266
|
+
start: '1354636962',
|
267
|
+
end: '1354637015',
|
268
|
+
tags: 'beans,rice',
|
269
|
+
user_id: 'another_user',
|
270
|
+
non_param: 'some_unknown_param'
|
271
271
|
}
|
272
272
|
url = @nitro.base_url + '?criteria=BALANCE&end=1354637015&method=user.getPointsBalance&pointCategory=other_points&sessionKey=1&start=1354636962&tags=beans,rice&userId=another_user'
|
273
273
|
stub_http_request(:get, url).
|
@@ -280,10 +280,10 @@ describe NitroApi do
|
|
280
280
|
describe "#get_points_leaders options_hash" do
|
281
281
|
it "gets points leaders" do
|
282
282
|
options = {
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
283
|
+
return_count: 20,
|
284
|
+
duration: 'ALLTIME',
|
285
|
+
point_category: 'points',
|
286
|
+
criteria: 'CREDITS'
|
287
287
|
}
|
288
288
|
|
289
289
|
results = { 'Nitro' => {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nitroapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|