agentmail 0.0.21 → 0.0.22

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.
Files changed (168) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +5 -0
  3. package/api/resources/inboxes/client/Client.js +3 -3
  4. package/api/resources/index.d.ts +3 -0
  5. package/api/resources/index.js +4 -1
  6. package/api/resources/messages/client/Client.js +5 -5
  7. package/api/resources/threads/client/Client.js +2 -2
  8. package/api/resources/webhooks/client/Client.d.ts +71 -0
  9. package/api/resources/webhooks/client/Client.js +316 -0
  10. package/api/resources/webhooks/client/index.d.ts +1 -0
  11. package/api/resources/webhooks/client/index.js +17 -0
  12. package/api/resources/webhooks/client/requests/ListWebhooksRequest.d.ts +12 -0
  13. package/api/resources/webhooks/client/requests/ListWebhooksRequest.js +5 -0
  14. package/api/resources/webhooks/client/requests/index.d.ts +1 -0
  15. package/api/resources/webhooks/client/requests/index.js +2 -0
  16. package/api/resources/webhooks/index.d.ts +2 -0
  17. package/api/resources/webhooks/index.js +18 -0
  18. package/api/resources/webhooks/types/CreateWebhookRequest.d.ts +9 -0
  19. package/api/resources/webhooks/types/CreateWebhookRequest.js +5 -0
  20. package/api/resources/webhooks/types/EventId.d.ts +7 -0
  21. package/api/resources/webhooks/types/EventId.js +5 -0
  22. package/api/resources/webhooks/types/EventType.d.ts +7 -0
  23. package/api/resources/webhooks/types/EventType.js +9 -0
  24. package/api/resources/webhooks/types/Events.d.ts +8 -0
  25. package/api/resources/webhooks/types/Events.js +5 -0
  26. package/api/resources/webhooks/types/Inboxes.d.ts +7 -0
  27. package/api/resources/webhooks/types/Inboxes.js +5 -0
  28. package/api/resources/webhooks/types/ListWebhooksResponse.d.ts +11 -0
  29. package/api/resources/webhooks/types/ListWebhooksResponse.js +5 -0
  30. package/api/resources/webhooks/types/MessageReceivedPayload.d.ts +7 -0
  31. package/api/resources/webhooks/types/MessageReceivedPayload.js +5 -0
  32. package/api/resources/webhooks/types/Payload.d.ts +8 -0
  33. package/api/resources/webhooks/types/Payload.js +5 -0
  34. package/api/resources/webhooks/types/SvixId.d.ts +7 -0
  35. package/api/resources/webhooks/types/SvixId.js +5 -0
  36. package/api/resources/webhooks/types/SvixSignature.d.ts +7 -0
  37. package/api/resources/webhooks/types/SvixSignature.js +5 -0
  38. package/api/resources/webhooks/types/SvixTimestamp.d.ts +7 -0
  39. package/api/resources/webhooks/types/SvixTimestamp.js +5 -0
  40. package/api/resources/webhooks/types/Url.d.ts +7 -0
  41. package/api/resources/webhooks/types/Url.js +5 -0
  42. package/api/resources/webhooks/types/Webhook.d.ts +14 -0
  43. package/api/resources/webhooks/types/Webhook.js +5 -0
  44. package/api/resources/webhooks/types/WebhookId.d.ts +7 -0
  45. package/api/resources/webhooks/types/WebhookId.js +5 -0
  46. package/api/resources/webhooks/types/index.d.ts +14 -0
  47. package/api/resources/webhooks/types/index.js +30 -0
  48. package/dist/Client.d.ts +3 -0
  49. package/dist/Client.js +5 -0
  50. package/dist/api/resources/inboxes/client/Client.js +3 -3
  51. package/dist/api/resources/index.d.ts +3 -0
  52. package/dist/api/resources/index.js +4 -1
  53. package/dist/api/resources/messages/client/Client.js +5 -5
  54. package/dist/api/resources/threads/client/Client.js +2 -2
  55. package/dist/api/resources/webhooks/client/Client.d.ts +71 -0
  56. package/dist/api/resources/webhooks/client/Client.js +316 -0
  57. package/dist/api/resources/webhooks/client/index.d.ts +1 -0
  58. package/dist/api/resources/webhooks/client/index.js +17 -0
  59. package/dist/api/resources/webhooks/client/requests/ListWebhooksRequest.d.ts +12 -0
  60. package/dist/api/resources/webhooks/client/requests/ListWebhooksRequest.js +5 -0
  61. package/dist/api/resources/webhooks/client/requests/index.d.ts +1 -0
  62. package/dist/api/resources/webhooks/client/requests/index.js +2 -0
  63. package/dist/api/resources/webhooks/index.d.ts +2 -0
  64. package/dist/api/resources/webhooks/index.js +18 -0
  65. package/dist/api/resources/webhooks/types/CreateWebhookRequest.d.ts +9 -0
  66. package/dist/api/resources/webhooks/types/CreateWebhookRequest.js +5 -0
  67. package/dist/api/resources/webhooks/types/EventId.d.ts +7 -0
  68. package/dist/api/resources/webhooks/types/EventId.js +5 -0
  69. package/dist/api/resources/webhooks/types/EventType.d.ts +7 -0
  70. package/dist/api/resources/webhooks/types/EventType.js +9 -0
  71. package/dist/api/resources/webhooks/types/Events.d.ts +8 -0
  72. package/dist/api/resources/webhooks/types/Events.js +5 -0
  73. package/dist/api/resources/webhooks/types/Inboxes.d.ts +7 -0
  74. package/dist/api/resources/webhooks/types/Inboxes.js +5 -0
  75. package/dist/api/resources/webhooks/types/ListWebhooksResponse.d.ts +11 -0
  76. package/dist/api/resources/webhooks/types/ListWebhooksResponse.js +5 -0
  77. package/dist/api/resources/webhooks/types/MessageReceivedPayload.d.ts +7 -0
  78. package/dist/api/resources/webhooks/types/MessageReceivedPayload.js +5 -0
  79. package/dist/api/resources/webhooks/types/Payload.d.ts +8 -0
  80. package/dist/api/resources/webhooks/types/Payload.js +5 -0
  81. package/dist/api/resources/webhooks/types/SvixId.d.ts +7 -0
  82. package/dist/api/resources/webhooks/types/SvixId.js +5 -0
  83. package/dist/api/resources/webhooks/types/SvixSignature.d.ts +7 -0
  84. package/dist/api/resources/webhooks/types/SvixSignature.js +5 -0
  85. package/dist/api/resources/webhooks/types/SvixTimestamp.d.ts +7 -0
  86. package/dist/api/resources/webhooks/types/SvixTimestamp.js +5 -0
  87. package/dist/api/resources/webhooks/types/Url.d.ts +7 -0
  88. package/dist/api/resources/webhooks/types/Url.js +5 -0
  89. package/dist/api/resources/webhooks/types/Webhook.d.ts +14 -0
  90. package/dist/api/resources/webhooks/types/Webhook.js +5 -0
  91. package/dist/api/resources/webhooks/types/WebhookId.d.ts +7 -0
  92. package/dist/api/resources/webhooks/types/WebhookId.js +5 -0
  93. package/dist/api/resources/webhooks/types/index.d.ts +14 -0
  94. package/dist/api/resources/webhooks/types/index.js +30 -0
  95. package/dist/serialization/resources/index.d.ts +2 -0
  96. package/dist/serialization/resources/index.js +3 -1
  97. package/dist/serialization/resources/webhooks/index.d.ts +1 -0
  98. package/dist/serialization/resources/webhooks/index.js +17 -0
  99. package/dist/serialization/resources/webhooks/types/CreateWebhookRequest.d.ts +17 -0
  100. package/dist/serialization/resources/webhooks/types/CreateWebhookRequest.js +48 -0
  101. package/dist/serialization/resources/webhooks/types/EventId.d.ts +10 -0
  102. package/dist/serialization/resources/webhooks/types/EventId.js +41 -0
  103. package/dist/serialization/resources/webhooks/types/EventType.d.ts +10 -0
  104. package/dist/serialization/resources/webhooks/types/EventType.js +41 -0
  105. package/dist/serialization/resources/webhooks/types/Events.d.ts +11 -0
  106. package/dist/serialization/resources/webhooks/types/Events.js +42 -0
  107. package/dist/serialization/resources/webhooks/types/Inboxes.d.ts +10 -0
  108. package/dist/serialization/resources/webhooks/types/Inboxes.js +41 -0
  109. package/dist/serialization/resources/webhooks/types/ListWebhooksResponse.d.ts +19 -0
  110. package/dist/serialization/resources/webhooks/types/ListWebhooksResponse.js +50 -0
  111. package/dist/serialization/resources/webhooks/types/MessageReceivedPayload.d.ts +14 -0
  112. package/dist/serialization/resources/webhooks/types/MessageReceivedPayload.js +47 -0
  113. package/dist/serialization/resources/webhooks/types/Payload.d.ts +15 -0
  114. package/dist/serialization/resources/webhooks/types/Payload.js +46 -0
  115. package/dist/serialization/resources/webhooks/types/SvixId.d.ts +10 -0
  116. package/dist/serialization/resources/webhooks/types/SvixId.js +41 -0
  117. package/dist/serialization/resources/webhooks/types/SvixSignature.d.ts +10 -0
  118. package/dist/serialization/resources/webhooks/types/SvixSignature.js +41 -0
  119. package/dist/serialization/resources/webhooks/types/SvixTimestamp.d.ts +10 -0
  120. package/dist/serialization/resources/webhooks/types/SvixTimestamp.js +41 -0
  121. package/dist/serialization/resources/webhooks/types/Url.d.ts +10 -0
  122. package/dist/serialization/resources/webhooks/types/Url.js +41 -0
  123. package/dist/serialization/resources/webhooks/types/Webhook.d.ts +21 -0
  124. package/dist/serialization/resources/webhooks/types/Webhook.js +52 -0
  125. package/dist/serialization/resources/webhooks/types/WebhookId.d.ts +10 -0
  126. package/dist/serialization/resources/webhooks/types/WebhookId.js +41 -0
  127. package/dist/serialization/resources/webhooks/types/index.d.ts +14 -0
  128. package/dist/serialization/resources/webhooks/types/index.js +30 -0
  129. package/dist/version.d.ts +1 -1
  130. package/dist/version.js +1 -1
  131. package/package.json +1 -1
  132. package/reference.md +198 -0
  133. package/serialization/resources/index.d.ts +2 -0
  134. package/serialization/resources/index.js +3 -1
  135. package/serialization/resources/webhooks/index.d.ts +1 -0
  136. package/serialization/resources/webhooks/index.js +17 -0
  137. package/serialization/resources/webhooks/types/CreateWebhookRequest.d.ts +17 -0
  138. package/serialization/resources/webhooks/types/CreateWebhookRequest.js +48 -0
  139. package/serialization/resources/webhooks/types/EventId.d.ts +10 -0
  140. package/serialization/resources/webhooks/types/EventId.js +41 -0
  141. package/serialization/resources/webhooks/types/EventType.d.ts +10 -0
  142. package/serialization/resources/webhooks/types/EventType.js +41 -0
  143. package/serialization/resources/webhooks/types/Events.d.ts +11 -0
  144. package/serialization/resources/webhooks/types/Events.js +42 -0
  145. package/serialization/resources/webhooks/types/Inboxes.d.ts +10 -0
  146. package/serialization/resources/webhooks/types/Inboxes.js +41 -0
  147. package/serialization/resources/webhooks/types/ListWebhooksResponse.d.ts +19 -0
  148. package/serialization/resources/webhooks/types/ListWebhooksResponse.js +50 -0
  149. package/serialization/resources/webhooks/types/MessageReceivedPayload.d.ts +14 -0
  150. package/serialization/resources/webhooks/types/MessageReceivedPayload.js +47 -0
  151. package/serialization/resources/webhooks/types/Payload.d.ts +15 -0
  152. package/serialization/resources/webhooks/types/Payload.js +46 -0
  153. package/serialization/resources/webhooks/types/SvixId.d.ts +10 -0
  154. package/serialization/resources/webhooks/types/SvixId.js +41 -0
  155. package/serialization/resources/webhooks/types/SvixSignature.d.ts +10 -0
  156. package/serialization/resources/webhooks/types/SvixSignature.js +41 -0
  157. package/serialization/resources/webhooks/types/SvixTimestamp.d.ts +10 -0
  158. package/serialization/resources/webhooks/types/SvixTimestamp.js +41 -0
  159. package/serialization/resources/webhooks/types/Url.d.ts +10 -0
  160. package/serialization/resources/webhooks/types/Url.js +41 -0
  161. package/serialization/resources/webhooks/types/Webhook.d.ts +21 -0
  162. package/serialization/resources/webhooks/types/Webhook.js +52 -0
  163. package/serialization/resources/webhooks/types/WebhookId.d.ts +10 -0
  164. package/serialization/resources/webhooks/types/WebhookId.js +41 -0
  165. package/serialization/resources/webhooks/types/index.d.ts +14 -0
  166. package/serialization/resources/webhooks/types/index.js +30 -0
  167. package/version.d.ts +1 -1
  168. package/version.js +1 -1
