UNPKG

@planet-a/affinity-node

Version:
145 lines (144 loc) 5.15 kB
import { ListEntries } from './list_entries.js'; import { listsUrl } from './urls.js'; export var EntityType; (function (EntityType) { /** Type specifying a list of people. */ EntityType[EntityType["PERSON"] = 0] = "PERSON"; /** Type specifying a list of organizations. */ EntityType[EntityType["ORGANIZATION"] = 1] = "ORGANIZATION"; /** Type specifying a list of opportunities. */ EntityType[EntityType["OPPORTUNITIES"] = 8] = "OPPORTUNITIES"; })(EntityType || (EntityType = {})); /** * See [here](https://support.affinity.co/hc/en-us/articles/360029432951-List-Level-Permissions) for details on the permissions held by these roles. */ export var RoleId; (function (RoleId) { /** List-level `Admin` role */ RoleId[RoleId["ADMIN"] = 0] = "ADMIN"; /** List-level `Basic` role */ RoleId[RoleId["BASIC"] = 1] = "BASIC"; /** List-level `Standard` role */ RoleId[RoleId["STANDARD"] = 2] = "STANDARD"; })(RoleId || (RoleId = {})); /** * All the Types listed below can be referred through looking at the Affinity web app as well. * * *Notes*: The API currently does not support updating and modifying fields. This must be done through the web product. */ export var FieldValueType; (function (FieldValueType) { /** * This type enables you to add person objects as a value. * Eg: External Source, Owner, Friends */ FieldValueType[FieldValueType["PERSON"] = 0] = "PERSON"; /** * This type enables you to add organization objects as a value. * Eg: Place of work, Co-Investors */ FieldValueType[FieldValueType["ORGANIZATION"] = 1] = "ORGANIZATION"; /** * This type allows you to add text values into a single cell. * This is best used when you want to store information that is unique to a person or organization. * Eg: Interests, Stage, Industry */ FieldValueType[FieldValueType["DROPDOWN"] = 2] = "DROPDOWN"; /** * This type enables you to add number as a value. * Eg: Deal Size, Check Size, Revenue */ FieldValueType[FieldValueType["NUMBER"] = 3] = "NUMBER"; /** * This type enables you to add date as a value. * Eg: Date of Event, Birthday */ FieldValueType[FieldValueType["DATE"] = 4] = "DATE"; /** * This type enables you to add a smart Google Maps location as a value. * Eg: Address */ FieldValueType[FieldValueType["LOCATION"] = 5] = "LOCATION"; /** * This type enables you to add a long text block as a value. Eg: Summary */ FieldValueType[FieldValueType["TEXT"] = 6] = "TEXT"; /** * This type allows you to add values in a particular order as well as assign colors to them. * This is the equivalent of a pick list. * Eg: Status, Priority, Ranking */ FieldValueType[FieldValueType["RANKED_DROPDOWN"] = 7] = "RANKED_DROPDOWN"; })(FieldValueType || (FieldValueType = {})); /** * @module */ export class Lists { /** @hidden */ constructor(axios) { Object.defineProperty(this, "axios", { enumerable: true, configurable: true, writable: true, value: axios }); Object.defineProperty(this, "entries", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.entries = new ListEntries(this.axios); } /** * Returns a collection of all the lists visible to you. * * @returns An array of all the list resources for lists visible to you. Each list resource in the array includes the id, name, and type. * * @example * ```typescript * const lists = await affinity.lists.all() * console.log(`The first of ${lists.length} list is named`, lists?.[0].name) * ``` */ async all() { const response = await this.axios.get(listsUrl()); return response.data; } /** * Creates a new list with the specified properties. * * @returns The newly created list resource. * * @example * ```typescript * const list = await affinity.lists.create({ * name: 'My List of Organizations', * type: ListType.ORGANIZATION, * is_public: true, * }) * console.log('The ID of the newly created list is', list.id) * ``` */ async create(query) { const response = await this.axios.post(listsUrl(), query); return response.data; } /** * Gets the details for a specific list given the existing list id. * * @returns The details of the list resource corresponding to the list ID specified in the path parameter. * These details include an array of the fields that are specific to this list. * An appropriate error is returned if an invalid list is supplied. * * @example * ```typescript * const list = await affinity.lists.get({ list_id: 123 }) * console.log('The name of the list is', list.name) * ``` */ async get(query) { const response = await this.axios.get(listsUrl(query.list_id)); return response.data; } }