UNPKG

keap-client

Version:

A client to work with Infusionsoft/Keap API.

995 lines (983 loc) 40.1 kB
declare class Api { private apiKey; private timeout; private retries; baseUrl: string; constructor(apiKey: string); /** * Set the request timeout * @param ms - The number of milliseconds before the request times out */ setRequestTimeout(ms: number): void; /** * Set the number of retries for the requests * @param retriesCount - The number of retries to make before giving up */ setRetries(retriesCount: number): void; /** * Make a request to the Infusionsoft API * @param method - The request method * @param url - The URL path of the API endpoint * @param data - Data to be sent with the request * @returns The response data * @throws Error if no API key has been set */ makeApiCall(method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", url: string, data?: object): Promise<object | Array<object> | undefined>; get(url: string): Promise<object | Array<object> | undefined>; post(url: string, data: object): Promise<object | Array<object> | undefined>; put(url: string, data: object): Promise<object | Array<object> | undefined>; delete(url: string, data?: object): Promise<object | Array<object> | undefined>; patch(url: string, data?: object): Promise<object | Array<object> | undefined>; } declare class Paginator<T> { private api; private nextUrl; private previousUrl; private count; private items; constructor(api: Api, items: T[], nextUrl: string | null, previousUrl: string | null, count: number); /** * Fetches the next page of results. * @returns A new Paginator instance with the next page of results. */ next(): Promise<Paginator<T> | null>; /** * Fetches the previous page of results. * @returns A new Paginator instance with the previous page of results. */ previous(): Promise<Paginator<T> | null>; /** * Creates a new Paginator instance from the API response. * @param api - The API instance. * @param response - The API response. * @param itemKey - The key of the items in the response. * @returns A new Paginator instance. * @example * function handleResponse(response: any): Paginator<ItemsType> { * return Paginator.wrap(api, response, 'items'); * } */ static wrap<T>(api: Api, response: any, itemKey: string): Paginator<T>; /** * Gets the key of the items in the response. * @param response - The API response. * @returns The key of the items in the response. */ private getItemKey; /** * Gets the items of the current page. * @returns The items of the current page. */ getItems(): T[]; /** * Gets the total count of items. * @returns The total count of items. */ getCount(): number; } declare class Contacts { private api; /** * Creates a new Contact model. * @param api - The API client to use for making requests. */ constructor(api: Api); /** * Fetches a list of contacts. * @param parameters - Options for fetching contacts, like page size and page number. * email:string //Optional email address to query on * family_name:string //Optional last name or surname to query on * given_name:string //Optional first name or forename to query on * limit:number //Sets a total of items to return * offset:number //Sets a beginning range of items to return * optional_properties:string[] //Comma-delimited list of Contact properties to include in the response. (Some fields such as lead_source_id, custom_fields, and job_title aren't included, by default.) * order:string //Enum: "id" "date_created" "last_updated" "name" "firstName" "email" //Attribute to order items by * order_direction:string //Enum: "ASCENDING" "DESCENDING" //How to order the data i.e. ascending (A-Z) or descending (Z-A) * since:string //Date to start searching from on LastUpdated ex. 2017-01-01T22:17:59.039Z * until:string //Date to search to on LastUpdated ex. 2017-01-01T22:17:59.039Z * @example * const contacts = await contacts.getContacts({ limit: 5, offset: 10 }); * console.log(contacts); * @returns The list of contacts if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ getContacts(parameters?: { email: string; family_name: string; given_name: string; limit: number; offset: number; optional_properties: string[]; order: "id" | "date_created" | "last_updated" | "name" | "firstName" | "email"; order_direction: "ASCENDING" | "DESCENDING"; since: string; until: string; }): Promise<Paginator<IContact> | undefined>; /** * Creates a new contact in Keap. NB: Contact must contain at least one item in email_addresses or phone_numbers and country_code is required if region is specified on the adresses. * @param contactData {IContact} - The data to create a contact with ContactData. * @returns The newly created contact if the API call was successful, undefined otherwise. * @example * const contact = await contacts.createContact(given_name: 'John', * family_name: 'Doe', * email_addresses: [ * { * email: "string@example.com", * field: "EMAIL1" * } * ],); * console.log(contact); * @throws Will throw an error if the API call fails. */ createContact(contactData: IContact): Promise<Contact | undefined>; /** * Updates an existing contact. * @param contactId - The ID of the contact to update. * @param contactData {IContact} - The data to update the contact with. * @returns The updated contact if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. * @example * const contact = await contacts * .updateContact(123, { * given_name: "Jane", * family_name: "Doe" * }); */ updateContact(contactId: number, contactData: IContact): Promise<Contact | undefined>; /** * Deletes a contact by ID. * @param contactId - The ID of the contact to delete. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. * @example * const result = await contacts.deleteContact(123); * console.log(result); // true * if (result) { * console.log("Contact deleted successfully"); * }else{ * console.log("Failed to delete contact"); * } */ deleteContact(contactId: number): Promise<boolean | undefined>; /** * Fetches a single contact by ID. * @param contactId - The ID of the contact to fetch. * @returns The contact if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. * @example * const contact = await contacts.getContact(123); * console.log(contact.given_name); // "Jane" * console.log(contact.family_name); // "Doe" */ getContact(contactId: number): Promise<Contact | undefined>; /** * Fetches the contact model. * @returns The contact model if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. * @example * const contactModel = await contacts.getContactModel(); * console.log(contactModel); */ getContactModel(): Promise<ContactModel | undefined>; /** * Creates a new custom contact field. * @param customFieldData{CustomField} - The data to create a custom field with. * @returns The newly created custom field if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ createCustomField(customFieldData: CustomField): Promise<CustomField | undefined>; /** * Creates a new contact if the contact does not exist, or updates the contact if it does. * @param contactData {IContact} - The data to create or update a contact with. * @returns The newly created or updated contact if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. * @example * const contact = await contacts.createOrUpdate({ * given_name: "Jane", * family_name: "Doe" * }) * * console.log(contact); // {given_name: "Jane", family_name: "Doe", id: 123} * * * const contact = await contacts.createOrUpdate({ * given_name: "John", * family_name: "Doe" * id: 123 * }) * * console.log(contact); // {given_name: "John", family_name: "Doe", id: 123} */ createOrUpdate(contactData: IContact): Promise<Contact | undefined>; /** * Fetches the credit cards associated with a contact. * @param contactId - The ID of the contact to fetch credit cards for. * @returns The credit cards associated with the contact if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ getCreditCards(contactId: number): Promise<object | undefined>; /** * Creates a new credit card for a contact. * @param contactId - The ID of the contact to add the credit card to. * @param creditCardData - The data to create the credit card with. * @returns {Promise<CreditCard>} - The newly created credit card if the API call was successful, undefined otherwise. */ createCreditCard(contactId: number, creditCardData: object): Promise<CreditCard | undefined>; /** * Fetches the email addresses associated with a contact. * @param contactId - The ID of the contact to fetch email addresses for. * @returns The email addresses associated with the contact if the API call was successful, undefined otherwise. */ listEmails(contactId: number, options?: { email?: string; limit?: number; offset?: number; }): Promise<Paginator<EmailRecord> | undefined>; /** * Creates a new email address for a contact. * @param contactId - The ID of the contact to add the email address to. * @param emailData {EmailRecord} - The data to create the email address with. * @returns The newly created email address if the API call was successful, undefined otherwise. */ createEmail(contactId: number, emailData: EmailRecord): Promise<EmailRecord | undefined>; /** * Fetches the tags applied to a contact. * @param contactId - The ID of the contact to fetch tags for. * @param options - The options to use when fetching tags. * @returns The tags applied to the contact if the API call was successful, undefined otherwise. */ listAppliedTags(contactId: number, options?: { limit?: number; offset?: number; }): Promise<Paginator<Tag> | undefined>; /** * Applies a tag to a contact. * @param contactId {number} - The ID of the contact to apply the tag to. * @param tagIds {number[]} - The ID of the tag to apply. * @returns The result of the API call if it was successful, undefined otherwise. */ applyTags(contactId: number, tagIds: number[]): Promise<object | undefined>; /** * Removes a tag from a contact. * @param contactId - The ID of the contact to remove the tag from. * @param tagId - The ID of the tag to remove. * @returns The result of the API call if it was successful, undefined otherwise. */ removeTag(contactId: number, tagId: number): Promise<object | undefined>; /** * Removes multiple tags from a contact. * @param contactId - The ID of the contact to remove the tags from. * @param tagIds - The IDs of the tags to remove. * @param data - Data to be sent with the request. * @returns The result of the API call if it was successful, undefined otherwise. */ removeTags(contactId: number, tagIds: number[], data: object): Promise<object | undefined>; /** * Adds UTM tracking data to a contact. * @param contactId - The ID of the contact to add the UTM data to. * @param utmData - The UTM data to add. * @returns The result of the API call if it was successful, undefined otherwise. */ addUTM(contactId: number, utmData: UTM): Promise<UTM | undefined>; } declare class Contact { ScoreValue: string | null; addresses: Array<{ country_code: string; field: string; line1: string; line2: string; locality: string; postal_code: string; region: string; zip_code: string; zip_four: string; }> | null; anniversary: Date | null; birthday: Date | null; company: { company_name: string; id: number; } | null; company_name: string | null; contact_type: string | null; custom_fields: Array<{ content: object; id: number; }> | null; date_created: Date | null; email_addresses: Array<{ email: string; field: string; }> | null; email_opted_in: boolean | null; email_status: string | null; family_name: string | null; fax_numbers: Array<{ field: string; number: string; type: string; }> | null; given_name: string | null; id: number; job_title: string | null; last_updated: Date | null; lead_source_id: number | null; middle_name: string | null; opt_in_reason: string | null; origin: { date: Date; ip_address: string; } | null; owner_id: number | null; phone_numbers: Array<{ extension: string; field: string; number: string; type: string; }> | null; preferred_locale: string | null; preferred_name: string | null; prefix: string | null; relationships: Array<{ id: number; linked_contact_id: number; relationship_type_id: number; }> | null; social_accounts: Array<{ name: string; type: string; }> | null; source_type: string | null; spouse_name: string | null; suffix: string | null; tag_ids: Array<number> | null; time_zone: string | null; website: string | null; private contacts; /** * Creates a new Contact instance from the given data and API client. * @param api - The API client to use for making requests. * @param data - The data to use to populate the Contact instance. */ constructor(contacts: Contacts, data: IContact); /** * Updates the contact with the given data. * @param data - The data to update the contact with. * @returns The updated contact if the API call was successful, undefined otherwise. */ update(data: IContact): Promise<Contact | undefined>; /** * Deletes the contact. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ delete(): Promise<boolean | undefined>; /** * Refreshes the contact data from the API. * @returns The updated contact if the API call was successful, undefined otherwise. */ refresh(): Promise<Contact | undefined>; /** * Fetches the credit cards associated with this contact. * @returns The credit cards associated with this contact if the API call was successful, undefined otherwise. */ getCreditCards(): Promise<object | undefined>; /** * Creates a new credit card for this contact. * @param data - The data to create the credit card with. * @returns The newly created credit card if the API call was successful, undefined otherwise. */ addCreditCard(data: object): Promise<CreditCard | undefined>; /** * Fetches the email addresses associated with this contact. * @param options - The options to use when fetching email addresses. * @returns The email addresses associated with this contact if the API call was successful, undefined otherwise. */ getEmails(options?: { email?: string; limit?: number; offset?: number; }): Promise<Paginator<EmailRecord> | undefined>; /** * Adds a new email address to this contact. * @param data - The data to create the email address with. * @returns The newly created email address if the API call was successful, undefined otherwise. */ addEmail(data: EmailRecord): Promise<EmailRecord | undefined>; /** * Fetches the tags applied to this contact. * @param options - The options to use when fetching tags. * @returns The tags applied to this contact if the API call was successful, undefined otherwise. */ getAppliedTags(options?: { limit?: number; offset?: number; }): Promise<Paginator<Tag> | undefined>; /** * Applies the given tags to this contact. * @param tagIds - The IDs of the tags to apply. * @returns The result of the API call if it was successful, undefined otherwise. */ applyTags(tagIds: number[]): Promise<object | undefined>; /** * Removes the given tag from this contact. * @param tagId - The ID of the tag to remove. * @returns The result of the API call if it was successful, undefined otherwise. */ removeTag(tagId: number): Promise<object | undefined>; /** * Removes multiple tags from this contact. * @param tagIds - The IDs of the tags to remove. * @param data - Data to be sent with the request. * @returns The result of the API call if it was successful, undefined otherwise. */ removeTags(tagIds: number[], data: object): Promise<object | undefined>; /** * Adds UTM tracking data to this contact. * @param utmData - The UTM data to add. * @returns The result of the API call if it was successful, undefined otherwise. */ addUTM(utmData: UTM): Promise<UTM | undefined>; } declare class AccountInfo { private static instance; private api; /** * Creates a new AccountInfo model. * @param api - The API client to use for making requests. */ constructor(api: Api); /** * Fetches the current account information. * @returns The account information if the API call was successful, undefined otherwise. */ getAccountInfo(): Promise<IAccountInfo | undefined>; /** * Updates the current account information. * @returns The account information if the API call was successful, undefined otherwise. */ updateAccountInfo(data: IAccountInfo): Promise<IAccountInfo | undefined>; } declare class Opportunities { private api; /** * Creates a model. * @param api - The API client to use for making requests. */ constructor(api: Api); /** * Fetches a list of opportunities. * @param parameters - Options for fetching opportunities, like page size and page number. * @example * const opportunities = await opportunities.getopportunities({ limit: 5, offset: 10 }); * // parameters * //limit:number //Sets a total of items to return * //offset:number //Sets a beginning range of items to return * //order:"next_action" | "opportunity_name" | "contact_name" | "date_created", //Attribute to order items by * //search_term:string //Returns opportunities that match any of the contact's given_name, family_name, company_name, and email_addresses (searches EMAIL1 only) fields as well as opportunity_title * //stage_id:number <int64> //Returns opportunities for the provided stage id * //user_id:number <int64> //Returns opportunities for the provided user id * console.log(opportunities); * @returns The list of opportunities if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ getOpportunities(parameters?: { limit: number; offset: number; order: "next_action" | "opportunity_name" | "contact_name" | "date_created"; search_term: string; stage_id: number; user_id: number; }): Promise<Paginator<IOpportunity> | undefined>; /** * Creates a new opportunity. * @param data - The data to create the opportunity with. * @returns The newly created opportunity if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. * @example * const opportunity = await opportunities.createOpportunity({ * contact_id: 1, * opportunity_title: "New Opportunity", * stage_id: 1 * }); * console.log(opportunity); */ createOpportunity(data: IOpportunity): Promise<Opportunity | undefined>; /** * Replaces an existing opportunity. * @param data - The data to replace the opportunity with. * @returns The replaced opportunity if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ replaceOpportunity(data: IOpportunity): Promise<Opportunity | undefined>; /** * Retrieves an opportunity by ID. * @param id - The ID of the opportunity to fetch. * @returns The opportunity if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ getOpportunity(id: number): Promise<Opportunity | undefined>; /** * Deletes an opportunity by ID. * @param id - The ID of the opportunity to delete. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ deleteOpportunity(id: number): Promise<boolean | undefined>; /** * Updates an existing opportunity. * @param data - The data to update the opportunity with. * @returns The updated opportunity if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ updateOpportunity(data: IOpportunity): Promise<Opportunity | undefined>; } declare class Opportunity { affiliate_id?: number; contact: ReferenceContact; custom_fields?: Array<{ content: object; id: number; }>; date_created?: string; estimated_close_date?: string; id?: number; include_in_forecast?: number; last_updated?: string; next_action_date?: string; next_action_notes?: string; opportunity_notes?: string; opportunity_title: string; projected_revenue_high?: number; projected_revenue_low?: number; stage: OpportunityStage; user?: { first_name: string; id: number; last_name: string; }; private opportunities; /** * Creates a new Opportunity instance from the given data and Opportunities model. * @param opps - The Opportunities model to use for making requests. * @param data - The data to use to populate the Opportunity instance. * @throws Will throw an error if any of the required fields are missing. */ constructor(opps: Opportunities, data: IOpportunity); /** * Deletes this opportunity. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails or if this opportunity does not have an ID. */ delete(): Promise<boolean | undefined>; /** * Updates this opportunity. * @param data - The data to update this opportunity with. * @returns The updated opportunity if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails or if this opportunity does not have an ID. */ update(data: IOpportunity): Promise<Opportunity | undefined>; /** * Refreshes the opportunity data from the API. * @returns The updated opportunity if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails or if this opportunity does not have an ID. */ refresh(): Promise<Opportunity | undefined>; /** * Replaces this opportunity. * @param data - The data to replace this opportunity with. * @returns The replaced opportunity if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails or if this opportunity does not have an ID. */ replace(data: IOpportunity): Promise<Opportunity | undefined>; } declare class Products { private api; /** * Creates a model. * @param api - The API client to use for making requests. */ constructor(api: Api); /** * Fetches a list of products. * @param options - Options for fetching products, like page size and page number. * @returns The list of products if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ getProducts(options?: { active?: boolean; limit?: number; offset?: number; }): Promise<Paginator<Products> | undefined>; /** * Creates a new product. * @param data - The data to create a product with. * @returns The newly created product if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ createProduct(data: IProduct): Promise<Product | undefined>; /** * Fetches a single product by ID. * @param productId - The ID of the product to fetch. * @returns The product if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ getProduct(productId: number): Promise<Product | undefined>; /** * Updates a product. * @param data - The data to update the product with. * @returns The updated product if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ updateProduct(data: IProduct): Promise<Product | undefined>; /** * Deletes a product. * @param productId - The ID of the product to delete. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ deleteProduct(productId: number): Promise<boolean | undefined>; /** * Uploads a product image. * @param productId - The ID of the product to upload the image to. * @param fileData - The base64 encoded image data. * @param fileName - The name of the image. * @param checksum - The checksum of the image. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ uploadProductImage(productId: number, fileData: Base64Image, fileName: ImageName, checksum?: string): Promise<boolean | undefined>; /** * Deletes the product image associated with the given product id. * @param productId - The ID of the product to delete the image from. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ deleteProductImage(productId: number): Promise<boolean | undefined>; /** * Creates a new subscription plan associated with the given product id. * @param productId - The ID of the product to create the subscription plan for. * @param data - The data to create the subscription plan with. * @returns The newly created subscription plan if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ createASubscriptionPlan(productId: number, data: IProductSubscription): Promise<IProductSubscription | undefined>; /** * Fetches a single subscription plan associated with the given product id. * @param productId - The ID of the product to fetch the subscription plan from. * @param subscriptionId - The ID of the subscription plan to fetch. * @returns The subscription plan if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ getASubscriptionPlan(productId: number, subscriptionId: number): Promise<IProductSubscription | undefined>; /** * Deletes a subscription plan associated with the given product id. * @param productId - The ID of the product to delete the subscription plan from. * @param subscriptionId - The ID of the subscription plan to delete. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ deleteASubscriptionPlan(productId: number, subscriptionId: number): Promise<boolean | undefined>; } declare class Product { private products; active?: boolean; id: number; product_desc?: string; product_name: string; product_price?: number; product_short_desc?: string; sku?: string; subscription_only?: boolean; subscription_plans?: Array<IProductSubscription>; url?: string; /** * Creates a new Product instance from the given data and Products model. * @param products - The Products model to use for making requests. * @param data - The data to use to populate the Product instance. * @throws Will throw an error if any of the required fields are missing. */ constructor(products: Products, data: IProduct); /** * Updates this product with the given data. * @param data - The data to update this product with. * @returns The updated product if the API call was successful, undefined otherwise. */ update(data: IProduct): Promise<Product | undefined>; /** * Deletes this product. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ delete(): Promise<boolean | undefined>; /** * Refreshes this product from the API. * @returns The updated product if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ refresh(): Promise<Product | undefined>; /** * Creates a new subscription plan for this product. * @param data - The data to create the subscription plan with. * @returns The newly created subscription plan if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ createSubscriptionPlan(data: IProductSubscription): Promise<IProductSubscription | undefined>; /** * Retrieves a subscription plan associated with this product. * @param subscriptionId - The ID of the subscription plan to retrieve. * @returns The subscription plan if the API call was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ getSubscriptionPlan(subscriptionId: number): Promise<IProductSubscription | undefined>; /** * Deletes a subscription plan associated with this product. * @param subscriptionId - The ID of the subscription plan to delete. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ deleteSubscriptionPlan(subscriptionId: number): Promise<boolean | undefined>; /** * Uploads a product image associated with this product. * @param fileData - The base64 encoded image data. * @param fileName - The name of the image. * @param checksum - The checksum of the image. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ uploadImage(fileData: Base64Image, fileName: ImageName, checksum: string): Promise<boolean | undefined>; /** * Deletes the product image associated with this product. * @returns The result of the API call if it was successful, undefined otherwise. * @throws Will throw an error if the API call fails. */ deleteImage(): Promise<boolean | undefined>; } declare class Ecommerce { private api; /** * Creates a new ecommerce model. * @param api - The API client to use for making requests. */ constructor(api: Api); get Orders(): Order; get Subscriptions(): Subscription; get Transactions(): Transaction; } declare class Order { private api; constructor(api: Api); getOrders(params?: { limit?: number; offset?: number; since?: string; until?: string; paid?: boolean; order?: "order_date" | "update_date"; contact_id?: number; }): Promise<Paginator<IOrder> | undefined>; createOrder(options: { contact_id: number; lead_affiliate_id: number; order_date: string; order_title: string; order_type: string; promo_codes: string[]; sales_affiliate_id: number; shipping_address: ShippingInformation; }, data: IOrder): Promise<IOrder | undefined>; getOrder(id: number): Promise<IOrder | undefined>; deleteOrder(id: number): Promise<boolean | undefined>; createItem(orderId: number, data: { description?: string; price?: number; product_id: number; quantity?: number; }): Promise<IOrderItem | undefined>; deleteItem(orderId: number, itemId: number): Promise<boolean | undefined>; getOrderPayments(orderId: number): Promise<object | undefined>; createOrderPayment(orderId: number, data: createOrderPayment): Promise<object | undefined>; getOrderTransactions(orderId: number, options?: { contact_id?: number; limit?: number; offset?: number; since?: string; until?: string; }): Promise<Paginator<ITransaction> | undefined>; } declare class Subscription { private api; constructor(api: Api); getSubscriptions(): Promise<SubscriptionWithPagination | undefined>; createSubscription(data: createSubscription): Promise<ISubscription | undefined>; } declare class Transaction { private api; constructor(api: Api); getTransactions(options?: { contact_id?: number; limit?: number; offset?: number; since?: string; until?: string; }): Promise<Paginator<ITransaction> | undefined>; getTransaction(id: number): Promise<ITransaction | undefined>; } declare class Files { private api; /** * Creates a new Files model. * @param api - The API client to use for making requests. */ constructor(api: Api); /** * Lists files with optional filtering options. * @param options - The filtering options. * @returns A promise that resolves to a list of files with pagination. */ listFiles(options?: { contact_id?: number; name?: string; permission?: FileAssociation; type?: FileBoxType | FileCategory; viewable?: "PUBLIC" | "PRIVATE" | "BOTH"; limit?: number; offset?: number; }): Promise<Paginator<File> | undefined>; /** * Uploads a new file. * @param file - The file upload request data. * @returns A promise that resolves to the uploaded file response. */ uploadFile(file: FileUploadRequest): Promise<FileResponse | undefined>; /** * Retrieves a file by ID. * @param id - The ID of the file to retrieve. * @returns A promise that resolves to the file response. */ getFile(id: number): Promise<FileResponse | undefined>; /** * Replaces an existing file by ID. * @param id - The ID of the file to replace. * @param file - The file upload request data. * @returns A promise that resolves to the replaced file response. */ replaceFile(id: number, file: FileUploadRequest): Promise<FileResponse | undefined>; /** * Deletes a file by ID. * @param id - The ID of the file to delete. * @returns A promise that resolves to true if the file was deleted, otherwise undefined. */ deleteFile(id: number): Promise<boolean | undefined>; } declare class Emails { private api; /** * Creates a new Email model. * @param api - The API client to use for making requests. */ constructor(api: Api); /** * Lists emails with optional filtering options. * @param options - The filtering options. * @returns A promise that resolves to a list of emails with pagination. */ listEmails(options?: { email?: string; contact_id?: number; ordered?: boolean; since_sent_date?: string; until_sent_date?: string; limit?: number; offset?: number; }): Promise<Paginator<EmailRecord> | undefined>; /** * Creates a new email record. * @param emailData - The email data to create. * @returns A promise that resolves to the created email record. */ createEmail(emailData: EmailRecord): Promise<EmailRecord | undefined>; /** * Sends an email. * @param request - The email send request data. * @returns A promise that resolves to the send email request. */ sendEmail(request: SendEmailRequest): Promise<SendEmailRequest | undefined>; /** * Creates a set of email records. * @param emails - The email records to create. * @returns A promise that resolves to the created email records. */ createASet(emails: EmailRecord[]): Promise<{ emails: EmailRecord[]; } | undefined>; /** * Retrieves an email record by ID. * @param id - The ID of the email record to retrieve. * @returns A promise that resolves to the email record. */ get(id: number): Promise<EmailRecord | undefined>; /** * Deletes an email record by ID. * @param id - The ID of the email record to delete. * @returns A promise that resolves to true if the email was deleted, otherwise undefined. */ delete(id: number): Promise<boolean | undefined>; } declare class Users { private api; /** * Creates a new Users model. * @param api - The API client to use for making requests. */ constructor(api: Api); listUsers(options?: { include_inactive?: boolean; include_partners?: boolean; limit?: number; offset?: number; }): Promise<Paginator<IUser> | undefined>; createUser(data: UserCreateRequest): Promise<IUser | undefined>; } declare class KeapClient { private api; private _accountInfo?; private _contacts?; private _opportunities?; private _products?; private _ecommerce?; private _files?; private _emails?; private _users?; /** * Creates a new instance of KeapClient. * @param parameters - Options to create the client with. * @param parameters.apiKey - The API key to use for authentication. * @param [parameters.requestTimeout] - The number of milliseconds before the request times out. * @param [parameters.retries] - The number of retries to make before giving up. */ constructor(parameters: { apiKey: string; requestTimeout?: number; retries?: number; }); /** * Gets an instance of AccountInfo that can be used to fetch the current account information. * @returns An instance of AccountInfo. */ get AccountInfo(): AccountInfo; /** * Gets an instance of Contact that can be used to create, update, delete, * and fetch contacts. * @returns An instance of Contact. */ get Contacts(): Contacts; get Opportunities(): Opportunities; get Products(): Products; get Ecommerce(): Ecommerce; get Emails(): Emails; get Files(): Files; get Users(): Users; } export { KeapClient };