Class: SeatLayer::Sessions

Inherits:
Resource show all
Defined in:
lib/seatlayer/inventory.rb

Overview

Short-lived, origin-bound browser tokens.

The governing rule: the SDK mints tokens, widgets consume them. Your secret key never reaches a browser.

Constant Summary collapse

CAPABILITIES =
["event:view", "event:block", "event:cancel", "event:reports"].freeze

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from SeatLayer::Resource

Instance Method Details

#create_designer_session(workspace_id:, chart_id:, allowed_origin:, authority: nil, mode: nil, expires_in_seconds: nil) ⇒ Object

Mint a designer token so an organiser can edit a chart inside your own UI. Requires a chart id that already exists — create or copy one first.



139
140
141
142
143
144
145
# File 'lib/seatlayer/inventory.rb', line 139

def create_designer_session(workspace_id:, chart_id:, allowed_origin:,
                            authority: nil, mode: nil, expires_in_seconds: nil)
  body = compact({ "workspaceId" => workspace_id, "chartId" => chart_id,
                   "allowedOrigin" => allowed_origin, "authority" => authority,
                   "mode" => mode, "expiresInSeconds" => expires_in_seconds })
  @client.post("/v1/designer/sessions", body)
end

#create_manage_session(event_key, allowed_origin:, capabilities:, expires_in_seconds: nil) ⇒ Object

Mint a manage-session token for the control room.

capabilities is required here even though the API defaults it. That default grants all four — including event:cancel, which un-books paid inventory. Granting the ability to reverse sales by forgetting an argument is not a default worth inheriting.



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/seatlayer/inventory.rb', line 120

def create_manage_session(event_key, allowed_origin:, capabilities:, expires_in_seconds: nil)
  if capabilities.nil? || capabilities.empty?
    raise ArgumentError,
          "capabilities is required: pass the smallest set the page needs, e.g. " \
          '["event:view"]. Omitting it server-side grants event:cancel, ' \
          "which can reverse paid bookings."
  end

  body = compact({ "allowedOrigin" => allowed_origin, "capabilities" => capabilities,
                   "expiresInSeconds" => expires_in_seconds })
  @client.post("/v1/events/#{encode(event_key)}/manage-sessions", body)
end

#revoke_designer_session(session_id) ⇒ Object



147
148
149
# File 'lib/seatlayer/inventory.rb', line 147

def revoke_designer_session(session_id)
  @client.delete("/v1/designer/sessions/#{encode(session_id)}")
end

#revoke_manage_session(event_key, session_id) ⇒ Object



133
134
135
# File 'lib/seatlayer/inventory.rb', line 133

def revoke_manage_session(event_key, session_id)
  @client.delete("/v1/events/#{encode(event_key)}/manage-sessions/#{encode(session_id)}")
end