Class: SafetyKit::Resources::ClientSessions

Inherits:
Object
  • Object
show all
Defined in:
lib/safety_kit/resources/client_sessions.rb

Overview

Beta. Create browser-safe Webapp SDK session tokens from authenticated server-side code.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ClientSessions

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ClientSessions.

Parameters:



42
43
44
# File 'lib/safety_kit/resources/client_sessions.rb', line 42

def initialize(client:)
  @client = client
end

Instance Method Details

#create_session(body:, request_options: {}) ⇒ SafetyKit::Models::ClientSessionCreateSessionResponse

Some parameter documentations has been truncated, see Models::ClientSessionCreateSessionParams for more details.

Create a browser-safe SafetyKit webapp SDK session token from server-side code before rendering pages that load the browser SDK. Provide at least one of customer_user_id or customer_session_hash. When customer_user_id is present, use the same canonical user ID string that you send as user_id in SafetyKit server-to-server events. The request must be authenticated with a valid Bearer token.

Parameters:

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/safety_kit/resources/client_sessions.rb', line 27

def create_session(params)
  parsed, options = SafetyKit::ClientSessionCreateSessionParams.dump_request(params)
  path = @client.base_url_overridden? ? "v1/sessions" : "https://diagnostics.safetykit.com/v1/sessions"
  @client.request(
    method: :post,
    path: path,
    body: parsed[:body],
    model: SafetyKit::Models::ClientSessionCreateSessionResponse,
    options: options
  )
end