@azure/communication-email 1.0.0-beta.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -45
- package/dist/index.js +340 -213
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +11 -24
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js +7 -10
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailWithAttachments.js +9 -12
- package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
- package/dist-esm/src/emailClient.js +8 -34
- package/dist-esm/src/emailClient.js.map +1 -1
- package/dist-esm/src/generated/src/emailRestApiClient.js +53 -10
- package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
- package/dist-esm/src/generated/src/index.js +11 -0
- package/dist-esm/src/generated/src/index.js.map +1 -0
- package/dist-esm/src/generated/src/lroImpl.js +25 -0
- package/dist-esm/src/generated/src/lroImpl.js.map +1 -0
- package/dist-esm/src/generated/src/models/index.js +14 -1
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +133 -85
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +25 -16
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/email.js +79 -40
- package/dist-esm/src/generated/src/operations/email.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/email.js +9 -0
- package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -0
- package/dist-esm/src/generated/src/operationsInterfaces/index.js +9 -0
- package/dist-esm/src/generated/src/operationsInterfaces/index.js.map +1 -0
- package/dist-esm/src/models.js +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/test/public/emailClient.spec.js +98 -127
- package/dist-esm/test/public/emailClient.spec.js.map +1 -1
- package/dist-esm/test/public/utils/recordedClient.js +46 -32
- package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
- package/package.json +16 -15
- package/types/communication-email.d.ts +147 -134
- package/dist-esm/samples-dev/checkMessageStatus.js +0 -46
- package/dist-esm/samples-dev/checkMessageStatus.js.map +0 -1
- package/dist-esm/src/constants.js +0 -4
- package/dist-esm/src/constants.js.map +0 -1
- package/dist-esm/src/generated/src/emailRestApiClientContext.js +0 -38
- package/dist-esm/src/generated/src/emailRestApiClientContext.js.map +0 -1
package/dist/index.js
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
5
|
+
var coreAuth = require('@azure/core-auth');
|
6
6
|
var communicationCommon = require('@azure/communication-common');
|
7
|
+
var coreClient = require('@azure/core-client');
|
8
|
+
var coreLro = require('@azure/core-lro');
|
9
|
+
var tslib = require('tslib');
|
7
10
|
var logger$1 = require('@azure/logger');
|
8
|
-
var uuid = require('uuid');
|
9
11
|
|
10
12
|
function _interopNamespace(e) {
|
11
13
|
if (e && e.__esModule) return e;
|
@@ -25,7 +27,7 @@ function _interopNamespace(e) {
|
|
25
27
|
return Object.freeze(n);
|
26
28
|
}
|
27
29
|
|
28
|
-
var
|
30
|
+
var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
|
29
31
|
|
30
32
|
/*
|
31
33
|
* Copyright (c) Microsoft Corporation.
|
@@ -34,13 +36,13 @@ var coreHttp__namespace = /*#__PURE__*/_interopNamespace(coreHttp);
|
|
34
36
|
* Code generated by Microsoft (R) AutoRest Code Generator.
|
35
37
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
36
38
|
*/
|
37
|
-
const
|
39
|
+
const EmailSendResult = {
|
38
40
|
type: {
|
39
41
|
name: "Composite",
|
40
|
-
className: "
|
42
|
+
className: "EmailSendResult",
|
41
43
|
modelProperties: {
|
42
|
-
|
43
|
-
serializedName: "
|
44
|
+
id: {
|
45
|
+
serializedName: "id",
|
44
46
|
required: true,
|
45
47
|
type: {
|
46
48
|
name: "String"
|
@@ -52,40 +54,32 @@ const SendStatusResult = {
|
|
52
54
|
type: {
|
53
55
|
name: "String"
|
54
56
|
}
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
};
|
59
|
-
const CommunicationErrorResponse = {
|
60
|
-
type: {
|
61
|
-
name: "Composite",
|
62
|
-
className: "CommunicationErrorResponse",
|
63
|
-
modelProperties: {
|
57
|
+
},
|
64
58
|
error: {
|
65
59
|
serializedName: "error",
|
66
60
|
type: {
|
67
61
|
name: "Composite",
|
68
|
-
className: "
|
62
|
+
className: "ErrorDetail"
|
69
63
|
}
|
70
64
|
}
|
71
65
|
}
|
72
66
|
}
|
73
67
|
};
|
74
|
-
const
|
68
|
+
const ErrorDetail = {
|
75
69
|
type: {
|
76
70
|
name: "Composite",
|
77
|
-
className: "
|
71
|
+
className: "ErrorDetail",
|
78
72
|
modelProperties: {
|
79
73
|
code: {
|
80
74
|
serializedName: "code",
|
81
|
-
|
75
|
+
readOnly: true,
|
82
76
|
type: {
|
83
77
|
name: "String"
|
84
78
|
}
|
85
79
|
},
|
86
80
|
message: {
|
87
81
|
serializedName: "message",
|
88
|
-
|
82
|
+
readOnly: true,
|
89
83
|
type: {
|
90
84
|
name: "String"
|
91
85
|
}
|
@@ -103,15 +97,62 @@ const CommunicationError = {
|
|
103
97
|
type: {
|
104
98
|
name: "Sequence",
|
105
99
|
element: {
|
106
|
-
type: {
|
100
|
+
type: {
|
101
|
+
name: "Composite",
|
102
|
+
className: "ErrorDetail"
|
103
|
+
}
|
107
104
|
}
|
108
105
|
}
|
109
106
|
},
|
110
|
-
|
111
|
-
serializedName: "
|
107
|
+
additionalInfo: {
|
108
|
+
serializedName: "additionalInfo",
|
109
|
+
readOnly: true,
|
110
|
+
type: {
|
111
|
+
name: "Sequence",
|
112
|
+
element: {
|
113
|
+
type: {
|
114
|
+
name: "Composite",
|
115
|
+
className: "ErrorAdditionalInfo"
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
};
|
123
|
+
const ErrorAdditionalInfo = {
|
124
|
+
type: {
|
125
|
+
name: "Composite",
|
126
|
+
className: "ErrorAdditionalInfo",
|
127
|
+
modelProperties: {
|
128
|
+
type: {
|
129
|
+
serializedName: "type",
|
130
|
+
readOnly: true,
|
131
|
+
type: {
|
132
|
+
name: "String"
|
133
|
+
}
|
134
|
+
},
|
135
|
+
info: {
|
136
|
+
serializedName: "info",
|
137
|
+
readOnly: true,
|
138
|
+
type: {
|
139
|
+
name: "Dictionary",
|
140
|
+
value: { type: { name: "any" } }
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
};
|
146
|
+
const ErrorResponse = {
|
147
|
+
type: {
|
148
|
+
name: "Composite",
|
149
|
+
className: "ErrorResponse",
|
150
|
+
modelProperties: {
|
151
|
+
error: {
|
152
|
+
serializedName: "error",
|
112
153
|
type: {
|
113
154
|
name: "Composite",
|
114
|
-
className: "
|
155
|
+
className: "ErrorDetail"
|
115
156
|
}
|
116
157
|
}
|
117
158
|
}
|
@@ -122,17 +163,15 @@ const EmailMessage = {
|
|
122
163
|
name: "Composite",
|
123
164
|
className: "EmailMessage",
|
124
165
|
modelProperties: {
|
125
|
-
|
166
|
+
headers: {
|
126
167
|
serializedName: "headers",
|
127
168
|
type: {
|
128
|
-
name: "
|
129
|
-
|
130
|
-
type: { name: "Composite", className: "EmailCustomHeader" }
|
131
|
-
}
|
169
|
+
name: "Dictionary",
|
170
|
+
value: { type: { name: "String" } }
|
132
171
|
}
|
133
172
|
},
|
134
|
-
|
135
|
-
serializedName: "
|
173
|
+
senderAddress: {
|
174
|
+
serializedName: "senderAddress",
|
136
175
|
required: true,
|
137
176
|
type: {
|
138
177
|
name: "String"
|
@@ -145,13 +184,6 @@ const EmailMessage = {
|
|
145
184
|
className: "EmailContent"
|
146
185
|
}
|
147
186
|
},
|
148
|
-
importance: {
|
149
|
-
defaultValue: "normal",
|
150
|
-
serializedName: "importance",
|
151
|
-
type: {
|
152
|
-
name: "String"
|
153
|
-
}
|
154
|
-
},
|
155
187
|
recipients: {
|
156
188
|
serializedName: "recipients",
|
157
189
|
type: {
|
@@ -163,18 +195,28 @@ const EmailMessage = {
|
|
163
195
|
serializedName: "attachments",
|
164
196
|
type: {
|
165
197
|
name: "Sequence",
|
166
|
-
element: {
|
198
|
+
element: {
|
199
|
+
type: {
|
200
|
+
name: "Composite",
|
201
|
+
className: "EmailAttachment"
|
202
|
+
}
|
203
|
+
}
|
167
204
|
}
|
168
205
|
},
|
169
206
|
replyTo: {
|
170
207
|
serializedName: "replyTo",
|
171
208
|
type: {
|
172
209
|
name: "Sequence",
|
173
|
-
element: {
|
210
|
+
element: {
|
211
|
+
type: {
|
212
|
+
name: "Composite",
|
213
|
+
className: "EmailAddress"
|
214
|
+
}
|
215
|
+
}
|
174
216
|
}
|
175
217
|
},
|
176
218
|
disableUserEngagementTracking: {
|
177
|
-
serializedName: "
|
219
|
+
serializedName: "userEngagementTrackingDisabled",
|
178
220
|
type: {
|
179
221
|
name: "Boolean"
|
180
222
|
}
|
@@ -182,28 +224,6 @@ const EmailMessage = {
|
|
182
224
|
}
|
183
225
|
}
|
184
226
|
};
|
185
|
-
const EmailCustomHeader = {
|
186
|
-
type: {
|
187
|
-
name: "Composite",
|
188
|
-
className: "EmailCustomHeader",
|
189
|
-
modelProperties: {
|
190
|
-
name: {
|
191
|
-
serializedName: "name",
|
192
|
-
required: true,
|
193
|
-
type: {
|
194
|
-
name: "String"
|
195
|
-
}
|
196
|
-
},
|
197
|
-
value: {
|
198
|
-
serializedName: "value",
|
199
|
-
required: true,
|
200
|
-
type: {
|
201
|
-
name: "String"
|
202
|
-
}
|
203
|
-
}
|
204
|
-
}
|
205
|
-
}
|
206
|
-
};
|
207
227
|
const EmailContent = {
|
208
228
|
type: {
|
209
229
|
name: "Composite",
|
@@ -238,24 +258,38 @@ const EmailRecipients = {
|
|
238
258
|
modelProperties: {
|
239
259
|
to: {
|
240
260
|
serializedName: "to",
|
241
|
-
required: true,
|
242
261
|
type: {
|
243
262
|
name: "Sequence",
|
244
|
-
element: {
|
263
|
+
element: {
|
264
|
+
type: {
|
265
|
+
name: "Composite",
|
266
|
+
className: "EmailAddress"
|
267
|
+
}
|
268
|
+
}
|
245
269
|
}
|
246
270
|
},
|
247
|
-
|
248
|
-
serializedName: "
|
271
|
+
cc: {
|
272
|
+
serializedName: "cc",
|
249
273
|
type: {
|
250
274
|
name: "Sequence",
|
251
|
-
element: {
|
275
|
+
element: {
|
276
|
+
type: {
|
277
|
+
name: "Composite",
|
278
|
+
className: "EmailAddress"
|
279
|
+
}
|
280
|
+
}
|
252
281
|
}
|
253
282
|
},
|
254
|
-
|
255
|
-
serializedName: "
|
283
|
+
bcc: {
|
284
|
+
serializedName: "bcc",
|
256
285
|
type: {
|
257
286
|
name: "Sequence",
|
258
|
-
element: {
|
287
|
+
element: {
|
288
|
+
type: {
|
289
|
+
name: "Composite",
|
290
|
+
className: "EmailAddress"
|
291
|
+
}
|
292
|
+
}
|
259
293
|
}
|
260
294
|
}
|
261
295
|
}
|
@@ -266,8 +300,8 @@ const EmailAddress = {
|
|
266
300
|
name: "Composite",
|
267
301
|
className: "EmailAddress",
|
268
302
|
modelProperties: {
|
269
|
-
|
270
|
-
serializedName: "
|
303
|
+
address: {
|
304
|
+
serializedName: "address",
|
271
305
|
required: true,
|
272
306
|
type: {
|
273
307
|
name: "String"
|
@@ -294,15 +328,15 @@ const EmailAttachment = {
|
|
294
328
|
name: "String"
|
295
329
|
}
|
296
330
|
},
|
297
|
-
|
298
|
-
serializedName: "
|
331
|
+
contentType: {
|
332
|
+
serializedName: "contentType",
|
299
333
|
required: true,
|
300
334
|
type: {
|
301
335
|
name: "String"
|
302
336
|
}
|
303
337
|
},
|
304
|
-
|
305
|
-
serializedName: "
|
338
|
+
contentInBase64: {
|
339
|
+
serializedName: "contentInBase64",
|
306
340
|
required: true,
|
307
341
|
type: {
|
308
342
|
name: "String"
|
@@ -311,10 +345,10 @@ const EmailAttachment = {
|
|
311
345
|
}
|
312
346
|
}
|
313
347
|
};
|
314
|
-
const
|
348
|
+
const EmailGetSendResultHeaders = {
|
315
349
|
type: {
|
316
350
|
name: "Composite",
|
317
|
-
className: "
|
351
|
+
className: "EmailGetSendResultHeaders",
|
318
352
|
modelProperties: {
|
319
353
|
retryAfter: {
|
320
354
|
serializedName: "retry-after",
|
@@ -325,17 +359,25 @@ const EmailGetSendStatusHeaders = {
|
|
325
359
|
}
|
326
360
|
}
|
327
361
|
};
|
328
|
-
const
|
362
|
+
const EmailGetSendResultExceptionHeaders = {
|
329
363
|
type: {
|
330
364
|
name: "Composite",
|
331
|
-
className: "
|
365
|
+
className: "EmailGetSendResultExceptionHeaders",
|
332
366
|
modelProperties: {
|
333
|
-
|
334
|
-
serializedName: "
|
367
|
+
xMsErrorCode: {
|
368
|
+
serializedName: "x-ms-error-code",
|
335
369
|
type: {
|
336
370
|
name: "String"
|
337
371
|
}
|
338
|
-
}
|
372
|
+
}
|
373
|
+
}
|
374
|
+
}
|
375
|
+
};
|
376
|
+
const EmailSendHeaders = {
|
377
|
+
type: {
|
378
|
+
name: "Composite",
|
379
|
+
className: "EmailSendHeaders",
|
380
|
+
modelProperties: {
|
339
381
|
operationLocation: {
|
340
382
|
serializedName: "operation-location",
|
341
383
|
type: {
|
@@ -347,9 +389,17 @@ const EmailSendHeaders = {
|
|
347
389
|
type: {
|
348
390
|
name: "Number"
|
349
391
|
}
|
350
|
-
}
|
351
|
-
|
352
|
-
|
392
|
+
}
|
393
|
+
}
|
394
|
+
}
|
395
|
+
};
|
396
|
+
const EmailSendExceptionHeaders = {
|
397
|
+
type: {
|
398
|
+
name: "Composite",
|
399
|
+
className: "EmailSendExceptionHeaders",
|
400
|
+
modelProperties: {
|
401
|
+
xMsErrorCode: {
|
402
|
+
serializedName: "x-ms-error-code",
|
353
403
|
type: {
|
354
404
|
name: "String"
|
355
405
|
}
|
@@ -360,17 +410,19 @@ const EmailSendHeaders = {
|
|
360
410
|
|
361
411
|
var Mappers = /*#__PURE__*/Object.freeze({
|
362
412
|
__proto__: null,
|
363
|
-
|
364
|
-
|
365
|
-
|
413
|
+
EmailSendResult: EmailSendResult,
|
414
|
+
ErrorDetail: ErrorDetail,
|
415
|
+
ErrorAdditionalInfo: ErrorAdditionalInfo,
|
416
|
+
ErrorResponse: ErrorResponse,
|
366
417
|
EmailMessage: EmailMessage,
|
367
|
-
EmailCustomHeader: EmailCustomHeader,
|
368
418
|
EmailContent: EmailContent,
|
369
419
|
EmailRecipients: EmailRecipients,
|
370
420
|
EmailAddress: EmailAddress,
|
371
421
|
EmailAttachment: EmailAttachment,
|
372
|
-
|
373
|
-
|
422
|
+
EmailGetSendResultHeaders: EmailGetSendResultHeaders,
|
423
|
+
EmailGetSendResultExceptionHeaders: EmailGetSendResultExceptionHeaders,
|
424
|
+
EmailSendHeaders: EmailSendHeaders,
|
425
|
+
EmailSendExceptionHeaders: EmailSendExceptionHeaders
|
374
426
|
});
|
375
427
|
|
376
428
|
/*
|
@@ -380,6 +432,17 @@ var Mappers = /*#__PURE__*/Object.freeze({
|
|
380
432
|
* Code generated by Microsoft (R) AutoRest Code Generator.
|
381
433
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
382
434
|
*/
|
435
|
+
const accept = {
|
436
|
+
parameterPath: "accept",
|
437
|
+
mapper: {
|
438
|
+
defaultValue: "application/json",
|
439
|
+
isConstant: true,
|
440
|
+
serializedName: "Accept",
|
441
|
+
type: {
|
442
|
+
name: "String"
|
443
|
+
}
|
444
|
+
}
|
445
|
+
};
|
383
446
|
const endpoint = {
|
384
447
|
parameterPath: "endpoint",
|
385
448
|
mapper: {
|
@@ -391,10 +454,10 @@ const endpoint = {
|
|
391
454
|
},
|
392
455
|
skipEncoding: true
|
393
456
|
};
|
394
|
-
const
|
395
|
-
parameterPath: "
|
457
|
+
const operationId = {
|
458
|
+
parameterPath: "operationId",
|
396
459
|
mapper: {
|
397
|
-
serializedName: "
|
460
|
+
serializedName: "operationId",
|
398
461
|
required: true,
|
399
462
|
type: {
|
400
463
|
name: "String"
|
@@ -404,7 +467,7 @@ const messageId = {
|
|
404
467
|
const apiVersion = {
|
405
468
|
parameterPath: "apiVersion",
|
406
469
|
mapper: {
|
407
|
-
defaultValue: "
|
470
|
+
defaultValue: "2023-03-31",
|
408
471
|
isConstant: true,
|
409
472
|
serializedName: "api-version",
|
410
473
|
type: {
|
@@ -423,27 +486,25 @@ const contentType = {
|
|
423
486
|
}
|
424
487
|
}
|
425
488
|
};
|
426
|
-
const
|
427
|
-
parameterPath: "
|
489
|
+
const message = {
|
490
|
+
parameterPath: "message",
|
428
491
|
mapper: EmailMessage
|
429
492
|
};
|
430
|
-
const
|
431
|
-
parameterPath: "
|
493
|
+
const operationId1 = {
|
494
|
+
parameterPath: ["options", "operationId"],
|
432
495
|
mapper: {
|
433
|
-
serializedName: "
|
434
|
-
required: true,
|
496
|
+
serializedName: "Operation-Id",
|
435
497
|
type: {
|
436
|
-
name: "
|
498
|
+
name: "Uuid"
|
437
499
|
}
|
438
500
|
}
|
439
501
|
};
|
440
|
-
const
|
441
|
-
parameterPath: "
|
502
|
+
const clientRequestId = {
|
503
|
+
parameterPath: ["options", "clientRequestId"],
|
442
504
|
mapper: {
|
443
|
-
serializedName: "
|
444
|
-
required: true,
|
505
|
+
serializedName: "x-ms-client-request-id",
|
445
506
|
type: {
|
446
|
-
name: "
|
507
|
+
name: "Uuid"
|
447
508
|
}
|
448
509
|
}
|
449
510
|
};
|
@@ -455,10 +516,32 @@ const repeatabilityFirstSent = {
|
|
455
516
|
* Code generated by Microsoft (R) AutoRest Code Generator.
|
456
517
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
457
518
|
*/
|
458
|
-
|
459
|
-
|
519
|
+
class LroImpl {
|
520
|
+
constructor(sendOperationFn, args, spec, requestPath = spec.path, requestMethod = spec.httpMethod) {
|
521
|
+
this.sendOperationFn = sendOperationFn;
|
522
|
+
this.args = args;
|
523
|
+
this.spec = spec;
|
524
|
+
this.requestPath = requestPath;
|
525
|
+
this.requestMethod = requestMethod;
|
526
|
+
}
|
527
|
+
async sendInitialRequest() {
|
528
|
+
return this.sendOperationFn(this.args, this.spec);
|
529
|
+
}
|
530
|
+
async sendPollRequest(path) {
|
531
|
+
const _a = this.spec, restSpec = tslib.__rest(_a, ["requestBody"]);
|
532
|
+
return this.sendOperationFn(this.args, Object.assign(Object.assign({}, restSpec), { path, httpMethod: "GET" }));
|
533
|
+
}
|
534
|
+
}
|
535
|
+
|
536
|
+
/*
|
537
|
+
* Copyright (c) Microsoft Corporation.
|
538
|
+
* Licensed under the MIT License.
|
539
|
+
*
|
540
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
541
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
460
542
|
*/
|
461
|
-
|
543
|
+
/** Class containing Email operations. */
|
544
|
+
class EmailImpl {
|
462
545
|
/**
|
463
546
|
* Initialize a new instance of the class Email class.
|
464
547
|
* @param client Reference to the service client
|
@@ -467,75 +550,114 @@ class Email {
|
|
467
550
|
this.client = client;
|
468
551
|
}
|
469
552
|
/**
|
470
|
-
* Gets the status of
|
471
|
-
* @param
|
553
|
+
* Gets the status of the email send operation.
|
554
|
+
* @param operationId ID of the long running operation (GUID) returned from a previous call to send
|
555
|
+
* email
|
472
556
|
* @param options The options parameters.
|
473
557
|
*/
|
474
|
-
|
475
|
-
|
476
|
-
return this.client.sendOperationRequest({ messageId, options: operationOptions }, getSendStatusOperationSpec);
|
558
|
+
getSendResult(operationId, options) {
|
559
|
+
return this.client.sendOperationRequest({ operationId, options }, getSendResultOperationSpec);
|
477
560
|
}
|
478
561
|
/**
|
479
562
|
* Queues an email message to be sent to one or more recipients
|
480
|
-
* @param
|
481
|
-
* is, that the client can make the request multiple times with the same Repeatability-Request-Id and
|
482
|
-
* get back an appropriate response without the server executing the request multiple times. The value
|
483
|
-
* of the Repeatability-Request-Id is an opaque string representing a client-generated, globally unique
|
484
|
-
* for all time, identifier for the request. It is recommended to use version 4 (random) UUIDs.
|
485
|
-
* @param repeatabilityFirstSent Must be sent by clients to specify that a request is repeatable.
|
486
|
-
* Repeatability-First-Sent is used to specify the date and time at which the request was first created
|
487
|
-
* in the IMF-fix date form of HTTP-date as defined in RFC7231. eg- Tue, 26 Mar 2019 16:06:51 GMT
|
488
|
-
* @param emailMessage Message payload for sending an email
|
563
|
+
* @param message Message payload for sending an email
|
489
564
|
* @param options The options parameters.
|
490
565
|
*/
|
491
|
-
|
492
|
-
const
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
566
|
+
async beginSend(message, options) {
|
567
|
+
const directSendOperation = async (args, spec) => {
|
568
|
+
return this.client.sendOperationRequest(args, spec);
|
569
|
+
};
|
570
|
+
const sendOperation = async (args, spec) => {
|
571
|
+
var _a;
|
572
|
+
let currentRawResponse = undefined;
|
573
|
+
const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse;
|
574
|
+
const callback = (rawResponse, flatResponse) => {
|
575
|
+
currentRawResponse = rawResponse;
|
576
|
+
providedCallback === null || providedCallback === void 0 ? void 0 : providedCallback(rawResponse, flatResponse);
|
577
|
+
};
|
578
|
+
const updatedArgs = Object.assign(Object.assign({}, args), { options: Object.assign(Object.assign({}, args.options), { onResponse: callback }) });
|
579
|
+
const flatResponse = await directSendOperation(updatedArgs, spec);
|
580
|
+
return {
|
581
|
+
flatResponse,
|
582
|
+
rawResponse: {
|
583
|
+
statusCode: currentRawResponse.status,
|
584
|
+
body: currentRawResponse.parsedBody,
|
585
|
+
headers: currentRawResponse.headers.toJSON()
|
586
|
+
}
|
587
|
+
};
|
588
|
+
};
|
589
|
+
const lro = new LroImpl(sendOperation, { message, options }, sendOperationSpec);
|
590
|
+
const poller = new coreLro.LroEngine(lro, {
|
591
|
+
resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom,
|
592
|
+
intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs,
|
593
|
+
lroResourceLocationConfig: "azure-async-operation"
|
594
|
+
});
|
595
|
+
await poller.poll();
|
596
|
+
return poller;
|
597
|
+
}
|
598
|
+
/**
|
599
|
+
* Queues an email message to be sent to one or more recipients
|
600
|
+
* @param message Message payload for sending an email
|
601
|
+
* @param options The options parameters.
|
602
|
+
*/
|
603
|
+
async beginSendAndWait(message, options) {
|
604
|
+
const poller = await this.beginSend(message, options);
|
605
|
+
return poller.pollUntilDone();
|
499
606
|
}
|
500
607
|
}
|
501
608
|
// Operation Specifications
|
502
|
-
const serializer =
|
503
|
-
const
|
504
|
-
path: "/emails/{
|
609
|
+
const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
|
610
|
+
const getSendResultOperationSpec = {
|
611
|
+
path: "/emails/operations/{operationId}",
|
505
612
|
httpMethod: "GET",
|
506
613
|
responses: {
|
507
614
|
200: {
|
508
|
-
bodyMapper:
|
509
|
-
headersMapper:
|
615
|
+
bodyMapper: EmailSendResult,
|
616
|
+
headersMapper: EmailGetSendResultHeaders
|
510
617
|
},
|
511
618
|
default: {
|
512
|
-
bodyMapper:
|
513
|
-
headersMapper:
|
619
|
+
bodyMapper: ErrorResponse,
|
620
|
+
headersMapper: EmailGetSendResultExceptionHeaders
|
514
621
|
}
|
515
622
|
},
|
516
623
|
queryParameters: [apiVersion],
|
517
|
-
urlParameters: [endpoint,
|
624
|
+
urlParameters: [endpoint, operationId],
|
625
|
+
headerParameters: [accept],
|
518
626
|
serializer
|
519
627
|
};
|
520
628
|
const sendOperationSpec = {
|
521
629
|
path: "/emails:send",
|
522
630
|
httpMethod: "POST",
|
523
631
|
responses: {
|
632
|
+
200: {
|
633
|
+
bodyMapper: EmailSendResult,
|
634
|
+
headersMapper: EmailSendHeaders
|
635
|
+
},
|
636
|
+
201: {
|
637
|
+
bodyMapper: EmailSendResult,
|
638
|
+
headersMapper: EmailSendHeaders
|
639
|
+
},
|
524
640
|
202: {
|
641
|
+
bodyMapper: EmailSendResult,
|
525
642
|
headersMapper: EmailSendHeaders
|
526
643
|
},
|
527
|
-
|
528
|
-
bodyMapper:
|
644
|
+
204: {
|
645
|
+
bodyMapper: EmailSendResult,
|
529
646
|
headersMapper: EmailSendHeaders
|
647
|
+
},
|
648
|
+
default: {
|
649
|
+
bodyMapper: ErrorResponse,
|
650
|
+
headersMapper: EmailSendExceptionHeaders
|
530
651
|
}
|
531
652
|
},
|
532
|
-
requestBody:
|
653
|
+
requestBody: message,
|
533
654
|
queryParameters: [apiVersion],
|
534
655
|
urlParameters: [endpoint],
|
535
656
|
headerParameters: [
|
657
|
+
accept,
|
536
658
|
contentType,
|
537
|
-
|
538
|
-
|
659
|
+
operationId1,
|
660
|
+
clientRequestId
|
539
661
|
],
|
540
662
|
mediaType: "json",
|
541
663
|
serializer
|
@@ -548,15 +670,14 @@ const sendOperationSpec = {
|
|
548
670
|
* Code generated by Microsoft (R) AutoRest Code Generator.
|
549
671
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
550
672
|
*/
|
551
|
-
|
552
|
-
const packageVersion = "1.0.0-beta.1";
|
553
|
-
class EmailRestApiClientContext extends coreHttp__namespace.ServiceClient {
|
673
|
+
class EmailRestApiClient extends coreClient__namespace.ServiceClient {
|
554
674
|
/**
|
555
|
-
* Initializes a new instance of the
|
675
|
+
* Initializes a new instance of the EmailRestApiClient class.
|
556
676
|
* @param endpoint The communication resource, for example https://my-resource.communication.azure.com
|
557
677
|
* @param options The parameter options
|
558
678
|
*/
|
559
679
|
constructor(endpoint, options) {
|
680
|
+
var _a, _b;
|
560
681
|
if (endpoint === undefined) {
|
561
682
|
throw new Error("'endpoint' cannot be null");
|
562
683
|
}
|
@@ -564,43 +685,51 @@ class EmailRestApiClientContext extends coreHttp__namespace.ServiceClient {
|
|
564
685
|
if (!options) {
|
565
686
|
options = {};
|
566
687
|
}
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
688
|
+
const defaults = {
|
689
|
+
requestContentType: "application/json; charset=utf-8"
|
690
|
+
};
|
691
|
+
const packageDetails = `azsdk-js-communication-email/1.0.0`;
|
692
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
693
|
+
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
694
|
+
: `${packageDetails}`;
|
695
|
+
const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
|
696
|
+
userAgentPrefix
|
697
|
+
}, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{endpoint}" });
|
698
|
+
super(optionsWithDefaults);
|
574
699
|
// Parameter assignments
|
575
700
|
this.endpoint = endpoint;
|
576
701
|
// Assigning values to Constant parameters
|
577
|
-
this.apiVersion = options.apiVersion || "
|
702
|
+
this.apiVersion = options.apiVersion || "2023-03-31";
|
703
|
+
this.email = new EmailImpl(this);
|
704
|
+
this.addCustomApiVersionPolicy(options.apiVersion);
|
578
705
|
}
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
706
|
+
/** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
|
707
|
+
addCustomApiVersionPolicy(apiVersion) {
|
708
|
+
if (!apiVersion) {
|
709
|
+
return;
|
710
|
+
}
|
711
|
+
const apiVersionPolicy = {
|
712
|
+
name: "CustomApiVersionPolicy",
|
713
|
+
async sendRequest(request, next) {
|
714
|
+
const param = request.url.split("?");
|
715
|
+
if (param.length > 1) {
|
716
|
+
const newParams = param[1].split("&").map((item) => {
|
717
|
+
if (item.indexOf("api-version") > -1) {
|
718
|
+
return "api-version=" + apiVersion;
|
719
|
+
}
|
720
|
+
else {
|
721
|
+
return item;
|
722
|
+
}
|
723
|
+
});
|
724
|
+
request.url = param[0] + "?" + newParams.join("&");
|
725
|
+
}
|
726
|
+
return next(request);
|
727
|
+
}
|
728
|
+
};
|
729
|
+
this.pipeline.addPolicy(apiVersionPolicy);
|
597
730
|
}
|
598
731
|
}
|
599
732
|
|
600
|
-
// Copyright (c) Microsoft Corporation.
|
601
|
-
// Licensed under the MIT license.
|
602
|
-
const SDK_VERSION = "1.0.0-beta.1";
|
603
|
-
|
604
733
|
// Copyright (c) Microsoft Corporation.
|
605
734
|
/**
|
606
735
|
* The \@azure/logger configuration for this package.
|
@@ -613,7 +742,7 @@ const logger = logger$1.createClientLogger("communication-email");
|
|
613
742
|
*
|
614
743
|
* @param options - The value being checked.
|
615
744
|
*/
|
616
|
-
const isEmailClientOptions = (options) => !!options && !communicationCommon.isKeyCredential(options);
|
745
|
+
const isEmailClientOptions = (options) => !!options && !coreAuth.isTokenCredential(options) && !communicationCommon.isKeyCredential(options);
|
617
746
|
/**
|
618
747
|
* The Email service client.
|
619
748
|
*/
|
@@ -621,48 +750,46 @@ class EmailClient {
|
|
621
750
|
constructor(connectionStringOrUrl, credentialOrOptions, maybeOptions = {}) {
|
622
751
|
const { url, credential } = communicationCommon.parseClientArguments(connectionStringOrUrl, credentialOrOptions);
|
623
752
|
const options = isEmailClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;
|
624
|
-
const libInfo = `azsdk-js-communication-email/${SDK_VERSION}`;
|
625
|
-
if (!options.userAgentOptions) {
|
626
|
-
options.userAgentOptions = {};
|
627
|
-
}
|
628
|
-
if (options.userAgentOptions.userAgentPrefix) {
|
629
|
-
options.userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`;
|
630
|
-
}
|
631
|
-
else {
|
632
|
-
options.userAgentOptions.userAgentPrefix = libInfo;
|
633
|
-
}
|
634
753
|
const internalPipelineOptions = Object.assign(Object.assign({}, options), {
|
635
754
|
loggingOptions: {
|
636
755
|
logger: logger.info,
|
637
756
|
},
|
638
757
|
});
|
639
758
|
const authPolicy = communicationCommon.createCommunicationAuthPolicy(credential);
|
640
|
-
|
641
|
-
this.
|
759
|
+
this.generatedClient = new EmailRestApiClient(url, internalPipelineOptions);
|
760
|
+
this.generatedClient.pipeline.addPolicy(authPolicy);
|
642
761
|
}
|
643
762
|
/**
|
644
763
|
* Queues an email message to be sent to one or more recipients
|
645
|
-
* @param
|
646
|
-
|
647
|
-
async send(emailMessage) {
|
648
|
-
var _a;
|
649
|
-
const response = await this.api.email.send(uuid.v4(), new Date().toUTCString(), emailMessage);
|
650
|
-
return {
|
651
|
-
messageId: (_a = response.xMsRequestId) !== null && _a !== void 0 ? _a : "",
|
652
|
-
};
|
653
|
-
}
|
654
|
-
/**
|
655
|
-
* Gets the status of a message sent previously.
|
656
|
-
* @param messageId - System generated message id (GUID) returned from a previous call to send email
|
764
|
+
* @param message - Message payload for sending an email
|
765
|
+
* @param options - The options parameters.
|
657
766
|
*/
|
658
|
-
|
659
|
-
|
660
|
-
return {
|
661
|
-
messageId: response.messageId,
|
662
|
-
status: response.status,
|
663
|
-
};
|
767
|
+
beginSend(message, options) {
|
768
|
+
return this.generatedClient.email.beginSend(message, options);
|
664
769
|
}
|
665
770
|
}
|
666
771
|
|
772
|
+
/*
|
773
|
+
* Copyright (c) Microsoft Corporation.
|
774
|
+
* Licensed under the MIT License.
|
775
|
+
*
|
776
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
777
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
778
|
+
*/
|
779
|
+
/** Known values of {@link EmailSendStatus} that the service accepts. */
|
780
|
+
exports.KnownEmailSendStatus = void 0;
|
781
|
+
(function (KnownEmailSendStatus) {
|
782
|
+
/** NotStarted */
|
783
|
+
KnownEmailSendStatus["NotStarted"] = "NotStarted";
|
784
|
+
/** Running */
|
785
|
+
KnownEmailSendStatus["Running"] = "Running";
|
786
|
+
/** Succeeded */
|
787
|
+
KnownEmailSendStatus["Succeeded"] = "Succeeded";
|
788
|
+
/** Failed */
|
789
|
+
KnownEmailSendStatus["Failed"] = "Failed";
|
790
|
+
/** Canceled */
|
791
|
+
KnownEmailSendStatus["Canceled"] = "Canceled";
|
792
|
+
})(exports.KnownEmailSendStatus || (exports.KnownEmailSendStatus = {}));
|
793
|
+
|
667
794
|
exports.EmailClient = EmailClient;
|
668
795
|
//# sourceMappingURL=index.js.map
|