mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
[intercom-client] Add separate User type for creating and updating (#40035)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
6d1bed7dac
commit
afd89d0e4f
Vendored
+70
-64
@@ -1,85 +1,91 @@
|
||||
import { Company } from "./Company";
|
||||
import { Company } from './Company';
|
||||
|
||||
export type UserIdentifier = { "id": string } | { "user_id": string } | { "email": string }
|
||||
export type UserIdentifier = { id: string } | { user_id: string } | { email: string };
|
||||
|
||||
export interface Avatar {
|
||||
"type": "avatar",
|
||||
"image_url": string | null
|
||||
type: 'avatar';
|
||||
image_url: string | null;
|
||||
}
|
||||
|
||||
export interface SocialProfile {
|
||||
"name": "Twitter",
|
||||
readonly "id": string | null,
|
||||
"username": string | null,
|
||||
"url": string | null
|
||||
name: 'Twitter';
|
||||
readonly id: string | null;
|
||||
username: string | null;
|
||||
url: string | null;
|
||||
}
|
||||
|
||||
export interface Segment {
|
||||
readonly "id": string
|
||||
readonly id: string;
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
readonly "id": string
|
||||
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
|
||||
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[]
|
||||
interface BaseUser {
|
||||
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;
|
||||
}
|
||||
|
||||
},
|
||||
"tags": {
|
||||
"type": "tag.list",
|
||||
"tags": Tag[]
|
||||
}
|
||||
export interface User extends BaseUser {
|
||||
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 CreateUpdateUser extends BaseUser {
|
||||
companies: Partial<Company>[];
|
||||
}
|
||||
|
||||
export interface List {
|
||||
"type": "user.list",
|
||||
"total_count": number,
|
||||
"users": User[],
|
||||
"pages": { "next"?: string, "page": number, "per_page": number, "total_pages": number }
|
||||
}
|
||||
type: 'user.list';
|
||||
total_count: number;
|
||||
users: User[];
|
||||
pages: { next?: string; page: number; per_page: number; total_pages: number };
|
||||
}
|
||||
|
||||
Vendored
+9
-6
@@ -1,11 +1,14 @@
|
||||
// Type definitions for intercom-client 2.11
|
||||
// Project: https://github.com/intercom/intercom-node
|
||||
// Definitions by: Jinesh Shah <https://github.com/jineshshah36>, Josef Hornych <https://github.com/peping>, Mikhail Monchak <https://github.com/mikhail-monchak>
|
||||
// Definitions by: Jinesh Shah <https://github.com/jineshshah36>
|
||||
// Josef Hornych <https://github.com/peping>
|
||||
// Mikhail Monchak <https://github.com/mikhail-monchak>
|
||||
// Chris Doe <https://github.com/cdoe>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
/// <reference types="node" />
|
||||
|
||||
import { List as UserList, User, UserIdentifier } from './User';
|
||||
import { List as UserList, User, UserIdentifier, CreateUpdateUser } from './User';
|
||||
import { List as LeadList, Lead, LeadIdentifier } from './Lead';
|
||||
import { Visitor, VisitorIdentifier } from './Visitor';
|
||||
import { CompanyIdentifier, List as CompanyList, Company } from './Company';
|
||||
@@ -47,11 +50,11 @@ export class ApiResponse<T> extends IncomingMessage {
|
||||
export type callback<T> = ((d: T) => void) | ((err: IntercomError, d: T) => void);
|
||||
|
||||
export class Users {
|
||||
create(user: Partial<User>): Promise<ApiResponse<User>>;
|
||||
create(user: Partial<User>, cb: callback<ApiResponse<User>>): void;
|
||||
create(user: Partial<CreateUpdateUser>): Promise<ApiResponse<User>>;
|
||||
create(user: Partial<CreateUpdateUser>, cb: callback<ApiResponse<User>>): void;
|
||||
|
||||
update(user: UserIdentifier & Partial<User>): Promise<ApiResponse<User>>;
|
||||
update(user: UserIdentifier & Partial<User>, cb: callback<ApiResponse<User>>): void;
|
||||
update(user: UserIdentifier & Partial<CreateUpdateUser>): Promise<ApiResponse<User>>;
|
||||
update(user: UserIdentifier & Partial<CreateUpdateUser>, cb: callback<ApiResponse<User>>): void;
|
||||
|
||||
find(identifier: UserIdentifier): Promise<ApiResponse<User>>;
|
||||
find(identifier: UserIdentifier, cb: callback<ApiResponse<User>>): void;
|
||||
|
||||
Reference in New Issue
Block a user