@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.
- package/Client.d.ts +14 -48
- package/Client.js +20 -49
- package/README.md +113 -808
- package/api/client/requests/SendMessageRequest.d.ts +12 -47
- package/api/resources/audiences/client/Client.d.ts +10 -5
- package/api/resources/audiences/client/Client.js +45 -15
- package/api/resources/auditEvents/client/Client.d.ts +4 -2
- package/api/resources/auditEvents/client/Client.js +17 -5
- package/api/resources/authTokens/client/Client.d.ts +2 -1
- package/api/resources/authTokens/client/Client.js +8 -2
- package/api/resources/automations/client/Client.d.ts +4 -2
- package/api/resources/automations/client/Client.js +16 -4
- package/api/resources/brands/client/Client.d.ts +10 -5
- package/api/resources/brands/client/Client.js +45 -15
- package/api/resources/bulk/client/Client.d.ts +10 -5
- package/api/resources/bulk/client/Client.js +45 -15
- package/api/resources/commons/errors/AlreadyExistsError.d.ts +2 -1
- package/api/resources/commons/errors/AlreadyExistsError.js +2 -1
- package/api/resources/commons/errors/BadRequestError.d.ts +2 -1
- package/api/resources/commons/errors/BadRequestError.js +2 -1
- package/api/resources/commons/errors/ConflictError.d.ts +2 -1
- package/api/resources/commons/errors/ConflictError.js +2 -1
- package/api/resources/commons/errors/MessageNotFoundError.d.ts +2 -1
- package/api/resources/commons/errors/MessageNotFoundError.js +2 -1
- package/api/resources/commons/errors/NotFoundError.d.ts +2 -1
- package/api/resources/commons/errors/NotFoundError.js +2 -1
- package/api/resources/commons/errors/PaymentRequiredError.d.ts +2 -1
- package/api/resources/commons/errors/PaymentRequiredError.js +2 -1
- package/api/resources/inbound/client/Client.d.ts +2 -1
- package/api/resources/inbound/client/Client.js +10 -4
- package/api/resources/lists/client/Client.d.ts +20 -10
- package/api/resources/lists/client/Client.js +89 -29
- package/api/resources/messages/client/Client.d.ts +12 -6
- package/api/resources/messages/client/Client.js +56 -20
- package/api/resources/notifications/client/Client.d.ts +12 -6
- package/api/resources/notifications/client/Client.js +58 -13
- package/api/resources/profiles/client/Client.d.ts +16 -8
- package/api/resources/profiles/client/Client.js +75 -24
- package/api/resources/templates/client/Client.d.ts +2 -1
- package/api/resources/templates/client/Client.js +9 -3
- package/api/resources/tenants/client/Client.d.ts +14 -7
- package/api/resources/tenants/client/Client.js +61 -19
- package/api/resources/translations/client/Client.d.ts +4 -2
- package/api/resources/translations/client/Client.js +18 -6
- package/api/resources/users/resources/preferences/client/Client.d.ts +6 -3
- package/api/resources/users/resources/preferences/client/Client.js +38 -11
- package/api/resources/users/resources/tenants/client/Client.d.ts +10 -5
- package/api/resources/users/resources/tenants/client/Client.js +45 -12
- package/api/resources/users/resources/tokens/client/Client.d.ts +12 -6
- package/api/resources/users/resources/tokens/client/Client.js +53 -17
- package/core/fetcher/APIResponse.d.ts +10 -0
- package/core/fetcher/Fetcher.js +7 -0
- package/core/fetcher/Headers.d.ts +2 -0
- package/core/fetcher/Headers.js +84 -0
- package/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/core/fetcher/HttpResponsePromise.js +103 -0
- package/core/fetcher/RawResponse.d.ts +29 -0
- package/core/fetcher/RawResponse.js +44 -0
- package/core/fetcher/index.d.ts +3 -0
- package/core/fetcher/index.js +7 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +1 -1
- package/dist/Client.d.ts +14 -48
- package/dist/Client.js +20 -49
- package/dist/api/client/requests/SendMessageRequest.d.ts +12 -47
- package/dist/api/resources/audiences/client/Client.d.ts +10 -5
- package/dist/api/resources/audiences/client/Client.js +45 -15
- package/dist/api/resources/auditEvents/client/Client.d.ts +4 -2
- package/dist/api/resources/auditEvents/client/Client.js +17 -5
- package/dist/api/resources/authTokens/client/Client.d.ts +2 -1
- package/dist/api/resources/authTokens/client/Client.js +8 -2
- package/dist/api/resources/automations/client/Client.d.ts +4 -2
- package/dist/api/resources/automations/client/Client.js +16 -4
- package/dist/api/resources/brands/client/Client.d.ts +10 -5
- package/dist/api/resources/brands/client/Client.js +45 -15
- package/dist/api/resources/bulk/client/Client.d.ts +10 -5
- package/dist/api/resources/bulk/client/Client.js +45 -15
- package/dist/api/resources/commons/errors/AlreadyExistsError.d.ts +2 -1
- package/dist/api/resources/commons/errors/AlreadyExistsError.js +2 -1
- package/dist/api/resources/commons/errors/BadRequestError.d.ts +2 -1
- package/dist/api/resources/commons/errors/BadRequestError.js +2 -1
- package/dist/api/resources/commons/errors/ConflictError.d.ts +2 -1
- package/dist/api/resources/commons/errors/ConflictError.js +2 -1
- package/dist/api/resources/commons/errors/MessageNotFoundError.d.ts +2 -1
- package/dist/api/resources/commons/errors/MessageNotFoundError.js +2 -1
- package/dist/api/resources/commons/errors/NotFoundError.d.ts +2 -1
- package/dist/api/resources/commons/errors/NotFoundError.js +2 -1
- package/dist/api/resources/commons/errors/PaymentRequiredError.d.ts +2 -1
- package/dist/api/resources/commons/errors/PaymentRequiredError.js +2 -1
- package/dist/api/resources/inbound/client/Client.d.ts +2 -1
- package/dist/api/resources/inbound/client/Client.js +10 -4
- package/dist/api/resources/lists/client/Client.d.ts +20 -10
- package/dist/api/resources/lists/client/Client.js +89 -29
- package/dist/api/resources/messages/client/Client.d.ts +12 -6
- package/dist/api/resources/messages/client/Client.js +56 -20
- package/dist/api/resources/notifications/client/Client.d.ts +12 -6
- package/dist/api/resources/notifications/client/Client.js +58 -13
- package/dist/api/resources/profiles/client/Client.d.ts +16 -8
- package/dist/api/resources/profiles/client/Client.js +75 -24
- package/dist/api/resources/templates/client/Client.d.ts +2 -1
- package/dist/api/resources/templates/client/Client.js +9 -3
- package/dist/api/resources/tenants/client/Client.d.ts +14 -7
- package/dist/api/resources/tenants/client/Client.js +61 -19
- package/dist/api/resources/translations/client/Client.d.ts +4 -2
- package/dist/api/resources/translations/client/Client.js +18 -6
- package/dist/api/resources/users/resources/preferences/client/Client.d.ts +6 -3
- package/dist/api/resources/users/resources/preferences/client/Client.js +38 -11
- package/dist/api/resources/users/resources/tenants/client/Client.d.ts +10 -5
- package/dist/api/resources/users/resources/tenants/client/Client.js +45 -12
- package/dist/api/resources/users/resources/tokens/client/Client.d.ts +12 -6
- package/dist/api/resources/users/resources/tokens/client/Client.js +53 -17
- package/dist/core/fetcher/APIResponse.d.ts +10 -0
- package/dist/core/fetcher/Fetcher.js +7 -0
- package/dist/core/fetcher/Headers.d.ts +2 -0
- package/dist/core/fetcher/Headers.js +84 -0
- package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/core/fetcher/HttpResponsePromise.js +103 -0
- package/dist/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/core/fetcher/RawResponse.js +44 -0
- package/dist/core/fetcher/index.d.ts +3 -0
- package/dist/core/fetcher/index.js +7 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/errors/CourierError.d.ts +4 -1
- package/dist/errors/CourierError.js +4 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/errors/CourierError.d.ts +4 -1
- package/errors/CourierError.js +4 -7
- package/package.json +3 -2
- package/reference.md +12 -50
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/Client.d.ts
CHANGED
|
@@ -84,58 +84,24 @@ export declare class CourierClient {
|
|
|
84
84
|
* @example
|
|
85
85
|
* await client.send({
|
|
86
86
|
* message: {
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* context: undefined,
|
|
91
|
-
* metadata: undefined,
|
|
92
|
-
* preferences: undefined,
|
|
93
|
-
* providers: undefined,
|
|
94
|
-
* routing: undefined,
|
|
95
|
-
* timeout: undefined,
|
|
96
|
-
* delay: undefined,
|
|
97
|
-
* expiry: undefined,
|
|
98
|
-
* to: undefined,
|
|
87
|
+
* to: {
|
|
88
|
+
* email: "email@example.com"
|
|
89
|
+
* },
|
|
99
90
|
* content: {
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* align: "left",
|
|
110
|
-
* text_style: undefined,
|
|
111
|
-
* color: undefined,
|
|
112
|
-
* bold: undefined,
|
|
113
|
-
* italic: undefined,
|
|
114
|
-
* strikethrough: undefined,
|
|
115
|
-
* underline: undefined,
|
|
116
|
-
* locales: undefined,
|
|
117
|
-
* format: undefined
|
|
118
|
-
* }, {
|
|
119
|
-
* type: "text",
|
|
120
|
-
* channels: undefined,
|
|
121
|
-
* ref: undefined,
|
|
122
|
-
* if: undefined,
|
|
123
|
-
* loop: undefined,
|
|
124
|
-
* content: "content",
|
|
125
|
-
* align: "left",
|
|
126
|
-
* text_style: undefined,
|
|
127
|
-
* color: undefined,
|
|
128
|
-
* bold: undefined,
|
|
129
|
-
* italic: undefined,
|
|
130
|
-
* strikethrough: undefined,
|
|
131
|
-
* underline: undefined,
|
|
132
|
-
* locales: undefined,
|
|
133
|
-
* format: undefined
|
|
134
|
-
* }]
|
|
91
|
+
* title: "Welcome!",
|
|
92
|
+
* body: "Thanks for signing up, {{name}}"
|
|
93
|
+
* },
|
|
94
|
+
* data: {
|
|
95
|
+
* "name": "Peter Parker"
|
|
96
|
+
* },
|
|
97
|
+
* routing: {
|
|
98
|
+
* method: "single",
|
|
99
|
+
* channels: ["email"]
|
|
135
100
|
* }
|
|
136
101
|
* }
|
|
137
102
|
* })
|
|
138
103
|
*/
|
|
139
|
-
send(request: Courier.SendMessageRequest, requestOptions?: CourierClient.IdempotentRequestOptions):
|
|
104
|
+
send(request: Courier.SendMessageRequest, requestOptions?: CourierClient.IdempotentRequestOptions): core.HttpResponsePromise<Courier.SendMessageResponse>;
|
|
105
|
+
private __send;
|
|
140
106
|
protected _getAuthorizationHeader(): Promise<string>;
|
|
141
107
|
}
|
package/Client.js
CHANGED
|
@@ -141,65 +141,33 @@ class CourierClient {
|
|
|
141
141
|
* @example
|
|
142
142
|
* await client.send({
|
|
143
143
|
* message: {
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* context: undefined,
|
|
148
|
-
* metadata: undefined,
|
|
149
|
-
* preferences: undefined,
|
|
150
|
-
* providers: undefined,
|
|
151
|
-
* routing: undefined,
|
|
152
|
-
* timeout: undefined,
|
|
153
|
-
* delay: undefined,
|
|
154
|
-
* expiry: undefined,
|
|
155
|
-
* to: undefined,
|
|
144
|
+
* to: {
|
|
145
|
+
* email: "email@example.com"
|
|
146
|
+
* },
|
|
156
147
|
* content: {
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* align: "left",
|
|
167
|
-
* text_style: undefined,
|
|
168
|
-
* color: undefined,
|
|
169
|
-
* bold: undefined,
|
|
170
|
-
* italic: undefined,
|
|
171
|
-
* strikethrough: undefined,
|
|
172
|
-
* underline: undefined,
|
|
173
|
-
* locales: undefined,
|
|
174
|
-
* format: undefined
|
|
175
|
-
* }, {
|
|
176
|
-
* type: "text",
|
|
177
|
-
* channels: undefined,
|
|
178
|
-
* ref: undefined,
|
|
179
|
-
* if: undefined,
|
|
180
|
-
* loop: undefined,
|
|
181
|
-
* content: "content",
|
|
182
|
-
* align: "left",
|
|
183
|
-
* text_style: undefined,
|
|
184
|
-
* color: undefined,
|
|
185
|
-
* bold: undefined,
|
|
186
|
-
* italic: undefined,
|
|
187
|
-
* strikethrough: undefined,
|
|
188
|
-
* underline: undefined,
|
|
189
|
-
* locales: undefined,
|
|
190
|
-
* format: undefined
|
|
191
|
-
* }]
|
|
148
|
+
* title: "Welcome!",
|
|
149
|
+
* body: "Thanks for signing up, {{name}}"
|
|
150
|
+
* },
|
|
151
|
+
* data: {
|
|
152
|
+
* "name": "Peter Parker"
|
|
153
|
+
* },
|
|
154
|
+
* routing: {
|
|
155
|
+
* method: "single",
|
|
156
|
+
* channels: ["email"]
|
|
192
157
|
* }
|
|
193
158
|
* }
|
|
194
159
|
* })
|
|
195
160
|
*/
|
|
196
161
|
send(request, requestOptions) {
|
|
162
|
+
return core.HttpResponsePromise.fromPromise(this.__send(request, requestOptions));
|
|
163
|
+
}
|
|
164
|
+
__send(request, requestOptions) {
|
|
197
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
198
166
|
var _a, _b, _c;
|
|
199
167
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
200
168
|
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, "/send"),
|
|
201
169
|
method: "POST",
|
|
202
|
-
headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.
|
|
170
|
+
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),
|
|
203
171
|
contentType: "application/json",
|
|
204
172
|
requestType: "json",
|
|
205
173
|
body: request,
|
|
@@ -208,12 +176,13 @@ class CourierClient {
|
|
|
208
176
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
209
177
|
});
|
|
210
178
|
if (_response.ok) {
|
|
211
|
-
return _response.body;
|
|
179
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
212
180
|
}
|
|
213
181
|
if (_response.error.reason === "status-code") {
|
|
214
182
|
throw new errors.CourierError({
|
|
215
183
|
statusCode: _response.error.statusCode,
|
|
216
184
|
body: _response.error.body,
|
|
185
|
+
rawResponse: _response.rawResponse,
|
|
217
186
|
});
|
|
218
187
|
}
|
|
219
188
|
switch (_response.error.reason) {
|
|
@@ -221,12 +190,14 @@ class CourierClient {
|
|
|
221
190
|
throw new errors.CourierError({
|
|
222
191
|
statusCode: _response.error.statusCode,
|
|
223
192
|
body: _response.error.rawBody,
|
|
193
|
+
rawResponse: _response.rawResponse,
|
|
224
194
|
});
|
|
225
195
|
case "timeout":
|
|
226
196
|
throw new errors.CourierTimeoutError("Timeout exceeded when calling POST /send.");
|
|
227
197
|
case "unknown":
|
|
228
198
|
throw new errors.CourierError({
|
|
229
199
|
message: _response.error.errorMessage,
|
|
200
|
+
rawResponse: _response.rawResponse,
|
|
230
201
|
});
|
|
231
202
|
}
|
|
232
203
|
});
|