Skip to content

Commit 602404b

Browse files
authored
[Communication] Sms redesign new (Azure#19510)
* draft of the implementation * adding newTestCases * adding newTestCases * adding newTestCases * resolving conflicts * Draft * fixing pom * adding change log entry * fixing readme * re-generated code * Wrapping the SmsResponseItem into SmsSendResult * Wrapping the SmsResponseItem into SmsSendResult * added with response methods * remove with response methods * addressing comments * addressing comments * fixing readme * fixing coverage * fixing readme * fixing test coverage * fixing code coverage * addressing comments * addressing comments * addressing comments * addressing comments * fixing Readme Headers * fixing Readme dot
1 parent 320da85 commit 602404b

File tree

75 files changed

+2088
-1375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2088
-1375
lines changed

sdk/communication/azure-communication-sms/CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Release History
2-
32
## 1.0.0-beta.5 (Unreleased)
3+
###Added
4+
- Support for creating SmsClient with TokenCredential.
5+
- Added support for 1:N SMS messaging.
6+
- Added support for tagging SMS messages.
7+
- Send method series in SmsClient are idempotent under retry policy.
8+
- Added `SmsOptions`
9+
10+
### Breaking Change
11+
- Updated `public Mono<SendSmsResponse> sendMessage(PhoneNumberIdentifier from, PhoneNumberIdentifier to, String message)` to `public Mono<SendSmsResponse> sendMessage(PhoneNumberIdentifier from,List<PhoneNumberIdentifier> to, String message)`
12+
- Replaced `SendSmsResponse` with `SmsSendResult`
13+
414

515
## 1.0.0-beta.4 (Skipped)
616
### Added
Lines changed: 49 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Azure Communications SMS Service client library for Java
1+
## Azure Communications SMS Service client library for Java
22

33
Azure Communication SMS is used to send simple text messages.
44

@@ -38,54 +38,32 @@ via the endpoint() and httpClient() functions respectively.
3838
`AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID` and `AZURE_TENANT_ID` environment variables
3939
are needed to create a DefaultAzureCredential object.
4040

41-
<!-- embedme src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java#L81-L91 -->
41+
To create a SmsClient
42+
<!-- embedme src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java#L22-L35 -->
4243
```java
4344
// You can find your endpoint and access key from your resource in the Azure Portal
4445
String endpoint = "https://<RESOURCE_NAME>.communication.azure.com";
45-
46-
// Create an HttpClient builder of your choice and customize it
47-
HttpClient httpClient = new NettyAsyncHttpClientBuilder().build();
48-
49-
SmsClient smsClient = new SmsClientBuilder()
50-
.endpoint(endpoint)
51-
.credential(new DefaultAzureCredentialBuilder().build())
52-
.httpClient(httpClient)
53-
.buildClient();
54-
```
55-
56-
### Access Key Authentication
57-
58-
SMS messaging also uses HMAC authentication with a resource access key. The access key must be provided
59-
via the accessKey() function. Endpoint and httpClient must also be set via the endpoint() and httpClient()
60-
functions respectively.
61-
62-
<!-- embedme src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java#L25-L41 -->
63-
```java
64-
// You can find your endpoint and access key from your resource in the Azure Portal
65-
String endpoint = "https://<RESOURCE_NAME>.communication.azure.com";
66-
AzureKeyCredential keyCredential = new AzureKeyCredential("SECRET");
67-
46+
//Enter your azureKeyCredential
47+
AzureKeyCredential azureKeyCredential = new AzureKeyCredential("SECRET");
6848
// Instantiate the http client
6949
HttpClient httpClient = new NettyAsyncHttpClientBuilder().build();
70-
7150
// Create a new SmsClientBuilder to instantiate an SmsClient
7251
SmsClientBuilder smsClientBuilder = new SmsClientBuilder();
73-
7452
// Set the endpoint, access key, and the HttpClient
7553
smsClientBuilder.endpoint(endpoint)
76-
.credential(keyCredential)
54+
.credential(azureKeyCredential)
7755
.httpClient(httpClient);
78-
7956
// Build a new SmsClient
8057
SmsClient smsClient = smsClientBuilder.buildClient();
8158
```
8259

8360
Alternatively, you can provide the entire connection string using the connectionString() function instead of providing the endpoint and access key.
84-
<!-- embedme src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java#L66-L72 -->
61+
<!-- embedme src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java#L39-L46 -->
8562
```java
63+
// Create an HttpClient builder of your choice and customize it
64+
HttpClient httpClient = new NettyAsyncHttpClientBuilder().build();
8665
// You can find your connection string from your resource in the Azure Portal
8766
String connectionString = "<connection_string>";
88-
8967
SmsClient smsClient = new SmsClientBuilder()
9068
.connectionString(connectionString)
9169
.httpClient(httpClient)
@@ -94,40 +72,46 @@ SmsClient smsClient = new SmsClientBuilder()
9472

9573
## Examples
9674

97-
### Sending a message
98-
Use the `sendMessage` function to send a new message to a list of phone numbers.
99-
(Currently SMS Services only supports one phone number).
75+
### Sending a message to a single recipient
76+
Use the `send` function to send a new message to a phone number.
10077
Once you send the message, you'll receive a response where you can access several
101-
properties such as the message id with the `response.getMessageId()` function.
78+
properties such as the message id with the `messageResponseItem.getMessageId()` function.
10279

103-
<!-- embedme src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java#L43-L59 -->
80+
<!-- embedme src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java#L50-L60 -->
10481
```java
105-
// Currently Sms services only supports one phone number
106-
List<PhoneNumberIdentifier> to = new ArrayList<PhoneNumberIdentifier>();
107-
to.add(new PhoneNumberIdentifier("<to-phone-number>"));
108-
109-
// SendSmsOptions is an optional field. It can be used
110-
// to enable a delivery report to the Azure Event Grid
111-
SendSmsOptions options = new SendSmsOptions();
112-
options.setEnableDeliveryReport(true);
113-
114-
// Send the message and check the response for a message id
115-
SendSmsResponse response = smsClient.sendMessage(
116-
new PhoneNumberIdentifier("<leased-phone-number>"),
117-
to,
82+
//Send an sms to only one phone number
83+
SmsSendOptions options = new SmsSendOptions();
84+
options.setDeliveryReportEnabled(true);
85+
options.setTag("Tag"); /* Optional */
86+
// Send the message to a list of phone Numbers and check the response for a messages ids
87+
SmsSendResult response = smsClient.send(
88+
"<from-phone-number>",
89+
"<to-phone-number>",
11890
"your message",
11991
options /* Optional */);
120-
12192
System.out.println("MessageId: " + response.getMessageId());
12293
```
94+
### Sending a message to multiple recipients
95+
Use the `send` function to send a new message to a list of phone numbers.
96+
Once you send the message, you'll receive a PagedIterable response where you can access several
97+
properties such as the message id with the `messageResponseItem.getMessageId()` function.
12398

124-
## Contributing
125-
126-
This project welcomes contributions and suggestions. Most contributions require you to agree to a [Contributor License Agreement (CLA)][cla] declaring that you have the right to, and actually do, grant us the rights to use your contribution.
127-
128-
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
129-
130-
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments.
99+
<!-- embedme src/samples/java/com/azure/communication/sms/samples/quickstart/ReadmeSamples.java#L64-L76 -->
100+
```java
101+
//Send an sms to multiple phone numbers
102+
SmsSendOptions options = new SmsSendOptions();
103+
options.setDeliveryReportEnabled(true);
104+
options.setTag("Tag"); /* Optional */
105+
// Send the message to a list of phone Numbers and check the response for a messages ids
106+
Iterable<SmsSendResult> responseMultiplePhones = smsClient.send(
107+
"<from-phone-number>",
108+
new ArrayList<String>(Arrays.asList("<to-phone-number1>", "<to-phone-number2>")),
109+
"your message",
110+
options /* Optional */,
111+
null);
112+
for (SmsSendResult messageResponseItem : responseMultiplePhones) {
113+
System.out.println("MessageId sent to " + messageResponseItem.getTo() + ": " + messageResponseItem.getMessageId());
114+
```
131115

132116

133117
## Troubleshooting
@@ -149,3 +133,11 @@ Check out other client libraries for Azure Communication Services
149133
[source]: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/communication/azure-communication-sms/src
150134

151135
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Feng%2Fazure-communications-sms%2FREADME.png)
136+
137+
## Contributing
138+
139+
This project welcomes contributions and suggestions. Most contributions require you to agree to a [Contributor License Agreement (CLA)][cla] declaring that you have the right to, and actually do, grant us the rights to use your contribution.
140+
141+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
142+
143+
This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments.

sdk/communication/azure-communication-sms/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!-- Copyright (c) Microsoft Corporation. All rights reserved.
22
Licensed under the MIT License. -->
33
<project xmlns="http://maven.apache.org/POM/4.0.0"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
66
<modelVersion>4.0.0</modelVersion>
77

88
<parent>
@@ -105,7 +105,7 @@
105105
<scope>test</scope>
106106
</dependency>
107107
</dependencies>
108-
<build>
108+
<build>
109109
<plugins>
110110
<plugin>
111111
<groupId>org.jacoco</groupId>

0 commit comments

Comments
 (0)