def test_send_sms(self):

        # calling send() with sms values
        sms_response = self.sms_client.send(
            from_phone_number=PhoneNumber(self.phone_number),
            to_phone_numbers=[PhoneNumber(self.phone_number)],
            message="Hello World via SMS",
            send_sms_options=SendSmsOptions(enable_delivery_report=True))  # optional property

        assert sms_response.message_id is not None
    async def test_send_sms_async(self):

        sms_client = SmsClient.from_connection_string(self.connection_str)

        async with sms_client:
            # calling send() with sms values
            sms_response = await sms_client.send(
                from_phone_number=PhoneNumber(self.phone_number),
                to_phone_numbers=[PhoneNumber(self.phone_number)],
                message="Hello World via SMS",
                send_sms_options=SendSmsOptions(enable_delivery_report=True))  # optional property

            assert sms_response.message_id is not None
Ejemplo n.º 3
0
 def send_sms(self,
              message_to_send: str,
              delivery_report_bool: bool = False) -> SendSmsResponse:
     sms_response = self.sms_client.send(
         from_phone_number=PhoneNumber(self.leased_phone_number),
         to_phone_numbers=[
             PhoneNumber(phone_number)
             for phone_number in self.target_phone_numbers.split(',')
         ],
         message=message_to_send,
         send_sms_options=SendSmsOptions(
             enable_delivery_report=delivery_report_bool))
     print(sms_response.__dict__)
     return sms_response
Ejemplo n.º 4
0
    def send_sms(self):
        connection_string = "COMMUNICATION_SERVICES_CONNECTION_STRING"

        sms_client = SmsClient.from_connection_string(connection_string)

        # calling send() with sms values
        smsresponse = sms_client.send(
            from_phone_number=PhoneNumberIdentifier("<leased-phone-number>"),
            to_phone_numbers=[PhoneNumberIdentifier("<to-phone-number>")],
            message="Hello World via SMS",
            send_sms_options=SendSmsOptions(
                enable_delivery_report=True))  # optional property

        print(smsresponse)
    async def send_sms_async(self):
        connection_string = "COMMUNICATION_SERVICES_CONNECTION_STRING"
        sms_client = SmsClient.from_connection_string(connection_string)

        async with sms_client:
            try:
                # calling send() with constructed request object
                smsresponse = await sms_client.send(
                    from_phone_number=PhoneNumberIdentifier("<leased-phone-number>"),
                    to_phone_numbers=[PhoneNumberIdentifier("<to-phone-number>")],
                    message="Hello World via SMS",
                    send_sms_options=SendSmsOptions(enable_delivery_report=True)) # optional property
            except Exception:
                print(Exception)
                pass

            print(smsresponse)
Ejemplo n.º 6
0
    async def test_send_sms_async_from_managed_identity(self):
        endpoint, access_key = parse_connection_str(self.connection_str)
        from devtools_testutils import is_live
        if not is_live():
            credential = FakeTokenCredential()
        else:
            credential = DefaultAzureCredential()
        sms_client = SmsClient(endpoint, credential)
        print(sms_client)
        async with sms_client:
            # calling send() with sms values
            sms_response = await sms_client.send(
                from_phone_number=PhoneNumber(self.phone_number),
                to_phone_numbers=[PhoneNumber(self.phone_number)],
                message="Hello World via SMS",
                send_sms_options=SendSmsOptions(enable_delivery_report=True)
            )  # optional property

            assert sms_response.message_id is not None