Skip to content

Commit e2ec7ed

Browse files
committed
PR code review
1 parent 847e4dc commit e2ec7ed

16 files changed

Lines changed: 89 additions & 83 deletions

sinch/domains/sms/api/v1/base/base_sms.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ class BaseSms:
44
def __init__(self, sinch):
55
self._sinch = sinch
66

7+
def _get_path_identifier(self) -> str:
8+
"""
9+
Returns the appropriate path identifier based on authentication method.
10+
- SMS auth: returns service_plan_id
11+
- Project auth: returns project_id
12+
13+
Returns:
14+
str: The path identifier to use for the endpoint.
15+
"""
16+
if self._sinch.configuration.authentication_method == "sms_auth":
17+
return self._sinch.configuration.service_plan_id
18+
else:
19+
return self._sinch.configuration.project_id
20+
721
def _request(self, endpoint_class, request_data):
822
"""
923
A helper method to make requests to endpoints.
@@ -17,14 +31,8 @@ def _request(self, endpoint_class, request_data):
1731
"""
1832
self._sinch.configuration.validate_authentication_parameters()
1933

20-
# Use service_plan_id for SMS auth, project_id for project auth
21-
if self._sinch.configuration.authentication_method == "sms_auth":
22-
path_identifier = self._sinch.configuration.service_plan_id
23-
else:
24-
path_identifier = self._sinch.configuration.project_id
25-
2634
endpoint = endpoint_class(
27-
project_id=path_identifier,
35+
project_id=self._get_path_identifier(),
2836
request_data=request_data,
2937
)
3038

