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
|
@@ -0,0 +1,42 @@
|
|
|
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.UpdateThreadRequest = void 0;
|
|
38
|
+
const core = __importStar(require("../../../../core/index.js"));
|
|
39
|
+
exports.UpdateThreadRequest = core.serialization.object({
|
|
40
|
+
addLabels: core.serialization.property("add_labels", core.serialization.list(core.serialization.string()).optional()),
|
|
41
|
+
removeLabels: core.serialization.property("remove_labels", core.serialization.list(core.serialization.string()).optional()),
|
|
42
|
+
});
|
|
@@ -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 { ThreadId } from "./ThreadId.js";
|
|
5
|
+
import { ThreadLabels } from "./ThreadLabels.js";
|
|
6
|
+
export declare const UpdateThreadResponse: core.serialization.ObjectSchema<serializers.UpdateThreadResponse.Raw, AgentMail.UpdateThreadResponse>;
|
|
7
|
+
export declare namespace UpdateThreadResponse {
|
|
8
|
+
interface Raw {
|
|
9
|
+
thread_id: ThreadId.Raw;
|
|
10
|
+
labels: ThreadLabels.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.UpdateThreadResponse = void 0;
|
|
38
|
+
const core = __importStar(require("../../../../core/index.js"));
|
|
39
|
+
const ThreadId_js_1 = require("./ThreadId.js");
|
|
40
|
+
const ThreadLabels_js_1 = require("./ThreadLabels.js");
|
|
41
|
+
exports.UpdateThreadResponse = core.serialization.object({
|
|
42
|
+
threadId: core.serialization.property("thread_id", ThreadId_js_1.ThreadId),
|
|
43
|
+
labels: ThreadLabels_js_1.ThreadLabels,
|
|
44
|
+
});
|
|
@@ -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);
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.4.
|
|
1
|
+
export declare const SDK_VERSION = "0.4.14";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/BaseClient.mjs
CHANGED
|
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
|
|
|
6
6
|
const headers = mergeHeaders({
|
|
7
7
|
"X-Fern-Language": "JavaScript",
|
|
8
8
|
"X-Fern-SDK-Name": "agentmail",
|
|
9
|
-
"X-Fern-SDK-Version": "0.4.
|
|
10
|
-
"User-Agent": "agentmail/0.4.
|
|
9
|
+
"X-Fern-SDK-Version": "0.4.14",
|
|
10
|
+
"User-Agent": "agentmail/0.4.14",
|
|
11
11
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
12
12
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
13
13
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as core from "../../core/index.mjs";
|
|
2
|
+
import * as errors from "../../errors/index.mjs";
|
|
3
|
+
import type * as AgentMail from "../index.mjs";
|
|
4
|
+
export declare class UnprocessableError extends errors.AgentMailError {
|
|
5
|
+
constructor(body: AgentMail.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as errors from "../../errors/index.mjs";
|
|
3
|
+
export class UnprocessableError extends errors.AgentMailError {
|
|
4
|
+
constructor(body, rawResponse) {
|
|
5
|
+
super({
|
|
6
|
+
message: "UnprocessableError",
|
|
7
|
+
statusCode: 422,
|
|
8
|
+
body: body,
|
|
9
|
+
rawResponse: rawResponse,
|
|
10
|
+
});
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
this.name = this.constructor.name;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -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
|
|
@@ -335,7 +335,7 @@ export class MessagesClient {
|
|
|
335
335
|
});
|
|
336
336
|
if (_response.ok) {
|
|
337
337
|
return {
|
|
338
|
-
data: serializers.
|
|
338
|
+
data: serializers.UpdateMessageResponse.parseOrThrow(_response.body, {
|
|
339
339
|
unrecognizedObjectKeys: "passthrough",
|
|
340
340
|
allowUnrecognizedUnionMembers: true,
|
|
341
341
|
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
|
*
|
|
@@ -232,6 +232,96 @@ export class ThreadsClient {
|
|
|
232
232
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v0/inboxes/{inbox_id}/threads/{thread_id}/attachments/{attachment_id}");
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* 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.
|
|
237
|
+
*
|
|
238
|
+
* @param {AgentMail.inboxes.InboxId} inbox_id
|
|
239
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
240
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
241
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
242
|
+
*
|
|
243
|
+
* @throws {@link AgentMail.ValidationError}
|
|
244
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
245
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* await client.inboxes.threads.update("inbox_id", "thread_id", {})
|
|
249
|
+
*/
|
|
250
|
+
update(inbox_id, thread_id, request, requestOptions) {
|
|
251
|
+
return core.HttpResponsePromise.fromPromise(this.__update(inbox_id, thread_id, request, requestOptions));
|
|
252
|
+
}
|
|
253
|
+
__update(inbox_id, thread_id, request, requestOptions) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
256
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
257
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
258
|
+
const _response = yield core.fetcher({
|
|
259
|
+
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)
|
|
260
|
+
.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 }))}`),
|
|
261
|
+
method: "PATCH",
|
|
262
|
+
headers: _headers,
|
|
263
|
+
contentType: "application/json",
|
|
264
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
265
|
+
requestType: "json",
|
|
266
|
+
body: serializers.UpdateThreadRequest.jsonOrThrow(request, {
|
|
267
|
+
unrecognizedObjectKeys: "strip",
|
|
268
|
+
omitUndefined: true,
|
|
269
|
+
}),
|
|
270
|
+
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,
|
|
271
|
+
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,
|
|
272
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
273
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
274
|
+
logging: this._options.logging,
|
|
275
|
+
});
|
|
276
|
+
if (_response.ok) {
|
|
277
|
+
return {
|
|
278
|
+
data: serializers.UpdateThreadResponse.parseOrThrow(_response.body, {
|
|
279
|
+
unrecognizedObjectKeys: "passthrough",
|
|
280
|
+
allowUnrecognizedUnionMembers: true,
|
|
281
|
+
allowUnrecognizedEnumValues: true,
|
|
282
|
+
skipValidation: true,
|
|
283
|
+
breadcrumbsPrefix: ["response"],
|
|
284
|
+
}),
|
|
285
|
+
rawResponse: _response.rawResponse,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
if (_response.error.reason === "status-code") {
|
|
289
|
+
switch (_response.error.statusCode) {
|
|
290
|
+
case 400:
|
|
291
|
+
throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
|
|
292
|
+
unrecognizedObjectKeys: "passthrough",
|
|
293
|
+
allowUnrecognizedUnionMembers: true,
|
|
294
|
+
allowUnrecognizedEnumValues: true,
|
|
295
|
+
skipValidation: true,
|
|
296
|
+
breadcrumbsPrefix: ["response"],
|
|
297
|
+
}), _response.rawResponse);
|
|
298
|
+
case 404:
|
|
299
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
300
|
+
unrecognizedObjectKeys: "passthrough",
|
|
301
|
+
allowUnrecognizedUnionMembers: true,
|
|
302
|
+
allowUnrecognizedEnumValues: true,
|
|
303
|
+
skipValidation: true,
|
|
304
|
+
breadcrumbsPrefix: ["response"],
|
|
305
|
+
}), _response.rawResponse);
|
|
306
|
+
case 422:
|
|
307
|
+
throw new AgentMail.UnprocessableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
308
|
+
unrecognizedObjectKeys: "passthrough",
|
|
309
|
+
allowUnrecognizedUnionMembers: true,
|
|
310
|
+
allowUnrecognizedEnumValues: true,
|
|
311
|
+
skipValidation: true,
|
|
312
|
+
breadcrumbsPrefix: ["response"],
|
|
313
|
+
}), _response.rawResponse);
|
|
314
|
+
default:
|
|
315
|
+
throw new errors.AgentMailError({
|
|
316
|
+
statusCode: _response.error.statusCode,
|
|
317
|
+
body: _response.error.body,
|
|
318
|
+
rawResponse: _response.rawResponse,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v0/inboxes/{inbox_id}/threads/{thread_id}");
|
|
323
|
+
});
|
|
324
|
+
}
|
|
235
325
|
/**
|
|
236
326
|
* 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.
|
|
237
327
|
*
|
|
@@ -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
|
*
|
|
@@ -232,6 +232,96 @@ export class ThreadsClient {
|
|
|
232
232
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v0/pods/{pod_id}/threads/{thread_id}/attachments/{attachment_id}");
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* 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.
|
|
237
|
+
*
|
|
238
|
+
* @param {AgentMail.pods.PodId} pod_id
|
|
239
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
240
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
241
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
242
|
+
*
|
|
243
|
+
* @throws {@link AgentMail.ValidationError}
|
|
244
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
245
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* await client.pods.threads.update("pod_id", "thread_id", {})
|
|
249
|
+
*/
|
|
250
|
+
update(pod_id, thread_id, request, requestOptions) {
|
|
251
|
+
return core.HttpResponsePromise.fromPromise(this.__update(pod_id, thread_id, request, requestOptions));
|
|
252
|
+
}
|
|
253
|
+
__update(pod_id, thread_id, request, requestOptions) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
256
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
257
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
258
|
+
const _response = yield core.fetcher({
|
|
259
|
+
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)
|
|
260
|
+
.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 }))}`),
|
|
261
|
+
method: "PATCH",
|
|
262
|
+
headers: _headers,
|
|
263
|
+
contentType: "application/json",
|
|
264
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
265
|
+
requestType: "json",
|
|
266
|
+
body: serializers.UpdateThreadRequest.jsonOrThrow(request, {
|
|
267
|
+
unrecognizedObjectKeys: "strip",
|
|
268
|
+
omitUndefined: true,
|
|
269
|
+
}),
|
|
270
|
+
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,
|
|
271
|
+
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,
|
|
272
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
273
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
274
|
+
logging: this._options.logging,
|
|
275
|
+
});
|
|
276
|
+
if (_response.ok) {
|
|
277
|
+
return {
|
|
278
|
+
data: serializers.UpdateThreadResponse.parseOrThrow(_response.body, {
|
|
279
|
+
unrecognizedObjectKeys: "passthrough",
|
|
280
|
+
allowUnrecognizedUnionMembers: true,
|
|
281
|
+
allowUnrecognizedEnumValues: true,
|
|
282
|
+
skipValidation: true,
|
|
283
|
+
breadcrumbsPrefix: ["response"],
|
|
284
|
+
}),
|
|
285
|
+
rawResponse: _response.rawResponse,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
if (_response.error.reason === "status-code") {
|
|
289
|
+
switch (_response.error.statusCode) {
|
|
290
|
+
case 400:
|
|
291
|
+
throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
|
|
292
|
+
unrecognizedObjectKeys: "passthrough",
|
|
293
|
+
allowUnrecognizedUnionMembers: true,
|
|
294
|
+
allowUnrecognizedEnumValues: true,
|
|
295
|
+
skipValidation: true,
|
|
296
|
+
breadcrumbsPrefix: ["response"],
|
|
297
|
+
}), _response.rawResponse);
|
|
298
|
+
case 404:
|
|
299
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
300
|
+
unrecognizedObjectKeys: "passthrough",
|
|
301
|
+
allowUnrecognizedUnionMembers: true,
|
|
302
|
+
allowUnrecognizedEnumValues: true,
|
|
303
|
+
skipValidation: true,
|
|
304
|
+
breadcrumbsPrefix: ["response"],
|
|
305
|
+
}), _response.rawResponse);
|
|
306
|
+
case 422:
|
|
307
|
+
throw new AgentMail.UnprocessableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
308
|
+
unrecognizedObjectKeys: "passthrough",
|
|
309
|
+
allowUnrecognizedUnionMembers: true,
|
|
310
|
+
allowUnrecognizedEnumValues: true,
|
|
311
|
+
skipValidation: true,
|
|
312
|
+
breadcrumbsPrefix: ["response"],
|
|
313
|
+
}), _response.rawResponse);
|
|
314
|
+
default:
|
|
315
|
+
throw new errors.AgentMailError({
|
|
316
|
+
statusCode: _response.error.statusCode,
|
|
317
|
+
body: _response.error.body,
|
|
318
|
+
rawResponse: _response.rawResponse,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v0/pods/{pod_id}/threads/{thread_id}");
|
|
323
|
+
});
|
|
324
|
+
}
|
|
235
325
|
/**
|
|
236
326
|
* 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.
|
|
237
327
|
*
|
|
@@ -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
|
*
|
|
@@ -229,6 +229,95 @@ export class ThreadsClient {
|
|
|
229
229
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v0/threads/{thread_id}/attachments/{attachment_id}");
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* 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.
|
|
234
|
+
*
|
|
235
|
+
* @param {AgentMail.ThreadId} thread_id
|
|
236
|
+
* @param {AgentMail.UpdateThreadRequest} request
|
|
237
|
+
* @param {ThreadsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
238
|
+
*
|
|
239
|
+
* @throws {@link AgentMail.ValidationError}
|
|
240
|
+
* @throws {@link AgentMail.NotFoundError}
|
|
241
|
+
* @throws {@link AgentMail.UnprocessableError}
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* await client.threads.update("thread_id", {})
|
|
245
|
+
*/
|
|
246
|
+
update(thread_id, request, requestOptions) {
|
|
247
|
+
return core.HttpResponsePromise.fromPromise(this.__update(thread_id, request, requestOptions));
|
|
248
|
+
}
|
|
249
|
+
__update(thread_id, request, requestOptions) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
252
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
253
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
254
|
+
const _response = yield core.fetcher({
|
|
255
|
+
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)
|
|
256
|
+
.http, `/v0/threads/${core.url.encodePathParam(serializers.ThreadId.jsonOrThrow(thread_id, { omitUndefined: true }))}`),
|
|
257
|
+
method: "PATCH",
|
|
258
|
+
headers: _headers,
|
|
259
|
+
contentType: "application/json",
|
|
260
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
261
|
+
requestType: "json",
|
|
262
|
+
body: serializers.UpdateThreadRequest.jsonOrThrow(request, {
|
|
263
|
+
unrecognizedObjectKeys: "strip",
|
|
264
|
+
omitUndefined: true,
|
|
265
|
+
}),
|
|
266
|
+
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,
|
|
267
|
+
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,
|
|
268
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
269
|
+
fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
|
|
270
|
+
logging: this._options.logging,
|
|
271
|
+
});
|
|
272
|
+
if (_response.ok) {
|
|
273
|
+
return {
|
|
274
|
+
data: serializers.UpdateThreadResponse.parseOrThrow(_response.body, {
|
|
275
|
+
unrecognizedObjectKeys: "passthrough",
|
|
276
|
+
allowUnrecognizedUnionMembers: true,
|
|
277
|
+
allowUnrecognizedEnumValues: true,
|
|
278
|
+
skipValidation: true,
|
|
279
|
+
breadcrumbsPrefix: ["response"],
|
|
280
|
+
}),
|
|
281
|
+
rawResponse: _response.rawResponse,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
if (_response.error.reason === "status-code") {
|
|
285
|
+
switch (_response.error.statusCode) {
|
|
286
|
+
case 400:
|
|
287
|
+
throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
|
|
288
|
+
unrecognizedObjectKeys: "passthrough",
|
|
289
|
+
allowUnrecognizedUnionMembers: true,
|
|
290
|
+
allowUnrecognizedEnumValues: true,
|
|
291
|
+
skipValidation: true,
|
|
292
|
+
breadcrumbsPrefix: ["response"],
|
|
293
|
+
}), _response.rawResponse);
|
|
294
|
+
case 404:
|
|
295
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
296
|
+
unrecognizedObjectKeys: "passthrough",
|
|
297
|
+
allowUnrecognizedUnionMembers: true,
|
|
298
|
+
allowUnrecognizedEnumValues: true,
|
|
299
|
+
skipValidation: true,
|
|
300
|
+
breadcrumbsPrefix: ["response"],
|
|
301
|
+
}), _response.rawResponse);
|
|
302
|
+
case 422:
|
|
303
|
+
throw new AgentMail.UnprocessableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
304
|
+
unrecognizedObjectKeys: "passthrough",
|
|
305
|
+
allowUnrecognizedUnionMembers: true,
|
|
306
|
+
allowUnrecognizedEnumValues: true,
|
|
307
|
+
skipValidation: true,
|
|
308
|
+
breadcrumbsPrefix: ["response"],
|
|
309
|
+
}), _response.rawResponse);
|
|
310
|
+
default:
|
|
311
|
+
throw new errors.AgentMailError({
|
|
312
|
+
statusCode: _response.error.statusCode,
|
|
313
|
+
body: _response.error.body,
|
|
314
|
+
rawResponse: _response.rawResponse,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v0/threads/{thread_id}");
|
|
319
|
+
});
|
|
320
|
+
}
|
|
232
321
|
/**
|
|
233
322
|
* 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.
|
|
234
323
|
*
|
|
@@ -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
|
+
}
|