@azure/communication-email 1.0.0-alpha.20230301.3 → 1.0.0-alpha.20230303.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/README.md +32 -24
  2. package/dist/index.js +155 -220
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/samples-dev/checkMessageStatus.js +41 -0
  5. package/dist-esm/samples-dev/checkMessageStatus.js.map +1 -0
  6. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +8 -10
  7. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
  8. package/dist-esm/samples-dev/sendEmailSingleRecipient.js +5 -7
  9. package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
  10. package/dist-esm/samples-dev/sendEmailWithAttachments.js +7 -9
  11. package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
  12. package/dist-esm/src/emailClient.js +19 -4
  13. package/dist-esm/src/emailClient.js.map +1 -1
  14. package/dist-esm/src/generated/src/emailRestApiClient.js +1 -1
  15. package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
  16. package/dist-esm/src/generated/src/models/index.js +80 -14
  17. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  18. package/dist-esm/src/generated/src/models/mappers.js +87 -77
  19. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  20. package/dist-esm/src/generated/src/models/parameters.js +16 -14
  21. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  22. package/dist-esm/src/generated/src/operations/email.js +26 -72
  23. package/dist-esm/src/generated/src/operations/email.js.map +1 -1
  24. package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -1
  25. package/dist-esm/src/models.js +1 -1
  26. package/dist-esm/src/models.js.map +1 -1
  27. package/dist-esm/test/public/emailClient.spec.js +74 -24
  28. package/dist-esm/test/public/emailClient.spec.js.map +1 -1
  29. package/dist-esm/test/public/utils/recordedClient.js +13 -9
  30. package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
  31. package/package.json +1 -2
  32. package/types/communication-email.d.ts +110 -132
  33. package/dist-esm/src/generated/src/lroImpl.js +0 -25
  34. package/dist-esm/src/generated/src/lroImpl.js.map +0 -1
package/README.md CHANGED
@@ -18,7 +18,7 @@ npm install @azure/communication-email
18
18
 
19
19
  ## Examples
20
20
 
21
- `EmailClient` provides the functionality to send email messages.
21
+ `EmailClient` provides the functionality to send email messages .
22
22
 
23
23
  ## Authentication
24
24
 
@@ -42,7 +42,7 @@ AZURE_CLIENT_SECRET, AZURE_CLIENT_ID and AZURE_TENANT_ID environment variables a
42
42
 
43
43
  ```typescript
44
44
  import { DefaultAzureCredential } from "@azure/identity";
45
- import { EmailClient } from "@azure/communication-email";
45
+ import { SmsClient } from "@azure/communication-email";
46
46
 
47
47
  const endpoint = "https://<resource-name>.communication.azure.com";
48
48
  let credential = new DefaultAzureCredential();
@@ -51,11 +51,11 @@ const client = new EmailClient(endpoint, credential);
51
51
 
52
52
  ### Send an Email Message
53
53
 
54
- To send an email message, call the `beginSend` function from the `EmailClient`. This will return a poller. You can use this poller to check on the status of the operation and retrieve the result once it's finished.
54
+ To send an email message, call the `send` function from the `EmailClient`.
55
55
 
56
56
  ```javascript Snippet:Azure_Communication_Email_Send
