Skip to content

Instantly share code, notes, and snippets.

@haysclark
Last active January 17, 2023 23:55
Show Gist options
  • Save haysclark/df7b4526def9bc83eac554d8896d32e6 to your computer and use it in GitHub Desktop.
Save haysclark/df7b4526def9bc83eac554d8896d32e6 to your computer and use it in GitHub Desktop.
Typescript types for Close.io - WIP
declare module "close.io" {
interface DataResult<T> {
has_more: boolean
total_results: number
data: T[]
}
interface PhoneResult extends Record<string, any> {
type: string // "office"
phone_formatted: string // "+1 800-444-5555"
country: string // "US"
phone: string // "+18004445555"
}
interface EmailResult extends Record<string, any> {
type: string // "office"
email: string // "[email protected]"
}
interface IntegrationLinkResult extends Record<string, any> {
name: string // "LinkedIn Search"
url: string // "https://www.linkedin.com/search/results/people/?keywords=Gob"
}
interface AddressResult extends Record<string, any> {
city: string // "San Francisco"
label: string // "business"
country: string // "US"
address_1: string // "747 Howard St"
zipcode: string // "94103"
address_2: string // "Room 3"
state: string // "CA"
}
interface ContactResult extends Record<string, any> {
updated_by: string
title: string
date_updated: string // "2023-01-17T20:50:33.738000+00:00"
phones: PhoneResult[]
lead_id: string
emails: EmailResult[]
integration_links: IntegrationLinkResult[]
created_by: string
id: string
urls: string[]
organization_id: string
display_name: string
name: string
date_created: string // "2023-01-17T20:50:33.738000+00:00"
}
interface LeadResult extends Record<string, any> {
created_by_name: string
status_label: string
integration_links: IntegrationLinkResult[]
tasks: []
date_created: string // '2023-01-17T20:50:33.733000+00:00',
display_name: string
addresses: AddressResult[]
custom: any
id: string
organization_id: string
description: string
name: string
url: string
updated_by_name: string
created_by: string
html_url: string
opportunities: string[]
date_updated: string // '2023-01-17T21:02:00.784000+00:00',
status_id: string
contacts: ContactResult[]
updated_by: string
}
interface StatusResult {
status: 'ok' | string
}
// eslint-disable-next-line import/no-default-export
export default class Closeio {
constructor(apiKey: string)
lead: {
search(
options:
| {
limit?: number
skip?: number
fields?: string
query?: string | Record<string, any>
}
| any,
): Promise<DataResult<LeadResult>>
create(options: any): Promise<LeadResult>
merge(options: { source: string, destination: string}): Promise<StatusResult>
read(id: string): Promise<LeadResult>
update(id: string, options: any): Promise<LeadResult>
delete(id: string): Promise<any>
}
contact: {
search(options: any): Promise<any>
create(options: any): Promise<any>
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
activity: {
search(options: any): Promise<any>
note: {
search(options: any): Promise<any>
create(options: any): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
email: {
search(options: any): Promise<any>
create(options: any): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
call: {
search(options: any): Promise<any>
delete(id: string): Promise<any>
}
}
opportunity: {
search(options: any): Promise<any>
create(options: any): Promise<any>
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
task: {
search(options: any): Promise<any>
create(options: any): Promise<any>
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
user: {
me(): Promise<any>
read(id: string): Promise<any>
}
organization: {
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
}
report: {
read(id: string): Promise<any>
}
email_template: {
search(options: any): Promise<any>
create(options: any): Promise<any>
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
saved_search: {
search(options: any): Promise<any>
create(options: any): Promise<any>
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
sequence: {
search(options: any): Promise<any>
create(options: any): Promise<any>
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
sequence_subscription: {
create(options: any): Promise<any>
update(id: string, options: any): Promise<any>
}
status: {
lead: {
list(options: any): Promise<any>
create(options: any): Promise<any>
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
opportunity: {
list(options: any): Promise<any>
create(options: any): Promise<any>
read(id: string): Promise<any>
update(id: string, options: any): Promise<any>
delete(id: string): Promise<any>
}
}
event: {
search(options: any): Promise<any>
read(id: string): Promise<any>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment