@trycourier/courier 6.4.0 → 6.4.2

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 (133) hide show
  1. package/Client.d.ts +14 -48
  2. package/Client.js +20 -49
  3. package/README.md +113 -808
  4. package/api/client/requests/SendMessageRequest.d.ts +12 -47
  5. package/api/resources/audiences/client/Client.d.ts +10 -5
  6. package/api/resources/audiences/client/Client.js +45 -15
  7. package/api/resources/auditEvents/client/Client.d.ts +4 -2
  8. package/api/resources/auditEvents/client/Client.js +17 -5
  9. package/api/resources/authTokens/client/Client.d.ts +2 -1
  10. package/api/resources/authTokens/client/Client.js +8 -2
  11. package/api/resources/automations/client/Client.d.ts +4 -2
  12. package/api/resources/automations/client/Client.js +16 -4
  13. package/api/resources/brands/client/Client.d.ts +10 -5
  14. package/api/resources/brands/client/Client.js +45 -15
  15. package/api/resources/bulk/client/Client.d.ts +10 -5
  16. package/api/resources/bulk/client/Client.js +45 -15
  17. package/api/resources/commons/errors/AlreadyExistsError.d.ts +2 -1
  18. package/api/resources/commons/errors/AlreadyExistsError.js +2 -1
  19. package/api/resources/commons/errors/BadRequestError.d.ts +2 -1
  20. package/api/resources/commons/errors/BadRequestError.js +2 -1
  21. package/api/resources/commons/errors/ConflictError.d.ts +2 -1
  22. package/api/resources/commons/errors/ConflictError.js +2 -1
  23. package/api/resources/commons/errors/MessageNotFoundError.d.ts +2 -1
  24. package/api/resources/commons/errors/MessageNotFoundError.js +2 -1
  25. package/api/resources/commons/errors/NotFoundError.d.ts +2 -1
  26. package/api/resources/commons/errors/NotFoundError.js +2 -1
  27. package/api/resources/commons/errors/PaymentRequiredError.d.ts +2 -1
  28. package/api/resources/commons/errors/PaymentRequiredError.js +2 -1
  29. package/api/resources/inbound/client/Client.d.ts +2 -1
  30. package/api/resources/inbound/client/Client.js +10 -4
  31. package/api/resources/lists/client/Client.d.ts +20 -10
  32. package/api/resources/lists/client/Client.js +89 -29
  33. package/api/resources/messages/client/Client.d.ts +12 -6
  34. package/api/resources/messages/client/Client.js +56 -20
  35. package/api/resources/notifications/client/Client.d.ts +12 -6
  36. package/api/resources/notifications/client/Client.js +58 -13
  37. package/api/resources/profiles/client/Client.d.ts +16 -8
  38. package/api/resources/profiles/client/Client.js +75 -24
  39. package/api/resources/templates/client/Client.d.ts +2 -1
  40. package/api/resources/templates/client/Client.js +9 -3
  41. package/api/resources/tenants/client/Client.d.ts +14 -7
  42. package/api/resources/tenants/client/Client.js +61 -19
  43. package/api/resources/translations/client/Client.d.ts +4 -2
  44. package/api/resources/translations/client/Client.js +18 -6
  45. package/api/resources/users/resources/preferences/client/Client.d.ts +6 -3
  46. package/api/resources/users/resources/preferences/client/Client.js +38 -11
  47. package/api/resources/users/resources/tenants/client/Client.d.ts +10 -5
  48. package/api/resources/users/resources/tenants/client/Client.js +45 -12
  49. package/api/resources/users/resources/tokens/client/Client.d.ts +12 -6
  50. package/api/resources/users/resources/tokens/client/Client.js +53 -17
  51. package/core/fetcher/APIResponse.d.ts +10 -0
  52. package/core/fetcher/Fetcher.js +7 -0
  53. package/core/fetcher/Headers.d.ts +2 -0
  54. package/core/fetcher/Headers.js +84 -0
  55. package/core/fetcher/HttpResponsePromise.d.ts +58 -0
  56. package/core/fetcher/HttpResponsePromise.js +103 -0
  57. package/core/fetcher/RawResponse.d.ts +29 -0
  58. package/core/fetcher/RawResponse.js +44 -0
  59. package/core/fetcher/index.d.ts +3 -0
  60. package/core/fetcher/index.js +7 -1
  61. package/core/index.d.ts +1 -1
  62. package/core/index.js +1 -1
  63. package/dist/Client.d.ts +14 -48
  64. package/dist/Client.js +20 -49
  65. package/dist/api/client/requests/SendMessageRequest.d.ts +12 -47
  66. package/dist/api/resources/audiences/client/Client.d.ts +10 -5
  67. package/dist/api/resources/audiences/client/Client.js +45 -15
  68. package/dist/api/resources/auditEvents/client/Client.d.ts +4 -2
  69. package/dist/api/resources/auditEvents/client/Client.js +17 -5
  70. package/dist/api/resources/authTokens/client/Client.d.ts +2 -1
  71. package/dist/api/resources/authTokens/client/Client.js +8 -2
  72. package/dist/api/resources/automations/client/Client.d.ts +4 -2
  73. package/dist/api/resources/automations/client/Client.js +16 -4
  74. package/dist/api/resources/brands/client/Client.d.ts +10 -5
  75. package/dist/api/resources/brands/client/Client.js +45 -15
  76. package/dist/api/resources/bulk/client/Client.d.ts +10 -5
  77. package/dist/api/resources/bulk/client/Client.js +45 -15
  78. package/dist/api/resources/commons/errors/AlreadyExistsError.d.ts +2 -1
  79. package/dist/api/resources/commons/errors/AlreadyExistsError.js +2 -1
  80. package/dist/api/resources/commons/errors/BadRequestError.d.ts +2 -1
  81. package/dist/api/resources/commons/errors/BadRequestError.js +2 -1
  82. package/dist/api/resources/commons/errors/ConflictError.d.ts +2 -1
  83. package/dist/api/resources/commons/errors/ConflictError.js +2 -1
  84. package/dist/api/resources/commons/errors/MessageNotFoundError.d.ts +2 -1
  85. package/dist/api/resources/commons/errors/MessageNotFoundError.js +2 -1
  86. package/dist/api/resources/commons/errors/NotFoundError.d.ts +2 -1
  87. package/dist/api/resources/commons/errors/NotFoundError.js +2 -1
  88. package/dist/api/resources/commons/errors/PaymentRequiredError.d.ts +2 -1
  89. package/dist/api/resources/commons/errors/PaymentRequiredError.js +2 -1
  90. package/dist/api/resources/inbound/client/Client.d.ts +2 -1
  91. package/dist/api/resources/inbound/client/Client.js +10 -4
  92. package/dist/api/resources/lists/client/Client.d.ts +20 -10
  93. package/dist/api/resources/lists/client/Client.js +89 -29
  94. package/dist/api/resources/messages/client/Client.d.ts +12 -6
  95. package/dist/api/resources/messages/client/Client.js +56 -20
  96. package/dist/api/resources/notifications/client/Client.d.ts +12 -6
  97. package/dist/api/resources/notifications/client/Client.js +58 -13
  98. package/dist/api/resources/profiles/client/Client.d.ts +16 -8
  99. package/dist/api/resources/profiles/client/Client.js +75 -24
  100. package/dist/api/resources/templates/client/Client.d.ts +2 -1
  101. package/dist/api/resources/templates/client/Client.js +9 -3
  102. package/dist/api/resources/tenants/client/Client.d.ts +14 -7
  103. package/dist/api/resources/tenants/client/Client.js +61 -19
  104. package/dist/api/resources/translations/client/Client.d.ts +4 -2
  105. package/dist/api/resources/translations/client/Client.js +18 -6
  106. package/dist/api/resources/users/resources/preferences/client/Client.d.ts +6 -3
  107. package/dist/api/resources/users/resources/preferences/client/Client.js +38 -11
  108. package/dist/api/resources/users/resources/tenants/client/Client.d.ts +10 -5
  109. package/dist/api/resources/users/resources/tenants/client/Client.js +45 -12
  110. package/dist/api/resources/users/resources/tokens/client/Client.d.ts +12 -6
  111. package/dist/api/resources/users/resources/tokens/client/Client.js +53 -17
  112. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  113. package/dist/core/fetcher/Fetcher.js +7 -0
  114. package/dist/core/fetcher/Headers.d.ts +2 -0
  115. package/dist/core/fetcher/Headers.js +84 -0
  116. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  117. package/dist/core/fetcher/HttpResponsePromise.js +103 -0
  118. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  119. package/dist/core/fetcher/RawResponse.js +44 -0
  120. package/dist/core/fetcher/index.d.ts +3 -0
  121. package/dist/core/fetcher/index.js +7 -1
  122. package/dist/core/index.d.ts +1 -1
  123. package/dist/core/index.js +1 -1
  124. package/dist/errors/CourierError.d.ts +4 -1
  125. package/dist/errors/CourierError.js +4 -7
  126. package/dist/version.d.ts +1 -1
  127. package/dist/version.js +1 -1
  128. package/errors/CourierError.d.ts +4 -1
  129. package/errors/CourierError.js +4 -7
  130. package/package.json +3 -2
  131. package/reference.md +12 -50
  132. package/version.d.ts +1 -1
  133. package/version.js +1 -1
