mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Adding more types to intercom-client (#26936)
This commit is contained in:
committed by
Mohamed Hegazy
parent
eb868d6677
commit
b42074d845
Vendored
+1
-3
@@ -1,7 +1,5 @@
|
||||
|
||||
export interface CompanyIdentifier {
|
||||
company_id: string
|
||||
}
|
||||
export type CompanyIdentifier = { id: string } | { company_id: string }
|
||||
|
||||
export interface Company {
|
||||
readonly "type": "company",
|
||||
|
||||
Vendored
+24
@@ -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<UserIdId>, Partial<IntercomUserIdId>, Partial<EmailIdId> {
|
||||
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 }
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
import { UserIdentifier } from "./User";
|
||||
|
||||
export interface TagIdentifier {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface Tag extends Partial<TagIdentifier> {
|
||||
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;
|
||||
Vendored
+29
@@ -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<T> extends IncomingMessage {
|
||||
@@ -80,3 +84,28 @@ export class Companies {
|
||||
|
||||
archive(): Promise<Company>;
|
||||
}
|
||||
|
||||
export class Tags {
|
||||
create(tag: Partial<Tag>): Promise<ApiResponse<Tag>>;
|
||||
create(tag: Partial<Tag>, cb: callback<ApiResponse<Tag>>): void;
|
||||
|
||||
tag(tagOper: TagOper): Promise<ApiResponse<Tag>>;
|
||||
tag(tagOper: TagOper, cb: callback<ApiResponse<Tag>>): void;
|
||||
|
||||
untag(tagOper: TagOper): Promise<ApiResponse<Tag>>;
|
||||
untag(tagOper: TagOper, cb: callback<ApiResponse<Tag>>): void;
|
||||
|
||||
delete(tag: TagIdentifier): Promise<IncomingMessage>;
|
||||
delete(tag: TagIdentifier, cb: callback<IncomingMessage>): void;
|
||||
|
||||
list(): Promise<ApiResponse<TagList>>;
|
||||
list(cb: callback<ApiResponse<TagList>>): void;
|
||||
}
|
||||
|
||||
export class Events {
|
||||
create(event: Partial<Event>): Promise<IncomingMessage>;
|
||||
create(event: Partial<Event>, cb: callback<IncomingMessage>): void;
|
||||
|
||||
listBy(params: EventListParam): Promise<ApiResponse<CompanyList>>;
|
||||
listBy(params: EventListParam, cb: callback<ApiResponse<CompanyList>>): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user