-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Communication]: SMS 1:N Messages, Custom Tags, and Idempotence (#16836)
* Updated SMS clients with new swagger * Updated SMS client tests * Updated SMS samples * Added resending failed messages to SMS samples * Updated SMS clients to latest swagger * Updated SMS client tests and recordings * Updated SMS samples with changes from new swagger * Added more test cases * Rebased README file * Fixed pylint issues * Added Idempotence Parameters * Updated SWAGGER formatting * Added custom SendMessageRequest model to rename the smsSendOptions field to sendSmsOptions * Updated SMS options parameter * Hide repeatability_result from SmsSendResult * Updated failure message in SMS samples * Updated formatting in models file * Updated SmsSendResult * Refactored SmsSendResult * Fixed pylint issue * Updated CHANGELOG * Use UTC time zone for repeatability_first_sent * Cleaned up CHANGELOG * Updated SMS samples * Updated SmsSendOptions * Add test for idempotency * Added case when single recipient phone number is a string * Updated method documentation in SMS clients
- Loading branch information
1 parent
5d5d5e0
commit e1b84af
Showing
34 changed files
with
1,233 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,14 +28,14 @@ pip install azure-communication-sms | |
## Key concepts | ||
|
||
Azure Communication SMS package is used to do following: | ||
- Send an SMS | ||
- Send SMS Messages | ||
|
||
## Examples | ||
|
||
The following section provides several code snippets covering some of the most common Azure Communication Services tasks, including: | ||
|
||
- [Client Initialization](#client-initialization) | ||
- [Sending an SMS](#sending-an-sms) | ||
- [Sending SMS Messages](#sending--zsms) | ||
|
||
### Client Initialization | ||
|
||
|
@@ -54,23 +54,27 @@ endpoint = os.getenv('AZURE_COMMUNICATION_SERVICE_ENDPOINT') | |
sms_client = SmsClient(endpoint, DefaultAzureCredential()) | ||
``` | ||
|
||
### Sending an SMS | ||
### Sending SMS Messages | ||
|
||
Once the client is initialized, the `.send()` method can be invoked: | ||
|
||
```Python | ||
from azure.communication.sms import SendSmsOptions, PhoneNumberIdentifier | ||
from azure.communication.sms import SendSmsOptions | ||
|
||
smsresponse = sms_client.send( | ||
sms_responses = sms_client.send( | ||
from_phone_number=PhoneNumberIdentifier("<leased-phone-number>"), | ||
to_phone_number=[PhoneNumberIdentifier("<to-phone-number>")], | ||
to_phone_numbers=["<to-phone-number-1>", "<to-phone-number-2>", "<to-phone-number-3>"], | ||
message="Hello World via SMS", | ||
send_sms_options=SendSmsOptions(enable_delivery_report=True)) # optional property | ||
enable_delivery_report=True, # optional property | ||
tag="custom-tag") # optional property | ||
``` | ||
|
||
- `from-phone-number`: an SMS enabled phone number associated with your communication service | ||
- `to-phone-number`: the phone number you wish to send a message to | ||
- `send_sms_options`: an optional parameter that you can use to configure Delivery Reporting. This is useful for scenarios where you want to emit events when SMS messages are delivered. | ||
- `from_phone_number`: An SMS enabled phone number associated with your communication service. | ||
- `to_phone_numbers`: The phone numbers you wish to send a message to. | ||
- `message`: The message that you want to send. | ||
- `enable_delivery_report`: An optional parameter that you can use to configure delivery reporting. This is useful for scenarios where you want to emit events when SMS messages are delivered. | ||
- `tag`: An optional parameter that you can use to configure custom tagging. | ||
|
||
|
||
## Troubleshooting | ||
The Azure Communication Service Identity client will raise exceptions defined in [Azure Core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md). | ||
|
@@ -93,4 +97,7 @@ When you submit a pull request, a CLA-bot will automatically determine whether y | |
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. | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments. | ||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments. | ||
|
||
<!-- LINKS --> | ||
[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md |
13 changes: 2 additions & 11 deletions
13
sdk/communication/azure-communication-sms/azure/communication/sms/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
from ._sms_client import SmsClient | ||
|
||
from ._shared.models import ( | ||
PhoneNumberIdentifier, | ||
) | ||
|
||
from ._generated.models import ( | ||
SendSmsOptions, | ||
SendSmsResponse, | ||
) | ||
from ._models import SmsSendResult | ||
|
||
__all__ = [ | ||
'SmsClient', | ||
'PhoneNumberIdentifier', | ||
'SendSmsOptions', | ||
'SendSmsResponse', | ||
'SmsSendResult', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...n-sms/azure/communication/sms/_generated/models/_azure_communication_sms_service_enums.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from enum import Enum, EnumMeta | ||
from six import with_metaclass | ||
|
||
class _CaseInsensitiveEnumMeta(EnumMeta): | ||
def __getitem__(self, name): | ||
return super().__getitem__(name.upper()) | ||
|
||
def __getattr__(cls, name): | ||
"""Return the enum member matching `name` | ||
We use __getattr__ instead of descriptors or inserting into the enum | ||
class' __dict__ in order to support `name` and `value` being both | ||
properties for enum members (which live in the class' __dict__) and | ||
enum members themselves. | ||
""" | ||
try: | ||
return cls._member_map_[name.upper()] | ||
except KeyError: | ||
raise AttributeError(name) | ||
|
||
|
||
class SmsSendResponseItemRepeatabilityResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): | ||
"""The result of a repeatable request with one of the case-insensitive values accepted or | ||
rejected. | ||
""" | ||
|
||
ACCEPTED = "accepted" | ||
REJECTED = "rejected" |
Oops, something went wrong.