@@ -69,7 +69,10 @@ class Lists {
69
69
  * @example
70
70
  * await client.lists.list()
71
71
  */
72
- list() {
72
+ list(request = {}, requestOptions) {
73
+ return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
74
+ }
75
+ __list() {
73
76
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
74
77
  var _a, _b, _c;
75
78
  const { cursor, pattern } = request;
@@ -83,7 +86,7 @@ class Lists {
83
86
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
84
87
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, "/lists"),
85
88
  method: "GET",
86
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
89
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
87
90
  contentType: "application/json",
88
91
  queryParameters: _queryParams,
89
92
  requestType: "json",
@@ -92,16 +95,17 @@ class Lists {
92
95
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
93
96
  });
94
97
  if (_response.ok) {
95
- return _response.body;
98
+ return { data: _response.body, rawResponse: _response.rawResponse };
96
99
  }
97
100
  if (_response.error.reason === "status-code") {
98
101
  switch (_response.error.statusCode) {
99
102
  case 400:
100
- throw new Courier.BadRequestError(_response.error.body);
103
+ throw new Courier.BadRequestError(_response.error.body, _response.rawResponse);
101
104
  default:
102
105
  throw new errors.CourierError({
103
106
  statusCode: _response.error.statusCode,
104
107
  body: _response.error.body,
108
+ rawResponse: _response.rawResponse,
105
109
  });
106
110
  }
107
111
  }
@@ -110,12 +114,14 @@ class Lists {
110
114
  throw new errors.CourierError({
111
115
  statusCode: _response.error.statusCode,
112
116
  body: _response.error.rawBody,
117
+ rawResponse: _response.rawResponse,
113
118
  });
114
119
  case "timeout":
115
120
  throw new errors.CourierTimeoutError("Timeout exceeded when calling GET /lists.");
116
121
  case "unknown":
117
122
  throw new errors.CourierError({
118
123
  message: _response.error.errorMessage,
124
+ rawResponse: _response.rawResponse,
119
125
  });
120
126
  }
121
127
  });
