diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 7e1718d4..f318350f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,6 +7,8 @@ env: PROJECT_ID: ${{ secrets.PROJECT_ID }} NUMBERS_ORIGIN: ${{ secrets.NUMBERS_ORIGIN }} SMS_ORIGIN: ${{ secrets.SMS_ORIGIN }} + SERVICE_PLAN_ID: ${{ secrets.SERVICE_PLAN_ID }} + SMS_API_TOKEN: ${{ secrets.SMS_API_TOKEN }} CONVERSATION_ORIGIN: ${{ secrets.CONVERSATION_ORIGIN }} AUTH_ORIGIN: ${{ secrets.AUTH_ORIGIN }} DISABLE_SSL: ${{ secrets.DISABLE_SSL }} diff --git a/sinch/core/clients/sinch_client_async.py b/sinch/core/clients/sinch_client_async.py index 72f34593..55133dc7 100644 --- a/sinch/core/clients/sinch_client_async.py +++ b/sinch/core/clients/sinch_client_async.py @@ -25,7 +25,9 @@ def __init__( logger_name: str = None, logger: Logger = None, application_key: str = None, - application_secret: str = None + application_secret: str = None, + service_plan_id: str = None, + sms_api_token: str = None ): self.configuration = Configuration( key_id=key_id, @@ -36,7 +38,9 @@ def __init__( transport=HTTPXTransport(self), token_manager=TokenManagerAsync(self), application_secret=application_secret, - application_key=application_key + application_key=application_key, + service_plan_id=service_plan_id, + sms_api_token=sms_api_token ) self.authentication = AuthenticationAsync(self) diff --git a/sinch/core/clients/sinch_client_base.py b/sinch/core/clients/sinch_client_base.py index f7f66c91..6072bfe0 100644 --- a/sinch/core/clients/sinch_client_base.py +++ b/sinch/core/clients/sinch_client_base.py @@ -30,7 +30,9 @@ def __init__( logger_name: str = None, logger: Logger = None, application_key: str = None, - application_secret: str = None + application_secret: str = None, + service_plan_id: str = None, + sms_api_token: str = None ): pass diff --git a/sinch/core/clients/sinch_client_configuration.py b/sinch/core/clients/sinch_client_configuration.py index 7ec0ec91..1af0f756 100644 --- a/sinch/core/clients/sinch_client_configuration.py +++ b/sinch/core/clients/sinch_client_configuration.py @@ -4,6 +4,7 @@ from sinch.core.ports.http_transport import HTTPTransport from sinch.core.token_manager import TokenManager, TokenManagerAsync +from sinch.core.enums import HTTPAuthentication class Configuration: @@ -22,7 +23,9 @@ def __init__( disable_https=False, connection_timeout=10, application_key: str = None, - application_secret: str = None + application_secret: str = None, + service_plan_id: str = None, + sms_api_token: str = None ): self.key_id = key_id self.key_secret = key_secret @@ -30,6 +33,8 @@ def __init__( self.application_key = application_key self.application_secret = application_secret self.connection_timeout = connection_timeout + self.sms_api_token = sms_api_token + self.service_plan_id = service_plan_id self.auth_origin = "auth.sinch.com" self.numbers_origin = "numbers.api.sinch.com" self.verification_origin = "verification.api.sinch.com" @@ -39,7 +44,10 @@ def __init__( self._conversation_region = "eu" self._conversation_domain = ".conversation.api.sinch.com" self._sms_region = "us" + self._sms_region_with_service_plan_id = "us" self._sms_domain = "zt.{}.sms.api.sinch.com" + self._sms_domain_with_service_plan_id = "{}.sms.api.sinch.com" + self._sms_authentication = HTTPAuthentication.OAUTH.value self._templates_region = "eu" self._templates_domain = ".template.api.sinch.com" self.token_manager = token_manager @@ -48,6 +56,7 @@ def __init__( self._set_conversation_origin() self._set_sms_origin() + self._set_sms_origin_with_service_plan_id() self._set_templates_origin() self._set_voice_origin() @@ -58,23 +67,35 @@ def __init__( else: self.logger = logging.getLogger("Sinch") - def _set_voice_origin(self): - if not self._voice_region: - self.voice_origin = self._voice_domain.format("calling") - else: - self.voice_origin = self._voice_domain.format("calling-" + self._voice_region) + def _set_sms_origin_with_service_plan_id(self): + self.sms_origin_with_service_plan_id = self._sms_domain_with_service_plan_id.format( + self._sms_region_with_service_plan_id + ) - def _set_voice_region(self, region): - self._voice_region = region - self._set_voice_origin() + def _set_sms_region_with_service_plan_id(self, region): + self._sms_region_with_service_plan_id = region + self._set_sms_origin_with_service_plan_id() - def _get_voice_region(self): - return self._voice_region + def _get_sms_region_with_service_plan_id(self): + return self._sms_region_with_service_plan_id - voice_region = property( - _get_voice_region, - _set_voice_region, - doc="Voice Region" + sms_region_with_service_plan_id = property( + _get_sms_region_with_service_plan_id, + _set_sms_region_with_service_plan_id, + doc="SMS Region for service plan id version of the SMS API" + ) + + def _set_sms_domain_with_service_plan_id(self, domain): + self._sms_domain_with_service_plan_id = domain + self._set_sms_origin_with_service_plan_id() + + def _get_sms_domain_with_service_plan_id(self): + return self._sms_domain_with_service_plan_id + + sms_domain_with_service_plan_id = property( + _get_sms_domain_with_service_plan_id, + _set_sms_domain_with_service_plan_id, + doc="SMS Domain for service plan id version of the SMS API" ) def _set_sms_origin(self): @@ -163,3 +184,22 @@ def _get_templates_domain(self): _set_templates_domain, doc="Conversation API Templates Domain" ) + + def _set_voice_origin(self): + if not self._voice_region: + self.voice_origin = self._voice_domain.format("calling") + else: + self.voice_origin = self._voice_domain.format("calling-" + self._voice_region) + + def _set_voice_region(self, region): + self._voice_region = region + self._set_voice_origin() + + def _get_voice_region(self): + return self._voice_region + + voice_region = property( + _get_voice_region, + _set_voice_region, + doc="Voice Region" + ) diff --git a/sinch/core/clients/sinch_client_sync.py b/sinch/core/clients/sinch_client_sync.py index 45f249a1..b2e6055c 100644 --- a/sinch/core/clients/sinch_client_sync.py +++ b/sinch/core/clients/sinch_client_sync.py @@ -25,7 +25,9 @@ def __init__( logger_name: str = None, logger: Logger = None, application_key: str = None, - application_secret: str = None + application_secret: str = None, + service_plan_id: str = None, + sms_api_token: str = None ): self.configuration = Configuration( key_id=key_id, @@ -36,7 +38,9 @@ def __init__( transport=HTTPTransportRequests(self), token_manager=TokenManager(self), application_key=application_key, - application_secret=application_secret + application_secret=application_secret, + service_plan_id=service_plan_id, + sms_api_token=sms_api_token ) self.authentication = Authentication(self) diff --git a/sinch/core/enums.py b/sinch/core/enums.py index c1d63ee8..0898c2cc 100644 --- a/sinch/core/enums.py +++ b/sinch/core/enums.py @@ -13,3 +13,4 @@ class HTTPAuthentication(Enum): BASIC = "BASIC" OAUTH = "OAUTH" SIGNED = "SIGNED" + SMS_TOKEN = "SMS_TOKEN" diff --git a/sinch/core/ports/http_transport.py b/sinch/core/ports/http_transport.py index 865ea719..e76f38b9 100644 --- a/sinch/core/ports/http_transport.py +++ b/sinch/core/ports/http_transport.py @@ -63,6 +63,20 @@ def authenticate(self, endpoint, request_data): endpoint.get_url_without_origin(self.sinch) ) request_data.headers = signature.get_http_headers_with_signature() + elif endpoint.HTTP_AUTHENTICATION == HTTPAuthentication.SMS_TOKEN.value: + if not self.sinch.configuration.sms_api_token or not self.sinch.configuration.service_plan_id: + raise ValidationException( + message=( + "sms_api_token and service_plan_id are required by this API. " + "Those credentials can be obtained from Sinch portal." + ), + is_from_server=False, + response=None + ) + request_data.headers.update({ + "Authorization": f"Bearer {self.sinch.configuration.sms_api_token}", + "Content-Type": "application/json" + }) return request_data diff --git a/sinch/domains/sms/__init__.py b/sinch/domains/sms/__init__.py index ac3a39e0..d2223066 100644 --- a/sinch/domains/sms/__init__.py +++ b/sinch/domains/sms/__init__.py @@ -111,7 +111,7 @@ def list( return IntBasedPaginator._initialize( sinch=self._sinch, endpoint=ListDeliveryReportsEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ListSMSDeliveryReportsRequest( page=page, page_size=page_size, @@ -133,7 +133,7 @@ def get_for_batch( ) -> GetSMSDeliveryReportForBatchResponse: return self._sinch.configuration.transport.request( GetDeliveryReportForBatchEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=GetSMSDeliveryReportForBatchRequest( batch_id=batch_id, type_=type_, @@ -150,7 +150,7 @@ def get_for_number( ) -> GetSMSDeliveryReportForNumberResponse: return self._sinch.configuration.transport.request( GetDeliveryReportForNumberEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=GetSMSDeliveryReportForNumberRequest( batch_id=batch_id, recipient_number=recipient_number @@ -173,7 +173,7 @@ async def list( return await AsyncIntBasedPaginator._initialize( sinch=self._sinch, endpoint=ListDeliveryReportsEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ListSMSDeliveryReportsRequest( page=page, page_size=page_size, @@ -203,7 +203,7 @@ def list( return IntBasedPaginator._initialize( sinch=self._sinch, endpoint=ListInboundMessagesEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ListSMSInboundMessageRequest( page=page, page_size=page_size, @@ -218,7 +218,7 @@ def list( def get(self, inbound_id: str) -> GetInboundMessagesResponse: return self._sinch.configuration.transport.request( GetInboundMessagesEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=GetSMSInboundMessageRequest( inbound_id=inbound_id ) @@ -239,7 +239,7 @@ async def list( return await AsyncIntBasedPaginator._initialize( sinch=self._sinch, endpoint=ListInboundMessagesEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ListSMSInboundMessageRequest( page=page, page_size=page_size, @@ -277,7 +277,7 @@ def send( ) -> SendSMSBatchResponse: return self._sinch.configuration.transport.request( SendBatchSMSEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=SendBatchRequest( to=to, body=body, @@ -311,7 +311,7 @@ def list( return IntBasedPaginator._initialize( sinch=self._sinch, endpoint=ListSMSBatchesEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ListBatchesRequest( page=page, page_size=page_size, @@ -326,7 +326,7 @@ def list( def get(self, batch_id: str) -> GetSMSBatchResponse: return self._sinch.configuration.transport.request( GetSMSEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=GetBatchRequest( batch_id=batch_id ) @@ -353,7 +353,7 @@ def send_dry_run( ) -> SendSMSBatchDryRunResponse: return self._sinch.configuration.transport.request( SendBatchSMSDryRunEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=BatchDryRunRequest( per_recipient=per_recipient, number_of_recipients=number_of_recipients, @@ -377,7 +377,7 @@ def send_dry_run( def cancel(self, batch_id: str) -> CancelSMSBatchResponse: return self._sinch.configuration.transport.request( CancelBatchEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=CancelBatchRequest( batch_id=batch_id ) @@ -398,7 +398,7 @@ def update( ) -> UpdateSMSBatchResponse: return self._sinch.configuration.transport.request( UpdateBatchSMSEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=UpdateBatchRequest( batch_id=batch_id, to_add=to_add, @@ -432,7 +432,7 @@ def replace( ) -> ReplaceSMSBatchResponse: return self._sinch.configuration.transport.request( ReplaceBatchSMSEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ReplaceBatchRequest( batch_id=batch_id, to=to, @@ -459,7 +459,7 @@ def send_delivery_feedback( ) -> SendSMSDeliveryFeedbackResponse: return self._sinch.configuration.transport.request( SendDeliveryReportEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=SendDeliveryFeedbackRequest( batch_id=batch_id, recipients=recipients @@ -481,7 +481,7 @@ async def list( return await AsyncIntBasedPaginator._initialize( sinch=self._sinch, endpoint=ListSMSBatchesEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ListBatchesRequest( page=page, page_size=page_size, @@ -507,7 +507,7 @@ def create( ) -> CreateSMSGroupResponse: return self._sinch.configuration.transport.request( CreateSMSGroupEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=CreateSMSGroupRequest( name=name, members=members, @@ -525,7 +525,7 @@ def list( return IntBasedPaginator._initialize( sinch=self._sinch, endpoint=ListSMSGroupEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ListSMSGroupRequest( page=page, page_size=page_size @@ -539,7 +539,7 @@ def delete( ) -> SinchDeleteSMSGroupResponse: return self._sinch.configuration.transport.request( DeleteSMSGroupEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=DeleteSMSGroupRequest( group_id=group_id ) @@ -552,7 +552,7 @@ def get( ) -> GetSMSGroupResponse: return self._sinch.configuration.transport.request( GetSMSGroupEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=GetSMSGroupRequest( group_id=group_id ) @@ -565,7 +565,7 @@ def get_group_phone_numbers( ) -> SinchGetSMSGroupPhoneNumbersResponse: return self._sinch.configuration.transport.request( GetSMSGroupPhoneNumbersEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=GetSMSGroupPhoneNumbersRequest( group_id=group_id ) @@ -584,7 +584,7 @@ def update( ) -> UpdateSMSGroupResponse: return self._sinch.configuration.transport.request( UpdateSMSGroupEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=UpdateSMSGroupRequest( group_id=group_id, name=name, @@ -605,7 +605,7 @@ def replace( ) -> ReplaceSMSGroupResponse: return self._sinch.configuration.transport.request( ReplaceSMSGroupEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ReplaceSMSGroupPhoneNumbersRequest( group_id=group_id, members=members, @@ -624,7 +624,7 @@ async def list( return await AsyncIntBasedPaginator._initialize( sinch=self._sinch, endpoint=ListSMSGroupEndpoint( - project_id=self._sinch.configuration.project_id, + sinch=self._sinch, request_data=ListSMSGroupRequest( page=page, page_size=page_size diff --git a/sinch/domains/sms/endpoints/batches/cancel_batch.py b/sinch/domains/sms/endpoints/batches/cancel_batch.py index 757fa29f..091a966d 100644 --- a/sinch/domains/sms/endpoints/batches/cancel_batch.py +++ b/sinch/domains/sms/endpoints/batches/cancel_batch.py @@ -6,19 +6,17 @@ class CancelBatchEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches/{batch_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches/{batch_id}" HTTP_METHOD = HTTPMethods.DELETE.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: CancelBatchRequest): - super(CancelBatchEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: CancelBatchRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( - origin=sinch.configuration.sms_origin, - project_id=self.project_id, + origin=self.sms_origin, + project_or_service_id=self.project_or_service_id, batch_id=self.request_data.batch_id ) diff --git a/sinch/domains/sms/endpoints/batches/get_batch.py b/sinch/domains/sms/endpoints/batches/get_batch.py index 70a6a7c8..555ab5d6 100644 --- a/sinch/domains/sms/endpoints/batches/get_batch.py +++ b/sinch/domains/sms/endpoints/batches/get_batch.py @@ -6,19 +6,17 @@ class GetSMSEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches/{batch_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches/{batch_id}" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: GetBatchRequest): - super(GetSMSEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: GetBatchRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( - origin=sinch.configuration.sms_origin, - project_id=self.project_id, + origin=self.sms_origin, + project_or_service_id=self.project_or_service_id, batch_id=self.request_data.batch_id ) diff --git a/sinch/domains/sms/endpoints/batches/list_batches.py b/sinch/domains/sms/endpoints/batches/list_batches.py index 65625dba..b770efbf 100644 --- a/sinch/domains/sms/endpoints/batches/list_batches.py +++ b/sinch/domains/sms/endpoints/batches/list_batches.py @@ -7,19 +7,17 @@ class ListSMSBatchesEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: ListBatchesRequest): - super(ListSMSBatchesEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: ListBatchesRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( - origin=sinch.configuration.sms_origin, - project_id=self.project_id + origin=self.sms_origin, + project_or_service_id=self.project_or_service_id ) def build_query_params(self): diff --git a/sinch/domains/sms/endpoints/batches/replace_batch.py b/sinch/domains/sms/endpoints/batches/replace_batch.py index fdc20387..15fdd838 100644 --- a/sinch/domains/sms/endpoints/batches/replace_batch.py +++ b/sinch/domains/sms/endpoints/batches/replace_batch.py @@ -6,19 +6,17 @@ class ReplaceBatchSMSEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches/{batch_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches/{batch_id}" HTTP_METHOD = HTTPMethods.PUT.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: ReplaceBatchRequest): - super(ReplaceBatchSMSEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: ReplaceBatchRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( - origin=sinch.configuration.sms_origin, - project_id=self.project_id, + origin=self.sms_origin, + project_or_service_id=self.project_or_service_id, batch_id=self.request_data.batch_id ) diff --git a/sinch/domains/sms/endpoints/batches/send_batch.py b/sinch/domains/sms/endpoints/batches/send_batch.py index 249a4ebc..4bb94f1a 100644 --- a/sinch/domains/sms/endpoints/batches/send_batch.py +++ b/sinch/domains/sms/endpoints/batches/send_batch.py @@ -6,19 +6,17 @@ class SendBatchSMSEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches" HTTP_METHOD = HTTPMethods.POST.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: SendBatchRequest): - super(SendBatchSMSEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: SendBatchRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( - origin=sinch.configuration.sms_origin, - project_id=self.project_id + origin=self.sms_origin, + project_or_service_id=self.project_or_service_id ) def request_body(self): diff --git a/sinch/domains/sms/endpoints/batches/send_batch_dry_run.py b/sinch/domains/sms/endpoints/batches/send_batch_dry_run.py index 7cddf4d0..b9c64f2a 100644 --- a/sinch/domains/sms/endpoints/batches/send_batch_dry_run.py +++ b/sinch/domains/sms/endpoints/batches/send_batch_dry_run.py @@ -6,19 +6,17 @@ class SendBatchSMSDryRunEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches/dry_run" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches/dry_run" HTTP_METHOD = HTTPMethods.POST.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: BatchDryRunRequest): - super(SendBatchSMSDryRunEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: BatchDryRunRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id + project_or_service_id=self.project_or_service_id ) def build_query_params(self): diff --git a/sinch/domains/sms/endpoints/batches/send_delivery_feedback.py b/sinch/domains/sms/endpoints/batches/send_delivery_feedback.py index 2eb2b3cf..3c3f7933 100644 --- a/sinch/domains/sms/endpoints/batches/send_delivery_feedback.py +++ b/sinch/domains/sms/endpoints/batches/send_delivery_feedback.py @@ -6,19 +6,17 @@ class SendDeliveryReportEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches/{batch_id}/delivery_feedback" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches/{batch_id}/delivery_feedback" HTTP_METHOD = HTTPMethods.POST.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: SendDeliveryFeedbackRequest): - super(SendDeliveryReportEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: SendDeliveryFeedbackRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, batch_id=self.request_data.batch_id ) diff --git a/sinch/domains/sms/endpoints/batches/update_batch.py b/sinch/domains/sms/endpoints/batches/update_batch.py index e9e02c83..28a88056 100644 --- a/sinch/domains/sms/endpoints/batches/update_batch.py +++ b/sinch/domains/sms/endpoints/batches/update_batch.py @@ -6,19 +6,17 @@ class UpdateBatchSMSEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches/{batch_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches/{batch_id}" HTTP_METHOD = HTTPMethods.POST.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: UpdateBatchRequest): - super(UpdateBatchSMSEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: UpdateBatchRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, batch_id=self.request_data.batch_id ) diff --git a/sinch/domains/sms/endpoints/delivery_reports/get_all_delivery_reports_for_project.py b/sinch/domains/sms/endpoints/delivery_reports/get_all_delivery_reports_for_project.py index 65b8c869..dc1b55d8 100644 --- a/sinch/domains/sms/endpoints/delivery_reports/get_all_delivery_reports_for_project.py +++ b/sinch/domains/sms/endpoints/delivery_reports/get_all_delivery_reports_for_project.py @@ -7,19 +7,17 @@ class ListDeliveryReportsEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/delivery_reports" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/delivery_reports" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: ListSMSDeliveryReportsRequest): - super(ListDeliveryReportsEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: ListSMSDeliveryReportsRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id + project_or_service_id=self.project_or_service_id ) def build_query_params(self): diff --git a/sinch/domains/sms/endpoints/delivery_reports/get_delivery_report_for_batch.py b/sinch/domains/sms/endpoints/delivery_reports/get_delivery_report_for_batch.py index aa25bb87..4018d3bf 100644 --- a/sinch/domains/sms/endpoints/delivery_reports/get_delivery_report_for_batch.py +++ b/sinch/domains/sms/endpoints/delivery_reports/get_delivery_report_for_batch.py @@ -6,14 +6,12 @@ class GetDeliveryReportForBatchEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches/{batch_id}/delivery_report" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches/{batch_id}/delivery_report" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: GetSMSDeliveryReportForBatchRequest): - super(GetDeliveryReportForBatchEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: GetSMSDeliveryReportForBatchRequest, sinch): + super().__init__(request_data, sinch) def build_query_params(self): params = {} @@ -31,7 +29,7 @@ def build_query_params(self): def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, batch_id=self.request_data.batch_id ) diff --git a/sinch/domains/sms/endpoints/delivery_reports/get_delivery_report_for_number.py b/sinch/domains/sms/endpoints/delivery_reports/get_delivery_report_for_number.py index 8cc737eb..97dcdf9d 100644 --- a/sinch/domains/sms/endpoints/delivery_reports/get_delivery_report_for_number.py +++ b/sinch/domains/sms/endpoints/delivery_reports/get_delivery_report_for_number.py @@ -6,19 +6,17 @@ class GetDeliveryReportForNumberEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/batches/{batch_id}/delivery_report/{recipient_msisdn}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/batches/{batch_id}/delivery_report/{recipient_msisdn}" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: GetSMSDeliveryReportForNumberRequest): - super(GetDeliveryReportForNumberEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: GetSMSDeliveryReportForNumberRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, batch_id=self.request_data.batch_id, recipient_msisdn=self.request_data.recipient_number ) diff --git a/sinch/domains/sms/endpoints/groups/create_group.py b/sinch/domains/sms/endpoints/groups/create_group.py index d384d9b4..3d57eb91 100644 --- a/sinch/domains/sms/endpoints/groups/create_group.py +++ b/sinch/domains/sms/endpoints/groups/create_group.py @@ -6,19 +6,17 @@ class CreateSMSGroupEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/groups" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/groups" HTTP_METHOD = HTTPMethods.POST.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: CreateSMSGroupRequest): - super(CreateSMSGroupEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: CreateSMSGroupRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id + project_or_service_id=self.project_or_service_id ) def request_body(self): diff --git a/sinch/domains/sms/endpoints/groups/delete_group.py b/sinch/domains/sms/endpoints/groups/delete_group.py index afaaa62b..e4790c3c 100644 --- a/sinch/domains/sms/endpoints/groups/delete_group.py +++ b/sinch/domains/sms/endpoints/groups/delete_group.py @@ -6,19 +6,17 @@ class DeleteSMSGroupEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/groups/{group_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/groups/{group_id}" HTTP_METHOD = HTTPMethods.DELETE.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: DeleteSMSGroupRequest): - super(DeleteSMSGroupEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: DeleteSMSGroupRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, group_id=self.request_data.group_id ) diff --git a/sinch/domains/sms/endpoints/groups/get_group.py b/sinch/domains/sms/endpoints/groups/get_group.py index 7e14f82b..23c98848 100644 --- a/sinch/domains/sms/endpoints/groups/get_group.py +++ b/sinch/domains/sms/endpoints/groups/get_group.py @@ -6,19 +6,17 @@ class GetSMSGroupEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/groups/{group_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/groups/{group_id}" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: GetSMSGroupRequest): - super(GetSMSGroupEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: GetSMSGroupRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, group_id=self.request_data.group_id ) diff --git a/sinch/domains/sms/endpoints/groups/get_phone_numbers_for_group.py b/sinch/domains/sms/endpoints/groups/get_phone_numbers_for_group.py index 1e203f6f..7e1e81ac 100644 --- a/sinch/domains/sms/endpoints/groups/get_phone_numbers_for_group.py +++ b/sinch/domains/sms/endpoints/groups/get_phone_numbers_for_group.py @@ -6,19 +6,17 @@ class GetSMSGroupPhoneNumbersEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/groups/{group_id}/members" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/groups/{group_id}/members" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: GetSMSGroupPhoneNumbersRequest): - super(GetSMSGroupPhoneNumbersEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: GetSMSGroupPhoneNumbersRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, group_id=self.request_data.group_id ) diff --git a/sinch/domains/sms/endpoints/groups/list_groups.py b/sinch/domains/sms/endpoints/groups/list_groups.py index a25460be..758f3f71 100644 --- a/sinch/domains/sms/endpoints/groups/list_groups.py +++ b/sinch/domains/sms/endpoints/groups/list_groups.py @@ -7,19 +7,17 @@ class ListSMSGroupEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/groups" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/groups" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: ListSMSGroupRequest): - super(ListSMSGroupEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: ListSMSGroupRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id + project_or_service_id=self.project_or_service_id ) def build_query_params(self): diff --git a/sinch/domains/sms/endpoints/groups/replace_group.py b/sinch/domains/sms/endpoints/groups/replace_group.py index 1db394c5..07234168 100644 --- a/sinch/domains/sms/endpoints/groups/replace_group.py +++ b/sinch/domains/sms/endpoints/groups/replace_group.py @@ -6,19 +6,17 @@ class ReplaceSMSGroupEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/groups/{group_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/groups/{group_id}" HTTP_METHOD = HTTPMethods.PUT.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: ReplaceSMSGroupPhoneNumbersRequest): - super(ReplaceSMSGroupEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: ReplaceSMSGroupPhoneNumbersRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, group_id=self.request_data.group_id ) diff --git a/sinch/domains/sms/endpoints/groups/update_group.py b/sinch/domains/sms/endpoints/groups/update_group.py index eb834048..ccc4d0c2 100644 --- a/sinch/domains/sms/endpoints/groups/update_group.py +++ b/sinch/domains/sms/endpoints/groups/update_group.py @@ -6,19 +6,17 @@ class UpdateSMSGroupEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/groups/{group_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/groups/{group_id}" HTTP_METHOD = HTTPMethods.POST.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: UpdateSMSGroupRequest): - super(UpdateSMSGroupEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: UpdateSMSGroupRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, group_id=self.request_data.group_id ) diff --git a/sinch/domains/sms/endpoints/inbounds/get_incoming_message.py b/sinch/domains/sms/endpoints/inbounds/get_incoming_message.py index 9cfb371f..94f7d052 100644 --- a/sinch/domains/sms/endpoints/inbounds/get_incoming_message.py +++ b/sinch/domains/sms/endpoints/inbounds/get_incoming_message.py @@ -6,19 +6,17 @@ class GetInboundMessagesEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/inbounds/{inbound_id}" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/inbounds/{inbound_id}" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: GetSMSInboundMessageRequest): - super(GetInboundMessagesEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: GetSMSInboundMessageRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id, + project_or_service_id=self.project_or_service_id, inbound_id=self.request_data.inbound_id ) diff --git a/sinch/domains/sms/endpoints/inbounds/list_incoming_messages.py b/sinch/domains/sms/endpoints/inbounds/list_incoming_messages.py index 327f1578..4eb2d2d4 100644 --- a/sinch/domains/sms/endpoints/inbounds/list_incoming_messages.py +++ b/sinch/domains/sms/endpoints/inbounds/list_incoming_messages.py @@ -7,19 +7,17 @@ class ListInboundMessagesEndpoint(SMSEndpoint): - ENDPOINT_URL = "{origin}/xms/v1/{project_id}/inbounds" + ENDPOINT_URL = "{origin}/xms/v1/{project_or_service_id}/inbounds" HTTP_METHOD = HTTPMethods.GET.value HTTP_AUTHENTICATION = HTTPAuthentication.OAUTH.value - def __init__(self, project_id: str, request_data: ListSMSInboundMessageRequest): - super(ListInboundMessagesEndpoint, self).__init__(project_id, request_data) - self.project_id = project_id - self.request_data = request_data + def __init__(self, request_data: ListSMSInboundMessageRequest, sinch): + super().__init__(request_data, sinch) def build_url(self, sinch) -> str: return self.ENDPOINT_URL.format( origin=sinch.configuration.sms_origin, - project_id=self.project_id + project_or_service_id=self.project_or_service_id ) def build_query_params(self): diff --git a/sinch/domains/sms/endpoints/sms_endpoint.py b/sinch/domains/sms/endpoints/sms_endpoint.py index ba82ae2b..89bcb830 100644 --- a/sinch/domains/sms/endpoints/sms_endpoint.py +++ b/sinch/domains/sms/endpoints/sms_endpoint.py @@ -1,9 +1,23 @@ from sinch.core.models.http_response import HTTPResponse from sinch.core.endpoint import HTTPEndpoint from sinch.domains.sms.exceptions import SMSException +from sinch.core.enums import HTTPAuthentication class SMSEndpoint(HTTPEndpoint): + def __init__(self, request_data, sinch): + self.request_data = request_data + self.sinch = sinch + + if sinch.configuration.service_plan_id: + self.project_or_service_id = sinch.configuration.service_plan_id + self.HTTP_AUTHENTICATION = HTTPAuthentication.SMS_TOKEN.value + self.sms_origin = self.sinch.configuration.sms_origin_with_service_plan_id + + else: + self.project_or_service_id = sinch.configuration.project_id + self.sms_origin = self.sinch.configuration.sms_origin + def handle_response(self, response: HTTPResponse): if response.status_code >= 400: raise SMSException( diff --git a/tests/conftest.py b/tests/conftest.py index 6fb297b7..a6625f5d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,6 +5,7 @@ from sinch import SinchClient from sinch import SinchClientAsync from sinch.core.models.http_response import HTTPResponse +from sinch.core.models.http_request import HttpRequest from sinch.domains.authentication.models.authentication import OAuthToken from sinch.core.models.base_model import SinchBaseModel, SinchRequestBaseModel @@ -60,6 +61,7 @@ def configure_origin( if sms_origin: sinch_client.configuration.sms_origin = sms_origin + sinch_client.configuration.sms_origin_with_service_plan_id = sms_origin if verification_origin: sinch_client.configuration.verification_origin = verification_origin @@ -154,6 +156,16 @@ def application_secret(): return os.getenv("APPLICATION_SECRET") +@pytest.fixture +def service_plan_id(): + return os.getenv("SERVICE_PLAN_ID") + + +@pytest.fixture +def sms_api_token(): + return os.getenv("SMS_API_TOKEN") + + @pytest.fixture def verification_id(): return os.getenv("VERIFICATION_ID") @@ -204,6 +216,19 @@ def verification_request_signature_timestamp(): return os.getenv("VERIFICATION_REQUEST_SIGNATURE_TIMESTAMP") +@pytest.fixture +def empty_http_request(): + return HttpRequest( + headers={}, + protocol=None, + http_method=None, + request_body=None, + query_params=None, + url=None, + auth=None + ) + + @pytest.fixture def http_response(): return HTTPResponse( @@ -286,6 +311,14 @@ def second_token_based_pagination_response(): ) +@pytest.fixture +def int_based_pagination_request_data(): + return IntBasedPaginationRequest( + page=0, + page_size=2 + ) + + @pytest.fixture def first_int_based_pagination_response(): return IntBasedPaginationResponse( @@ -316,14 +349,6 @@ def third_int_based_pagination_response(): ) -@pytest.fixture -def int_based_pagination_request_data(): - return IntBasedPaginationRequest( - page=0, - page_size=2 - ) - - @pytest.fixture def sinch_client_sync( key_id, @@ -392,3 +417,14 @@ def sinch_client_async( voice_origin, disable_ssl ) + + +@pytest.fixture +def sinch_client_sync_with_service_plan_id( + sinch_client_sync, + service_plan_id, + sms_api_token +): + sinch_client_sync.configuration.service_plan_id = service_plan_id + sinch_client_sync.configuration.sms_api_token = sms_api_token + return sinch_client_sync diff --git a/tests/e2e/conversation/contact/test_merge_contacts.py b/tests/e2e/conversation/contact/test_merge_contacts.py index be1d1891..bf1279ef 100644 --- a/tests/e2e/conversation/contact/test_merge_contacts.py +++ b/tests/e2e/conversation/contact/test_merge_contacts.py @@ -1,4 +1,7 @@ -from sinch.domains.conversation.models.contact.responses import MergeConversationContactsResponse, ListConversationContactsResponse +from sinch.domains.conversation.models.contact.responses import ( + MergeConversationContactsResponse, + ListConversationContactsResponse +) def test_merge_contacts(sinch_client_sync): diff --git a/tests/e2e/sms/batches/test_batch_sms.py b/tests/e2e/sms/batches/test_batch_sms.py index b1a20e1d..f28366ff 100644 --- a/tests/e2e/sms/batches/test_batch_sms.py +++ b/tests/e2e/sms/batches/test_batch_sms.py @@ -33,7 +33,6 @@ def test_send_sms_zen_of_python(sinch_client_sync, phone_number, origin_phone_nu body=line, feedback_enabled=True ) - assert isinstance(send_sms_response, SendSMSBatchResponse) @@ -43,7 +42,7 @@ async def test_send_sms_async(sinch_client_async, phone_number, origin_phone_num to=[phone_number], from_=origin_phone_number, body="Asynchronous Spanish Inquisition", - feedback_enabled=True, + feedback_enabled=True ) assert isinstance(send_sms_response, SendSMSBatchResponse) @@ -54,6 +53,21 @@ def test_send_sms_sync(sinch_client_sync, phone_number, origin_phone_number): to=[phone_number], from_=origin_phone_number, body="Synchronous Spanish Inquisition", - feedback_enabled=True, + feedback_enabled=True + ) + assert isinstance(send_sms_response, SendSMSBatchResponse) + + +def test_send_sms_sync_with_service_plan_id( + sinch_client_sync_with_service_plan_id, + phone_number, + origin_phone_number +): + send_sms_response = sinch_client_sync_with_service_plan_id.sms.batches.send( + delivery_report="none", + to=[phone_number], + from_=origin_phone_number, + body="Synchronous Spanish Inquisition", + feedback_enabled=True ) assert isinstance(send_sms_response, SendSMSBatchResponse) diff --git a/tests/e2e/sms/batches/test_cancel_batch.py b/tests/e2e/sms/batches/test_cancel_batch.py index 67eb350f..a4bfad51 100644 --- a/tests/e2e/sms/batches/test_cancel_batch.py +++ b/tests/e2e/sms/batches/test_cancel_batch.py @@ -16,6 +16,25 @@ def test_cancel_sms_batch(sinch_client_sync, phone_number, origin_phone_number): assert isinstance(cancel_batch_response, CancelSMSBatchResponse) +def test_cancel_sms_batch_with_service_plan_id( + sinch_client_sync_with_service_plan_id, + phone_number, + origin_phone_number +): + send_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.send( + delivery_report="none", + to=[phone_number], + from_=origin_phone_number, + body="Synchronous Batch Cancel", + feedback_enabled=True, + send_at="2024-08-24T21:37:00Z" + ) + cancel_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.cancel( + batch_id=send_batch_response.id + ) + assert isinstance(cancel_batch_response, CancelSMSBatchResponse) + + async def test_cancel_sms_batch_async(sinch_client_async, phone_number, origin_phone_number): send_batch_response = await sinch_client_async.sms.batches.send( delivery_report="none", diff --git a/tests/e2e/sms/batches/test_dry_run.py b/tests/e2e/sms/batches/test_dry_run.py index 2643f6e7..3070fd4d 100644 --- a/tests/e2e/sms/batches/test_dry_run.py +++ b/tests/e2e/sms/batches/test_dry_run.py @@ -12,6 +12,21 @@ def test_send_sms_dry_run(sinch_client_sync, phone_number, origin_phone_number): assert isinstance(send_dry_run_response, SendSMSBatchDryRunResponse) +def test_send_sms_dry_run_with_service_plan_id( + sinch_client_sync_with_service_plan_id, + phone_number, + origin_phone_number +): + send_dry_run_response = sinch_client_sync_with_service_plan_id.sms.batches.send_dry_run( + number_of_recipients=10, + per_recipient=True, + to=[phone_number], + from_=origin_phone_number, + body="Spanish Inquisition" + ) + assert isinstance(send_dry_run_response, SendSMSBatchDryRunResponse) + + async def test_send_sms_dry_run_async(sinch_client_async, phone_number, origin_phone_number): send_dry_run_response = await sinch_client_async.sms.batches.send_dry_run( number_of_recipients=10, diff --git a/tests/e2e/sms/batches/test_get_batch.py b/tests/e2e/sms/batches/test_get_batch.py index e255b254..9a628538 100644 --- a/tests/e2e/sms/batches/test_get_batch.py +++ b/tests/e2e/sms/batches/test_get_batch.py @@ -9,6 +9,14 @@ def test_get_sms_batch(sinch_client_sync): assert isinstance(get_batch_response, GetSMSBatchResponse) +def test_get_sms_batch_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.list() + get_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.get( + batch_id=list_batch_response.result.batches[0].id + ) + assert isinstance(get_batch_response, GetSMSBatchResponse) + + async def test_get_sms_batch_async(sinch_client_async): list_batch_response = await sinch_client_async.sms.batches.list() get_batch_response = await sinch_client_async.sms.batches.get( diff --git a/tests/e2e/sms/batches/test_list_batches.py b/tests/e2e/sms/batches/test_list_batches.py index 7353f948..42c86bd4 100644 --- a/tests/e2e/sms/batches/test_list_batches.py +++ b/tests/e2e/sms/batches/test_list_batches.py @@ -7,9 +7,15 @@ def test_list_sms_batches(sinch_client_sync): assert isinstance(list_batches_response, IntBasedPaginator) +def test_list_sms_batches_using_service_plan_id(sinch_client_sync_with_service_plan_id): + list_batches_response = sinch_client_sync_with_service_plan_id.sms.batches.list() + assert isinstance(list_batches_response, IntBasedPaginator) + assert len(list_batches_response.result.batches) > 0 + + def test_list_sms_batches_with_page_size_1(sinch_client_sync): list_batches_response = sinch_client_sync.sms.batches.list( - page_size=1, + page_size=1 ) assert isinstance(list_batches_response.result, ListSMSBatchesResponse) assert len(list_batches_response.result.batches) == 1 diff --git a/tests/e2e/sms/batches/test_replace_batch.py b/tests/e2e/sms/batches/test_replace_batch.py index f53bfb83..0e0c56d1 100644 --- a/tests/e2e/sms/batches/test_replace_batch.py +++ b/tests/e2e/sms/batches/test_replace_batch.py @@ -13,6 +13,21 @@ def test_replace_sms_batch(sinch_client_sync, phone_number): assert isinstance(replace_batch_response, ReplaceSMSBatchResponse) +def test_replace_sms_batch_with_service_plan_id( + sinch_client_sync_with_service_plan_id, + phone_number +): + list_batches_response = sinch_client_sync_with_service_plan_id.sms.batches.list( + start_date="2022-11-24T14:15:22Z" + ) + replace_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.replace( + batch_id=list_batches_response.result.batches[0].id, + to=[phone_number], + body="Replace SMS batch test" + ) + assert isinstance(replace_batch_response, ReplaceSMSBatchResponse) + + async def test_replace_sms_batch_async(sinch_client_async, sinch_client_sync, phone_number): list_batches_response = sinch_client_sync.sms.batches.list( start_date="2022-11-24T14:15:22Z" diff --git a/tests/e2e/sms/batches/test_send_delivery_feedback.py b/tests/e2e/sms/batches/test_send_delivery_feedback.py index a3449a7f..a1d096bc 100644 --- a/tests/e2e/sms/batches/test_send_delivery_feedback.py +++ b/tests/e2e/sms/batches/test_send_delivery_feedback.py @@ -13,6 +13,15 @@ def test_send_delivery_feedback(sinch_client_sync, phone_number): assert isinstance(delivery_feedback_response, SendSMSDeliveryFeedbackResponse) +def test_send_delivery_feedback_with_service_plan_id(sinch_client_sync_with_service_plan_id, phone_number): + list_batches_response = sinch_client_sync_with_service_plan_id.sms.batches.list() + delivery_feedback_response = sinch_client_sync_with_service_plan_id.sms.batches.send_delivery_feedback( + batch_id=list_batches_response.result.batches[0].id, + recipients=[phone_number] + ) + assert isinstance(delivery_feedback_response, SendSMSDeliveryFeedbackResponse) + + async def test_send_delivery_feedback_async(sinch_client_async, phone_number): list_batches_response = await sinch_client_async.sms.batches.list( start_date="2019-08-24T14:15:22Z", diff --git a/tests/e2e/sms/batches/test_update_batch.py b/tests/e2e/sms/batches/test_update_batch.py index 96a46950..b0b68b36 100644 --- a/tests/e2e/sms/batches/test_update_batch.py +++ b/tests/e2e/sms/batches/test_update_batch.py @@ -1,6 +1,27 @@ from sinch.domains.sms.models.batches.responses import UpdateSMSBatchResponse +def test_update_sms_batch_with_service_plan_id( + sinch_client_sync_with_service_plan_id, + phone_number, + origin_phone_number +): + send_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.send( + delivery_report="none", + to=[phone_number], + from_=origin_phone_number, + body="Update Batch Test", + feedback_enabled=True, + send_at="2024-12-01T21:37:00Z" + ) + update_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.update( + batch_id=send_batch_response.id, + body="Update Batch Test After Update" + ) + assert isinstance(update_batch_response, UpdateSMSBatchResponse) + assert update_batch_response.body == "Update Batch Test After Update" + + def test_update_sms_batch(sinch_client_sync, phone_number, origin_phone_number): send_batch_response = sinch_client_sync.sms.batches.send( delivery_report="none", diff --git a/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_batch.py b/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_batch.py index 72d2055a..711a7107 100644 --- a/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_batch.py +++ b/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_batch.py @@ -19,6 +19,28 @@ def test_get_delivery_reports_for_specific_batch(sinch_client_sync, phone_number assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForBatchResponse) +def test_get_delivery_reports_for_specific_batch_with_service_plan_id( + sinch_client_sync_with_service_plan_id, + phone_number, + origin_phone_number +): + send_batch_response = sinch_client_sync_with_service_plan_id.sms.batches.send( + delivery_report="summary", + to=[phone_number], + from_=origin_phone_number, + body="Delivery report test.", + feedback_enabled=True, + callback_url="http://testcallback.pl" + ) + get_delivery_report_response = sinch_client_sync_with_service_plan_id.sms.delivery_reports.get_for_batch( + batch_id=send_batch_response.id, + type_="summary", + status=["Queued"], + code=[400] + ) + assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForBatchResponse) + + async def test_get_delivery_reports_for_specific_batch_async(sinch_client_async, phone_number, origin_phone_number): send_batch_response = await sinch_client_async.sms.batches.send( delivery_report="summary", diff --git a/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_number.py b/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_number.py index 64f7e41f..4b2e24b1 100644 --- a/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_number.py +++ b/tests/e2e/sms/delivery_reports/test_get_delivery_report_for_number.py @@ -17,6 +17,19 @@ def test_get_delivery_reports_for_specific_number(sinch_client_sync): assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForNumberResponse) +def test_get_delivery_reports_for_specific_number_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_delivery_reports_response = sinch_client_sync_with_service_plan_id.sms.delivery_reports.list( + start_date="2019-08-24T14:15:22Z" + ) + assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) + + get_delivery_report_response = sinch_client_sync_with_service_plan_id.sms.delivery_reports.get_for_number( + batch_id=list_delivery_reports_response.result.delivery_reports[0].batch_id, + recipient_number=list_delivery_reports_response.result.delivery_reports[0].recipient + ) + assert isinstance(get_delivery_report_response, GetSMSDeliveryReportForNumberResponse) + + async def test_get_delivery_reports_for_specific_number_async(sinch_client_async, sinch_client_sync): list_delivery_reports_response = sinch_client_sync.sms.delivery_reports.list( start_date="2019-08-24T14:15:22Z" diff --git a/tests/e2e/sms/delivery_reports/test_get_delivery_reports_for_project.py b/tests/e2e/sms/delivery_reports/test_get_delivery_reports_for_project.py index d7b5e0d1..c9bdcc05 100644 --- a/tests/e2e/sms/delivery_reports/test_get_delivery_reports_for_project.py +++ b/tests/e2e/sms/delivery_reports/test_get_delivery_reports_for_project.py @@ -8,6 +8,13 @@ def test_get_delivery_reports_for_project(sinch_client_sync): assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) +def test_get_delivery_reports_for_project_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_delivery_reports_response = sinch_client_sync_with_service_plan_id.sms.delivery_reports.list( + start_date="2019-08-24T14:15:22Z" + ) + assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) + + async def test_get_delivery_reports_for_project_async(sinch_client_async): list_delivery_reports_response = await sinch_client_async.sms.delivery_reports.list() assert isinstance(list_delivery_reports_response.result, ListSMSDeliveryReportsResponse) diff --git a/tests/e2e/sms/groups/test_create_group.py b/tests/e2e/sms/groups/test_create_group.py index af46cc57..a2ef1fd3 100644 --- a/tests/e2e/sms/groups/test_create_group.py +++ b/tests/e2e/sms/groups/test_create_group.py @@ -9,6 +9,14 @@ def test_create_sms_group(sinch_client_sync, phone_number): assert isinstance(create_group_response, CreateSMSGroupResponse) +def test_create_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id, phone_number): + create_group_response = sinch_client_sync_with_service_plan_id.sms.groups.create( + name="KillerRabbit", + members=[phone_number] + ) + assert isinstance(create_group_response, CreateSMSGroupResponse) + + async def test_create_sms_group_async_using_child_groups(sinch_client_async, phone_number): create_group_response = await sinch_client_async.sms.groups.create( name="KillerRabbit2", diff --git a/tests/e2e/sms/groups/test_delete_group.py b/tests/e2e/sms/groups/test_delete_group.py index 50b575d6..ba1a6390 100644 --- a/tests/e2e/sms/groups/test_delete_group.py +++ b/tests/e2e/sms/groups/test_delete_group.py @@ -10,6 +10,15 @@ def test_delete_sms_group(sinch_client_sync): assert isinstance(delete_group_response, SinchDeleteSMSGroupResponse) +def test_delete_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() + + delete_group_response = sinch_client_sync_with_service_plan_id.sms.groups.delete( + group_id=list_group_response.result.groups[0].id + ) + assert isinstance(delete_group_response, SinchDeleteSMSGroupResponse) + + async def test_delete_sms_group_async(sinch_client_async): list_group_response = await sinch_client_async.sms.groups.list() diff --git a/tests/e2e/sms/groups/test_get_group.py b/tests/e2e/sms/groups/test_get_group.py index 5fb4b73d..a995201f 100644 --- a/tests/e2e/sms/groups/test_get_group.py +++ b/tests/e2e/sms/groups/test_get_group.py @@ -1,6 +1,15 @@ from sinch.domains.sms.models.groups.responses import GetSMSGroupResponse +def test_get_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() + + get_group_response = sinch_client_sync_with_service_plan_id.sms.groups.get( + group_id=list_group_response.result.groups[0].id + ) + assert isinstance(get_group_response, GetSMSGroupResponse) + + def test_get_sms_group(sinch_client_sync): list_group_response = sinch_client_sync.sms.groups.list() diff --git a/tests/e2e/sms/groups/test_get_phone_numbers_for_group.py b/tests/e2e/sms/groups/test_get_phone_numbers_for_group.py index eb72bd58..584547f3 100644 --- a/tests/e2e/sms/groups/test_get_phone_numbers_for_group.py +++ b/tests/e2e/sms/groups/test_get_phone_numbers_for_group.py @@ -1,6 +1,17 @@ from sinch.domains.sms.models.groups.responses import SinchGetSMSGroupPhoneNumbersResponse +def test_get_group_phone_numbers_sms_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() + + get_group_response = sinch_client_sync_with_service_plan_id.sms.groups.get_group_phone_numbers( + group_id=list_group_response.result.groups[0].id + ) + + assert isinstance(get_group_response, SinchGetSMSGroupPhoneNumbersResponse) + assert get_group_response.phone_numbers + + def test_get_group_phone_numbers_sms(sinch_client_sync): list_group_response = sinch_client_sync.sms.groups.list() diff --git a/tests/e2e/sms/groups/test_list_groups.py b/tests/e2e/sms/groups/test_list_groups.py index 1c1db513..3190e398 100644 --- a/tests/e2e/sms/groups/test_list_groups.py +++ b/tests/e2e/sms/groups/test_list_groups.py @@ -7,6 +7,11 @@ def test_list_sms_groups(sinch_client_sync): assert isinstance(list_group_response.result, SinchListSMSGroupResponse) +def test_list_sms_groups_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() + assert isinstance(list_group_response.result, SinchListSMSGroupResponse) + + async def test_list_sms_groups_async(sinch_client_async): list_group_response = await sinch_client_async.sms.groups.list() assert isinstance(list_group_response.result, SinchListSMSGroupResponse) diff --git a/tests/e2e/sms/groups/test_replace_group.py b/tests/e2e/sms/groups/test_replace_group.py index 7861862c..74e1c2ad 100644 --- a/tests/e2e/sms/groups/test_replace_group.py +++ b/tests/e2e/sms/groups/test_replace_group.py @@ -1,6 +1,16 @@ from sinch.domains.sms.models.groups.responses import ReplaceSMSGroupResponse +def test_replace_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() + + replace_group_response = sinch_client_sync_with_service_plan_id.sms.groups.replace( + group_id=list_group_response.result.groups[0].id, + members=["48111111111"] + ) + assert isinstance(replace_group_response, ReplaceSMSGroupResponse) + + def test_replace_sms_group(sinch_client_sync): list_group_response = sinch_client_sync.sms.groups.list() diff --git a/tests/e2e/sms/groups/test_update_group.py b/tests/e2e/sms/groups/test_update_group.py index c56a92ee..ffcab07d 100644 --- a/tests/e2e/sms/groups/test_update_group.py +++ b/tests/e2e/sms/groups/test_update_group.py @@ -1,4 +1,5 @@ from sinch.domains.sms.models.groups.responses import UpdateSMSGroupResponse +from sinch.core.enums import HTTPAuthentication def test_update_sms_group(sinch_client_sync, phone_number): @@ -12,6 +13,17 @@ def test_update_sms_group(sinch_client_sync, phone_number): assert update_group_response.name == "KillerRabbit222" +def test_update_sms_group_with_service_plan_id(sinch_client_sync_with_service_plan_id, phone_number): + list_group_response = sinch_client_sync_with_service_plan_id.sms.groups.list() + + update_group_response = sinch_client_sync_with_service_plan_id.sms.groups.update( + name="KillerRabbit222", + group_id=list_group_response.result.groups[0].id + ) + assert isinstance(update_group_response, UpdateSMSGroupResponse) + assert update_group_response.name == "KillerRabbit222" + + def test_add_phone_number_to_sms_group(sinch_client_sync, phone_number): list_group_response = sinch_client_sync.sms.groups.list() diff --git a/tests/e2e/sms/inbounds/test_list_inbound_messages.py b/tests/e2e/sms/inbounds/test_list_inbound_messages.py index 58cece3b..85e00405 100644 --- a/tests/e2e/sms/inbounds/test_list_inbound_messages.py +++ b/tests/e2e/sms/inbounds/test_list_inbound_messages.py @@ -6,6 +6,11 @@ def test_list_inbound_sms(sinch_client_sync): assert isinstance(list_incoming_message_response.result, SinchListInboundMessagesResponse) +def test_list_inbound_sms_with_service_plan_id(sinch_client_sync_with_service_plan_id): + list_incoming_message_response = sinch_client_sync_with_service_plan_id.sms.inbounds.list() + assert isinstance(list_incoming_message_response.result, SinchListInboundMessagesResponse) + + async def test_list_inbound_sms_async(sinch_client_async): list_incoming_message_response = await sinch_client_async.sms.inbounds.list() assert isinstance(list_incoming_message_response.result, SinchListInboundMessagesResponse) diff --git a/tests/integration/test_domain_endpoint_error_handling.py b/tests/integration/test_domain_endpoint_error_handling.py index 428875ac..59cb6f3d 100644 --- a/tests/integration/test_domain_endpoint_error_handling.py +++ b/tests/integration/test_domain_endpoint_error_handling.py @@ -34,10 +34,10 @@ def test_conversation_endpoint_error_handling(project_id, http_response): assert error.response_status_code == http_response.status_code -def test_sms_endpoint_error_handling(project_id, sms_http_response): +def test_sms_endpoint_error_handling(sinch_client_sync, sms_http_response): numbers_endpoint = SMSEndpoint( - project_id=project_id, - request_data={} + request_data={}, + sinch=sinch_client_sync ) with pytest.raises(SMSException) as error: numbers_endpoint.handle_response(sms_http_response) diff --git a/tests/integration/test_http_transport.py b/tests/integration/test_http_transport.py new file mode 100644 index 00000000..af4e44a8 --- /dev/null +++ b/tests/integration/test_http_transport.py @@ -0,0 +1,41 @@ +from sinch.core.adapters.requests_http_transport import HTTPTransportRequests +from sinch.domains.sms.endpoints.batches.send_batch import SendBatchSMSEndpoint + + +def test_authenticate_method_with_service_plan_id_version_of_sms_api( + sinch_client_sync_with_service_plan_id, + empty_http_request +): + sms_endpoint = SendBatchSMSEndpoint( + sinch=sinch_client_sync_with_service_plan_id, + request_data=empty_http_request + ) + http_transport = HTTPTransportRequests(sinch=sinch_client_sync_with_service_plan_id) + http_transport.authenticate(endpoint=sms_endpoint, request_data=empty_http_request) + + assert empty_http_request.headers + assert "Bearer" in empty_http_request.headers["Authorization"] + assert ( + empty_http_request.headers["Authorization"] == + f"Bearer {sinch_client_sync_with_service_plan_id.configuration.sms_api_token}" + ) + assert empty_http_request.headers["Content-Type"] == "application/json" + + +def test_authenticate_method_with_project_id_version_of_sms_api( + sinch_client_sync, + empty_http_request +): + sms_endpoint = SendBatchSMSEndpoint( + sinch=sinch_client_sync, + request_data=empty_http_request, + ) + http_transport = HTTPTransportRequests(sinch=sinch_client_sync) + http_transport.authenticate(endpoint=sms_endpoint, request_data=empty_http_request) + + assert empty_http_request.headers + assert ( + empty_http_request.headers["Authorization"] == + f"Bearer {sinch_client_sync.configuration.token_manager.token.access_token}" + ) + assert empty_http_request.headers["Content-Type"] == "application/json" diff --git a/tests/integration/test_sms_endpoint_credendials_formatting.py b/tests/integration/test_sms_endpoint_credendials_formatting.py new file mode 100644 index 00000000..4c8a0151 --- /dev/null +++ b/tests/integration/test_sms_endpoint_credendials_formatting.py @@ -0,0 +1,23 @@ +from sinch.domains.sms.endpoints.sms_endpoint import SMSEndpoint +from sinch.core.enums import HTTPAuthentication + + +def test_sms_endpoint_service_plan_id_credentials_processing(sinch_client_sync_with_service_plan_id, service_plan_id): + sms_endpoint = SMSEndpoint( + sinch=sinch_client_sync_with_service_plan_id, + request_data={} + ) + assert sms_endpoint.project_or_service_id == service_plan_id + assert sms_endpoint.HTTP_AUTHENTICATION == HTTPAuthentication.SMS_TOKEN.value + assert ( + sms_endpoint.sms_origin == sinch_client_sync_with_service_plan_id.configuration.sms_origin_with_service_plan_id + ) + + +def test_sms_endpoint_with_project_id_credentials_processing(sinch_client_sync, project_id): + sms_endpoint = SMSEndpoint( + sinch=sinch_client_sync, + request_data={} + ) + assert sms_endpoint.project_or_service_id == project_id + assert sms_endpoint.sms_origin == sinch_client_sync.configuration.sms_origin diff --git a/tests/unit/test_configuration.py b/tests/unit/test_configuration.py index fb83355d..da5815b7 100644 --- a/tests/unit/test_configuration.py +++ b/tests/unit/test_configuration.py @@ -19,29 +19,28 @@ def test_configuration_initialization_happy_path(sinch_client_sync): def test_set_sms_region_property_and_check_that_sms_origin_was_updated(sinch_client_sync): - sinch_client_sync.configuration.sms_region = ( - "We interrupt this program to annoy you" - "and make things generally more irritating." - ) - assert "irritating" in sinch_client_sync.configuration.sms_origin + sinch_client_sync.configuration.sms_region = "pl" + assert "zt.pl.sms.api.sinch.com" == sinch_client_sync.configuration.sms_origin def test_set_sms_domain_property_and_check_that_sms_origin_was_updated(sinch_client_sync): - sinch_client_sync.configuration.sms_region = ( - "We interrupt this program to annoy you" - "and make things generally more irritating." - ) - assert "irritating" in sinch_client_sync.configuration.sms_origin + sinch_client_sync.configuration.sms_domain = "{}.monty.python" + assert "us.monty.python" == sinch_client_sync.configuration.sms_origin + + +def test_set_sms_region_with_service_plan_id_property_and_check_that_sms_origin_was_updated(sinch_client_sync): + sinch_client_sync.configuration.sms_region_with_service_plan_id = "Herring" + assert sinch_client_sync.configuration.sms_origin_with_service_plan_id.startswith("Herring") def test_set_conversation_region_property_and_check_that_sms_origin_was_updated(sinch_client_sync): - sinch_client_sync.configuration.conversation_region = "My_brain_hurts!" + sinch_client_sync.configuration.conversation_region = "My_brain_hurts" assert "brain" in sinch_client_sync.configuration.conversation_origin assert "hurts" in sinch_client_sync.configuration.conversation_origin def test_set_conversation_domain_property_and_check_that_sms_origin_was_updated(sinch_client_sync): - sinch_client_sync.configuration.conversation_domain= "My_brain_hurts!" + sinch_client_sync.configuration.conversation_domain= "My_brain_hurts" assert "brain" in sinch_client_sync.configuration.conversation_origin assert "hurts" in sinch_client_sync.configuration.conversation_origin