# NOTE: This file is auto generated by OpenAPI Generator 7.22.0 (https://openapi-generator.tech).
# Do not edit this file manually.
defmodule Spatio.Api.Realtime do
@moduledoc """
API calls for all endpoints tagged `Realtime`.
"""
alias Spatio.Connection
import Spatio.RequestBuilder
@doc """
Exchange a bearer token for a short-lived Yjs collaboration JWT.
The Yjs Cloudflare Worker that powers live document collaboration (`wss://realtime-collaboration.<account>.workers.dev`) only accepts platform-signed JWTs. Third-party clients holding an OAuth access token or PAT call this endpoint to mint a 5-minute collaboration JWT they can present to the worker. The minted JWT inherits user + workspace identity from the presenting bearer token. Optionally scope it to a single room by supplying `room` in the request body.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:body` (IssueCollaborationTokenRequest):
### Returns
- `{:ok, Spatio.Model.IssueCollaborationToken200Response.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec issue_collaboration_token(Tesla.Env.client, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.IssueCollaborationToken200Response.t} | {:error, Tesla.Env.t}
def issue_collaboration_token(connection, opts \\ []) do
optional_params = %{
:body => :body
}
request =
%{}
|> method(:post)
|> url("/v1/realtime/collaboration-token")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.IssueCollaborationToken200Response},
{401, false},
{500, false}
])
end
end