-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Communication]: SMS 1:N Messages, Custom Tags, and Idempotence #16836
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1596b03
Updated SMS clients with new swagger
lsundaralingam 214605a
Updated SMS client tests
lsundaralingam ea773b2
Updated SMS samples
lsundaralingam 57cc156
Added resending failed messages to SMS samples
lsundaralingam ba3c2af
Updated SMS clients to latest swagger
lsundaralingam 850d194
Updated SMS client tests and recordings
lsundaralingam b2b87f6
Updated SMS samples with changes from new swagger
lsundaralingam 527ac62
Added more test cases
lsundaralingam 0c6cad9
Rebased README file
lsundaralingam 52eb222
Fixed pylint issues
lsundaralingam cfdd168
Added Idempotence Parameters
lsundaralingam b2a6d6f
Updated SWAGGER formatting
lsundaralingam 34eb926
Added custom SendMessageRequest model to rename the smsSendOptions fi…
lsundaralingam 6576d90
Updated SMS options parameter
lsundaralingam 9590bb7
Hide repeatability_result from SmsSendResult
lsundaralingam 87a2301
Updated failure message in SMS samples
lsundaralingam 1577572
Updated formatting in models file
lsundaralingam 3383cd8
Updated SmsSendResult
lsundaralingam b64d567
Refactored SmsSendResult
lsundaralingam 63e9dac
Fixed pylint issue
lsundaralingam 521ef56
Updated CHANGELOG
lsundaralingam 51b6396
Use UTC time zone for repeatability_first_sent
lsundaralingam 763fe6c
Cleaned up CHANGELOG
lsundaralingam c763cdc
Updated SMS samples
lsundaralingam 9c1a87e
Updated SmsSendOptions
lsundaralingam b486623
Add test for idempotency
lsundaralingam 494827a
Added case when single recipient phone number is a string
lsundaralingam 837fb30
Updated method documentation in SMS clients
lsundaralingam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.