Skip to content

Commit 173ebbd

Browse files
committed
feature(numbers): update number sinch events with OAS spec
1 parent 63a8a3a commit 173ebbd

3 files changed

Lines changed: 56 additions & 12 deletions

File tree

‎sinch/domains/numbers/models/v1/internal/update_event_destination_request.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77

88
class UpdateEventDestinationRequest(BaseModelConfigurationRequest):
9-
hmac_secret: Optional[StrictStr] = Field(default=None, alias="hmacSecret")
9+
hmac_secret: Optional[StrictStr] = Field(default=None, alias="hmacSecret", description="The HMAC secret to be updated for the specified project")

‎sinch/domains/numbers/sinch_events/v1/events/number_sinch_event.py‎

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,65 @@
11
from datetime import datetime
2-
from typing import Optional, Union, Literal
2+
from typing import Literal, Optional, Union
3+
34
from pydantic import Field, StrictStr
5+
46
from sinch.domains.numbers.sinch_events.v1.internal import SinchEvent
57

68

79
class NumberSinchEvent(SinchEvent):
8-
event_id: Optional[StrictStr] = Field(default=None, alias="eventId")
9-
timestamp: Optional[datetime] = Field(default=None)
10-
project_id: Optional[StrictStr] = Field(default=None, alias="projectId")
11-
resource_id: Optional[StrictStr] = Field(default=None, alias="resourceId")
10+
event_id: Optional[StrictStr] = Field(
11+
default=None, alias="eventId", description="The ID of the event."
12+
)
13+
timestamp: Optional[datetime] = Field(
14+
default=None,
15+
description="The date and time when the callback was created and added to the callbacks queue.",
16+
)
17+
project_id: Optional[StrictStr] = Field(
18+
default=None,
19+
alias="projectId",
20+
description="The ID of the project to which the event belongs.",
21+
)
22+
resource_id: Optional[StrictStr] = Field(
23+
default=None,
24+
alias="resourceId",
25+
description="The unique identifier of the resource, depending on the resource type. For example, a phone number, a hosting order ID, or a brand ID.",
26+
)
1227
resource_type: Optional[Union[Literal["ACTIVE_NUMBER"], StrictStr]] = (
1328
Field(default=None, alias="resourceType")
1429
)
1530
event_type: Optional[
1631
Union[
1732
Literal[
18-
"PROVISIONING_TO_CAMPAIGN",
19-
"DEPROVISIONING_FROM_CAMPAIGN",
2033
"PROVISIONING_TO_SMS_PLATFORM",
2134
"DEPROVISIONING_FROM_SMS_PLATFORM",
35+
"PROVISIONING_TO_CAMPAIGN",
36+
"DEPROVISIONING_FROM_CAMPAIGN",
2237
"PROVISIONING_TO_VOICE_PLATFORM",
23-
"DEPROVISIONING_TO_VOICE_PLATFORM",
38+
"DEPROVISIONING_FROM_VOICE_PLATFORM",
39+
"NUMBER_ORDER_PROCESSING",
2440
],
2541
StrictStr,
2642
]
27-
] = Field(default=None, alias="eventType")
28-
status: Optional[Union[Literal["SUCCEEDED", "FAILED"], StrictStr]] = None
43+
] = Field(
44+
default=None, alias="eventType", description="The type of the event."
45+
)
46+
status: Optional[
47+
Union[
48+
Literal[
49+
"SUCCEEDED",
50+
"FAILED",
51+
"IN_REVIEW",
52+
"BLOCKED",
53+
"COMPLETED",
54+
"REJECTED",
55+
"EXPIRED",
56+
],
57+
StrictStr,
58+
]
59+
] = Field(
60+
default=None,
61+
description="The status of the event or the state transition it represents.",
62+
)
2963
failure_code: Optional[
3064
Union[
3165
Literal[
@@ -47,4 +81,13 @@ class NumberSinchEvent(SinchEvent):
4781
],
4882
StrictStr,
4983
]
50-
] = Field(default=None, alias="failureCode")
84+
] = Field(
85+
default=None,
86+
alias="failureCode",
87+
description="If the status is FAILED, a failure code will be provided. For numbers provisioning to SMS platform, there won't be any extra `failureCode`, as the result is binary. For campaign provisioning-related failures, refer to the list for the possible values.",
88+
)
89+
internal_failure_code: Optional[StrictStr] = Field(
90+
default=None,
91+
alias="internalFailureCode",
92+
description="If the status is FAILED, certain processes (eg. number to campaign provisioning) will have an internalFailureCode in the payload. The details of these codes can be found in our dedicated [Provisioning errors](https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors) documentation.",
93+
)

‎tests/unit/domains/numbers/v1/sinch_events/events/test_number_sinch_event_model.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_number_sinch_event_response_missing_optional_fields_expects_parsed_data
6969
assert response.event_type is None
7070
assert response.status is None
7171
assert response.failure_code is None
72+
assert response.internal_failure_code is None
7273

7374

7475
def test_number_sinch_event_response_invalid_data_expects_validation_error(invalid_data):

0 commit comments

Comments
 (0)