Class: Cadenya::Resources::WidgetSessions
- Inherits:
-
Object
- Object
- Cadenya::Resources::WidgetSessions
- Defined in:
- lib/cadenya/resources/widget_sessions.rb,
sig/cadenya/resources/widget_sessions.rbs
Overview
Mint and manage widget sessions. Session creation is server-to-server only: the customer's backend authenticates its visitor, asserts tenant/subject context, attaches any per-visitor secrets, and receives a short-lived bearer token the browser uses against the widget host.
Instance Method Summary collapse
-
#create(spec:, workspace_id: nil, metadata: nil, secrets: nil, request_options: {}) ⇒ Cadenya::Models::WidgetSession
Some parameter documentations has been truncated, see Models::WidgetSessionCreateParams for more details.
-
#delete(id, workspace_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::WidgetSessionDeleteParams for more details.
-
#delete_tenant(workspace_id: nil, tenant_id: nil, request_options: {}) ⇒ Cadenya::Models::WidgetSessionDeleteTenantResponse
Some parameter documentations has been truncated, see Models::WidgetSessionDeleteTenantParams for more details.
-
#initialize(client:) ⇒ WidgetSessions
constructor
private
A new instance of WidgetSessions.
-
#list(workspace_id: nil, cursor: nil, include_info: nil, labels: nil, limit: nil, sort_order: nil, state: nil, subject_id: nil, tenant_id: nil, widget_id: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::WidgetSession>
Some parameter documentations has been truncated, see Models::WidgetSessionListParams for more details.
-
#retrieve(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::WidgetSession
Some parameter documentations has been truncated, see Models::WidgetSessionRetrieveParams for more details.
-
#revoke(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::WidgetSession
Some parameter documentations has been truncated, see Models::WidgetSessionRevokeParams for more details.
Constructor Details
#initialize(client:) ⇒ WidgetSessions
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 WidgetSessions.
235 236 237 |
# File 'lib/cadenya/resources/widget_sessions.rb', line 235 def initialize(client:) @client = client end |
Instance Method Details
#create(spec:, workspace_id: nil, metadata: nil, secrets: nil, request_options: {}) ⇒ Cadenya::Models::WidgetSession
Some parameter documentations has been truncated, see Models::WidgetSessionCreateParams for more details.
Mints a session against a widget and returns the session bearer token
(spec.token, returned only on creation) plus the authoritative widget hostname
(info.host). Asserting a tenant upserts the tenant record; attached secrets
flow to every conversation the session creates.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cadenya/resources/widget_sessions.rb', line 33 def create(params) parsed, = Cadenya::WidgetSessionCreateParams.dump_request(params) workspace_id = parsed.delete(:workspace_id) do @client.workspace_id end @client.request( method: :post, path: ["v1/workspaces/%1$s/widget_sessions", workspace_id], body: parsed, model: Cadenya::WidgetSession, options: ) end |
#delete(id, workspace_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::WidgetSessionDeleteParams for more details.
Deletes a session and its secrets. The session's conversations are disassociated, not deleted; use the tenant-level delete for full erasure.
151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/cadenya/resources/widget_sessions.rb', line 151 def delete(id, params = {}) parsed, = Cadenya::WidgetSessionDeleteParams.dump_request(params) workspace_id = parsed.delete(:workspace_id) do @client.workspace_id end @client.request( method: :delete, path: ["v1/workspaces/%1$s/widget_sessions/%2$s", workspace_id, id], model: NilClass, options: ) end |
#delete_tenant(workspace_id: nil, tenant_id: nil, request_options: {}) ⇒ Cadenya::Models::WidgetSessionDeleteTenantResponse
Some parameter documentations has been truncated, see Models::WidgetSessionDeleteTenantParams for more details.
Deletes every session belonging to a tenant across all widgets in the workspace, along with the conversations those sessions created — built for GDPR erasure requests. The tenant is required; an empty value is rejected rather than matching everything.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/cadenya/resources/widget_sessions.rb', line 184 def delete_tenant(params = {}) parsed, = Cadenya::WidgetSessionDeleteTenantParams.dump_request(params) query = Cadenya::Internal::Util.encode_query_params(parsed) workspace_id = parsed.delete(:workspace_id) do @client.workspace_id end @client.request( method: :delete, path: ["v1/workspaces/%1$s/widget_sessions", workspace_id], query: query.transform_keys(tenant_id: "tenantId"), model: Cadenya::Models::WidgetSessionDeleteTenantResponse, options: ) end |
#list(workspace_id: nil, cursor: nil, include_info: nil, labels: nil, limit: nil, sort_order: nil, state: nil, subject_id: nil, tenant_id: nil, widget_id: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::WidgetSession>
Some parameter documentations has been truncated, see Models::WidgetSessionListParams for more details.
Lists widget sessions in a workspace, filterable by widget, tenant, subject, and state
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/cadenya/resources/widget_sessions.rb', line 111 def list(params = {}) parsed, = Cadenya::WidgetSessionListParams.dump_request(params) query = Cadenya::Internal::Util.encode_query_params(parsed) workspace_id = parsed.delete(:workspace_id) do @client.workspace_id end @client.request( method: :get, path: ["v1/workspaces/%1$s/widget_sessions", workspace_id], query: query.transform_keys( include_info: "includeInfo", sort_order: "sortOrder", subject_id: "subjectId", tenant_id: "tenantId", widget_id: "widgetId" ), page: Cadenya::Internal::CursorPagination, model: Cadenya::WidgetSession, options: ) end |
#retrieve(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::WidgetSession
Some parameter documentations has been truncated, see Models::WidgetSessionRetrieveParams for more details.
Retrieves a widget session. The bearer token is never returned on reads.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cadenya/resources/widget_sessions.rb', line 64 def retrieve(id, params = {}) parsed, = Cadenya::WidgetSessionRetrieveParams.dump_request(params) workspace_id = parsed.delete(:workspace_id) do @client.workspace_id end @client.request( method: :get, path: ["v1/workspaces/%1$s/widget_sessions/%2$s", workspace_id, id], model: Cadenya::WidgetSession, options: ) end |
#revoke(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::WidgetSession
Some parameter documentations has been truncated, see Models::WidgetSessionRevokeParams for more details.
Transitions a session to STATE_REVOKED. Outstanding tokens stop working immediately, open event streams close within seconds, and the session's secrets are deleted. Terminal.
218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/cadenya/resources/widget_sessions.rb', line 218 def revoke(id, params = {}) parsed, = Cadenya::WidgetSessionRevokeParams.dump_request(params) workspace_id = parsed.delete(:workspace_id) do @client.workspace_id end @client.request( method: :post, path: ["v1/workspaces/%1$s/widget_sessions/%2$s:revoke", workspace_id, id], model: Cadenya::WidgetSession, options: ) end |