glitch_auth 0.0.1 → 0.0.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/lib/glitch_auth.rb +14 -2
- metadata +3 -3
data/lib/glitch_auth.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
# This class builds a url that can be used to authenticate
|
2
|
+
# with the API for Glitch, the game (http://www.glitch.com).
|
1
3
|
class Glitch_Auth
|
2
4
|
|
3
|
-
# Default constructor
|
5
|
+
# Default constructor.
|
6
|
+
#
|
7
|
+
# @param [String] token the API token associated with the client's API key
|
8
|
+
# @param [String] redirect_uri the callback URL associated with the client's API key
|
4
9
|
def initialize(token, redirect_uri)
|
5
10
|
|
6
11
|
# unique to glitch
|
@@ -17,14 +22,18 @@ class Glitch_Auth
|
|
17
22
|
|
18
23
|
end
|
19
24
|
|
25
|
+
|
26
|
+
# @param [String] value a string specifying the token already associated with this client's API key.
|
20
27
|
def token(value)
|
21
28
|
@token = value
|
22
29
|
end
|
23
30
|
|
31
|
+
# @param [String] value a string specifying the redirect_uri already associated with this client's API key.
|
24
32
|
def redirect_uri(value)
|
25
33
|
@redirect_uri = value
|
26
34
|
end
|
27
35
|
|
36
|
+
# @param [String] value a string specifying the response_type required. Must be either 'code' or 'token'.
|
28
37
|
def response_type(value)
|
29
38
|
if (value == 'code' || value == 'token')
|
30
39
|
@response_type = value
|
@@ -33,6 +42,7 @@ class Glitch_Auth
|
|
33
42
|
end
|
34
43
|
end
|
35
44
|
|
45
|
+
# @param [String] value a string specifying the scope of the request. Must be either 'identity', 'read' or 'write'.
|
36
46
|
def scope(value)
|
37
47
|
if (value == 'identity' || value == 'read' || value == 'write')
|
38
48
|
@scope = value
|
@@ -41,12 +51,14 @@ class Glitch_Auth
|
|
41
51
|
end
|
42
52
|
end
|
43
53
|
|
54
|
+
# @param [String] value a string specifying the state.
|
44
55
|
def state(value)
|
45
56
|
@state = value
|
46
57
|
end
|
47
58
|
|
59
|
+
# @return [String] a URI for authenticating with Glitch, customised as per the settings specified
|
48
60
|
def uri
|
49
|
-
|
61
|
+
"#{@path}?response_type=#{@response_type}&client_id=#{@token}&redirect_uri=#{@redirect_uri}&scope=#{@scope}&state=#{@state}"
|
50
62
|
end
|
51
63
|
|
52
64
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glitch_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- martian-a
|