Added Client class and definitions of functions for Client.users

This commit is contained in:
Josef Hornych 2018-06-18 12:37:48 +02:00
parent 7ecdecd262
commit 474ff58906
6 changed files with 209 additions and 0 deletions

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

View File

@ -0,0 +1,16 @@
# Installation
> `npm install --save @types/intercom-client`
# Summary
This package contains type definitions for intercom-client (https://github.com/intercom/intercom-node).
# Details
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/intercom-client
Additional Details
* Last updated: Thu, 03 May 2018 15:33:57 GMT
* Dependencies: none
* Global values: none
# Credits
These definitions were written by Jinesh Shah <https://github.com/jineshshah36>, Josef Hornych <https://github.com/peping>.

3
types/intercom-client/Scroll.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export declare class Scroll<T> {
}

85
types/intercom-client/User.d.ts vendored Normal file
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,
"username": "th1sland",
"url": "http://twitter.com/th1sland"
}
export interface Segment {
readonly "id": string
}
export interface Tag {
readonly "id": string
}
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 }
}

View File

@ -3,6 +3,9 @@
// Definitions by: Jinesh Shah <https://github.com/jineshshah36>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import {List as UserList, User, UserIdentifier} from './User';
import {Scroll} from './Scroll';
export interface IdentityVerificationOptions {
secretKey: string;
identifier: string;
@ -11,3 +14,36 @@ export interface IdentityVerificationOptions {
export const IdentityVerification: {
userHash(opts: IdentityVerificationOptions): string;
};
export declare class Client {
constructor(auth: { token: string });
constructor(username: string, password: string);
constructor(auth: { appId: string, appApiKey: string });
users: Users;
}
interface Company {
readonly "id": string
}
declare 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}>
}

View File

@ -0,0 +1,48 @@
{
"_from": "@types/intercom-client",
"_id": "@types/intercom-client@2.9.0",
"_inBundle": false,
"_integrity": "sha512-BijYT7XATNJ4TOwj3OULC8FRt2OgGJ18wxV/M5Hjl4Ql7kXa/Mr0s0fgcuegn6SsmEqOg/CYCPEeUILzKXHR/g==",
"_location": "/@types/intercom-client",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "@types/intercom-client",
"name": "@types/intercom-client",
"escapedName": "@types%2fintercom-client",
"scope": "@types",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#DEV:/",
"#USER"
],
"_resolved": "https://registry.npmjs.org/@types/intercom-client/-/intercom-client-2.9.0.tgz",
"_shasum": "7713308ace441835e687662bbf08d41393144295",
"_spec": "@types/intercom-client",
"_where": "C:\\Users\\Pepin\\Documents\\projects\\cqrs",
"bundleDependencies": false,
"contributors": [
{
"name": "Jinesh Shah",
"url": "https://github.com/jineshshah36"
}
],
"dependencies": {},
"deprecated": false,
"description": "TypeScript definitions for intercom-client",
"license": "MIT",
"main": "",
"name": "@types/intercom-client",
"repository": {
"type": "git",
"url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git"
},
"scripts": {},
"typeScriptVersion": "2.0",
"typesPublisherContentHash": "c27ac6cbc719f43db3d968722e9976bfc2d2d1380f77dae007bf5d360ed1aa84",
"version": "2.9.0"
}