// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import * as Shared from './shared'; import { APIPromise } from '../core/api-promise'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class Company extends APIResource { /** * Get organization by name */ retrieve( name: string, params: CompanyRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get(path`/company/name/${name}`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Get organization by tenant id header. * * Args: organization_slug_query (str | None): Optional organization slug query * parameter. service (AdminOrganizationService): Admin organization service. * subscription_service (AdminSubscriptionService): Admin subscription service. * current_user (CurrentUser | None): The current user (None for guests). * * Returns: OrganizationResponse | AdminCompanyOrganizationResponse: Organization * response. Returns OrganizationResponse (with admin_username/admin_email) when * `organization_slug` is provided (global admin), and * AdminCompanyOrganizationResponse (excluding those fields) when called via tenant * header (admin page). * * Raises: HTTPException: - 400: If organization_slug is not provided and not found * in context. - 401: If organization_slug is provided but user is not * authenticated. - 403: If user is not a global_admin and attempts to specify * organization_slug. - 404: If organization_slug is provided but organization not * found. */ list(params: CompanyListParams | null | undefined = {}, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...query } = params ?? {}; return this._client.get('/company', { query, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Typeahead search for active members of the current organization (tenant from * X-Tenant-ID). Matches display name, email, or username with partial * case-insensitive match. */ retrieveMembers( params: CompanyRetrieveMembersParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...query } = params ?? {}; return this._client.get('/company/members', { query, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } export type CompanyListResponse = unknown; export type CompanyRetrieveMembersResponse = Array; export namespace CompanyRetrieveMembersResponse { /** * Member row for organization-scoped typeahead (public API). */ export interface CompanyRetrieveMembersResponseItem { /** * User ID */ id: string; /** * Username (often email) */ username: string; /** * Display name */ display_name?: string | null; /** * Email when stored separately from username */ email?: string | null; } } export interface CompanyRetrieveParams { '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 CompanyListParams { /** * Query param: Organization slug. Required for global_admin to access other * organizations. */ organization_slug?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface CompanyRetrieveMembersParams { /** * Query param: Maximum number of results (1–20) */ limit?: number; /** * Query param: Search substring (display name, email, or username). Omit or * whitespace-only for no results. */ q?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: 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 Company { export { type CompanyListResponse as CompanyListResponse, type CompanyRetrieveMembersResponse as CompanyRetrieveMembersResponse, type CompanyRetrieveParams as CompanyRetrieveParams, type CompanyListParams as CompanyListParams, type CompanyRetrieveMembersParams as CompanyRetrieveMembersParams, }; }