Class: SafetyKit::Resources::ClientSessions

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

Overview

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:



37
38
39
# File 'lib/safety_kit/resources/client_sessions.rb', line 37

def initialize(client:)
  @client = client
end

Instance Method Details

#create_session(customer_session_hash: nil, customer_user_id: nil, request_options: {}) ⇒ SafetyKit::Models::ClientSessionCreateSessionResponse

Create a browser-safe SafetyKit webapp SDK session token from server-side code before rendering pages that load the browser SDK. The request must be authenticated with a valid Bearer token.

Parameters:

  • customer_session_hash (String)

    Hashed customer browser session value associated with the browser SDK session.

  • customer_user_id (String)

    Customer user identifier associated with the browser SDK session.

  • request_options (SafetyKit::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
# File 'lib/safety_kit/resources/client_sessions.rb', line 23

def create_session(params = {})
  parsed, options = SafetyKit::ClientSessionCreateSessionParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/sessions",
    body: parsed,
    model: SafetyKit::Models::ClientSessionCreateSessionResponse,
    options: options
  )
end