-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.ts
153 lines (119 loc) · 3.75 KB
/
users.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as Core from '../../core';
import * as Shared from '../shared';
import * as DocsAPI from './docs';
import { DocCreateParams, DocListParams, DocSearchParams, DocSearchResponse, Docs } from './docs';
import { OffsetPagination, type OffsetPaginationParams } from '../../pagination';
export class Users extends APIResource {
docs: DocsAPI.Docs = new DocsAPI.Docs(this._client);
/**
* Create User
*/
create(body: UserCreateParams, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.post('/users', { body, ...options });
}
/**
* Patch User
*/
update(userId: string, body: UserUpdateParams, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.patch(`/users/${userId}`, { body, ...options });
}
/**
* List Users
*/
list(query?: UserListParams, options?: Core.RequestOptions): Core.PagePromise<UsersOffsetPagination, User>;
list(options?: Core.RequestOptions): Core.PagePromise<UsersOffsetPagination, User>;
list(
query: UserListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<UsersOffsetPagination, User> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/users', UsersOffsetPagination, { query, ...options });
}
/**
* Delete User
*/
delete(userId: string, options?: Core.RequestOptions): Core.APIPromise<Shared.ResourceDeleted> {
return this._client.delete(`/users/${userId}`, options);
}
/**
* Create Or Update User
*/
createOrUpdate(
userId: string,
body: UserCreateOrUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<User> {
return this._client.post(`/users/${userId}`, { body, ...options });
}
/**
* Get User Details
*/
get(userId: string, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.get(`/users/${userId}`, options);
}
/**
* Update User
*/
reset(userId: string, body: UserResetParams, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.put(`/users/${userId}`, { body, ...options });
}
}
export class UsersOffsetPagination extends OffsetPagination<User> {}
export interface User {
id: string;
created_at: string;
updated_at: string;
about?: string;
metadata?: unknown | null;
name?: string;
}
export interface UserCreateParams {
about?: string;
metadata?: unknown | null;
name?: string;
}
export interface UserUpdateParams {
about?: string;
metadata?: unknown | null;
name?: string;
}
export interface UserListParams extends OffsetPaginationParams {
direction?: 'asc' | 'desc';
metadata_filter?: Record<string, unknown>;
sort_by?: 'created_at' | 'updated_at';
}
export interface UserCreateOrUpdateParams {
about?: string;
metadata?: unknown | null;
name?: string;
}
export interface UserResetParams {
about?: string;
metadata?: unknown | null;
name?: string;
}
Users.UsersOffsetPagination = UsersOffsetPagination;
Users.Docs = Docs;
export declare namespace Users {
export {
type User as User,
UsersOffsetPagination as UsersOffsetPagination,
type UserCreateParams as UserCreateParams,
type UserUpdateParams as UserUpdateParams,
type UserListParams as UserListParams,
type UserCreateOrUpdateParams as UserCreateOrUpdateParams,
type UserResetParams as UserResetParams,
};
export {
Docs as Docs,
type DocSearchResponse as DocSearchResponse,
type DocCreateParams as DocCreateParams,
type DocListParams as DocListParams,
type DocSearchParams as DocSearchParams,
};
}