57
- const message = {
58
- senderAddress: "sender@contoso.com",
57
+ const emailMessage = {
58
+ sender: "sender@contoso.com",
59
59
  content: {
60
60
  subject: "This is the subject",
61
61
  plainText: "This is the body",
@@ -63,15 +63,14 @@ const message = {
63
63
  recipients: {
64
64
  to: [
65
65
  {
66
- address: "customer@domain.com",
66
+ email: "customer@domain.com",
67
67
  displayName: "Customer Name",
68
68
  },
69
69
  ],
70
70
  },
71
71
  };
72
72
 
73
- const poller = await emailClient.beginSend(message);
74
- const response = await poller.pollUntilDone();
73
+ const response = await emailClient.send(emailMessage);
75
74
  ```
76
75
 
77
76
  ### Send an Email Message to Multiple Recipients
@@ -79,8 +78,8 @@ const response = await poller.pollUntilDone();
79
78
  To send an email message to multiple recipients, add a object for each recipient type and an object for each recipient.
80
79
 
81
80
  ```javascript Snippet:Azure_Communication_Email_Send_Multiple_Recipients
82
- const message = {
83
- senderAddress: "sender@contoso.com",
81
+ const emailMessage = {
82
+ sender: "sender@contoso.com",
84
83
  content: {
85
84
  subject: "This is the subject",
86
85
  plainText: "This is the body",
@@ -88,39 +87,38 @@ const message = {
88
87
  recipients: {
89
88
  to: [
90
89
  {
91
- address: "customer1@domain.com",
90
+ email: "customer1@domain.com",
92
91
  displayName: "Customer Name 1",
93
92
  },
94
93
  {
95
- address: "customer2@domain.com",
94
+ email: "customer2@domain.com",
96
95
  displayName: "Customer Name 2",
97
96
  },
98
97
  ],
99
98
  cc: [
100
99
  {
101
- address: "ccCustomer1@domain.com",
100
+ email: "ccCustomer1@domain.com",
102
101
  displayName: " CC Customer 1",
103
102
  },
104
103
  {
105
- address: "ccCustomer2@domain.com",
104
+ email: "ccCustomer2@domain.com",
106
105
  displayName: "CC Customer 2",
107
106
  },
108
107
  ],
109
108
  bcc: [
110
109
  {
111
- address: "bccCustomer1@domain.com",
110
+ email: "bccCustomer1@domain.com",
112
111
  displayName: " BCC Customer 1",
113
112
  },
114
113
  {
115
- address: "bccCustomer2@domain.com",
114
+ email: "bccCustomer2@domain.com",
116
115
  displayName: "BCC Customer 2",
117
116
  },
118
117
  ],
119
118
  },
120
119
  };
121
120
 
122
- const poller = await emailClient.beginSend(message);
123
- const response = await poller.pollUntilDone();
121
+ const response = await emailClient.send(emailMessage);
124
122
  ```
125
123
 
126
124
  ### Send Email with Attachments
@@ -130,8 +128,8 @@ Azure Communication Services support sending email with attachments.
130
128
  ```javascript Snippet:Azure_Communication_Email_Send_With_Attachments
131
129
  const filePath = "C://readme.txt";
132
130
 
133
- const message = {
134
- senderAddress: "sender@contoso.com",
131
+ const emailMessage = {
132
+ sender: "sender@contoso.com",
135
133
  content: {
136
134
  subject: "This is the subject",
137
135
  plainText: "This is the body",
@@ -139,7 +137,7 @@ const message = {
139
137
  recipients: {
140
138
  to: [
141
139
  {
142
- address: "customer@domain.com",
140
+ email: "customer@domain.com",
143
141
  displayName: "Customer Name",
144
142
  },
145
143
  ],
@@ -147,13 +145,23 @@ const message = {
147
145
  attachments: [
148
146
  {
149
147
  name: path.basename(filePath),
150
- contentType: "text/plain",
151
- contentInBase64: readFileSync(filePath, "base64"),
148
+ attachmentType: "txt",
149
+ contentBytesBase64: readFileSync(filePath, "base64"),
152
150
  },
153
151
  ],
154
152
  };
155
153
 
156
- const response = await emailClient.send(message);
154
+ const response = await emailClient.send(emailMessage);
155
+ ```
156
+
157
+ ### Get Email Message Status
158
+
159
+ The result from the `send` call contains a `messageId` which can be used to query the status of the email.
160
+
161
+ ```javascript Snippet:Azure_Communication_Email_GetSendStatus
162
+ const response = await emailClient.send(emailMessage);
163
+
164
+ const status = await emailClient.getSendStatus(response.messageId);
157
165
  ```
158
166
 
159
167
  ## Next steps