agentmail 0.0.64 → 0.0.67
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/README.md +20 -0
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/domains/client/Client.d.ts +5 -5
- package/dist/cjs/api/resources/domains/client/Client.js +66 -55
- package/dist/cjs/api/resources/drafts/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/drafts/client/Client.js +83 -70
- package/dist/cjs/api/resources/inboxes/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/client/Client.js +62 -52
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +83 -70
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +83 -70
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +83 -70
- package/dist/cjs/api/resources/threads/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/threads/client/Client.js +83 -70
- package/dist/cjs/api/resources/webhooks/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/webhooks/client/Client.js +62 -52
- package/dist/cjs/core/index.d.ts +2 -0
- package/dist/cjs/core/index.js +2 -0
- package/dist/cjs/core/pagination/Page.d.ts +32 -0
- package/dist/cjs/core/pagination/Page.js +100 -0
- package/dist/cjs/core/pagination/Pageable.d.ts +14 -0
- package/dist/cjs/core/pagination/Pageable.js +10 -0
- package/dist/cjs/core/pagination/index.d.ts +2 -0
- package/dist/cjs/core/pagination/index.js +7 -0
- package/dist/cjs/core/utils/index.d.ts +1 -0
- package/dist/cjs/core/utils/index.js +5 -0
- package/dist/cjs/core/utils/setObjectProperty.d.ts +11 -0
- package/dist/cjs/core/utils/setObjectProperty.js +42 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/domains/client/Client.d.mts +5 -5
- package/dist/esm/api/resources/domains/client/Client.mjs +66 -55
- package/dist/esm/api/resources/drafts/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/drafts/client/Client.mjs +83 -70
- package/dist/esm/api/resources/inboxes/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/client/Client.mjs +62 -52
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +83 -70
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +83 -70
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +83 -70
- package/dist/esm/api/resources/threads/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/threads/client/Client.mjs +83 -70
- package/dist/esm/api/resources/webhooks/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/webhooks/client/Client.mjs +62 -52
- package/dist/esm/core/index.d.mts +2 -0
- package/dist/esm/core/index.mjs +2 -0
- package/dist/esm/core/pagination/Page.d.mts +32 -0
- package/dist/esm/core/pagination/Page.mjs +96 -0
- package/dist/esm/core/pagination/Pageable.d.mts +14 -0
- package/dist/esm/core/pagination/Pageable.mjs +6 -0
- package/dist/esm/core/pagination/index.d.mts +2 -0
- package/dist/esm/core/pagination/index.mjs +2 -0
- package/dist/esm/core/utils/index.d.mts +1 -0
- package/dist/esm/core/utils/index.mjs +1 -0
- package/dist/esm/core/utils/setObjectProperty.d.mts +11 -0
- package/dist/esm/core/utils/setObjectProperty.mjs +39 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +92 -19
package/README.md
CHANGED
|
@@ -64,6 +64,26 @@ try {
|
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
## Pagination
|
|
68
|
+
|
|
69
|
+
List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { AgentMailClient } from "agentmail";
|
|
73
|
+
|
|
74
|
+
const client = new AgentMailClient({ apiKey: "YOUR_API_KEY" });
|
|
75
|
+
const response = await client.inboxes.list();
|
|
76
|
+
for await (const item of response) {
|
|
77
|
+
console.log(item);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Or you can manually iterate page-by-page
|
|
81
|
+
let page = await client.inboxes.list();
|
|
82
|
+
while (page.hasNextPage()) {
|
|
83
|
+
page = page.getNextPage();
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
67
87
|
## Advanced
|
|
68
88
|
|
|
69
89
|
### Additional Headers
|
package/dist/cjs/Client.js
CHANGED
|
@@ -51,8 +51,8 @@ class AgentMailClient {
|
|
|
51
51
|
this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
|
|
52
52
|
"X-Fern-Language": "JavaScript",
|
|
53
53
|
"X-Fern-SDK-Name": "agentmail",
|
|
54
|
-
"X-Fern-SDK-Version": "0.0.
|
|
55
|
-
"User-Agent": "agentmail/0.0.
|
|
54
|
+
"X-Fern-SDK-Version": "0.0.67",
|
|
55
|
+
"User-Agent": "agentmail/0.0.67",
|
|
56
56
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
57
57
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
58
58
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -36,8 +36,7 @@ export declare class Domains {
|
|
|
36
36
|
* @example
|
|
37
37
|
* await client.domains.list()
|
|
38
38
|
*/
|
|
39
|
-
list(request?: AgentMail.ListDomainsRequest, requestOptions?: Domains.RequestOptions): core.
|
|
40
|
-
private __list;
|
|
39
|
+
list(request?: AgentMail.ListDomainsRequest, requestOptions?: Domains.RequestOptions): Promise<core.Page<AgentMail.DomainSummary>>;
|
|
41
40
|
/**
|
|
42
41
|
* @param {AgentMail.DomainId} domain
|
|
43
42
|
* @param {Domains.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -45,7 +44,7 @@ export declare class Domains {
|
|
|
45
44
|
* @throws {@link AgentMail.NotFoundError}
|
|
46
45
|
*
|
|
47
46
|
* @example
|
|
48
|
-
* await client.domains.get("
|
|
47
|
+
* await client.domains.get("domain")
|
|
49
48
|
*/
|
|
50
49
|
get(domain: AgentMail.DomainId, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<AgentMail.Domain>;
|
|
51
50
|
private __get;
|
|
@@ -57,7 +56,8 @@ export declare class Domains {
|
|
|
57
56
|
*
|
|
58
57
|
* @example
|
|
59
58
|
* await client.domains.create({
|
|
60
|
-
* domain: "
|
|
59
|
+
* domain: "domain",
|
|
60
|
+
* feedbackEnabled: undefined
|
|
61
61
|
* })
|
|
62
62
|
*/
|
|
63
63
|
create(request: AgentMail.CreateDomainRequest, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<AgentMail.CreateDomainResponse>;
|
|
@@ -69,7 +69,7 @@ export declare class Domains {
|
|
|
69
69
|
* @throws {@link AgentMail.NotFoundError}
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
|
-
* await client.domains.delete("
|
|
72
|
+
* await client.domains.delete("domain")
|
|
73
73
|
*/
|
|
74
74
|
delete(domain: AgentMail.DomainId, requestOptions?: Domains.RequestOptions): core.HttpResponsePromise<void>;
|
|
75
75
|
private __delete;
|
|
@@ -63,64 +63,74 @@ class Domains {
|
|
|
63
63
|
* @example
|
|
64
64
|
* await client.domains.list()
|
|
65
65
|
*/
|
|
66
|
-
list(
|
|
67
|
-
return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
|
|
68
|
-
}
|
|
69
|
-
__list() {
|
|
66
|
+
list() {
|
|
70
67
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (_response.ok) {
|
|
91
|
-
return {
|
|
92
|
-
data: serializers.ListDomainsResponse.parseOrThrow(_response.body, {
|
|
93
|
-
unrecognizedObjectKeys: "passthrough",
|
|
94
|
-
allowUnrecognizedUnionMembers: true,
|
|
95
|
-
allowUnrecognizedEnumValues: true,
|
|
96
|
-
skipValidation: true,
|
|
97
|
-
breadcrumbsPrefix: ["response"],
|
|
98
|
-
}),
|
|
99
|
-
rawResponse: _response.rawResponse,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
if (_response.error.reason === "status-code") {
|
|
103
|
-
throw new errors.AgentMailError({
|
|
104
|
-
statusCode: _response.error.statusCode,
|
|
105
|
-
body: _response.error.body,
|
|
106
|
-
rawResponse: _response.rawResponse,
|
|
68
|
+
const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
var _a, _b, _c;
|
|
70
|
+
const { limit, pageToken } = request;
|
|
71
|
+
const _queryParams = {};
|
|
72
|
+
if (limit != null) {
|
|
73
|
+
_queryParams["limit"] = limit.toString();
|
|
74
|
+
}
|
|
75
|
+
if (pageToken != null) {
|
|
76
|
+
_queryParams["page_token"] = pageToken;
|
|
77
|
+
}
|
|
78
|
+
let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
79
|
+
const _response = yield core.fetcher({
|
|
80
|
+
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.Production).http, "/v0/domains"),
|
|
81
|
+
method: "GET",
|
|
82
|
+
headers: _headers,
|
|
83
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
84
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
85
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
86
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
107
87
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
88
|
+
if (_response.ok) {
|
|
89
|
+
return {
|
|
90
|
+
data: serializers.ListDomainsResponse.parseOrThrow(_response.body, {
|
|
91
|
+
unrecognizedObjectKeys: "passthrough",
|
|
92
|
+
allowUnrecognizedUnionMembers: true,
|
|
93
|
+
allowUnrecognizedEnumValues: true,
|
|
94
|
+
skipValidation: true,
|
|
95
|
+
breadcrumbsPrefix: ["response"],
|
|
96
|
+
}),
|
|
114
97
|
rawResponse: _response.rawResponse,
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
case "unknown":
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (_response.error.reason === "status-code") {
|
|
119
101
|
throw new errors.AgentMailError({
|
|
120
|
-
|
|
102
|
+
statusCode: _response.error.statusCode,
|
|
103
|
+
body: _response.error.body,
|
|
121
104
|
rawResponse: _response.rawResponse,
|
|
122
105
|
});
|
|
123
|
-
|
|
106
|
+
}
|
|
107
|
+
switch (_response.error.reason) {
|
|
108
|
+
case "non-json":
|
|
109
|
+
throw new errors.AgentMailError({
|
|
110
|
+
statusCode: _response.error.statusCode,
|
|
111
|
+
body: _response.error.rawBody,
|
|
112
|
+
rawResponse: _response.rawResponse,
|
|
113
|
+
});
|
|
114
|
+
case "timeout":
|
|
115
|
+
throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/domains.");
|
|
116
|
+
case "unknown":
|
|
117
|
+
throw new errors.AgentMailError({
|
|
118
|
+
message: _response.error.errorMessage,
|
|
119
|
+
rawResponse: _response.rawResponse,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
123
|
+
const dataWithRawResponse = yield list(request).withRawResponse();
|
|
124
|
+
return new core.Pageable({
|
|
125
|
+
response: dataWithRawResponse.data,
|
|
126
|
+
rawResponse: dataWithRawResponse.rawResponse,
|
|
127
|
+
hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
|
|
128
|
+
!(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
|
|
129
|
+
getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.domains) !== null && _a !== void 0 ? _a : []; },
|
|
130
|
+
loadPage: (response) => {
|
|
131
|
+
return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
|
|
132
|
+
},
|
|
133
|
+
});
|
|
124
134
|
});
|
|
125
135
|
}
|
|
126
136
|
/**
|
|
@@ -130,7 +140,7 @@ class Domains {
|
|
|
130
140
|
* @throws {@link AgentMail.NotFoundError}
|
|
131
141
|
*
|
|
132
142
|
* @example
|
|
133
|
-
* await client.domains.get("
|
|
143
|
+
* await client.domains.get("domain")
|
|
134
144
|
*/
|
|
135
145
|
get(domain, requestOptions) {
|
|
136
146
|
return core.HttpResponsePromise.fromPromise(this.__get(domain, requestOptions));
|
|
@@ -203,7 +213,8 @@ class Domains {
|
|
|
203
213
|
*
|
|
204
214
|
* @example
|
|
205
215
|
* await client.domains.create({
|
|
206
|
-
* domain: "
|
|
216
|
+
* domain: "domain",
|
|
217
|
+
* feedbackEnabled: undefined
|
|
207
218
|
* })
|
|
208
219
|
*/
|
|
209
220
|
create(request, requestOptions) {
|
|
@@ -282,7 +293,7 @@ class Domains {
|
|
|
282
293
|
* @throws {@link AgentMail.NotFoundError}
|
|
283
294
|
*
|
|
284
295
|
* @example
|
|
285
|
-
* await client.domains.delete("
|
|
296
|
+
* await client.domains.delete("domain")
|
|
286
297
|
*/
|
|
287
298
|
delete(domain, requestOptions) {
|
|
288
299
|
return core.HttpResponsePromise.fromPromise(this.__delete(domain, requestOptions));
|
|
@@ -38,8 +38,7 @@ export declare class Drafts {
|
|
|
38
38
|
* @example
|
|
39
39
|
* await client.drafts.list()
|
|
40
40
|
*/
|
|
41
|
-
list(request?: AgentMail.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): core.
|
|
42
|
-
private __list;
|
|
41
|
+
list(request?: AgentMail.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): Promise<core.Page<AgentMail.DraftItem>>;
|
|
43
42
|
/**
|
|
44
43
|
* @param {AgentMail.DraftId} draftId
|
|
45
44
|
* @param {Drafts.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -66,87 +66,100 @@ class Drafts {
|
|
|
66
66
|
* @example
|
|
67
67
|
* await client.drafts.list()
|
|
68
68
|
*/
|
|
69
|
-
list(
|
|
70
|
-
return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
|
|
71
|
-
}
|
|
72
|
-
__list() {
|
|
69
|
+
list() {
|
|
73
70
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
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
|
-
headers:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
breadcrumbsPrefix: ["response"],
|
|
113
|
-
}),
|
|
114
|
-
rawResponse: _response.rawResponse,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
if (_response.error.reason === "status-code") {
|
|
118
|
-
switch (_response.error.statusCode) {
|
|
119
|
-
case 404:
|
|
120
|
-
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
71
|
+
const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
var _a, _b, _c;
|
|
73
|
+
const { limit, pageToken, labels, before, after, ascending } = request;
|
|
74
|
+
const _queryParams = {};
|
|
75
|
+
if (limit != null) {
|
|
76
|
+
_queryParams["limit"] = limit.toString();
|
|
77
|
+
}
|
|
78
|
+
if (pageToken != null) {
|
|
79
|
+
_queryParams["page_token"] = pageToken;
|
|
80
|
+
}
|
|
81
|
+
if (labels != null) {
|
|
82
|
+
_queryParams["labels"] = (0, json_js_1.toJson)(serializers.Labels.jsonOrThrow(labels, {
|
|
83
|
+
unrecognizedObjectKeys: "strip",
|
|
84
|
+
omitUndefined: true,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
if (before != null) {
|
|
88
|
+
_queryParams["before"] = before.toISOString();
|
|
89
|
+
}
|
|
90
|
+
if (after != null) {
|
|
91
|
+
_queryParams["after"] = after.toISOString();
|
|
92
|
+
}
|
|
93
|
+
if (ascending != null) {
|
|
94
|
+
_queryParams["ascending"] = ascending.toString();
|
|
95
|
+
}
|
|
96
|
+
let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
97
|
+
const _response = yield core.fetcher({
|
|
98
|
+
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.Production).http, "/v0/drafts"),
|
|
99
|
+
method: "GET",
|
|
100
|
+
headers: _headers,
|
|
101
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
102
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
103
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
104
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
105
|
+
});
|
|
106
|
+
if (_response.ok) {
|
|
107
|
+
return {
|
|
108
|
+
data: serializers.ListDraftsResponse.parseOrThrow(_response.body, {
|
|
121
109
|
unrecognizedObjectKeys: "passthrough",
|
|
122
110
|
allowUnrecognizedUnionMembers: true,
|
|
123
111
|
allowUnrecognizedEnumValues: true,
|
|
124
112
|
skipValidation: true,
|
|
125
113
|
breadcrumbsPrefix: ["response"],
|
|
126
|
-
}),
|
|
127
|
-
|
|
114
|
+
}),
|
|
115
|
+
rawResponse: _response.rawResponse,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (_response.error.reason === "status-code") {
|
|
119
|
+
switch (_response.error.statusCode) {
|
|
120
|
+
case 404:
|
|
121
|
+
throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
122
|
+
unrecognizedObjectKeys: "passthrough",
|
|
123
|
+
allowUnrecognizedUnionMembers: true,
|
|
124
|
+
allowUnrecognizedEnumValues: true,
|
|
125
|
+
skipValidation: true,
|
|
126
|
+
breadcrumbsPrefix: ["response"],
|
|
127
|
+
}), _response.rawResponse);
|
|
128
|
+
default:
|
|
129
|
+
throw new errors.AgentMailError({
|
|
130
|
+
statusCode: _response.error.statusCode,
|
|
131
|
+
body: _response.error.body,
|
|
132
|
+
rawResponse: _response.rawResponse,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
switch (_response.error.reason) {
|
|
137
|
+
case "non-json":
|
|
128
138
|
throw new errors.AgentMailError({
|
|
129
139
|
statusCode: _response.error.statusCode,
|
|
130
|
-
body: _response.error.
|
|
140
|
+
body: _response.error.rawBody,
|
|
141
|
+
rawResponse: _response.rawResponse,
|
|
142
|
+
});
|
|
143
|
+
case "timeout":
|
|
144
|
+
throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/drafts.");
|
|
145
|
+
case "unknown":
|
|
146
|
+
throw new errors.AgentMailError({
|
|
147
|
+
message: _response.error.errorMessage,
|
|
131
148
|
rawResponse: _response.rawResponse,
|
|
132
149
|
});
|
|
133
150
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
message: _response.error.errorMessage,
|
|
147
|
-
rawResponse: _response.rawResponse,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
151
|
+
}));
|
|
152
|
+
const dataWithRawResponse = yield list(request).withRawResponse();
|
|
153
|
+
return new core.Pageable({
|
|
154
|
+
response: dataWithRawResponse.data,
|
|
155
|
+
rawResponse: dataWithRawResponse.rawResponse,
|
|
156
|
+
hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
|
|
157
|
+
!(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
|
|
158
|
+
getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.drafts) !== null && _a !== void 0 ? _a : []; },
|
|
159
|
+
loadPage: (response) => {
|
|
160
|
+
return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
|
|
161
|
+
},
|
|
162
|
+
});
|
|
150
163
|
});
|
|
151
164
|
}
|
|
152
165
|
/**
|
|
@@ -48,8 +48,7 @@ export declare class Inboxes {
|
|
|
48
48
|
* @example
|
|
49
49
|
* await client.inboxes.list()
|
|
50
50
|
*/
|
|
51
|
-
list(request?: AgentMail.inboxes.ListInboxesRequest, requestOptions?: Inboxes.RequestOptions): core.
|
|
52
|
-
private __list;
|
|
51
|
+
list(request?: AgentMail.inboxes.ListInboxesRequest, requestOptions?: Inboxes.RequestOptions): Promise<core.Page<AgentMail.inboxes.Inbox>>;
|
|
53
52
|
/**
|
|
54
53
|
* @param {AgentMail.inboxes.InboxId} inboxId
|
|
55
54
|
* @param {Inboxes.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -83,64 +83,74 @@ class Inboxes {
|
|
|
83
83
|
* @example
|
|
84
84
|
* await client.inboxes.list()
|
|
85
85
|
*/
|
|
86
|
-
list(
|
|
87
|
-
return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
|
|
88
|
-
}
|
|
89
|
-
__list() {
|
|
86
|
+
list() {
|
|
90
87
|
return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (_response.ok) {
|
|
111
|
-
return {
|
|
112
|
-
data: serializers.inboxes.ListInboxesResponse.parseOrThrow(_response.body, {
|
|
113
|
-
unrecognizedObjectKeys: "passthrough",
|
|
114
|
-
allowUnrecognizedUnionMembers: true,
|
|
115
|
-
allowUnrecognizedEnumValues: true,
|
|
116
|
-
skipValidation: true,
|
|
117
|
-
breadcrumbsPrefix: ["response"],
|
|
118
|
-
}),
|
|
119
|
-
rawResponse: _response.rawResponse,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
if (_response.error.reason === "status-code") {
|
|
123
|
-
throw new errors.AgentMailError({
|
|
124
|
-
statusCode: _response.error.statusCode,
|
|
125
|
-
body: _response.error.body,
|
|
126
|
-
rawResponse: _response.rawResponse,
|
|
88
|
+
const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
var _a, _b, _c;
|
|
90
|
+
const { limit, pageToken } = request;
|
|
91
|
+
const _queryParams = {};
|
|
92
|
+
if (limit != null) {
|
|
93
|
+
_queryParams["limit"] = limit.toString();
|
|
94
|
+
}
|
|
95
|
+
if (pageToken != null) {
|
|
96
|
+
_queryParams["page_token"] = pageToken;
|
|
97
|
+
}
|
|
98
|
+
let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
99
|
+
const _response = yield core.fetcher({
|
|
100
|
+
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.Production).http, "/v0/inboxes"),
|
|
101
|
+
method: "GET",
|
|
102
|
+
headers: _headers,
|
|
103
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
104
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
105
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
106
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
127
107
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
108
|
+
if (_response.ok) {
|
|
109
|
+
return {
|
|
110
|
+
data: serializers.inboxes.ListInboxesResponse.parseOrThrow(_response.body, {
|
|
111
|
+
unrecognizedObjectKeys: "passthrough",
|
|
112
|
+
allowUnrecognizedUnionMembers: true,
|
|
113
|
+
allowUnrecognizedEnumValues: true,
|
|
114
|
+
skipValidation: true,
|
|
115
|
+
breadcrumbsPrefix: ["response"],
|
|
116
|
+
}),
|
|
134
117
|
rawResponse: _response.rawResponse,
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
case "unknown":
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (_response.error.reason === "status-code") {
|
|
139
121
|
throw new errors.AgentMailError({
|
|
140
|
-
|
|
122
|
+
statusCode: _response.error.statusCode,
|
|
123
|
+
body: _response.error.body,
|
|
141
124
|
rawResponse: _response.rawResponse,
|
|
142
125
|
});
|
|
143
|
-
|
|
126
|
+
}
|
|
127
|
+
switch (_response.error.reason) {
|
|
128
|
+
case "non-json":
|
|
129
|
+
throw new errors.AgentMailError({
|
|
130
|
+
statusCode: _response.error.statusCode,
|
|
131
|
+
body: _response.error.rawBody,
|
|
132
|
+
rawResponse: _response.rawResponse,
|
|
133
|
+
});
|
|
134
|
+
case "timeout":
|
|
135
|
+
throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/inboxes.");
|
|
136
|
+
case "unknown":
|
|
137
|
+
throw new errors.AgentMailError({
|
|
138
|
+
message: _response.error.errorMessage,
|
|
139
|
+
rawResponse: _response.rawResponse,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}));
|
|
143
|
+
const dataWithRawResponse = yield list(request).withRawResponse();
|
|
144
|
+
return new core.Pageable({
|
|
145
|
+
response: dataWithRawResponse.data,
|
|
146
|
+
rawResponse: dataWithRawResponse.rawResponse,
|
|
147
|
+
hasNextPage: (response) => (response === null || response === void 0 ? void 0 : response.nextPageToken) != null &&
|
|
148
|
+
!(typeof (response === null || response === void 0 ? void 0 : response.nextPageToken) === "string" && (response === null || response === void 0 ? void 0 : response.nextPageToken) === ""),
|
|
149
|
+
getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.inboxes) !== null && _a !== void 0 ? _a : []; },
|
|
150
|
+
loadPage: (response) => {
|
|
151
|
+
return list(core.setObjectProperty(request, "pageToken", response === null || response === void 0 ? void 0 : response.nextPageToken));
|
|
152
|
+
},
|
|
153
|
+
});
|
|
144
154
|
});
|
|
145
155
|
}
|
|
146
156
|
/**
|
|
@@ -39,8 +39,7 @@ export declare class Drafts {
|
|
|
39
39
|
* @example
|
|
40
40
|
* await client.inboxes.drafts.list("inbox_id")
|
|
41
41
|
*/
|
|
42
|
-
list(inboxId: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): core.
|
|
43
|
-
private __list;
|
|
42
|
+
list(inboxId: AgentMail.inboxes.InboxId, request?: AgentMail.inboxes.ListDraftsRequest, requestOptions?: Drafts.RequestOptions): Promise<core.Page<AgentMail.DraftItem>>;
|
|
44
43
|
/**
|
|
45
44
|
* @param {AgentMail.inboxes.InboxId} inboxId
|
|
46
45
|
* @param {AgentMail.DraftId} draftId
|