playlyfe 0.7.0 → 0.7.1
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/lib/playlyfe.rb +8 -3
- data/test/test.rb +27 -1
- metadata +2 -2
data/lib/playlyfe.rb
CHANGED
@@ -7,6 +7,7 @@ class PlaylyfeError < StandardError
|
|
7
7
|
def initialize(res)
|
8
8
|
message = []
|
9
9
|
begin
|
10
|
+
@raw = res
|
10
11
|
res = JSON.parse(res)
|
11
12
|
@name = res['error']
|
12
13
|
@message = res['error_description']
|
@@ -18,6 +19,7 @@ class PlaylyfeError < StandardError
|
|
18
19
|
end
|
19
20
|
|
20
21
|
class Playlyfe
|
22
|
+
attr_reader :sdk_version
|
21
23
|
|
22
24
|
def initialize(options = {})
|
23
25
|
if options[:type].nil?
|
@@ -26,6 +28,7 @@ class Playlyfe
|
|
26
28
|
err.message = "You must pass in a type whether 'client' for client credentials flow or 'code' for auth code flow"
|
27
29
|
raise err
|
28
30
|
end
|
31
|
+
@sdk_version = '0.7.1'
|
29
32
|
@version = options[:version] ||= 'v1'
|
30
33
|
@type = options[:type]
|
31
34
|
@id = options[:client_id]
|
@@ -139,11 +142,13 @@ class Playlyfe
|
|
139
142
|
if options[:raw] == true
|
140
143
|
return res.body
|
141
144
|
else
|
142
|
-
|
145
|
+
if res.body == 'null'
|
146
|
+
return nil
|
147
|
+
else
|
148
|
+
return JSON.parse(res.body)
|
149
|
+
end
|
143
150
|
end
|
144
151
|
rescue => e
|
145
|
-
puts e
|
146
|
-
puts e.response
|
147
152
|
raise PlaylyfeError.new(e.response)
|
148
153
|
end
|
149
154
|
end
|
data/test/test.rb
CHANGED
@@ -4,6 +4,16 @@ require 'playlyfe'
|
|
4
4
|
|
5
5
|
class PlaylyfeTest < Test::Unit::TestCase
|
6
6
|
|
7
|
+
def test_version
|
8
|
+
pl = Playlyfe.new(
|
9
|
+
version: 'v1',
|
10
|
+
client_id: "Zjc0MWU0N2MtODkzNS00ZWNmLWEwNmYtY2M1MGMxNGQ1YmQ4",
|
11
|
+
client_secret: "YzllYTE5NDQtNDMwMC00YTdkLWFiM2MtNTg0Y2ZkOThjYTZkMGIyNWVlNDAtNGJiMC0xMWU0LWI2NGEtYjlmMmFkYTdjOTI3",
|
12
|
+
type: 'client'
|
13
|
+
)
|
14
|
+
assert_equal pl.sdk_version, '0.7.1'
|
15
|
+
end
|
16
|
+
|
7
17
|
def test_invalid_client
|
8
18
|
begin
|
9
19
|
Playlyfe.new(
|
@@ -162,6 +172,22 @@ class PlaylyfeTest < Test::Unit::TestCase
|
|
162
172
|
|
163
173
|
raw_data = pl.get(route: '/runtime/player', query: { player_id: player_id }, raw: true)
|
164
174
|
assert_equal raw_data.class, String
|
175
|
+
|
176
|
+
new_metric = pl.post(route: '/design/versions/latest/metrics', query: {}, body: {
|
177
|
+
id: 'apple',
|
178
|
+
name: 'apple',
|
179
|
+
type: 'point',
|
180
|
+
image: 'default-point-metric',
|
181
|
+
description: '',
|
182
|
+
constraints: {
|
183
|
+
default: '0',
|
184
|
+
max: 'Infinity',
|
185
|
+
min: '0'
|
186
|
+
}
|
187
|
+
});
|
188
|
+
assert_equal new_metric['id'], 'apple'
|
189
|
+
deleted_metric = pl.delete(route: '/design/versions/latest/metrics/apple')
|
190
|
+
assert_equal deleted_metric['message'], "The metric 'apple' has been deleted successfully"
|
165
191
|
end
|
166
192
|
|
167
193
|
def test_init_production
|
@@ -171,7 +197,7 @@ class PlaylyfeTest < Test::Unit::TestCase
|
|
171
197
|
client_secret: "NDc3NTA0NmItMjBkZi00MjI2LWFhMjUtOTI0N2I1YTkxYjc2M2U3ZGI0MDAtNGQ1Mi0xMWU0LWJmZmUtMzkyZTdiOTYxYmMx",
|
172
198
|
type: 'client'
|
173
199
|
)
|
174
|
-
|
200
|
+
pl.get(route: '/game/players', query: { limit: 1 })
|
175
201
|
end
|
176
202
|
|
177
203
|
def test_store
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playlyfe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
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:
|
12
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest_client
|