Merge pull request #26636 from Peping/master

[@types/intercom-client] typings for Client and its property users
This commit is contained in:
Nathan Shively-Sanders
2018-06-18 10:10:08 -07:00
committed by GitHub
3 changed files with 121 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
export declare class Scroll<T> {
}
+85
View File
@@ -0,0 +1,85 @@
import {Company} from "intercom-client";
export type UserIdentifier = { "id": string } | { "user_id": string } | { "email": string }
export interface Avatar {
"type": "avatar",
"image_url": string | null
}
export interface SocialProfile {
"name": "Twitter",
readonly "id": string | null,
"username": string | null,
"url": string | null
}
export interface Segment {
readonly "id": string
}
export interface Tag {
readonly "id": string
}
export interface LocationData {
"type": "location_data",
"city_name": string | null,
"continent_code": string | null,
"country_code": string | null,
"country_name": string | null,
"latitude": number | null,
"longitude": number | null,
"postal_code": string | null,
"region_name": string | null,
"timezone": string | null
}
export interface User {
"type": "user" | "contact",
readonly "id": string,
"user_id": string | null,
"email": string | null,
"app_id"?: string,
"phone": string | null,
"name": string | null,
readonly "updated_at": number,
"last_seen_ip": string | null,
"unsubscribed_from_emails": boolean,
"last_request_at": number | null,
"signed_up_at": number | null,
readonly "created_at": number,
"session_count": number,
"user_agent_data": string | null,
"pseudonym": string | null,
"anonymous": boolean,
"custom_attributes": {
[key: string]: any
},
"avatar": Avatar,
"location_data": LocationData | {},
"social_profiles": {
"type": "social_profile.list",
"social_profiles": SocialProfile[]
},
"companies": {
"type": "company.list",
"companies": Company[]
},
"segments": {
"type": "segment.list",
"segments": Segment[]
},
"tags": {
"type": "tag.list",
"tags": Tag[]
}
}
export interface List {
"type": "user.list",
"total_count": number,
"users": User[],
"pages": { "next"?: string, "page": number, "per_page": number, "total_pages": number }
}
+33 -1
View File
@@ -1,7 +1,10 @@
// Type definitions for intercom-client 2.9
// Project: https://github.com/intercom/intercom-node
// Definitions by: Jinesh Shah <https://github.com/jineshshah36>
// Definitions by: Jinesh Shah <https://github.com/jineshshah36>, Josef Hornych <https://github.com/peping>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import { List as UserList, User, UserIdentifier } from './User';
import { Scroll } from './Scroll';
export interface IdentityVerificationOptions {
secretKey: string;
@@ -11,3 +14,32 @@ export interface IdentityVerificationOptions {
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;
}
export interface Company {
readonly "id": string;
}
export class Users {
create(user: Partial<User>): Promise<User>;
update(user: UserIdentifier & Partial<User>): Promise<User>;
find(identifier: UserIdentifier): Promise<User>;
list(): Promise<UserList>;
listBy(params: {tag_id: string, segment_id: string}): Promise<UserList>;
scroll: Scroll<User>;
archive(): Promise<User>;
requestPermanentDeletion(): Promise<{id: number}>;
}