sinch/domains/sms/api/v1/batches_apis.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,18 @@ def list(
8484
page_size: Optional[int] = None,
8585
start_date: Optional[datetime] = None,
8686
end_date: Optional[datetime] = None,
87-
var_from: Optional[List[str]] = None,
87+
from_: Optional[List[str]] = None,
8888
client_reference: Optional[str] = None,
8989
**kwargs,
9090
) -> Paginator[BatchResponse]:
91-
# Use service_plan_id for SMS auth, project_id for project auth
92-
if self._sinch.configuration.authentication_method == "sms_auth":
93-
path_identifier = self._sinch.configuration.service_plan_id
94-
else:
95-
path_identifier = self._sinch.configuration.project_id
96-
9791
endpoint = ListBatchesEndpoint(
98-
project_id=path_identifier,
92+
project_id=self._get_path_identifier(),
9993
request_data=ListBatchesRequest(
10094
page=page,
10195
page_size=page_size,
10296
start_date=start_date,
10397
end_date=end_date,
104-
var_from=var_from,
98+
from_=from_,
10599
client_reference=client_reference,
106100
**kwargs,
107101
),

sinch/domains/sms/api/v1/delivery_reports_apis.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,8 @@ def list(
6262
client_reference: Optional[str] = None,
6363
**kwargs,
6464
) -> Paginator[RecipientDeliveryReport]:
65-
# Use service_plan_id for SMS auth, project_id for project auth
66-
if self._sinch.configuration.authentication_method == "sms_auth":
67-
path_identifier = self._sinch.configuration.service_plan_id
68-
else:
69-
path_identifier = self._sinch.configuration.project_id
70-
7165
endpoint = ListDeliveryReportsEndpoint(
72-
project_id=path_identifier,
66+
project_id=self._get_path_identifier(),
7367
request_data=ListDeliveryReportsRequest(
7468
page=page,
7569
page_size=page_size,
@@ -81,7 +75,6 @@ def list(
8175
**kwargs,
8276
),
8377
)
84-
# Set the authentication method based on configuration
8578
endpoint.set_authentication_method(self._sinch)
8679

8780
return SMSPaginator(sinch=self._sinch, endpoint=endpoint)

sinch/domains/sms/models/v1/internal/batch_id_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
class BatchIdRequest(BaseModelConfigurationRequest):
88
batch_id: StrictStr = Field(
99
default=...,
10-
description="The unique identifier of the batch message for which delivery feedback is being provided.",
10+
description="The unique identifier of the batch message.",
1111
)

sinch/domains/sms/models/v1/internal/list_batches_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ListBatchesRequest(BaseModelConfigurationRequest):
1111
page_size: Optional[conint(strict=True, le=100, ge=1)] = 30
1212
start_date: Optional[datetime] = None
1313
end_date: Optional[datetime] = None
14-
var_from: Optional[conlist(StrictStr)] = Field(default=None, alias="from")
14+
from_: Optional[conlist(StrictStr)] = Field(default=None, alias="from")
1515
client_reference: Optional[
1616
constr(strict=True, max_length=2048, min_length=0)
1717
] = None

sinch/domains/sms/models/v1/internal/update_binary_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99

1010
class UpdateBinaryRequest(BaseModelConfigurationRequest):
11-
var_from: Optional[StrictStr] = Field(
11+
from_: Optional[StrictStr] = Field(
1212
default=None,
1313
alias="from",
1414
description="Sender number. Must be valid phone number, short code or alphanumeric.",
1515
)
1616
type: Optional[StrictStr] = Field(
17-
default=None,
17+
default="mt_binary",
1818
description="SMS in [binary](https://community.sinch.com/t5/Glossary/Binary-SMS/ta-p/7470) format.",
1919
)
2020
to_add: Optional[conlist(StrictStr)] = Field(

sinch/domains/sms/models/v1/internal/update_media_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010

1111
class UpdateMediaRequest(BaseModelConfigurationRequest):
12-
var_from: Optional[StrictStr] = Field(
12+
from_: Optional[StrictStr] = Field(
1313
default=None,
1414
alias="from",
1515
description="Sender number. Must be valid phone number, short code or alphanumeric.",
1616
)
17-
type: Optional[StrictStr] = Field(default=None, description="MMS")
17+
type: Optional[StrictStr] = Field(default="mt_media", description="MMS")
1818
to_add: Optional[conlist(StrictStr)] = Field(
1919
default=None,
2020
description="List of phone numbers and group IDs to add to the batch.",

sinch/domains/sms/models/v1/internal/update_text_request.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88

99

1010
class UpdateTextRequest(BaseModelConfigurationRequest):
11-
var_from: Optional[StrictStr] = Field(
11+
from_: Optional[StrictStr] = Field(
1212
default=None,
1313
alias="from",
1414
description="Sender number. Must be valid phone number, short code or alphanumeric.",
1515
)
16-
type: Optional[StrictStr] = Field(default=None, description="Regular SMS")
16+
type: Optional[StrictStr] = Field(
17+
default="mt_text", description="Regular SMS"
18+
)
1719
to_add: Optional[conlist(StrictStr)] = Field(
1820
default=None,
1921
description="List of phone numbers and group IDs to add to the batch.",

sinch/domains/sms/models/v1/shared/binary_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BinaryRequest(BaseModelConfigurationRequest):
1414
default=...,
1515
description="A list of phone numbers and group IDs that will receive the batch. [More info](https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628).",
1616
)
17-
var_from: Optional[StrictStr] = Field(
17+
from_: Optional[StrictStr] = Field(
1818
default=None,
1919
alias="from",
2020
description="Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic Default Originator not configured.",
@@ -28,7 +28,7 @@ class BinaryRequest(BaseModelConfigurationRequest):
2828
description="The UDH header of a binary message HEX encoded. Max 140 bytes including the `body`.",
2929
)
3030
type: Optional[StrictStr] = Field(
31-
default=None,
31+
default="mt_binary",
3232
description="SMS in [binary](https://community.sinch.com/t5/Glossary/Binary-SMS/ta-p/7470) format.",
3333
)
3434
delivery_report: Optional[DeliveryReportType] = None

sinch/domains/sms/models/v1/shared/binary_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BinaryResponse(BaseModelConfigurationResponse):
1414
default=None,
1515
description="A list of phone numbers and group IDs that have received the batch. [More info](https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628).",
1616
)
17-
var_from: Optional[StrictStr] = Field(
17+
from_: Optional[StrictStr] = Field(
1818
default=None,
1919
alias="from",
2020
description="The sender number provided. Required if the Automatic Default Originator is not configured.",

0 commit comments

Comments
 (0)