Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Communication] - SMS - Add Tests and Clean Up #19149

Merged
merged 5 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/communication/Azure.Communication.Sms/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

### Breaking
- Updated `Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default)`
to `Task<Response<SmsSendResult>> SendAsync(string from, string to, string message, Models.SmsSendOptions options = default)`
to `Task<Response<SmsSendResult>> SendAsync(string from, string to, string message, SmsSendOptions options = default)`
- Replaced `SendSmsResponse` with `SmsSendResult`

## 1.0.0-beta.3 (2020-11-16)
Expand Down
35 changes: 18 additions & 17 deletions sdk/communication/Azure.Communication.Sms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,32 @@ SmsClient client = new SmsClient(new Uri(endpoint), tokenCredential);
```

## Examples
### Send a SMS Message
### Send a 1:1 SMS Message
To send a SMS message, call the `Send` or `SendAsync` function from the `SmsClient`.
```C# Snippet:Azure_Communication_Sms_Tests_SendAsync
SmsSendResult result = await client.SendAsync(
from: "+18001230000" // Phone number acquired on your Azure Communication resource
to: "+18005670000",
message: "Hi");
Console.WriteLine($"Sms id: {result.MessageId}");
SmsSendResult sendResult = await smsClient.SendAsync(
from: "<from-phone-number>", // Your E.164 formatted from phone number used to send SMS
to: "<to-phone-number>", // E.164 formatted recipient phone number
message: "Hi");
Console.WriteLine($"Sms id: {sendResult.MessageId}");
```
### Send a Group SMS Message
### Send a 1:N SMS Message
To send a SMS message to a list of recipients, call the `Send` or `SendAsync` function from the `SmsClient` with a list of recipient's phone numbers.
You may also add pass in an options object to specify whether the delivery report should be enabled and set custom tags.
```C# Snippet:Azure_Communication_SmsClient_Send_GroupSmsWithOptions
Response<IEnumerable<SmsSendResult>> response = await client.SendAsync(
from: "+18001230000" // Phone number acquired on your Azure Communication resource
to: new string[] {"+18005670000", "+18008900000}",
message: "Hi",
options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL
{
Tag = "marketing", // custom tags
});
Response<IEnumerable<SmsSendResult>> response = await smsClient.SendAsync(
from: "<from-phone-number>", // Your E.164 formatted from phone number used to send SMS
to: new string[] { "<to-phone-number-1>", "<to-phone-number-2>" }, // E.164 formatted recipient phone numbers
message: "Weekly Promotion!",
options: new SmsSendOptions(enableDeliveryReport: true) // OPTIONAL
{
Tag = "marketing", // custom tags
});
IEnumerable<SmsSendResult> results = response.Value;
foreach (SmsSendResult result in results)
{
Console.WriteLine($"Sms id: {result.MessageId}");
Console.WriteLine($"Send Result Successful: {result.Successful}");
}
```
## Troubleshooting
Expand All @@ -81,8 +82,8 @@ All SMS operations will throw a RequestFailedException on failure.
try
{
SmsSendResult result = await client.SendAsync(
from: "+18001230000" // Phone number acquired on your Azure Communication resource
to: "+18005670000",
from: "<from-phone-number>" // Your E.164 formatted phone number used to send SMS
to: "<to-phone-number>", // E.164 formatted recipient phone number
message: "Hi");
Console.WriteLine($"Sms id: {result.MessageId}");
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading