nylas
Version:
A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
148 lines (147 loc) • 3.67 kB
TypeScript
import { ListQueryParams } from './listQueryParams.js';
/**
* Interface representing a Nylas Contact object.
*/
export interface Contact {
id: string;
grantId: string;
object: 'contact';
birthday?: string;
companyName?: string;
displayName: string;
emails: Email[];
imAddresses: InstantMessagingAddress[];
givenName?: string;
jobTitle?: string;
managerName?: string;
middleName?: string;
nickname?: string;
notes?: string;
officeLocation?: string;
pictureUrl?: string;
picture?: string;
suffix?: string;
surname?: string;
source?: SourceType;
phoneNumbers: PhoneNumber[];
physicalAddresses: PhysicalAddress[];
webPages: WebPage[];
groups: ContactGroup[];
}
/**
* Custom Types.
*/
export type SourceType = 'address_book' | 'inbox' | 'domain';
export type GroupType = 'user' | 'system' | 'other';
/**
* Interface for email addresses in a contact.
*/
export interface Email {
email?: string;
type?: string;
}
/**
* Interface for IM addresses in a contact.
*/
export interface InstantMessagingAddress {
type?: string;
imAddress?: string;
}
/**
* Interface for phone numbers in a contact.
*/
export interface PhoneNumber {
number?: string;
type?: string;
}
/**
* Interface for physical addresses in a contact.
*/
export interface PhysicalAddress {
format?: string;
streetAddress?: string;
city?: string;
postalCode?: string;
state?: string;
country?: string;
type?: string;
}
/**
* Interface for web pages in a contact.
*/
export interface WebPage {
url?: string;
type?: string;
}
/**
* Interface representing a contact group.
*/
export interface ContactGroup {
id: string;
object: 'contact_group';
grantId?: string;
groupType?: GroupType;
name?: string;
path?: string;
}
/**
* Interface representing the query parameters for listing contacts.
*/
export interface ListContactQueryParams extends ListQueryParams {
/**
* Returns the contacts matching the exact contact's email.
*/
email?: string;
/**
* Returns the contacts matching the contact's exact phone number
*/
phoneNumber?: string;
/**
* Returns the contacts matching from the address book or auto-generated contacts from emails.
* For example of contacts only from the address book: /contacts?source=address_bookor for only autogenerated contacts:/contacts?source=inbox`
*/
source?: string;
/**
* Returns the contacts belonging to the Contact Group matching this ID
*/
group?: string;
/**
* When set to true, returns the contacts also within the specified Contact Group subgroups, if the group parameter is set.
*/
recurse?: boolean;
}
/**
* Interface representing the query parameters for retrieving a single contact.
*/
export interface FindContactQueryParams {
profilePicture?: boolean;
}
/**
* Interface for creating a contact.
*/
export type CreateContactRequest = {
displayName?: string;
birthday?: string;
companyName?: string;
emails?: Email[];
givenName?: string;
imAddresses?: InstantMessagingAddress[];
jobTitle?: string;
managerName?: string;
middleName?: string;
nickname?: string;
notes?: string;
officeLocation?: string;
phoneNumbers?: PhoneNumber[];
physicalAddresses?: PhysicalAddress[];
suffix?: string;
surname?: string;
webPages?: WebPage[];
picture?: string;
source?: SourceType;
groups?: ContactGroup[];
};
/**
* Interface for updating a contact.
*/
export type UpdateContactRequest = CreateContactRequest;