sinch.domains.numbers.sinch_events.v1 package

class sinch.domains.numbers.sinch_events.v1.SinchEvents(callback_secret: str)[source]

Bases: object

Parameters:

callback_secret (str)

validate_authentication_header(
headers: Dict[str, str],
json_payload: str | bytes,
) bool[source]

Validate the authorization header for a callback request

Parameters:
  • headers (Dict[str, str]) – Incoming request’s headers

  • json_payload (Union[str, bytes]) – Incoming request’s raw body (str or bytes)

Returns:

True if the X-Sinch-Signature header is valid

Return type:

bool

parse_event(
event_body: str | bytes | Dict[str, Any],
headers: Dict[str, str] | None = None,
) NumberSinchEvent[source]

Parses the event payload into a NumberSinchEvent object.

Handles a known issue where the server omits timezone information from the timestamp field. If the timezone is missing, the method assumes UTC and returns a timezone-aware datetime object.

Parameters:
  • event_body (Union[str, bytes, Dict[str, Any]]) – The event payload (JSON string, raw bytes, or dict).

  • headers (Optional[Dict[str, str]]) – Request headers (used to decode charset when event_body is bytes).

Returns:

A parsed Pydantic object with a timezone-aware timestamp.

Return type:

NumberSinchEvent