-
Notifications
You must be signed in to change notification settings - Fork 118
/
threads.ts
127 lines (119 loc) · 3 KB
/
threads.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
import {
ListThreadsQueryParams,
Thread,
UpdateThreadRequest,
} from '../models/threads.js';
import { AsyncListResponse, Resource } from './resource.js';
import { Overrides } from '../config.js';
import {
NylasBaseResponse,
NylasListResponse,
NylasResponse,
} from '../models/response.js';
/**
* The parameters for the {@link Threads.list} method
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
export interface ListThreadsParams {
identifier: string;
queryParams?: ListThreadsQueryParams;
}
/**
* The parameters for the {@link Threads.find} method
* @property identifier The identifier of the grant to act upon
* @property threadId The id of the thread to retrieve.
* @property queryParams The query parameters to include in the request
*/
export interface FindThreadParams {
identifier: string;
threadId: string;
}
/**
* The parameters for the {@link Threads.update} method
* @property identifier The identifier of the grant to act upon
* @property threadId The id of the thread to update
* @property requestBody The values to update the thread with
*/
export interface UpdateThreadParams {
identifier: string;
threadId: string;
requestBody: UpdateThreadRequest;
}
/**
* The parameters for the {@link Threads.destroy} method
* @property identifier The identifier of the grant to act upon
* @property threadId The id of the thread to delete
*/
export interface DestroyThreadParams {
identifier: string;
threadId: string;
}
/**
* Nylas Threads API
*
* The Nylas Threads API allows you to list, find, update, and delete threads on user accounts.
*/
export class Threads extends Resource {
/**
* Return all Threads
* @return A list of threads
*/
public list({
identifier,
queryParams,
overrides,
}: ListThreadsParams & Overrides): AsyncListResponse<
NylasListResponse<Thread>
> {
return super._list<NylasListResponse<Thread>>({
queryParams,
overrides,
path: `/v3/grants/${identifier}/threads`,
});
}
/**
* Return a Thread
* @return The thread
*/
public find({
identifier,
threadId,
overrides,
}: FindThreadParams & Overrides): Promise<NylasResponse<Thread>> {
return super._find({
path: `/v3/grants/${identifier}/threads/${threadId}`,
overrides,
});
}
/**
* Update a Thread
* @return The updated thread
*/
public update({
identifier,
threadId,
requestBody,
overrides,
}: UpdateThreadParams & Overrides): Promise<NylasResponse<Thread>> {
return super._update({
path: `/v3/grants/${identifier}/threads/${threadId}`,
requestBody,
overrides,
});
}
/**
* Delete a Thread
* @return The deleted thread
*/
public destroy({
identifier,
threadId,
overrides,
}: DestroyThreadParams & Overrides): Promise<NylasBaseResponse> {
return super._destroy({
path: `/v3/grants/${identifier}/threads/${threadId}`,
overrides,
});
}
}