diff --git a/types/intercom-client/Company.d.ts b/types/intercom-client/Company.d.ts index ee20d80863..e0b218fb8c 100644 --- a/types/intercom-client/Company.d.ts +++ b/types/intercom-client/Company.d.ts @@ -1,7 +1,5 @@ -export interface CompanyIdentifier { - company_id: string -} +export type CompanyIdentifier = { id: string } | { company_id: string } export interface Company { readonly "type": "company", diff --git a/types/intercom-client/Event.d.ts b/types/intercom-client/Event.d.ts new file mode 100644 index 0000000000..d4e5832373 --- /dev/null +++ b/types/intercom-client/Event.d.ts @@ -0,0 +1,24 @@ +interface IntercomUserIdId { intercom_user_id: string } +interface UserIdId { user_id: string } +interface EmailIdId { email: string } + +export type EventIdentifier = IntercomUserIdId | UserIdId | EmailIdId; + +export interface Event extends Partial, Partial, Partial { + readonly id: string, + created_at: number, + event_name: string, + metadata?: any; +} + +export type ListParam = EventIdentifier & { + type: 'user', + per_page?: number, // max 100 +} + +export interface List { + "type": "event.list", + "total_count": number, + "events": (Event)[], + "pages": { "next"?: string, "page": number, "per_page": number, "total_pages": number } +} diff --git a/types/intercom-client/Tag.d.ts b/types/intercom-client/Tag.d.ts new file mode 100644 index 0000000000..0faebb074b --- /dev/null +++ b/types/intercom-client/Tag.d.ts @@ -0,0 +1,30 @@ +import { UserIdentifier } from "./User"; + +export interface TagIdentifier { + id: string +} + +export interface Tag extends Partial { + readonly type: "tag", + readonly id: string, + name: string, +} + +export interface List { + "type": "tag.list", + "total_count": number, + "tags": (Tag)[], + "pages": { "next"?: string, "page": number, "per_page": number, "total_pages": number } +} + +interface TagUsers { + name: string, + users: UserIdentifier[] +} + +interface TagCompanies { + name: string, + users: { id: string }[] +} + +type TagOper = TagCompanies | TagUsers; diff --git a/types/intercom-client/index.d.ts b/types/intercom-client/index.d.ts index c9c9fc3364..25b166e10d 100644 --- a/types/intercom-client/index.d.ts +++ b/types/intercom-client/index.d.ts @@ -7,6 +7,8 @@ import { List as UserList, User, UserIdentifier } from './User'; 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'; @@ -29,6 +31,8 @@ export class Client { users: Users; companies: Companies; + tags: Tags; + events: Events; } export class ApiResponse extends IncomingMessage { @@ -80,3 +84,28 @@ export class Companies { 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; +}