@@ -132,12 +138,15 @@ class Lists {
132
138
  * await client.lists.get("list_id")
133
139
  */
134
140
  get(listId, requestOptions) {
141
+ return core.HttpResponsePromise.fromPromise(this.__get(listId, requestOptions));
142
+ }
143
+ __get(listId, requestOptions) {
135
144
  return __awaiter(this, void 0, void 0, function* () {
136
145
  var _a, _b, _c;
137
146
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
138
147
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}`),
139
148
  method: "GET",
140
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
149
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
141
150
  contentType: "application/json",
142
151
  requestType: "json",
143
152
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -145,16 +154,17 @@ class Lists {
145
154
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
146
155
  });
147
156
  if (_response.ok) {
148
- return _response.body;
157
+ return { data: _response.body, rawResponse: _response.rawResponse };
149
158
  }
150
159
  if (_response.error.reason === "status-code") {
151
160
  switch (_response.error.statusCode) {
152
161
  case 404:
153
- throw new Courier.NotFoundError(_response.error.body);
162
+ throw new Courier.NotFoundError(_response.error.body, _response.rawResponse);
154
163
  default:
155
164
  throw new errors.CourierError({
156
165
  statusCode: _response.error.statusCode,
157
166
  body: _response.error.body,
167
+ rawResponse: _response.rawResponse,
158
168
  });
159
169
  }
160
170
  }
@@ -163,12 +173,14 @@ class Lists {
163
173
  throw new errors.CourierError({
164
174
  statusCode: _response.error.statusCode,
165
175
  body: _response.error.rawBody,
176
+ rawResponse: _response.rawResponse,
166
177
  });
167
178
  case "timeout":
168
179
  throw new errors.CourierTimeoutError("Timeout exceeded when calling GET /lists/{list_id}.");
169
180
  case "unknown":
170
181
  throw new errors.CourierError({
171
182
  message: _response.error.errorMessage,
183
+ rawResponse: _response.rawResponse,
172
184
  });
173
185
  }
174
186
  });
@@ -187,12 +199,15 @@ class Lists {
187
199
  * })
188
200
  */
189
201
  update(listId, request, requestOptions) {
202
+ return core.HttpResponsePromise.fromPromise(this.__update(listId, request, requestOptions));
203
+ }
204
+ __update(listId, request, requestOptions) {
190
205
  return __awaiter(this, void 0, void 0, function* () {
191
206
  var _a, _b, _c;
192
207
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
193
208
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}`),
194
209
  method: "PUT",
195
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
210
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
196
211
  contentType: "application/json",
197
212
  requestType: "json",
198
213
  body: request,
@@ -201,12 +216,13 @@ class Lists {
201
216
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
202
217
  });
203
218
  if (_response.ok) {
204
- return _response.body;
219
+ return { data: _response.body, rawResponse: _response.rawResponse };
205
220
  }
206
221
  if (_response.error.reason === "status-code") {
207
222
  throw new errors.CourierError({
208
223
  statusCode: _response.error.statusCode,
209
224
  body: _response.error.body,
225
+ rawResponse: _response.rawResponse,
210
226
  });
211
227
  }
212
228
  switch (_response.error.reason) {
@@ -214,12 +230,14 @@ class Lists {
214
230
  throw new errors.CourierError({
215
231
  statusCode: _response.error.statusCode,
216
232
  body: _response.error.rawBody,
233
+ rawResponse: _response.rawResponse,
217
234
  });
218
235
  case "timeout":
219
236
  throw new errors.CourierTimeoutError("Timeout exceeded when calling PUT /lists/{list_id}.");
220
237
  case "unknown":
221
238
  throw new errors.CourierError({
222
239
  message: _response.error.errorMessage,
240
+ rawResponse: _response.rawResponse,
223
241
  });
224
242
  }
225
243
  });
