uboost-client 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +22 -10
- data/lib/uboost-client/uboost_client.rb +18 -1
- data/lib/uboost-client/version.rb +1 -1
- data/spec/simple_test.rb +9 -5
- metadata +2 -2
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# uBoost Client API
|
2
2
|
|
3
|
-
This is the unofficial ruby client for uBoost API. It is a wrapper for the REST interface described at [https://github.com/
|
3
|
+
This is the unofficial ruby client for uBoost API. It is a wrapper for the REST interface described at [https://github.com/uboost/uBoost-API-v2](https://github.com/uboost/uBoost-API-v2)
|
4
4
|
|
5
5
|
## Installing
|
6
6
|
|
@@ -43,7 +43,7 @@ response.message
|
|
43
43
|
|
44
44
|
### Account
|
45
45
|
|
46
|
-
https://github.com/
|
46
|
+
https://github.com/uboost/uBoost-API-v2#accounts-api
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
client.account.create({ "user_name" => "test_user_2" })
|
@@ -63,7 +63,7 @@ client.account.token(921679358)
|
|
63
63
|
|
64
64
|
### Points
|
65
65
|
|
66
|
-
https://github.com/
|
66
|
+
https://github.com/uboost/uBoost-API-v2#points-api
|
67
67
|
|
68
68
|
```ruby
|
69
69
|
client.points.point_transactions_for_account(921679358)
|
@@ -75,7 +75,7 @@ client.points.add_points_to_account(921679359, 30, {:description => 'a descripti
|
|
75
75
|
|
76
76
|
### Badges
|
77
77
|
|
78
|
-
https://github.com/
|
78
|
+
https://github.com/uboost/uBoost-API-v2#badges-api
|
79
79
|
|
80
80
|
```ruby
|
81
81
|
client.badges.award(921679359, 1)
|
@@ -85,7 +85,16 @@ client.badges.unaward(921679359, 1)
|
|
85
85
|
|
86
86
|
### Widgets
|
87
87
|
|
88
|
-
https://github.com/
|
88
|
+
https://github.com/uboost/uBoost-API-v2#widgets-api
|
89
|
+
|
90
|
+
Authentication for the Widgets API can be made by: sending in a student account's username and password, or have the gem automatically use SSO and cookies.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
# Use the student's username and password
|
94
|
+
response = client.account.select(921679358)
|
95
|
+
credentials = { credentials: { username: response.student["user_name"], password: response.student["password"]} }
|
96
|
+
client.widgets(credentials).profile
|
97
|
+
```
|
89
98
|
|
90
99
|
The widgets section can make use of a session store. Just pass a session object - something that quacks like a hash - and the first call it makes will cache the `_uboost_session_id` that the uBoost API returns, to `:uboost_session_id` in the session object.
|
91
100
|
|
@@ -93,20 +102,23 @@ The widgets section can make use of a session store. Just pass a session object
|
|
93
102
|
session = Hash.new # or a Ruby on Rails session, for example
|
94
103
|
|
95
104
|
# No caching
|
96
|
-
client.widgets.profile(:account_id => 921679373)
|
105
|
+
client.widgets.profile(:account_id => 921679373)
|
97
106
|
# Caching activated. It will cache the uboost sesion.
|
98
107
|
client.widgets(:session => session).profile(:account_id => 921679373)
|
99
108
|
# Caching activated. It will use the cached uboost sesion.
|
100
109
|
client.widgets(:session => session).profile(:account_id => 921679373)
|
101
110
|
|
102
111
|
client.widgets.my_badges(:account_id => 921679373)
|
103
|
-
client.widgets(:session => session).my_badges(:account_id => 921679373)
|
104
112
|
|
105
|
-
client.widgets.ubar(:account_id => 921679373)
|
113
|
+
client.widgets.ubar(:account_id => 921679373) # ubar doesn't accept :session
|
106
114
|
|
107
115
|
client.widgets.list_of_leaderboards(:account_id => 921679373)
|
108
|
-
client.widgets(:session => session).list_of_leaderboards(:account_id => 921679373)
|
109
116
|
|
110
117
|
client.widgets.leaderboard(:account_id => 921679373, :leaderboard_id => 226)
|
111
|
-
|
118
|
+
|
119
|
+
client.widgets.badge_categories(:account_id => 921679373)
|
120
|
+
|
121
|
+
client.widgets.badges_for_category(:account_id => 921679373, :badge_category_id => 31)
|
122
|
+
|
123
|
+
client.widgets.unearned_badges(:account_id => 921679373, :badge_category_id => 31)
|
112
124
|
```
|
@@ -233,9 +233,26 @@ module UboostClient
|
|
233
233
|
OpenStruct.new(JSON.parse(response.body))
|
234
234
|
end
|
235
235
|
|
236
|
+
def badge_categories(options = Hash.new)
|
237
|
+
response = get(@url + '/badge_categories', options)
|
238
|
+
OpenStruct.new(JSON.parse(response.body))
|
239
|
+
end
|
240
|
+
|
241
|
+
def badges_for_category(options = Hash.new)
|
242
|
+
options = {:account_id => nil, :badge_category_id => nil}.merge(options)
|
243
|
+
response = get(@url + '/badge_categories/' + options[:badge_category_id].to_s + '/badges', options)
|
244
|
+
OpenStruct.new(JSON.parse(response.body))
|
245
|
+
end
|
246
|
+
|
236
247
|
def my_badges(options = Hash.new)
|
237
248
|
options = {:account_id => nil, :badge_category_id => 'all'}.merge(options)
|
238
|
-
response = get(@url + '/badges/mine/' + options[:badge_category_id], options)
|
249
|
+
response = get(@url + '/badges/mine/' + options[:badge_category_id].to_s, options)
|
250
|
+
OpenStruct.new(JSON.parse(response.body))
|
251
|
+
end
|
252
|
+
|
253
|
+
def unearned_badges(options = Hash.new)
|
254
|
+
options = {:account_id => nil, :badge_category_id => nil}.merge(options)
|
255
|
+
response = get(@url + '/badges/unearned/' + options[:badge_category_id].to_s, options)
|
239
256
|
OpenStruct.new(JSON.parse(response.body))
|
240
257
|
end
|
241
258
|
|
data/spec/simple_test.rb
CHANGED
@@ -15,25 +15,29 @@ client = UboostClient::Client.new(:subdomain => subdomain, :api_credentials => a
|
|
15
15
|
# puts client.account.find(:external_id => '3253466')
|
16
16
|
# puts client.account.token(921679358)
|
17
17
|
# puts client.points.point_transactions_for_account(921679358)
|
18
|
+
|
18
19
|
# puts client.account.points_transactions(921679358)
|
19
20
|
# puts client.points.add_points_to_account(921679359, 30, {:description => 'whatps'})
|
21
|
+
|
20
22
|
# puts client.badges.award(921679373, 467)
|
21
23
|
# puts client.badges.unaward(921679373, 467)
|
22
24
|
|
23
25
|
# puts client.widgets.profile(:account_id => 921679373)
|
24
26
|
# puts client.widgets(:session => session).profile(:account_id => 921679373)
|
25
|
-
# puts client.widgets(:session => session).profile(:account_id => 921679373)
|
26
27
|
|
27
28
|
# puts client.widgets.my_badges(:account_id => 921679373)
|
28
29
|
# puts client.widgets(:session => session).my_badges(:account_id => 921679373)
|
29
|
-
# puts client.widgets(:session => session).my_badges(:account_id => 921679373)
|
30
30
|
|
31
|
-
puts client.widgets.ubar(:account_id => 921679373)
|
31
|
+
# puts client.widgets.ubar(:account_id => 921679373)
|
32
32
|
|
33
33
|
# puts client.widgets.list_of_leaderboards(:account_id => 921679373)
|
34
34
|
# puts client.widgets(:session => session).list_of_leaderboards(:account_id => 921679373)
|
35
|
-
# puts client.widgets(:session => session).list_of_leaderboards(:account_id => 921679373)
|
36
35
|
|
37
36
|
# puts client.widgets.leaderboard(:account_id => 921679373, :leaderboard_id => 226)
|
38
37
|
# puts client.widgets(:session => session).leaderboard(:account_id => 921679373, :leaderboard_id => 226)
|
39
|
-
|
38
|
+
|
39
|
+
# puts client.widgets.badge_categories(:account_id => 921679373)
|
40
|
+
|
41
|
+
# puts client.widgets.badges_for_category(:account_id => 921679373, :badge_category_id => 31)
|
42
|
+
|
43
|
+
# puts client.widgets.unearned_badges(:account_id => 921679373, :badge_category_id => 31)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uboost-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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-11-
|
12
|
+
date: 2012-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|