Class: PlatformSdk::Identity::Client

Inherits:
Object
  • Object
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

Methods included from ErrorHandleable

#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

#post_payload(path, body) ⇒ Object



26
27
28
29
30
31
# File 'lib/platform_sdk/identity/clients.rb', line 26

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