@@ -234,12 +252,15 @@ class Lists {
234
252
  * await client.lists.delete("list_id")
235
253
  */
236
254
  delete(listId, requestOptions) {
255
+ return core.HttpResponsePromise.fromPromise(this.__delete(listId, requestOptions));
256
+ }
257
+ __delete(listId, requestOptions) {
237
258
  return __awaiter(this, void 0, void 0, function* () {
238
259
  var _a, _b, _c;
239
260
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
240
261
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}`),
241
262
  method: "DELETE",
242
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
263
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
243
264
  contentType: "application/json",
244
265
  requestType: "json",
245
266
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -247,12 +268,13 @@ class Lists {
247
268
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
248
269
  });
249
270
  if (_response.ok) {
250
- return;
271
+ return { data: undefined, rawResponse: _response.rawResponse };
251
272
  }
252
273
  if (_response.error.reason === "status-code") {
253
274
  throw new errors.CourierError({
254
275
  statusCode: _response.error.statusCode,
255
276
  body: _response.error.body,
277
+ rawResponse: _response.rawResponse,
256
278
  });
257
279
  }
258
280
  switch (_response.error.reason) {
@@ -260,12 +282,14 @@ class Lists {
260
282
  throw new errors.CourierError({
261
283
  statusCode: _response.error.statusCode,
262
284
  body: _response.error.rawBody,
285
+ rawResponse: _response.rawResponse,
263
286
  });
264
287
  case "timeout":
265
288
  throw new errors.CourierTimeoutError("Timeout exceeded when calling DELETE /lists/{list_id}.");
266
289
  case "unknown":
267
290
  throw new errors.CourierError({
268
291
  message: _response.error.errorMessage,
292
+ rawResponse: _response.rawResponse,
269
293
  });
270
294
  }
271
295
  });
@@ -280,12 +304,15 @@ class Lists {
280
304
  * await client.lists.restore("list_id")
281
305
  */
282
306
  restore(listId, requestOptions) {
307
+ return core.HttpResponsePromise.fromPromise(this.__restore(listId, requestOptions));
308
+ }
309
+ __restore(listId, requestOptions) {
283
310
  return __awaiter(this, void 0, void 0, function* () {
284
311
  var _a, _b, _c;
285
312
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
286
313
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}/restore`),
287
314
  method: "PUT",
288
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
315
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
289
316
  contentType: "application/json",
290
317
  requestType: "json",
291
318
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -293,12 +320,13 @@ class Lists {
293
320
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
294
321
  });
295
322
  if (_response.ok) {
296
- return;
323
+ return { data: undefined, rawResponse: _response.rawResponse };
297
324
  }
298
325
  if (_response.error.reason === "status-code") {
299
326
  throw new errors.CourierError({
300
327
  statusCode: _response.error.statusCode,
301
328
  body: _response.error.body,
329
+ rawResponse: _response.rawResponse,
302
330
  });
303
331
  }
304
332
  switch (_response.error.reason) {
@@ -306,12 +334,14 @@ class Lists {
306
334
  throw new errors.CourierError({
307
335
  statusCode: _response.error.statusCode,
308
336
  body: _response.error.rawBody,
337
+ rawResponse: _response.rawResponse,
309
338
  });
310
339
  case "timeout":
311
340
  throw new errors.CourierTimeoutError("Timeout exceeded when calling PUT /lists/{list_id}/restore.");
312
341
  case "unknown":
313
342
  throw new errors.CourierError({
314
343
  message: _response.error.errorMessage,
344
+ rawResponse: _response.rawResponse,
315
345
  });
316
346
  }
317
347
  });
