toopher_api 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -2
- data/lib/toopher_api.rb +54 -2
- metadata +19 -2
data/Rakefile
CHANGED
data/lib/toopher_api.rb
CHANGED
@@ -27,11 +27,14 @@ require 'uri'
|
|
27
27
|
require 'json'
|
28
28
|
require 'oauth'
|
29
29
|
|
30
|
+
# An exception class used to indicate an error returned by a Toopher API request
|
30
31
|
class ToopherApiError < StandardError
|
31
32
|
end
|
32
33
|
|
34
|
+
# Abstracts calls to the Toopher OAuth webservice
|
33
35
|
class ToopherAPI
|
34
36
|
|
37
|
+
# Default URL for the Toopher webservice API. Can be overridden in the constructor if necessary.
|
35
38
|
DEFAULT_BASE_URL = 'https://toopher-api.appspot.com/v1/'
|
36
39
|
|
37
40
|
# Creates a Toopher API consumer
|
@@ -54,8 +57,8 @@ class ToopherAPI
|
|
54
57
|
|
55
58
|
# Create the pairing between a particular user and their mobile device
|
56
59
|
#
|
57
|
-
# @param [String] pairing_phrase The pairing phrase
|
58
|
-
# @param [String] user_name
|
60
|
+
# @param [String] pairing_phrase The pairing phrase generated by a user's mobile application.
|
61
|
+
# @param [String] user_name A human recognizable string which represents the user making the request (usually their username). This is displayed to the user on the mobile app when authenticating.
|
59
62
|
#
|
60
63
|
# @return [PairingStatus] Information about the pairing request
|
61
64
|
def pair(pairing_phrase, user_name)
|
@@ -66,10 +69,21 @@ class ToopherAPI
|
|
66
69
|
end
|
67
70
|
|
68
71
|
# Check on the status of a previous pairing request
|
72
|
+
#
|
73
|
+
# @param [String] pairing_request_id The unique string identifier id returned by a previous pairing request.
|
74
|
+
#
|
75
|
+
# @return [PairingStatus] Information about the pairing request
|
69
76
|
def get_pairing_status(pairing_request_id)
|
70
77
|
return PairingStatus.new(get('pairings/' + pairing_request_id))
|
71
78
|
end
|
72
79
|
|
80
|
+
# Authenticate an action with Toopher
|
81
|
+
#
|
82
|
+
# @param [String] pairing_id The unique string identifier id returned by a previous pairing request.
|
83
|
+
# @param [String] terminal_name A human recognizable string which represents the terminal from which the user is making the request. This is displayed to the user on the mobile app when authenticating. If this is not included, then a terminal_id returned from a previous request must be provided (see below). These should be unique values for each different device from which a user connects to your service (as best you can detect).
|
84
|
+
# @param [String] action_name Optional action name, defaults to "log in" (displayed to the user)
|
85
|
+
#
|
86
|
+
# @return [AuthenticationStatus] Information about the authentication request
|
73
87
|
def authenticate(pairing_id, terminal_name, action_name = '')
|
74
88
|
parameters = {
|
75
89
|
'pairing_id' => pairing_id,
|
@@ -79,6 +93,9 @@ class ToopherAPI
|
|
79
93
|
return AuthenticationStatus.new(post('authentication_requests/initiate', parameters))
|
80
94
|
end
|
81
95
|
|
96
|
+
# Check on the status of a previous authentication request
|
97
|
+
#
|
98
|
+
# @param [String] authentication_request_id The unique string identifier id returned by a previous authentication request.
|
82
99
|
def get_authentication_status(authentication_request_id)
|
83
100
|
return AuthenticationStatus.new(get('authentication_requests/' + authentication_request_id))
|
84
101
|
end
|
@@ -110,10 +127,23 @@ class ToopherAPI
|
|
110
127
|
end
|
111
128
|
end
|
112
129
|
|
130
|
+
# Contains information about a particular pairing request
|
113
131
|
class PairingStatus
|
132
|
+
|
133
|
+
# @!attribute id
|
134
|
+
# @return [String] A unique identifier generated and returned by the Toopher web service that is used to identify this pairing. It can be used to request status information for the pairing and must be included in subsequent authentication requests for this user.
|
114
135
|
attr_accessor :id
|
136
|
+
|
137
|
+
# @!attribute enabled
|
138
|
+
# @return [Boolean] Indicates whether or not the pairing has been acknowledged and enabled by the user.
|
115
139
|
attr_accessor :enabled
|
140
|
+
|
141
|
+
# @!attribute user_id
|
142
|
+
# @return [String] A unique identifier generated and returned by the Toopher web service for a given user.
|
116
143
|
attr_accessor :user_id
|
144
|
+
|
145
|
+
# @!attribute user_name
|
146
|
+
# @return [String] The human recognizable user name associated with the given id.
|
117
147
|
attr_accessor :user_name
|
118
148
|
|
119
149
|
def initialize(json_obj)
|
@@ -124,13 +154,35 @@ class PairingStatus
|
|
124
154
|
end
|
125
155
|
end
|
126
156
|
|
157
|
+
# Contains information about a particular authentication request
|
127
158
|
class AuthenticationStatus
|
159
|
+
|
160
|
+
# @!attribute id
|
161
|
+
# @return [String] A unique string identifier generated and returned by the Toopher web service that is used to identify this authentication request. It can be used to request status information for the authentication request.
|
128
162
|
attr_accessor :id
|
163
|
+
|
164
|
+
# @!attribute pending
|
165
|
+
# @return [Boolean] Indicates whether the request is still pending.
|
129
166
|
attr_accessor :pending
|
167
|
+
|
168
|
+
# @!attribute granted
|
169
|
+
# @return [Boolean] Indicates whether the request was granted.
|
130
170
|
attr_accessor :granted
|
171
|
+
|
172
|
+
# @!attribute automated
|
173
|
+
# @return [Boolean] Indicates whether the request was automated.
|
131
174
|
attr_accessor :automated
|
175
|
+
|
176
|
+
# @!attribute reason
|
177
|
+
# @return [String]A string which provides additional information about the reason for the authentication outcome (if available).
|
132
178
|
attr_accessor :reason
|
179
|
+
|
180
|
+
# @!attribute terminal_id
|
181
|
+
# @return [String]A unique string identifier generated and returned by the Toopher web service for a given terminal.
|
133
182
|
attr_accessor :terminal_id
|
183
|
+
|
184
|
+
# @!attribute terminal_name
|
185
|
+
# @return [String] The human recognizable terminal name associated with the given id.
|
134
186
|
attr_accessor :terminal_name
|
135
187
|
|
136
188
|
def initialize(json_obj)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toopher_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.9.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yard
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.8.3
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.8.3
|
62
78
|
description: Synchronous interface to the toopher.com authentication api.
|
63
79
|
email: support@toopher.com
|
64
80
|
executables: []
|
@@ -69,7 +85,7 @@ files:
|
|
69
85
|
- lib/toopher_api.rb
|
70
86
|
- test/test_toopher_api.rb
|
71
87
|
- demo/toopher_demo.rb
|
72
|
-
homepage: http://toopher.org
|
88
|
+
homepage: http://dev.toopher.org
|
73
89
|
licenses: []
|
74
90
|
post_install_message:
|
75
91
|
rdoc_options: []
|
@@ -94,3 +110,4 @@ signing_key:
|
|
94
110
|
specification_version: 3
|
95
111
|
summary: Interface to the toopher.com authentication api
|
96
112
|
test_files: []
|
113
|
+
has_rdoc:
|