UNPKG

intercom-client

Version:

Official Node bindings to the Intercom API

266 lines (265 loc) 12.4 kB
/** * This file was auto-generated by Fern from our API Definition. */ import * as environments from "../../../../environments"; import * as core from "../../../../core"; import * as Intercom from "../../../index"; export declare namespace Companies { interface Options { environment?: core.Supplier<environments.IntercomEnvironment | string>; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier<string>; token?: core.Supplier<core.BearerToken | undefined>; /** Override the Intercom-Version header */ version?: "1.0" | "1.1" | "1.2" | "1.3" | "1.4" | "2.0" | "2.1" | "2.2" | "2.3" | "2.4" | "2.5" | "2.6" | "2.7" | "2.8" | "2.9" | "2.10" | "2.11" | "Unstable"; fetcher?: core.FetchFunction; } interface RequestOptions { /** The maximum time to wait for a response in seconds. */ timeoutInSeconds?: number; /** The number of times to retry the request. Defaults to 2. */ maxRetries?: number; /** A hook to abort the request. */ abortSignal?: AbortSignal; /** Additional headers to include in the request. */ headers?: Record<string, string>; /** Override the Intercom-Version header */ version?: "1.0" | "1.1" | "1.2" | "1.3" | "1.4" | "2.0" | "2.1" | "2.2" | "2.3" | "2.4" | "2.5" | "2.6" | "2.7" | "2.8" | "2.9" | "2.10" | "2.11" | "Unstable"; } } /** * Everything about your Companies */ export declare class Companies { protected readonly _options: Companies.Options; constructor(_options?: Companies.Options); /** * You can fetch a single company by passing in `company_id` or `name`. * * `https://api.intercom.io/companies?name={name}` * * `https://api.intercom.io/companies?company_id={company_id}` * * You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. * * `https://api.intercom.io/companies?tag_id={tag_id}` * * `https://api.intercom.io/companies?segment_id={segment_id}` * * @param {Intercom.RetrieveCompanyRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.NotFoundError} * * @example * await client.companies.retrieve({ * name: "my company", * company_id: "12345", * tag_id: "678910", * segment_id: "98765" * }) */ retrieve(request?: Intercom.RetrieveCompanyRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.CompaniesRetrieveResponse>; /** * You can create or update a company. * * Companies will be only visible in Intercom when there is at least one associated user. * * Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. * * {% admonition type="warning" name="Using `company_id`" %} * You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. * {% /admonition %} * * @param {Intercom.CreateOrUpdateCompanyRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.BadRequestError} * @throws {@link Intercom.UnauthorizedError} * * @example * await client.companies.createOrUpdate({ * name: "my company", * company_id: "company_remote_id", * remote_created_at: 1374138000 * }) * * @example * await client.companies.createOrUpdate() */ createOrUpdate(request?: Intercom.CreateOrUpdateCompanyRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.Company>; /** * You can fetch a single company. * * @param {Intercom.FindCompanyRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.NotFoundError} * * @example * await client.companies.find({ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ find(request: Intercom.FindCompanyRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.Company>; /** * You can update a single company using the Intercom provisioned `id`. * * {% admonition type="warning" name="Using `company_id`" %} * When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. * {% /admonition %} * * @param {Intercom.UpdateCompanyRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.NotFoundError} * * @example * await client.companies.update({ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ update(request: Intercom.UpdateCompanyRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.Company>; /** * You can delete a single company. * * @param {Intercom.DeleteCompanyRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.NotFoundError} * * @example * await client.companies.delete({ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ delete(request: Intercom.DeleteCompanyRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.DeletedCompanyObject>; /** * You can fetch a list of all contacts that belong to a company. * * @param {Intercom.ListAttachedContactsRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.NotFoundError} * * @example * await client.companies.listAttachedContacts({ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ listAttachedContacts(request: Intercom.ListAttachedContactsRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.CompanyAttachedContacts>; /** * You can fetch a list of all segments that belong to a company. * * @param {Intercom.ListSegmentsAttachedToCompanyRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.NotFoundError} * * @example * await client.companies.listAttachedSegments({ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ listAttachedSegments(request: Intercom.ListSegmentsAttachedToCompanyRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.CompanyAttachedSegments>; /** * You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. * * Note that the API does not include companies who have no associated users in list responses. * * When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). * {% admonition type="warning" name="Pagination" %} * You can use pagination to limit the number of results returned. The default is `20` results per page. * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * * @param {Intercom.ListCompaniesRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * * @example * await client.companies.list({ * order: "desc" * }) */ list(request?: Intercom.ListCompaniesRequest, requestOptions?: Companies.RequestOptions): Promise<core.Page<Intercom.Company>>; /** * The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. * * - Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. * - If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail * - If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire * * {% admonition type="info" name="Scroll Parameter" %} * You can get the first page of companies by simply sending a GET request to the scroll endpoint. * For subsequent requests you will need to use the scroll parameter from the response. * {% /admonition %} * {% admonition type="danger" name="Scroll network timeouts" %} * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: * "Request failed due to an internal network error. Please restart the scroll operation." * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. * {% /admonition %} * * @param {Intercom.ScrollCompaniesRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * * @example * await client.companies.scroll() */ scroll(request?: Intercom.ScrollCompaniesRequest, requestOptions?: Companies.RequestOptions): Promise<core.Page<Intercom.Company>>; /** * You can attach a company to a single contact. * * @param {Intercom.AttachContactToCompanyRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.BadRequestError} * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.NotFoundError} * * @example * await client.companies.attachContact({ * contact_id: "contact_id", * id: "667d608d8a68186f43bafd70" * }) * * @example * await client.companies.attachContact({ * contact_id: "contact_id", * id: "58a430d35458202d41b1e65b" * }) * * @example * await client.companies.attachContact({ * contact_id: "contact_id", * id: "123" * }) */ attachContact(request: Intercom.AttachContactToCompanyRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.Company>; /** * You can detach a company from a single contact. * * @param {Intercom.DetachContactFromCompanyRequest} request * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Intercom.UnauthorizedError} * @throws {@link Intercom.NotFoundError} * * @example * await client.companies.detachContact({ * contact_id: "58a430d35458202d41b1e65b", * company_id: "58a430d35458202d41b1e65b" * }) */ detachContact(request: Intercom.DetachContactFromCompanyRequest, requestOptions?: Companies.RequestOptions): Promise<Intercom.Company>; protected _getAuthorizationHeader(): Promise<string>; }