@@ -328,7 +358,10 @@ class Lists {
328
358
  * @example
329
359
  * await client.lists.getSubscribers("list_id")
330
360
  */
331
- getSubscribers(listId_1) {
361
+ getSubscribers(listId, request = {}, requestOptions) {
362
+ return core.HttpResponsePromise.fromPromise(this.__getSubscribers(listId, request, requestOptions));
363
+ }
364
+ __getSubscribers(listId_1) {
332
365
  return __awaiter(this, arguments, void 0, function* (listId, request = {}, requestOptions) {
333
366
  var _a, _b, _c;
334
367
  const { cursor } = request;
@@ -339,7 +372,7 @@ class Lists {
339
372
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
340
373
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}/subscriptions`),
341
374
  method: "GET",
342
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
375
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
343
376
  contentType: "application/json",
344
377
  queryParameters: _queryParams,
345
378
  requestType: "json",
@@ -348,16 +381,17 @@ class Lists {
348
381
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
349
382
  });
350
383
  if (_response.ok) {
351
- return _response.body;
384
+ return { data: _response.body, rawResponse: _response.rawResponse };
352
385
  }
353
386
  if (_response.error.reason === "status-code") {
354
387
  switch (_response.error.statusCode) {
355
388
  case 404:
356
- throw new Courier.NotFoundError(_response.error.body);
389
+ throw new Courier.NotFoundError(_response.error.body, _response.rawResponse);
357
390
  default:
358
391
  throw new errors.CourierError({
359
392
  statusCode: _response.error.statusCode,
360
393
  body: _response.error.body,
394
+ rawResponse: _response.rawResponse,
361
395
  });
362
396
  }
363
397
  }
@@ -366,12 +400,14 @@ class Lists {
366
400
  throw new errors.CourierError({
367
401
  statusCode: _response.error.statusCode,
368
402
  body: _response.error.rawBody,
403
+ rawResponse: _response.rawResponse,
369
404
  });
370
405
  case "timeout":
371
406
  throw new errors.CourierTimeoutError("Timeout exceeded when calling GET /lists/{list_id}/subscriptions.");
372
407
  case "unknown":
373
408
  throw new errors.CourierError({
374
409
  message: _response.error.errorMessage,
410
+ rawResponse: _response.rawResponse,
375
411
  });
376
412
  }
377
413
  });
@@ -397,12 +433,15 @@ class Lists {
397
433
  * })
398
434
  */
399
435
  updateSubscribers(listId, request, requestOptions) {
436
+ return core.HttpResponsePromise.fromPromise(this.__updateSubscribers(listId, request, requestOptions));
437
+ }
438
+ __updateSubscribers(listId, request, requestOptions) {
400
439
  return __awaiter(this, void 0, void 0, function* () {
401
440
  var _a, _b, _c;
402
441
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
403
442
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}/subscriptions`),
404
443
  method: "PUT",
405
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
444
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
406
445
  contentType: "application/json",
407
446
  requestType: "json",
408
447
  body: request,
@@ -411,16 +450,17 @@ class Lists {
411
450
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
412
451
  });
413
452
  if (_response.ok) {
414
- return;
453
+ return { data: undefined, rawResponse: _response.rawResponse };
415
454
  }
416
455
  if (_response.error.reason === "status-code") {
417
456
  switch (_response.error.statusCode) {
418
457
  case 400:
419
- throw new Courier.BadRequestError(_response.error.body);
458
+ throw new Courier.BadRequestError(_response.error.body, _response.rawResponse);
420
459
  default:
421
460
  throw new errors.CourierError({
422
461
  statusCode: _response.error.statusCode,
423
462
  body: _response.error.body,
463
+ rawResponse: _response.rawResponse,
424
464
  });
425
465
  }
426
466
  }
@@ -429,12 +469,14 @@ class Lists {
429
469
  throw new errors.CourierError({
430
470
  statusCode: _response.error.statusCode,
431
471
  body: _response.error.rawBody,
472
+ rawResponse: _response.rawResponse,
432
473
  });
433
474
  case "timeout":
434
475
  throw new errors.CourierTimeoutError("Timeout exceeded when calling PUT /lists/{list_id}/subscriptions.");
435
476
  case "unknown":
436
477
  throw new errors.CourierError({
437
478
  message: _response.error.errorMessage,
479
+ rawResponse: _response.rawResponse,
438
480
  });
439
481
  }
440
482
  });
@@ -460,12 +502,15 @@ class Lists {
460
502
  * })
