diff --git a/types/intercom-client/Scroll.d.ts b/types/intercom-client/Scroll.d.ts new file mode 100644 index 0000000000..2704a4cfbe --- /dev/null +++ b/types/intercom-client/Scroll.d.ts @@ -0,0 +1,3 @@ +export declare class Scroll { + +} \ No newline at end of file diff --git a/types/intercom-client/User.d.ts b/types/intercom-client/User.d.ts new file mode 100644 index 0000000000..880b8b5681 --- /dev/null +++ b/types/intercom-client/User.d.ts @@ -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 } +} \ No newline at end of file diff --git a/types/intercom-client/index.d.ts b/types/intercom-client/index.d.ts index b68dc87e71..4d9e572da0 100644 --- a/types/intercom-client/index.d.ts +++ b/types/intercom-client/index.d.ts @@ -1,7 +1,10 @@ // Type definitions for intercom-client 2.9 // Project: https://github.com/intercom/intercom-node -// Definitions by: Jinesh Shah +// Definitions by: Jinesh Shah , Josef Hornych // 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): Promise; + + update(user: UserIdentifier & Partial): Promise; + + find(identifier: UserIdentifier): Promise; + + list(): Promise; + + listBy(params: {tag_id: string, segment_id: string}): Promise; + + scroll: Scroll; + + archive(): Promise; + + requestPermanentDeletion(): Promise<{id: number}>; +}