agentmail 0.4.13 → 0.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/api/errors/UnprocessableError.d.ts +6 -0
- package/dist/cjs/api/errors/UnprocessableError.js +54 -0
- package/dist/cjs/api/errors/index.d.ts +1 -0
- package/dist/cjs/api/errors/index.js +1 -0
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +1 -1
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +1 -1
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +17 -0
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +90 -0
- package/dist/cjs/api/resources/messages/types/UpdateMessageResponse.d.ts +5 -0
- package/dist/cjs/api/resources/messages/types/UpdateMessageResponse.js +3 -0
- package/dist/cjs/api/resources/messages/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/messages/types/index.js +1 -0
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +17 -0
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +90 -0
- package/dist/cjs/api/resources/threads/client/Client.d.ts +16 -0
- package/dist/cjs/api/resources/threads/client/Client.js +89 -0
- package/dist/cjs/api/resources/threads/types/UpdateThreadRequest.d.ts +6 -0
- package/dist/cjs/api/resources/threads/types/UpdateThreadRequest.js +3 -0
- package/dist/cjs/api/resources/threads/types/UpdateThreadResponse.d.ts +5 -0
- package/dist/cjs/api/resources/threads/types/UpdateThreadResponse.js +3 -0
- package/dist/cjs/api/resources/threads/types/index.d.ts +2 -0
- package/dist/cjs/api/resources/threads/types/index.js +2 -0
- package/dist/cjs/serialization/resources/messages/types/UpdateMessageResponse.d.ts +12 -0
- package/dist/cjs/serialization/resources/messages/types/UpdateMessageResponse.js +44 -0
- package/dist/cjs/serialization/resources/messages/types/index.d.ts +1 -0
- package/dist/cjs/serialization/resources/messages/types/index.js +1 -0
- package/dist/cjs/serialization/resources/threads/types/UpdateThreadRequest.d.ts +10 -0
- package/dist/cjs/serialization/resources/threads/types/UpdateThreadRequest.js +42 -0
- package/dist/cjs/serialization/resources/threads/types/UpdateThreadResponse.d.ts +12 -0
- package/dist/cjs/serialization/resources/threads/types/UpdateThreadResponse.js +44 -0
- package/dist/cjs/serialization/resources/threads/types/index.d.ts +2 -0
- package/dist/cjs/serialization/resources/threads/types/index.js +2 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/api/errors/UnprocessableError.d.mts +6 -0
- package/dist/esm/api/errors/UnprocessableError.mjs +17 -0
- package/dist/esm/api/errors/index.d.mts +1 -0
- package/dist/esm/api/errors/index.mjs +1 -0
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +1 -1
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +1 -1
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +17 -0
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +90 -0
- package/dist/esm/api/resources/messages/types/UpdateMessageResponse.d.mts +5 -0
- package/dist/esm/api/resources/messages/types/UpdateMessageResponse.mjs +2 -0
- package/dist/esm/api/resources/messages/types/index.d.mts +1 -0
- package/dist/esm/api/resources/messages/types/index.mjs +1 -0
- package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +17 -0
- package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +90 -0
- package/dist/esm/api/resources/threads/client/Client.d.mts +16 -0
- package/dist/esm/api/resources/threads/client/Client.mjs +89 -0
- package/dist/esm/api/resources/threads/types/UpdateThreadRequest.d.mts +6 -0
- package/dist/esm/api/resources/threads/types/UpdateThreadRequest.mjs +2 -0
- package/dist/esm/api/resources/threads/types/UpdateThreadResponse.d.mts +5 -0
- package/dist/esm/api/resources/threads/types/UpdateThreadResponse.mjs +2 -0
- package/dist/esm/api/resources/threads/types/index.d.mts +2 -0
- package/dist/esm/api/resources/threads/types/index.mjs +2 -0
- package/dist/esm/serialization/resources/messages/types/UpdateMessageResponse.d.mts +12 -0
- package/dist/esm/serialization/resources/messages/types/UpdateMessageResponse.mjs +8 -0
- package/dist/esm/serialization/resources/messages/types/index.d.mts +1 -0
- package/dist/esm/serialization/resources/messages/types/index.mjs +1 -0
- package/dist/esm/serialization/resources/threads/types/UpdateThreadRequest.d.mts +10 -0
- package/dist/esm/serialization/resources/threads/types/UpdateThreadRequest.mjs +6 -0
- package/dist/esm/serialization/resources/threads/types/UpdateThreadResponse.d.mts +12 -0
- package/dist/esm/serialization/resources/threads/types/UpdateThreadResponse.mjs +8 -0
- package/dist/esm/serialization/resources/threads/types/index.d.mts +2 -0
- package/dist/esm/serialization/resources/threads/types/index.mjs +2 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +20 -2
- package/reference.md +230 -1
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
|
|
|
43
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
44
44
|
"X-Fern-Language": "JavaScript",
|
|
45
45
|
"X-Fern-SDK-Name": "agentmail",
|
|
46
|
-
"X-Fern-SDK-Version": "0.4.
|
|
47
|
-
"User-Agent": "agentmail/0.4.
|
|
46
|
+
"X-Fern-SDK-Version": "0.4.14",
|
|
47
|
+
"User-Agent": "agentmail/0.4.14",
|
|
48
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
49
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
50
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as core from "../../core/index.js";
|
|
2
|
+
import * as errors from "../../errors/index.js";
|
|
3
|
+
import type * as AgentMail from "../index.js";
|
|
4
|
+
export declare class UnprocessableError extends errors.AgentMailError {
|
|
5
|
+
constructor(body: AgentMail.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.UnprocessableError = void 0;
|
|
38
|
+
const errors = __importStar(require("../../errors/index.js"));
|
|
39
|
+
class UnprocessableError extends errors.AgentMailError {
|
|
40
|
+
constructor(body, rawResponse) {
|
|
41
|
+
super({
|
|
42
|
+
message: "UnprocessableError",
|
|
43
|
+
statusCode: 422,
|
|
44
|
+
body: body,
|
|
45
|
+
rawResponse: rawResponse,
|
|
46
|
+
});
|
|
47
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
48
|
+
if (Error.captureStackTrace) {
|
|
49
|
+
Error.captureStackTrace(this, this.constructor);
|
|
50
|
+
}
|
|
51
|
+
this.name = this.constructor.name;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.UnprocessableError = UnprocessableError;
|
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./IsTakenError.js"), exports);
|
|
18
18
|
__exportStar(require("./NotFoundError.js"), exports);
|
|
19
|
+
__exportStar(require("./UnprocessableError.js"), exports);
|
|
19
20
|
__exportStar(require("./ValidationError.js"), exports);
|
|
@@ -71,7 +71,7 @@ export declare class MessagesClient {
|
|
|
71
71
|
* @example
|
|
72
72
|
* await client.inboxes.messages.update("inbox_id", "message_id", {})
|
|
73
73
|
*/
|
|
74
|
-
update(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.UpdateMessageRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.
|
|
74
|
+
update(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.UpdateMessageRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.UpdateMessageResponse>;
|
|
75
75
|
private __update;
|
|
76
76
|
/**
|
|
77
77
|
* @param {AgentMail.inboxes.InboxId} inbox_id
|
|
@@ -371,7 +371,7 @@ class MessagesClient {
|
|
|
371
371
|
});
|
|
372
372
|
if (_response.ok) {
|
|
373
373
|
return {
|
|
374
|
-
data: serializers.
|
|
374
|
+
data: serializers.UpdateMessageResponse.parseOrThrow(_response.body, {
|
|
375
375
|
unrecognizedObjectKeys: "passthrough",
|
|
376
376
|
allowUnrecognizedUnionMembers: true,
|
|
377
377
|
allowUnrecognizedEnumValues: true,
|
|
@@ -47,6 +47,23 @@ export declare class ThreadsClient {
|
|
|
47
47
|
*/
|
|
48
48
|
getAttachment(inbox_id: AgentMail.inboxes.InboxId, thread_id: AgentMail.ThreadId, attachment_id: AgentMail.AttachmentId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.AttachmentResponse>;
|
|
49
49
|
private __getAttachment;
|
|
50
|
+
/**
|
|
51
|
+
* Updates thread labels. Cannot add or remove system labels (sent, received, bounced, etc.). Rejects requests with a `422` for threads with 100 or more messages.
|
|
52
|
+
*
|
|
53
|
+
* @param {AgentMail.inboxes.InboxId} inbox_id
|
|
54
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
55
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
56
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
57
|
+
*
|
|
58
|
+
* @throws {@link AgentMail.ValidationError}
|
|
59
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
60
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* await client.inboxes.threads.update("inbox_id", "thread_id", {})
|
|
64
|
+
*/
|
|
65
|
+
update(inbox_id: AgentMail.inboxes.InboxId, thread_id: AgentMail.ThreadId, request: AgentMail.UpdateThreadRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.UpdateThreadResponse>;
|
|
66
|
+
private __update;
|
|
50
67
|
/**
|
|
51
68
|
* Moves the thread to trash by adding a trash label to all messages. If the thread is already in trash, it will be permanently deleted. Use `permanent=true` to force permanent deletion.
|
|
52
69
|
*
|
|
@@ -268,6 +268,96 @@ class ThreadsClient {
|
|
|
268
268
|
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/inboxes/{inbox_id}/threads/{thread_id}/attachments/{attachment_id}");
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Updates thread labels. Cannot add or remove system labels (sent, received, bounced, etc.). Rejects requests with a `422` for threads with 100 or more messages.
|
|
273
|
+
*
|
|
274
|
+
* @param {AgentMail.inboxes.InboxId} inbox_id
|
|
275
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
276
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
277
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
278
|
+
*
|
|
279
|
+
* @throws {@link AgentMail.ValidationError}
|
|
280
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
281
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* await client.inboxes.threads.update("inbox_id", "thread_id", {})
|
|
285
|
+
*/
|
|
286
|
+
update(inbox_id, thread_id, request, requestOptions) {
|
|
287
|
+
return core.HttpResponsePromise.fromPromise(this.__update(inbox_id, thread_id, request, requestOptions));
|
|
288
|
+
}
|
|
289
|
+
__update(inbox_id, thread_id, request, requestOptions) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
292
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
293
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
294
|
+
const _response = yield core.fetcher({
|
|
295
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
|
|
296
|
+
.http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
|
|
297
|
+
method: "PATCH",
|
|
298
|
+
headers: _headers,
|
|
299
|
+
contentType: "application/json",
|
|
300
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
301
|
+
requestType: "json",
|
|
302
|
+
body: serializers.UpdateThreadRequest.jsonOrThrow(request, {
|
|
303
|
+
unrecognizedObjectKeys: "strip",
|
|
304
|
+
omitUndefined: true,
|
|
305
|
+
}),
|
|
306
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
307
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
308
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
309
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
310
|
+
logging: this._options.logging,
|
|
311
|
+
});
|
|
312
|
+
if (_response.ok) {
|
|
313
|
+
return {
|
|
314
|
+
data: serializers.UpdateThreadResponse.parseOrThrow(_response.body, {
|
|
315
|
+
unrecognizedObjectKeys: "passthrough",
|
|
316
|
+
allowUnrecognizedUnionMembers: true,
|
|
317
|
+
allowUnrecognizedEnumValues: true,
|
|
318
|
+
skipValidation: true,
|
|
319
|
+
breadcrumbsPrefix: ["response"],
|
|
320
|
+
}),
|
|
321
|
+
rawResponse: _response.rawResponse,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (_response.error.reason === "status-code") {
|
|
325
|
+
switch (_response.error.statusCode) {
|
|
326
|
+
case 400:
|
|
327
|
+
throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
|
|
328
|
+
unrecognizedObjectKeys: "passthrough",
|
|
329
|
+
allowUnrecognizedUnionMembers: true,
|
|
330
|
+
allowUnrecognizedEnumValues: true,
|
|
331
|
+
skipValidation: true,
|
|
332
|
+
breadcrumbsPrefix: ["response"],
|
|
333
|
+
}), _response.rawResponse);
|
|
334
|
+
case 404:
|
|
335
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
336
|
+
unrecognizedObjectKeys: "passthrough",
|
|
337
|
+
allowUnrecognizedUnionMembers: true,
|
|
338
|
+
allowUnrecognizedEnumValues: true,
|
|
339
|
+
skipValidation: true,
|
|
340
|
+
breadcrumbsPrefix: ["response"],
|
|
341
|
+
}), _response.rawResponse);
|
|
342
|
+
case 422:
|
|
343
|
+
throw new AgentMail.UnprocessableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
344
|
+
unrecognizedObjectKeys: "passthrough",
|
|
345
|
+
allowUnrecognizedUnionMembers: true,
|
|
346
|
+
allowUnrecognizedEnumValues: true,
|
|
347
|
+
skipValidation: true,
|
|
348
|
+
breadcrumbsPrefix: ["response"],
|
|
349
|
+
}), _response.rawResponse);
|
|
350
|
+
default:
|
|
351
|
+
throw new errors.AgentMailError({
|
|
352
|
+
statusCode: _response.error.statusCode,
|
|
353
|
+
body: _response.error.body,
|
|
354
|
+
rawResponse: _response.rawResponse,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PATCH", "/v0/inboxes/{inbox_id}/threads/{thread_id}");
|
|
359
|
+
});
|
|
360
|
+
}
|
|
271
361
|
/**
|
|
272
362
|
* Moves the thread to trash by adding a trash label to all messages. If the thread is already in trash, it will be permanently deleted. Use `permanent=true` to force permanent deletion.
|
|
273
363
|
*
|
|
@@ -50,3 +50,4 @@ __exportStar(require("./SendMessageRequest.js"), exports);
|
|
|
50
50
|
__exportStar(require("./SendMessageResponse.js"), exports);
|
|
51
51
|
__exportStar(require("./SendMessageTo.js"), exports);
|
|
52
52
|
__exportStar(require("./UpdateMessageRequest.js"), exports);
|
|
53
|
+
__exportStar(require("./UpdateMessageResponse.js"), exports);
|
|
@@ -47,6 +47,23 @@ export declare class ThreadsClient {
|
|
|
47
47
|
*/
|
|
48
48
|
getAttachment(pod_id: AgentMail.pods.PodId, thread_id: AgentMail.ThreadId, attachment_id: AgentMail.AttachmentId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.AttachmentResponse>;
|
|
49
49
|
private __getAttachment;
|
|
50
|
+
/**
|
|
51
|
+
* Updates thread labels. Cannot add or remove system labels (sent, received, bounced, etc.). Rejects requests with a `422` for threads with 100 or more messages.
|
|
52
|
+
*
|
|
53
|
+
* @param {AgentMail.pods.PodId} pod_id
|
|
54
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
55
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
56
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
57
|
+
*
|
|
58
|
+
* @throws {@link AgentMail.ValidationError}
|
|
59
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
60
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* await client.pods.threads.update("pod_id", "thread_id", {})
|
|
64
|
+
*/
|
|
65
|
+
update(pod_id: AgentMail.pods.PodId, thread_id: AgentMail.ThreadId, request: AgentMail.UpdateThreadRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.UpdateThreadResponse>;
|
|
66
|
+
private __update;
|
|
50
67
|
/**
|
|
51
68
|
* Moves the thread to trash by adding a trash label to all messages. If the thread is already in trash, it will be permanently deleted. Use `permanent=true` to force permanent deletion.
|
|
52
69
|
*
|
|
@@ -268,6 +268,96 @@ class ThreadsClient {
|
|
|
268
268
|
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/pods/{pod_id}/threads/{thread_id}/attachments/{attachment_id}");
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Updates thread labels. Cannot add or remove system labels (sent, received, bounced, etc.). Rejects requests with a `422` for threads with 100 or more messages.
|
|
273
|
+
*
|
|
274
|
+
* @param {AgentMail.pods.PodId} pod_id
|
|
275
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
276
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
277
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
278
|
+
*
|
|
279
|
+
* @throws {@link AgentMail.ValidationError}
|
|
280
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
281
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* await client.pods.threads.update("pod_id", "thread_id", {})
|
|
285
|
+
*/
|
|
286
|
+
update(pod_id, thread_id, request, requestOptions) {
|
|
287
|
+
return core.HttpResponsePromise.fromPromise(this.__update(pod_id, thread_id, request, requestOptions));
|
|
288
|
+
}
|
|
289
|
+
__update(pod_id, thread_id, request, requestOptions) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
292
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
293
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
294
|
+
const _response = yield core.fetcher({
|
|
295
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
|
|
296
|
+
.http, `/v0/pods/${core.url.encodePathParam(serializers.pods.PodId.jsonOrThrow(pod_id, { omitUndefined: true }))}/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
|
|
297
|
+
method: "PATCH",
|
|
298
|
+
headers: _headers,
|
|
299
|
+
contentType: "application/json",
|
|
300
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
301
|
+
requestType: "json",
|
|
302
|
+
body: serializers.UpdateThreadRequest.jsonOrThrow(request, {
|
|
303
|
+
unrecognizedObjectKeys: "strip",
|
|
304
|
+
omitUndefined: true,
|
|
305
|
+
}),
|
|
306
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
307
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
308
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
309
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
310
|
+
logging: this._options.logging,
|
|
311
|
+
});
|
|
312
|
+
if (_response.ok) {
|
|
313
|
+
return {
|
|
314
|
+
data: serializers.UpdateThreadResponse.parseOrThrow(_response.body, {
|
|
315
|
+
unrecognizedObjectKeys: "passthrough",
|
|
316
|
+
allowUnrecognizedUnionMembers: true,
|
|
317
|
+
allowUnrecognizedEnumValues: true,
|
|
318
|
+
skipValidation: true,
|
|
319
|
+
breadcrumbsPrefix: ["response"],
|
|
320
|
+
}),
|
|
321
|
+
rawResponse: _response.rawResponse,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (_response.error.reason === "status-code") {
|
|
325
|
+
switch (_response.error.statusCode) {
|
|
326
|
+
case 400:
|
|
327
|
+
throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
|
|
328
|
+
unrecognizedObjectKeys: "passthrough",
|
|
329
|
+
allowUnrecognizedUnionMembers: true,
|
|
330
|
+
allowUnrecognizedEnumValues: true,
|
|
331
|
+
skipValidation: true,
|
|
332
|
+
breadcrumbsPrefix: ["response"],
|
|
333
|
+
}), _response.rawResponse);
|
|
334
|
+
case 404:
|
|
335
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
336
|
+
unrecognizedObjectKeys: "passthrough",
|
|
337
|
+
allowUnrecognizedUnionMembers: true,
|
|
338
|
+
allowUnrecognizedEnumValues: true,
|
|
339
|
+
skipValidation: true,
|
|
340
|
+
breadcrumbsPrefix: ["response"],
|
|
341
|
+
}), _response.rawResponse);
|
|
342
|
+
case 422:
|
|
343
|
+
throw new AgentMail.UnprocessableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
344
|
+
unrecognizedObjectKeys: "passthrough",
|
|
345
|
+
allowUnrecognizedUnionMembers: true,
|
|
346
|
+
allowUnrecognizedEnumValues: true,
|
|
347
|
+
skipValidation: true,
|
|
348
|
+
breadcrumbsPrefix: ["response"],
|
|
349
|
+
}), _response.rawResponse);
|
|
350
|
+
default:
|
|
351
|
+
throw new errors.AgentMailError({
|
|
352
|
+
statusCode: _response.error.statusCode,
|
|
353
|
+
body: _response.error.body,
|
|
354
|
+
rawResponse: _response.rawResponse,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PATCH", "/v0/pods/{pod_id}/threads/{thread_id}");
|
|
359
|
+
});
|
|
360
|
+
}
|
|
271
361
|
/**
|
|
272
362
|
* Moves the thread to trash by adding a trash label to all messages. If the thread is already in trash, it will be permanently deleted. Use `permanent=true` to force permanent deletion.
|
|
273
363
|
*
|
|
@@ -44,6 +44,22 @@ export declare class ThreadsClient {
|
|
|
44
44
|
*/
|
|
45
45
|
getAttachment(thread_id: AgentMail.ThreadId, attachment_id: AgentMail.AttachmentId, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.AttachmentResponse>;
|
|
46
46
|
private __getAttachment;
|
|
47
|
+
/**
|
|
48
|
+
* Updates thread labels. Cannot add or remove system labels (sent, received, bounced, etc.). Rejects requests with a `422` for threads with 100 or more messages.
|
|
49
|
+
*
|
|
50
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
51
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
52
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
53
|
+
*
|
|
54
|
+
* @throws {@link AgentMail.ValidationError}
|
|
55
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
56
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* await client.threads.update("thread_id", {})
|
|
60
|
+
*/
|
|
61
|
+
update(thread_id: AgentMail.ThreadId, request: AgentMail.UpdateThreadRequest, requestOptions?: ThreadsClient.RequestOptions): core.HttpResponsePromise<AgentMail.UpdateThreadResponse>;
|
|
62
|
+
private __update;
|
|
47
63
|
/**
|
|
48
64
|
* Moves the thread to trash by adding a trash label to all messages. If the thread is already in trash, it will be permanently deleted. Use `permanent=true` to force permanent deletion.
|
|
49
65
|
*
|
|
@@ -265,6 +265,95 @@ class ThreadsClient {
|
|
|
265
265
|
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v0/threads/{thread_id}/attachments/{attachment_id}");
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Updates thread labels. Cannot add or remove system labels (sent, received, bounced, etc.). Rejects requests with a `422` for threads with 100 or more messages.
|
|
270
|
+
*
|
|
271
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
272
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
273
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
274
|
+
*
|
|
275
|
+
* @throws {@link AgentMail.ValidationError}
|
|
276
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
277
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* await client.threads.update("thread_id", {})
|
|
281
|
+
*/
|
|
282
|
+
update(thread_id, request, requestOptions) {
|
|
283
|
+
return core.HttpResponsePromise.fromPromise(this.__update(thread_id, request, requestOptions));
|
|
284
|
+
}
|
|
285
|
+
__update(thread_id, request, requestOptions) {
|
|
286
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
287
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
288
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
289
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
290
|
+
const _response = yield core.fetcher({
|
|
291
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
|
|
292
|
+
.http, `/v0/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
|
|
293
|
+
method: "PATCH",
|
|
294
|
+
headers: _headers,
|
|
295
|
+
contentType: "application/json",
|
|
296
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
297
|
+
requestType: "json",
|
|
298
|
+
body: serializers.UpdateThreadRequest.jsonOrThrow(request, {
|
|
299
|
+
unrecognizedObjectKeys: "strip",
|
|
300
|
+
omitUndefined: true,
|
|
301
|
+
}),
|
|
302
|
+
timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
|
|
303
|
+
maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
|
|
304
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
305
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
306
|
+
logging: this._options.logging,
|
|
307
|
+
});
|
|
308
|
+
if (_response.ok) {
|
|
309
|
+
return {
|
|
310
|
+
data: serializers.UpdateThreadResponse.parseOrThrow(_response.body, {
|
|
311
|
+
unrecognizedObjectKeys: "passthrough",
|
|
312
|
+
allowUnrecognizedUnionMembers: true,
|
|
313
|
+
allowUnrecognizedEnumValues: true,
|
|
314
|
+
skipValidation: true,
|
|
315
|
+
breadcrumbsPrefix: ["response"],
|
|
316
|
+
}),
|
|
317
|
+
rawResponse: _response.rawResponse,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
if (_response.error.reason === "status-code") {
|
|
321
|
+
switch (_response.error.statusCode) {
|
|
322
|
+
case 400:
|
|
323
|
+
throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
|
|
324
|
+
unrecognizedObjectKeys: "passthrough",
|
|
325
|
+
allowUnrecognizedUnionMembers: true,
|
|
326
|
+
allowUnrecognizedEnumValues: true,
|
|
327
|
+
skipValidation: true,
|
|
328
|
+
breadcrumbsPrefix: ["response"],
|
|
329
|
+
}), _response.rawResponse);
|
|
330
|
+
case 404:
|
|
331
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
332
|
+
unrecognizedObjectKeys: "passthrough",
|
|
333
|
+
allowUnrecognizedUnionMembers: true,
|
|
334
|
+
allowUnrecognizedEnumValues: true,
|
|
335
|
+
skipValidation: true,
|
|
336
|
+
breadcrumbsPrefix: ["response"],
|
|
337
|
+
}), _response.rawResponse);
|
|
338
|
+
case 422:
|
|
339
|
+
throw new AgentMail.UnprocessableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
340
|
+
unrecognizedObjectKeys: "passthrough",
|
|
341
|
+
allowUnrecognizedUnionMembers: true,
|
|
342
|
+
allowUnrecognizedEnumValues: true,
|
|
343
|
+
skipValidation: true,
|
|
344
|
+
breadcrumbsPrefix: ["response"],
|
|
345
|
+
}), _response.rawResponse);
|
|
346
|
+
default:
|
|
347
|
+
throw new errors.AgentMailError({
|
|
348
|
+
statusCode: _response.error.statusCode,
|
|
349
|
+
body: _response.error.body,
|
|
350
|
+
rawResponse: _response.rawResponse,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PATCH", "/v0/threads/{thread_id}");
|
|
355
|
+
});
|
|
356
|
+
}
|
|
268
357
|
/**
|
|
269
358
|
* Moves the thread to trash by adding a trash label to all messages. If the thread is already in trash, it will be permanently deleted. Use `permanent=true` to force permanent deletion.
|
|
270
359
|
*
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface UpdateThreadRequest {
|
|
2
|
+
/** Labels to add to thread. Cannot be system labels. */
|
|
3
|
+
addLabels?: string[];
|
|
4
|
+
/** Labels to remove from thread. Cannot be system labels. Takes priority over `add_labels` (in the event of duplicate labels passed in). */
|
|
5
|
+
removeLabels?: string[];
|
|
6
|
+
}
|
|
@@ -32,3 +32,5 @@ __exportStar(require("./ThreadSize.js"), exports);
|
|
|
32
32
|
__exportStar(require("./ThreadSubject.js"), exports);
|
|
33
33
|
__exportStar(require("./ThreadTimestamp.js"), exports);
|
|
34
34
|
__exportStar(require("./ThreadUpdatedAt.js"), exports);
|
|
35
|
+
__exportStar(require("./UpdateThreadRequest.js"), exports);
|
|
36
|
+
__exportStar(require("./UpdateThreadResponse.js"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as AgentMail from "../../../../api/index.js";
|
|
2
|
+
import * as core from "../../../../core/index.js";
|
|
3
|
+
import type * as serializers from "../../../index.js";
|
|
4
|
+
import { MessageId } from "./MessageId.js";
|
|
5
|
+
import { MessageLabels } from "./MessageLabels.js";
|
|
6
|
+
export declare const UpdateMessageResponse: core.serialization.ObjectSchema<serializers.UpdateMessageResponse.Raw, AgentMail.UpdateMessageResponse>;
|
|
7
|
+
export declare namespace UpdateMessageResponse {
|
|
8
|
+
interface Raw {
|
|
9
|
+
message_id: MessageId.Raw;
|
|
10
|
+
labels: MessageLabels.Raw;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.UpdateMessageResponse = void 0;
|
|
38
|
+
const core = __importStar(require("../../../../core/index.js"));
|
|
39
|
+
const MessageId_js_1 = require("./MessageId.js");
|
|
40
|
+
const MessageLabels_js_1 = require("./MessageLabels.js");
|
|
41
|
+
exports.UpdateMessageResponse = core.serialization.object({
|
|
42
|
+
messageId: core.serialization.property("message_id", MessageId_js_1.MessageId),
|
|
43
|
+
labels: MessageLabels_js_1.MessageLabels,
|
|
44
|
+
});
|
|
@@ -50,3 +50,4 @@ __exportStar(require("./SendMessageRequest.js"), exports);
|
|
|
50
50
|
__exportStar(require("./SendMessageResponse.js"), exports);
|
|
51
51
|
__exportStar(require("./SendMessageTo.js"), exports);
|
|
52
52
|
__exportStar(require("./UpdateMessageRequest.js"), exports);
|
|
53
|
+
__exportStar(require("./UpdateMessageResponse.js"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as AgentMail from "../../../../api/index.js";
|
|
2
|
+
import * as core from "../../../../core/index.js";
|
|
3
|
+
import type * as serializers from "../../../index.js";
|
|
4
|
+
export declare const UpdateThreadRequest: core.serialization.ObjectSchema<serializers.UpdateThreadRequest.Raw, AgentMail.UpdateThreadRequest>;
|
|
5
|
+
export declare namespace UpdateThreadRequest {
|
|
6
|
+
interface Raw {
|
|
7
|
+
add_labels?: string[] | null;
|
|
8
|
+
remove_labels?: string[] | null;
|
|
9
|
+
}
|
|
10
|
+
}
|