461
503
  */
462
504
  addSubscribers(listId, request, requestOptions) {
505
+ return core.HttpResponsePromise.fromPromise(this.__addSubscribers(listId, request, requestOptions));
506
+ }
507
+ __addSubscribers(listId, request, requestOptions) {
463
508
  return __awaiter(this, void 0, void 0, function* () {
464
509
  var _a, _b, _c;
465
510
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
466
511
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}/subscriptions`),
467
512
  method: "POST",
468
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Idempotency-Key": (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey) != null ? requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey : undefined, "X-Idempotency-Expiration": (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyExpiry) != null ? requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyExpiry : undefined }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
513
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Idempotency-Key": (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey) != null ? requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey : undefined, "X-Idempotency-Expiration": (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyExpiry) != null ? requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyExpiry : undefined }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
469
514
  contentType: "application/json",
470
515
  requestType: "json",
471
516
  body: request,
@@ -474,16 +519,17 @@ class Lists {
474
519
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
475
520
  });
476
521
  if (_response.ok) {
477
- return;
522
+ return { data: undefined, rawResponse: _response.rawResponse };
478
523
  }
479
524
  if (_response.error.reason === "status-code") {
480
525
  switch (_response.error.statusCode) {
481
526
  case 400:
482
- throw new Courier.BadRequestError(_response.error.body);
527
+ throw new Courier.BadRequestError(_response.error.body, _response.rawResponse);
483
528
  default:
484
529
  throw new errors.CourierError({
485
530
  statusCode: _response.error.statusCode,
486
531
  body: _response.error.body,
532
+ rawResponse: _response.rawResponse,
487
533
  });
488
534
  }
489
535
  }
@@ -492,12 +538,14 @@ class Lists {
492
538
  throw new errors.CourierError({
493
539
  statusCode: _response.error.statusCode,
494
540
  body: _response.error.rawBody,
541
+ rawResponse: _response.rawResponse,
495
542
  });
496
543
  case "timeout":
497
544
  throw new errors.CourierTimeoutError("Timeout exceeded when calling POST /lists/{list_id}/subscriptions.");
498
545
  case "unknown":
499
546
  throw new errors.CourierError({
500
547
  message: _response.error.errorMessage,
548
+ rawResponse: _response.rawResponse,
501
549
  });
502
550
  }
503
551
  });
@@ -515,13 +563,16 @@ class Lists {
515
563
  * preferences: undefined
516
564
  * })
517
565
  */
518
- subscribe(listId_1, userId_1) {
566
+ subscribe(listId, userId, request = {}, requestOptions) {
567
+ return core.HttpResponsePromise.fromPromise(this.__subscribe(listId, userId, request, requestOptions));
568
+ }
569
+ __subscribe(listId_1, userId_1) {
519
570
  return __awaiter(this, arguments, void 0, function* (listId, userId, request = {}, requestOptions) {
520
571
  var _a, _b, _c;
521
572
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
522
573
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}/subscriptions/${encodeURIComponent(userId)}`),
523
574
  method: "PUT",
524
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
575
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
525
576
  contentType: "application/json",
526
577
  requestType: "json",
527
578
  body: request,
@@ -530,12 +581,13 @@ class Lists {
530
581
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
531
582
  });