package/Client.d.ts CHANGED
@@ -6,6 +6,7 @@ import * as core from "./core";
6
6
  import { Inboxes } from "./api/resources/inboxes/client/Client";
7
7
  import { Threads } from "./api/resources/threads/client/Client";
8
8
  import { Messages } from "./api/resources/messages/client/Client";
9
+ import { Webhooks } from "./api/resources/webhooks/client/Client";
9
10
  export declare namespace AgentMailClient {
10
11
  interface Options {
11
12
  environment?: core.Supplier<environments.AgentMailEnvironment | string>;
@@ -29,8 +30,10 @@ export declare class AgentMailClient {
29
30
  protected _inboxes: Inboxes | undefined;
30
31
  protected _threads: Threads | undefined;
31
32
  protected _messages: Messages | undefined;
33
+ protected _webhooks: Webhooks | undefined;
32
34
  constructor(_options?: AgentMailClient.Options);
33
35
  get inboxes(): Inboxes;
34
36
  get threads(): Threads;
35
37
  get messages(): Messages;
38
+ get webhooks(): Webhooks;
36
39
  }
package/Client.js CHANGED
@@ -7,6 +7,7 @@ exports.AgentMailClient = void 0;
7
7
  const Client_1 = require("./api/resources/inboxes/client/Client");
8
8
  const Client_2 = require("./api/resources/threads/client/Client");
9
9
  const Client_3 = require("./api/resources/messages/client/Client");
10
+ const Client_4 = require("./api/resources/webhooks/client/Client");
10
11
  class AgentMailClient {
11
12
  constructor(_options = {}) {
12
13
  this._options = _options;
@@ -23,5 +24,9 @@ class AgentMailClient {
23
24
  var _a;
24
25
  return ((_a = this._messages) !== null && _a !== void 0 ? _a : (this._messages = new Client_3.Messages(this._options)));
25
26
  }
27
+ get webhooks() {
28
+ var _a;
29
+ return ((_a = this._webhooks) !== null && _a !== void 0 ? _a : (this._webhooks = new Client_4.Webhooks(this._options)));
30
+ }
26
31
  }
27
32
  exports.AgentMailClient = AgentMailClient;
@@ -83,7 +83,7 @@ class Inboxes {
83
83
  const _response = yield core.fetcher({
84
84
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, "/v0/inboxes"),
85
85
  method: "GET",
86
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
86
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
87
87
  contentType: "application/json",
88
88
  queryParameters: _queryParams,
89
89
  requestType: "json",
@@ -135,7 +135,7 @@ class Inboxes {
135
135
  const _response = yield core.fetcher({
136
136
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}`),
137
137
  method: "GET",
138
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
138
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
139
139
  contentType: "application/json",
140
140
  requestType: "json",
141
141
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -204,7 +204,7 @@ class Inboxes {
204
204
  const _response = yield core.fetcher({
205
205
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, "/v0/inboxes"),
206
206
  method: "POST",
207
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
207
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
208
208
  contentType: "application/json",
209
209
  requestType: "json",
210
210
  body: serializers.CreateInboxRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -4,6 +4,9 @@ export * as messages from "./messages";
4
4
  export * from "./messages/types";
5
5
  export * as threads from "./threads";
6
6
  export * from "./threads/types";
7
+ export * as webhooks from "./webhooks";
8
+ export * from "./webhooks/types";
7
9
  export * from "./inboxes/client/requests";
8
10
  export * from "./messages/client/requests";
9
11
  export * from "./threads/client/requests";
12
+ export * from "./webhooks/client/requests";
@@ -36,13 +36,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.threads = exports.messages = exports.inboxes = void 0;
39
+ exports.webhooks = exports.threads = exports.messages = exports.inboxes = void 0;
40
40
  exports.inboxes = __importStar(require("./inboxes"));
41
41
  __exportStar(require("./inboxes/types"), exports);
42
42
  exports.messages = __importStar(require("./messages"));
43
43
  __exportStar(require("./messages/types"), exports);
44
44
  exports.threads = __importStar(require("./threads"));
45
45
  __exportStar(require("./threads/types"), exports);
46
+ exports.webhooks = __importStar(require("./webhooks"));
47
+ __exportStar(require("./webhooks/types"), exports);
46
48
  __exportStar(require("./inboxes/client/requests"), exports);
47
49
  __exportStar(require("./messages/client/requests"), exports);
48
50
  __exportStar(require("./threads/client/requests"), exports);
51
+ __exportStar(require("./webhooks/client/requests"), exports);
@@ -91,7 +91,7 @@ class Messages {
91
91
  const _response = yield core.fetcher({
92
92
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/messages`),
93
93
  method: "GET",
94
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
94
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
95
95
  contentType: "application/json",
96
96
  queryParameters: _queryParams,
97
97
  requestType: "json",
@@ -154,7 +154,7 @@ class Messages {
154
154
  const _response = yield core.fetcher({
155
155
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/messages/${encodeURIComponent(serializers.MessageId.jsonOrThrow(messageId))}`),
156
156
  method: "GET",
157
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
157
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
158
158
  contentType: "application/json",
159
159
  requestType: "json",
160
160
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -209,7 +209,7 @@ class Messages {
209
209
  const _response = yield core.fetcher({
210
210
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/messages/${encodeURIComponent(serializers.MessageId.jsonOrThrow(messageId))}/attachments/${encodeURIComponent(serializers.AttachmentId.jsonOrThrow(attachmentId))}`),
211
211
  method: "GET",
212
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
212
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
213
213
  contentType: "application/json",
214
214
  requestType: "json",
215
215
  responseType: "streaming",
@@ -275,7 +275,7 @@ class Messages {
275
275
  const _response = yield core.fetcher({
276
276
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/messages/send`),
277
277
  method: "POST",
278
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
278
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
279
279
  contentType: "application/json",
280
280
  requestType: "json",
281
281
  body: serializers.SendMessageRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -352,7 +352,7 @@ class Messages {
352
352
  const _response = yield core.fetcher({
353
353
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/messages/${encodeURIComponent(serializers.MessageId.jsonOrThrow(messageId))}/reply`),
354
354
  method: "POST",
355
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
355
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
356
356
  contentType: "application/json",
357
357
  requestType: "json",
358
358
  body: serializers.ReplyToMessageRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -91,7 +91,7 @@ class Threads {
91
91
  const _response = yield core.fetcher({
92
92
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/threads`),
93
93
  method: "GET",
94
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
94
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
95
95
  contentType: "application/json",
96
96
  queryParameters: _queryParams,
97
97
  requestType: "json",
@@ -154,7 +154,7 @@ class Threads {
154
154
  const _response = yield core.fetcher({
155
155
  url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/inboxes/${encodeURIComponent(serializers.InboxId.jsonOrThrow(inboxId))}/threads/${encodeURIComponent(serializers.ThreadId.jsonOrThrow(threadId))}`),
156
156
  method: "GET",
157
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.21", "User-Agent": "agentmail/0.0.21", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
157
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
158
158
  contentType: "application/json",
159
159
  requestType: "json",
160
160
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -0,0 +1,71 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../environments";
5
+ import * as core from "../../../../core";
6
+ import * as AgentMail from "../../../index";
7
+ export declare namespace Webhooks {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.AgentMailEnvironment | string>;
10
+ /** Specify a custom URL to connect the client to. */
11
+ baseUrl?: core.Supplier<string>;
12
+ apiKey?: core.Supplier<core.BearerToken | undefined>;
13
+ }
14
+ interface RequestOptions {
15
+ /** The maximum time to wait for a response in seconds. */
16
+ timeoutInSeconds?: number;
17
+ /** The number of times to retry the request. Defaults to 2. */
18
+ maxRetries?: number;
19
+ /** A hook to abort the request. */
20
+ abortSignal?: AbortSignal;
21
+ /** Additional headers to include in the request. */
22
+ headers?: Record<string, string>;
23
+ }
24
+ }
25
+ export declare class Webhooks {
26
+ protected readonly _options: Webhooks.Options;
27
+ constructor(_options?: Webhooks.Options);
28
+ /**
29
+ * @param {AgentMail.ListWebhooksRequest} request
30
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
31
+ *
32
+ * @example
33
+ * await client.webhooks.list()
34
+ */
35
+ list(request?: AgentMail.ListWebhooksRequest, requestOptions?: Webhooks.RequestOptions): Promise<AgentMail.ListWebhooksResponse>;
36
+ /**
37
+ * @param {AgentMail.WebhookId} webhookId
38
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
39
+ *
40
+ * @throws {@link AgentMail.NotFoundError}
41
+ *
42
+ * @example
43
+ * await client.webhooks.get("webhook_id")
44
+ */
45
+ get(webhookId: AgentMail.WebhookId, requestOptions?: Webhooks.RequestOptions): Promise<AgentMail.Webhook>;
46
+ /**
47
+ * @param {AgentMail.CreateWebhookRequest} request
48
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
49
+ *
50
+ * @throws {@link AgentMail.ValidationError}
51
+ *
52
+ * @example
53
+ * await client.webhooks.create({
54
+ * url: "url",
55
+ * events: undefined,
56
+ * inboxes: undefined
57
+ * })
58
+ */
59
+ create(request: AgentMail.CreateWebhookRequest, requestOptions?: Webhooks.RequestOptions): Promise<AgentMail.Webhook>;
60
+ /**
61
+ * @param {AgentMail.WebhookId} webhookId
62
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
63
+ *
64
+ * @throws {@link AgentMail.NotFoundError}
65
+ *
66
+ * @example
67
+ * await client.webhooks.delete("webhook_id")
68
+ */
69
+ delete(webhookId: AgentMail.WebhookId, requestOptions?: Webhooks.RequestOptions): Promise<void>;
70
+ protected _getAuthorizationHeader(): Promise<string>;
71
+ }
@@ -0,0 +1,316 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.Webhooks = void 0;
52
+ const environments = __importStar(require("../../../../environments"));
53
+ const core = __importStar(require("../../../../core"));
54
+ const AgentMail = __importStar(require("../../../index"));
55
+ const url_join_1 = __importDefault(require("url-join"));
56
+ const serializers = __importStar(require("../../../../serialization/index"));
57
+ const errors = __importStar(require("../../../../errors/index"));
58
+ class Webhooks {
59
+ constructor(_options = {}) {
60
+ this._options = _options;
61
+ }
62
+ /**
63
+ * @param {AgentMail.ListWebhooksRequest} request
64
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
65
+ *
66
+ * @example
67
+ * await client.webhooks.list()
68
+ */
69
+ list() {
70
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
71
+ var _a, _b;
72
+ const { limit, lastKey } = request;
73
+ const _queryParams = {};
74
+ if (limit != null) {
75
+ _queryParams["limit"] = limit.toString();
76
+ }
77
+ if (lastKey != null) {
78
+ _queryParams["last_key"] = lastKey;
79
+ }
80
+ const _response = yield core.fetcher({
81
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, "/v0/webhooks"),
82
+ method: "GET",
83
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
84
+ contentType: "application/json",
85
+ queryParameters: _queryParams,
86
+ requestType: "json",
87
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
88
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
89
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
90
+ });
91
+ if (_response.ok) {
92
+ return serializers.ListWebhooksResponse.parseOrThrow(_response.body, {
93
+ unrecognizedObjectKeys: "passthrough",
94
+ allowUnrecognizedUnionMembers: true,
95
+ allowUnrecognizedEnumValues: true,
96
+ breadcrumbsPrefix: ["response"],
97
+ });
98
+ }
99
+ if (_response.error.reason === "status-code") {
100
+ throw new errors.AgentMailError({
101
+ statusCode: _response.error.statusCode,
102
+ body: _response.error.body,
103
+ });
104
+ }
105
+ switch (_response.error.reason) {
106
+ case "non-json":
107
+ throw new errors.AgentMailError({
108
+ statusCode: _response.error.statusCode,
109
+ body: _response.error.rawBody,
110
+ });
111
+ case "timeout":
112
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/webhooks.");
113
+ case "unknown":
114
+ throw new errors.AgentMailError({
115
+ message: _response.error.errorMessage,
116
+ });
117
+ }
118
+ });
119
+ }
120
+ /**
121
+ * @param {AgentMail.WebhookId} webhookId
122
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
123
+ *
124
+ * @throws {@link AgentMail.NotFoundError}
125
+ *
126
+ * @example
127
+ * await client.webhooks.get("webhook_id")
128
+ */
129
+ get(webhookId, requestOptions) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ var _a, _b;
132
+ const _response = yield core.fetcher({
133
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/webhooks/${encodeURIComponent(serializers.WebhookId.jsonOrThrow(webhookId))}`),
134
+ method: "GET",
135
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
136
+ contentType: "application/json",
137
+ requestType: "json",
138
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
139
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
140
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
141
+ });
142
+ if (_response.ok) {
143
+ return serializers.Webhook.parseOrThrow(_response.body, {
144
+ unrecognizedObjectKeys: "passthrough",
145
+ allowUnrecognizedUnionMembers: true,
146
+ allowUnrecognizedEnumValues: true,
147
+ breadcrumbsPrefix: ["response"],
148
+ });
149
+ }
150
+ if (_response.error.reason === "status-code") {
151
+ switch (_response.error.statusCode) {
152
+ case 404:
153
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
154
+ unrecognizedObjectKeys: "passthrough",
155
+ allowUnrecognizedUnionMembers: true,
156
+ allowUnrecognizedEnumValues: true,
157
+ breadcrumbsPrefix: ["response"],
158
+ }));
159
+ default:
160
+ throw new errors.AgentMailError({
161
+ statusCode: _response.error.statusCode,
162
+ body: _response.error.body,
163
+ });
164
+ }
165
+ }
166
+ switch (_response.error.reason) {
167
+ case "non-json":
168
+ throw new errors.AgentMailError({
169
+ statusCode: _response.error.statusCode,
170
+ body: _response.error.rawBody,
171
+ });
172
+ case "timeout":
173
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling GET /v0/webhooks/{webhook_id}.");
174
+ case "unknown":
175
+ throw new errors.AgentMailError({
176
+ message: _response.error.errorMessage,
177
+ });
178
+ }
179
+ });
180
+ }
181
+ /**
182
+ * @param {AgentMail.CreateWebhookRequest} request
183
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
184
+ *
185
+ * @throws {@link AgentMail.ValidationError}
186
+ *
187
+ * @example
188
+ * await client.webhooks.create({
189
+ * url: "url",
190
+ * events: undefined,
191
+ * inboxes: undefined
192
+ * })
193
+ */
194
+ create(request, requestOptions) {
195
+ return __awaiter(this, void 0, void 0, function* () {
196
+ var _a, _b;
197
+ const _response = yield core.fetcher({
198
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, "/v0/webhooks"),
199
+ method: "POST",
200
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
201
+ contentType: "application/json",
202
+ requestType: "json",
203
+ body: serializers.CreateWebhookRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
204
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
205
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
206
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
207
+ });
208
+ if (_response.ok) {
209
+ return serializers.Webhook.parseOrThrow(_response.body, {
210
+ unrecognizedObjectKeys: "passthrough",
211
+ allowUnrecognizedUnionMembers: true,
212
+ allowUnrecognizedEnumValues: true,
213
+ breadcrumbsPrefix: ["response"],
214
+ });
215
+ }
216
+ if (_response.error.reason === "status-code") {
217
+ switch (_response.error.statusCode) {
218
+ case 400:
219
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
220
+ unrecognizedObjectKeys: "passthrough",
221
+ allowUnrecognizedUnionMembers: true,
222
+ allowUnrecognizedEnumValues: true,
223
+ breadcrumbsPrefix: ["response"],
224
+ }));
225
+ default:
226
+ throw new errors.AgentMailError({
227
+ statusCode: _response.error.statusCode,
228
+ body: _response.error.body,
229
+ });
230
+ }
231
+ }
232
+ switch (_response.error.reason) {
233
+ case "non-json":
234
+ throw new errors.AgentMailError({
235
+ statusCode: _response.error.statusCode,
236
+ body: _response.error.rawBody,
237
+ });
238
+ case "timeout":
239
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling POST /v0/webhooks.");
240
+ case "unknown":
241
+ throw new errors.AgentMailError({
242
+ message: _response.error.errorMessage,
243
+ });
244
+ }
245
+ });
246
+ }
247
+ /**
248
+ * @param {AgentMail.WebhookId} webhookId
249
+ * @param {Webhooks.RequestOptions} requestOptions - Request-specific configuration.
250
+ *
251
+ * @throws {@link AgentMail.NotFoundError}
252
+ *
253
+ * @example
254
+ * await client.webhooks.delete("webhook_id")
255
+ */
256
+ delete(webhookId, requestOptions) {
257
+ return __awaiter(this, void 0, void 0, function* () {
258
+ var _a, _b;
259
+ const _response = yield core.fetcher({
260
+ url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.AgentMailEnvironment.Production, `/v0/webhooks/${encodeURIComponent(serializers.WebhookId.jsonOrThrow(webhookId))}`),
261
+ method: "DELETE",
262
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "agentmail", "X-Fern-SDK-Version": "0.0.22", "User-Agent": "agentmail/0.0.22", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
263
+ contentType: "application/json",
264
+ requestType: "json",
265
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
266
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
267
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
268
+ });
269
+ if (_response.ok) {
270
+ return;
271
+ }
272
+ if (_response.error.reason === "status-code") {
273
+ switch (_response.error.statusCode) {
274
+ case 404:
275
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
276
+ unrecognizedObjectKeys: "passthrough",
277
+ allowUnrecognizedUnionMembers: true,
278
+ allowUnrecognizedEnumValues: true,
279
+ breadcrumbsPrefix: ["response"],
280
+ }));
281
+ default:
282
+ throw new errors.AgentMailError({
283
+ statusCode: _response.error.statusCode,
284
+ body: _response.error.body,
285
+ });
286
+ }
287
+ }
288
+ switch (_response.error.reason) {
289
+ case "non-json":
290
+ throw new errors.AgentMailError({
291
+ statusCode: _response.error.statusCode,
292
+ body: _response.error.rawBody,
293
+ });
294
+ case "timeout":
295
+ throw new errors.AgentMailTimeoutError("Timeout exceeded when calling DELETE /v0/webhooks/{webhook_id}.");
296
+ case "unknown":
297
+ throw new errors.AgentMailError({
298
+ message: _response.error.errorMessage,
299
+ });
300
+ }
301
+ });
302
+ }
303
+ _getAuthorizationHeader() {
304
+ return __awaiter(this, void 0, void 0, function* () {
305
+ var _a;
306
+ const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env["AGENTMAIL_API_KEY"];
307
+ if (bearer == null) {
308
+ throw new errors.AgentMailError({
309
+ message: "Please specify a bearer by either passing it in to the constructor or initializing a AGENTMAIL_API_KEY environment variable",
310
+ });
311
+ }
312
+ return `Bearer ${bearer}`;
313
+ });
314
+ }
315
+ }
316
+ exports.Webhooks = Webhooks;
@@ -0,0 +1 @@
1
+ export * from "./requests";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as AgentMail from "../../../../index";
5
+ /**
6
+ * @example
7
+ * {}
8
+ */
9
+ export interface ListWebhooksRequest {
10
+ limit?: AgentMail.Limit;
11
+ lastKey?: AgentMail.LastKey;
12
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { type ListWebhooksRequest } from "./ListWebhooksRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export * from "./client";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./client"), exports);