Class: PlatformSdk::Identity::Client
- Inherits:
-
Object
- Object
- PlatformSdk::Identity::Client
show all
- Includes:
- ErrorHandleable
- Defined in:
- lib/platform_sdk/identity/clients.rb
Overview
Client for making calls to the Identity Server API
Instance Method Summary
collapse
#raise_error_with_payload, #with_rescue
Constructor Details
#initialize(identity_base_url, client_id, client_secret, auth_client = nil) ⇒ Client
Returns a new instance of Client.
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/platform_sdk/identity/clients.rb', line 9
def initialize(identity_base_url, client_id, client_secret, auth_client = nil)
@auth = auth_client.nil? ? AuthClient.new(identity_base_url, client_id, client_secret) : auth_client
@conn = Faraday.new(identity_base_url) do |conn|
conn.request :authorization, 'Bearer', -> { @auth.auth_token }
conn.request :retry
conn.request :json
conn.response :raise_error
conn.response :json
conn.adapter :net_http
end
end
|
Instance Method Details
#accept_terms_and_conditions(terms_and_conditions_id, account_id) ⇒ Object
30
31
32
|
# File 'lib/platform_sdk/identity/clients.rb', line 30
def accept_terms_and_conditions(terms_and_conditions_id, account_id)
put_payload("/api/TermsAndConditions/#{terms_and_conditions_id}/Accounts/#{account_id}", {})
end
|
#get_payload(path) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/platform_sdk/identity/clients.rb', line 34
def get_payload(path)
with_rescue do
response = @conn.get(path)
response.body
end
end
|
#post_payload(path, body) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/platform_sdk/identity/clients.rb', line 41
def post_payload(path, body)
with_rescue do
response = @conn.post(path, body)
response.body
end
end
|
#provision_identity(user_params) ⇒ Object
22
23
24
|
# File 'lib/platform_sdk/identity/clients.rb', line 22
def provision_identity(user_params)
post_payload('/api/accounts/WithProfile', user_params)
end
|
#put_payload(path, body) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/platform_sdk/identity/clients.rb', line 48
def put_payload(path, body)
with_rescue do
response = @conn.put(path, body)
response.body
end
end
|
#terms_and_conditions ⇒ Object
26
27
28
|
# File 'lib/platform_sdk/identity/clients.rb', line 26
def terms_and_conditions
get_payload('/api/TermsAndConditions')
end
|