532
583
  if (_response.ok) {
533
- return;
584
+ return { data: undefined, rawResponse: _response.rawResponse };
534
585
  }
535
586
  if (_response.error.reason === "status-code") {
536
587
  throw new errors.CourierError({
537
588
  statusCode: _response.error.statusCode,
538
589
  body: _response.error.body,
590
+ rawResponse: _response.rawResponse,
539
591
  });
540
592
  }
541
593
  switch (_response.error.reason) {
@@ -543,12 +595,14 @@ class Lists {
543
595
  throw new errors.CourierError({
544
596
  statusCode: _response.error.statusCode,
545
597
  body: _response.error.rawBody,
598
+ rawResponse: _response.rawResponse,
546
599
  });
547
600
  case "timeout":
548
601
  throw new errors.CourierTimeoutError("Timeout exceeded when calling PUT /lists/{list_id}/subscriptions/{user_id}.");
549
602
  case "unknown":
550
603
  throw new errors.CourierError({
551
604
  message: _response.error.errorMessage,
605
+ rawResponse: _response.rawResponse,
552
606
  });
553
607
  }
554
608
  });
@@ -566,12 +620,15 @@ class Lists {
566
620
  * await client.lists.unsubscribe("list_id", "user_id")
567
621
  */
568
622
  unsubscribe(listId, userId, requestOptions) {
623
+ return core.HttpResponsePromise.fromPromise(this.__unsubscribe(listId, userId, requestOptions));
624
+ }
625
+ __unsubscribe(listId, userId, requestOptions) {
569
626
  return __awaiter(this, void 0, void 0, function* () {
570
627
  var _a, _b, _c;
571
628
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
572
629
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, `/lists/${encodeURIComponent(listId)}/subscriptions/${encodeURIComponent(userId)}`),
573
630
  method: "DELETE",
574
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
631
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.2", "User-Agent": "@trycourier/courier/6.4.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
575
632
  contentType: "application/json",
576
633
  requestType: "json",
577
634
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -579,16 +636,17 @@ class Lists {
579
636
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
580
637
  });
581
638
  if (_response.ok) {
582
- return;
639
+ return { data: undefined, rawResponse: _response.rawResponse };
583
640
  }
584
641
  if (_response.error.reason === "status-code") {
585
642
  switch (_response.error.statusCode) {
586
643
  case 404:
587
- throw new Courier.NotFoundError(_response.error.body);
644
+ throw new Courier.NotFoundError(_response.error.body, _response.rawResponse);
588
645
  default:
589
646
  throw new errors.CourierError({
590
647
  statusCode: _response.error.statusCode,
591
648
  body: _response.error.body,
649
+ rawResponse: _response.rawResponse,
592
650
  });
593
651
  }
594
652
  }
@@ -597,12 +655,14 @@ class Lists {
597
655
  throw new errors.CourierError({
598
656
  statusCode: _response.error.statusCode,
599
657
  body: _response.error.rawBody,
658
+ rawResponse: _response.rawResponse,
600
659
  });
601
660
  case "timeout":
602
661
  throw new errors.CourierTimeoutError("Timeout exceeded when calling DELETE /lists/{list_id}/subscriptions/{user_id}.");
603
662
  case "unknown":
604
663
  throw new errors.CourierError({
605
664
  message: _response.error.errorMessage,
665
+ rawResponse: _response.rawResponse,
606
666
  });
607
667
  }
608
668
  });
