// Type definitions for intercom-client 2.11 // Project: https://github.com/intercom/intercom-node // Definitions by: Jinesh Shah , Josef Hornych , Mikhail Monchak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 /// import { List as UserList, User, UserIdentifier } from './User'; import { List as LeadList, Lead, LeadIdentifier } from './Lead'; import { Visitor, VisitorIdentifier } from './Visitor'; import { CompanyIdentifier, List as CompanyList, Company } from './Company'; import { TagIdentifier, List as TagList, Tag, TagOper } from './Tag'; import { List as EventList, Event, ListParam as EventListParam } from './Event'; import { Scroll } from './Scroll'; import { IntercomError } from './IntercomError'; import { IncomingMessage } from 'http'; export { IntercomError }; export interface IdentityVerificationOptions { secretKey: string; identifier: string; } export const IdentityVerification: { userHash(opts: IdentityVerificationOptions): string; }; export class Client { constructor(auth: { token: string } | { appId: string; appApiKey: string }); constructor(username: string, password: string); users: Users; companies: Companies; tags: Tags; events: Events; contacts: Leads; leads: Leads; visitors: Visitors; } export class ApiResponse extends IncomingMessage { body: T; } export type callback = ((d: T) => void) | ((err: IntercomError, d: T) => void); export class Users { create(user: Partial): Promise>; create(user: Partial, cb: callback>): void; update(user: UserIdentifier & Partial): Promise>; update(user: UserIdentifier & Partial, cb: callback>): void; find(identifier: UserIdentifier): Promise>; find(identifier: UserIdentifier, cb: callback>): void; list(): Promise>; list(cb: callback>): void; listBy(params: { tag_id?: string; segment_id?: string }): Promise>; listBy(params: { tag_id?: string; segment_id?: string }, cb: callback>): void; scroll: Scroll; archive(identifier: UserIdentifier): Promise>; archive(identifier: UserIdentifier, cb: callback>): void; requestPermanentDeletion(id: string): Promise<{ id: number }>; requestPermanentDeletion(id: string, cb: callback<{ id: number }>): void; requestPermanentDeletionByParams(identifier: UserIdentifier): Promise<{ id: number }>; requestPermanentDeletionByParams(identifier: UserIdentifier, cb: callback<{ id: number }>): void; } export class Leads { create(lead: Partial): Promise>; create(lead: Partial, cb: callback>): void; update(lead: UserIdentifier & Partial): Promise>; update(lead: UserIdentifier & Partial, cb: callback>): void; list(): Promise>; list(cb: callback>): void; listBy(params: { email?: string; tag_id?: string; segment_id?: string }): Promise>; listBy(params: { email?: string; tag_id?: string; segment_id?: string }, cb: callback>): void; find(identifier: LeadIdentifier): Promise>; find(identifier: LeadIdentifier, cb: callback>): void; delete(id: string): Promise>; delete(id: string, cb: callback>): void; convert(params: { contact: LeadIdentifier; user: UserIdentifier }): Promise>; convert(params: { contact: LeadIdentifier; user: UserIdentifier }, cb: callback>): void; } export class Visitors { update(visitor: VisitorIdentifier & Partial): Promise>; update(visitor: VisitorIdentifier & Partial, cb: callback>): void; find(identifier: VisitorIdentifier): Promise>; find(identifier: VisitorIdentifier, cb: callback>): void; delete(id: string): Promise>; delete(id: string, cb: callback>): void; convert(params: { identifier: VisitorIdentifier; type: 'lead' }): Promise>; convert(params: { identifier: VisitorIdentifier; type: 'user'; user: UserIdentifier }): Promise>; convert( params: { identifier: VisitorIdentifier; type: 'lead'; }, cb: callback>, ): void; convert( params: { identifier: VisitorIdentifier; type: 'user'; user: UserIdentifier; }, cb: callback>, ): void; } export class Companies { create(company: CompanyIdentifier & Partial): Promise>; create(company: CompanyIdentifier & Partial, cb: callback>): void; update(company: CompanyIdentifier & Partial): Promise>; update(company: CompanyIdentifier & Partial, cb: callback>): void; find(identifier: CompanyIdentifier): Promise>; find(identifier: CompanyIdentifier, cb: callback>): void; list(): Promise>; list(cb: callback>): void; listBy(params: { tag_id?: string; segment_id?: string }): Promise>; listBy(params: { tag_id?: string; segment_id?: string }, cb: callback>): void; scroll: Scroll; archive(): Promise; } export class Tags { create(tag: Partial): Promise>; create(tag: Partial, cb: callback>): void; tag(tagOper: TagOper): Promise>; tag(tagOper: TagOper, cb: callback>): void; untag(tagOper: TagOper): Promise>; untag(tagOper: TagOper, cb: callback>): void; delete(tag: TagIdentifier): Promise; delete(tag: TagIdentifier, cb: callback): void; list(): Promise>; list(cb: callback>): void; } export class Events { create(event: Partial): Promise; create(event: Partial, cb: callback): void; listBy(params: EventListParam): Promise>; listBy(params: EventListParam, cb: callback>): void; }