// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as AuthAPI from './auth'; import { APIPromise } from '../../core/api-promise'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; export class Token extends APIResource { /** * Validate a stored bearer token without raising on failure */ validate( params: TokenValidateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get('/auth/token/validate', { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Response for GET /auth/token/validate. */ export interface TokenValidateResponse { valid: boolean; /** * Tenant model. */ selected_tenant?: AuthAPI.Tenant | null; /** * Minimal user info returned by the token-validate endpoint. */ user?: TokenValidateResponse.User | null; } export namespace TokenValidateResponse { /** * Minimal user info returned by the token-validate endpoint. */ export interface User { id: string; display_name?: string | null; email?: string | null; picture?: string | null; } } export interface TokenValidateParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace Token { export { type TokenValidateResponse as TokenValidateResponse, type TokenValidateParams as TokenValidateParams, }; }