@@ -39,7 +39,8 @@ export declare class Messages {
39
39
  * @example
40
40
  * await client.messages.list()
41
41
  */
42
- list(request?: Courier.ListMessagesRequest, requestOptions?: Messages.RequestOptions): Promise<Courier.ListMessagesResponse>;
42
+ list(request?: Courier.ListMessagesRequest, requestOptions?: Messages.RequestOptions): core.HttpResponsePromise<Courier.ListMessagesResponse>;
43
+ private __list;
43
44
  /**
44
45
  * Fetch the status of a message you've previously sent.
45
46
  *
@@ -52,7 +53,8 @@ export declare class Messages {
52
53
  * @example
53
54
  * await client.messages.get("message_id")
54
55
  */
55
- get(messageId: string, requestOptions?: Messages.RequestOptions): Promise<Courier.MessageDetailsExtended>;
56
+ get(messageId: string, requestOptions?: Messages.RequestOptions): core.HttpResponsePromise<Courier.MessageDetailsExtended>;
57
+ private __get;
56
58
  /**
57
59
  * Cancel a message that is currently in the process of being delivered. A well-formatted API call to the cancel message API will return either `200` status code for a successful cancellation or `409` status code for an unsuccessful cancellation. Both cases will include the actual message record in the response body (see details below).
58
60
  *
@@ -62,7 +64,8 @@ export declare class Messages {
62
64
  * @example
63
65
  * await client.messages.cancel("message_id")
64
66
  */
65
- cancel(messageId: string, requestOptions?: Messages.IdempotentRequestOptions): Promise<Courier.MessageDetails>;
67
+ cancel(messageId: string, requestOptions?: Messages.IdempotentRequestOptions): core.HttpResponsePromise<Courier.MessageDetails>;
68
+ private __cancel;
66
69
  /**
67
70
  * Fetch the array of events of a message you've previously sent.
68
71
  *
@@ -76,7 +79,8 @@ export declare class Messages {
76
79
  * @example
77
80
  * await client.messages.getHistory("message_id")
78
81
  */
79
- getHistory(messageId: string, request?: Courier.GetMessageHistoryRequest, requestOptions?: Messages.RequestOptions): Promise<Courier.MessageHistoryResponse>;
82
+ getHistory(messageId: string, request?: Courier.GetMessageHistoryRequest, requestOptions?: Messages.RequestOptions): core.HttpResponsePromise<Courier.MessageHistoryResponse>;
83
+ private __getHistory;
80
84
  /**
81
85
  * @param {string} messageId - A unique identifier associated with the message you wish to retrieve (results from a send).
82
86
  * @param {Messages.RequestOptions} requestOptions - Request-specific configuration.
@@ -87,7 +91,8 @@ export declare class Messages {
87
91
  * @example
88
92
  * await client.messages.getContent("message_id")
89
93
  */
90
- getContent(messageId: string, requestOptions?: Messages.RequestOptions): Promise<Courier.RenderOutputResponse>;
94
+ getContent(messageId: string, requestOptions?: Messages.RequestOptions): core.HttpResponsePromise<Courier.RenderOutputResponse>;
95
+ private __getContent;
91
96
  /**
92
97
  * @param {string} requestId - A unique identifier representing the request ID
93
98
  * @param {Messages.RequestOptions} requestOptions - Request-specific configuration.
@@ -95,6 +100,7 @@ export declare class Messages {
95
100
  * @example
96
101
  * await client.messages.archive("request_id")
97
102
  */
98
- archive(requestId: string, requestOptions?: Messages.RequestOptions): Promise<void>;
103
+ archive(requestId: string, requestOptions?: Messages.RequestOptions): core.HttpResponsePromise<void>;
104
+ private __archive;
99
105
  protected _getAuthorizationHeader(): Promise<string>;
100
106
  }