Class: Round::Client
- Inherits:
-
Object
show all
- Includes:
- Helpers
- Defined in:
- lib/round/client.rb
Defined Under Namespace
Classes: Context, OTPAuthFailureError
Constant Summary
collapse
- UnknownKeyError =
Class.new(StandardError)
- OTPConflictError =
Class.new(StandardError)
Instance Method Summary
collapse
Methods included from Helpers
#extract_params
Constructor Details
#initialize(patchboard_client) ⇒ Client
Returns a new instance of Client.
18
19
20
|
# File 'lib/round/client.rb', line 18
def initialize(patchboard_client)
@patchboard_client = patchboard_client
end
|
Instance Method Details
#application ⇒ Object
62
63
64
|
# File 'lib/round/client.rb', line 62
def application
Application.new(resource: resources.app.get, client: self)
end
|
#authenticate_application(api_token:, admin_token:) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/round/client.rb', line 22
def authenticate_application(api_token:, admin_token:)
@patchboard_client
.context
.authorize(Context::Scheme::APPLICATION,
api_token: api_token, admin_token: admin_token)
authenticate_identify(api_token: api_token)
self.application.refresh
end
|
#authenticate_device(email:, api_token:, device_token:) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/round/client.rb', line 42
def authenticate_device(email:, api_token:, device_token:)
@patchboard_client
.context
.authorize(Context::Scheme::DEVICE,
api_token: api_token, device_token: device_token)
@patchboard_client
.context
.authorize(Context::Scheme::IDENTIFY,
api_token: api_token)
self.user(email).refresh
end
|
#authenticate_identify(api_token:) ⇒ Object
36
37
38
39
40
|
# File 'lib/round/client.rb', line 36
def authenticate_identify(api_token:)
@patchboard_client
.context
.authorize(Context::Scheme::IDENTIFY, api_token: api_token)
end
|
#context ⇒ Object
32
33
34
|
# File 'lib/round/client.rb', line 32
def context
@patchboard_client.context
end
|
#resources ⇒ Object
54
55
56
|
# File 'lib/round/client.rb', line 54
def resources
@patchboard_client.resources
end
|
#user(email) ⇒ Object
66
67
68
|
# File 'lib/round/client.rb', line 66
def user(email)
User.new(resource: resources.user_query(email: email), client: self)
end
|
#users ⇒ Object
58
59
60
|
# File 'lib/round/client.rb', line 58
def users
UserCollection.new(resource: resources.users, client: self)
end
|