// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import { APIPromise } from '../../core/api-promise'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; export class Organization extends APIResource { /** * Return the organization the current user most recently landed in. Answers a * cross-organization question, so no X-Tenant-ID is required and any value sent is * ignored. Returns null when there is no usable history. */ retrieveLastVisited( params: OrganizationRetrieveLastVisitedParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get('/users/organization/last-visited', { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Record that the current user landed in the organization resolved from * X-Tenant-ID. Call this once after landing on an organization page; repeat calls * for the same organization are cheap no-ops. */ visit(params: OrganizationVisitParams | null | undefined = {}, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.post('/users/organization/visit', { ...options, headers: buildHeaders([ { Accept: '*/*', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Response for the last visited organization lookup. * * `organization` is None when the user has no usable history. That is a normal * outcome, not an error: the column is added without backfill, so every user * reports None until their first recorded visit. * * Attributes: organization (LastVisitedOrganization | None): The most recent * organization, or None. */ export interface OrganizationRetrieveLastVisitedResponse { /** * An organization the user most recently landed in. * * Deliberately narrower than TenantModel: only what the UI needs to navigate. The * contract documents exactly these three fields, so adding TenantModel's optional * icon columns here would widen the response beyond it. * * Attributes: id (str): Organization UUID. name (str): Display name. slug (str): * URL slug the UI navigates with (`/o/{slug}`). */ organization?: OrganizationRetrieveLastVisitedResponse.Organization | null; } export namespace OrganizationRetrieveLastVisitedResponse { /** * An organization the user most recently landed in. * * Deliberately narrower than TenantModel: only what the UI needs to navigate. The * contract documents exactly these three fields, so adding TenantModel's optional * icon columns here would widen the response beyond it. * * Attributes: id (str): Organization UUID. name (str): Display name. slug (str): * URL slug the UI navigates with (`/o/{slug}`). */ export interface Organization { id: string; name: string; slug: string; } } export interface OrganizationRetrieveLastVisitedParams { '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 interface OrganizationVisitParams { '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 Organization { export { type OrganizationRetrieveLastVisitedResponse as OrganizationRetrieveLastVisitedResponse, type OrganizationRetrieveLastVisitedParams as OrganizationRetrieveLastVisitedParams, type OrganizationVisitParams as OrganizationVisitParams, }; }