mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #26657 from saulogt/master
Extending intercom types and fixing response type
This commit is contained in:
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
|
||||
export interface CompanyIdentifier {
|
||||
company_id: string
|
||||
}
|
||||
|
||||
export interface Company {
|
||||
readonly "type": "company",
|
||||
readonly "id": string,
|
||||
readonly app_id?: string,
|
||||
company_id?: string,
|
||||
plan?: string | { type: string, id: string, name: string },
|
||||
remote_created_at?: number,
|
||||
name?: string,
|
||||
readonly "updated_at": number,
|
||||
readonly "created_at": number,
|
||||
size?: number,
|
||||
website?: string,
|
||||
industry?: string,
|
||||
monthly_spend?: number,
|
||||
session_count?: number,
|
||||
user_count?: number,
|
||||
custom_attributes?: {
|
||||
[key: string]: any
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
export interface List {
|
||||
"type": "company.list",
|
||||
"total_count": number,
|
||||
"companies": (Company & CompanyIdentifier)[],
|
||||
"pages": { "next"?: string, "page": number, "per_page": number, "total_pages": number }
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
export interface IntercomError {
|
||||
statusCode: number,
|
||||
body: {
|
||||
type: "error.list",
|
||||
request_id: string,
|
||||
errors: Array<{
|
||||
code: string, //"400",
|
||||
message: string
|
||||
}>
|
||||
},
|
||||
headers: { status: string } & { [k: string]: string }
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
import {Company} from "intercom-client";
|
||||
import { Company } from "./Company";
|
||||
|
||||
export type UserIdentifier = { "id": string } | { "user_id": string } | { "email": string }
|
||||
|
||||
|
||||
Vendored
+44
-7
@@ -3,8 +3,16 @@
|
||||
// Definitions by: Jinesh Shah <https://github.com/jineshshah36>, Josef Hornych <https://github.com/peping>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
/// <reference types="node" />
|
||||
|
||||
import { List as UserList, User, UserIdentifier } from './User';
|
||||
import { CompanyIdentifier, List as CompanyList, Company } from './Company';
|
||||
import { Scroll } from './Scroll';
|
||||
import { IntercomError } from './IntercomError';
|
||||
|
||||
import { IncomingMessage } from 'http';
|
||||
|
||||
export { IntercomError };
|
||||
|
||||
export interface IdentityVerificationOptions {
|
||||
secretKey: string;
|
||||
@@ -20,22 +28,30 @@ export class Client {
|
||||
constructor(username: string, password: string);
|
||||
|
||||
users: Users;
|
||||
companies: Companies;
|
||||
}
|
||||
|
||||
export interface Company {
|
||||
readonly "id": string;
|
||||
export class ApiResponse<T> extends IncomingMessage {
|
||||
body: T;
|
||||
}
|
||||
|
||||
export type callback<T> = ((d: T) => void) | ((err: IntercomError, d: T) => void);
|
||||
|
||||
export class Users {
|
||||
create(user: Partial<User>): Promise<User>;
|
||||
create(user: Partial<User>): Promise<ApiResponse<User>>;
|
||||
create(user: Partial<User>, cb: callback<ApiResponse<User>>): void;
|
||||
|
||||
update(user: UserIdentifier & Partial<User>): Promise<User>;
|
||||
update(user: UserIdentifier & Partial<User>): Promise<ApiResponse<User>>;
|
||||
update(user: UserIdentifier & Partial<User>, cb: callback<ApiResponse<User>>): void;
|
||||
|
||||
find(identifier: UserIdentifier): Promise<User>;
|
||||
find(identifier: UserIdentifier): Promise<ApiResponse<User>>;
|
||||
find(identifier: UserIdentifier, cb: callback<ApiResponse<User>>): void;
|
||||
|
||||
list(): Promise<UserList>;
|
||||
list(): Promise<ApiResponse<User>>;
|
||||
list(cb: callback<ApiResponse<User>>): void;
|
||||
|
||||
listBy(params: {tag_id: string, segment_id: string}): Promise<UserList>;
|
||||
listBy(params: {tag_id?: string, segment_id?: string}): Promise<ApiResponse<UserList>>;
|
||||
listBy(params: {tag_id?: string, segment_id?: string}, cb: callback<ApiResponse<UserList>>): void;
|
||||
|
||||
scroll: Scroll<User>;
|
||||
|
||||
@@ -43,3 +59,24 @@ export class Users {
|
||||
|
||||
requestPermanentDeletion(): Promise<{id: number}>;
|
||||
}
|
||||
|
||||
export class Companies {
|
||||
create(company: CompanyIdentifier & Partial<Company>): Promise<ApiResponse<Company>>;
|
||||
create(company: CompanyIdentifier & Partial<Company>, cb: callback<ApiResponse<Company>>): void;
|
||||
|
||||
update(company: CompanyIdentifier & Partial<Company>): Promise<ApiResponse<Company>>;
|
||||
update(company: CompanyIdentifier & Partial<Company>, cb: callback<ApiResponse<Company>>): void;
|
||||
|
||||
find(identifier: CompanyIdentifier): Promise<ApiResponse<Company>>;
|
||||
find(identifier: CompanyIdentifier, cb: callback<ApiResponse<Company>>): void;
|
||||
|
||||
list(): Promise<ApiResponse<CompanyList>>;
|
||||
list(cb: callback<ApiResponse<CompanyList>>): void;
|
||||
|
||||
listBy(params: {tag_id?: string, segment_id?: string}): Promise<ApiResponse<CompanyList>>;
|
||||
listBy(params: {tag_id?: string, segment_id?: string}, cb: callback<ApiResponse<CompanyList>>): void;
|
||||
|
||||
scroll: Scroll<Company>;
|
||||
|
||||
archive(): Promise<Company>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user