sinch.domains.sms.sinch_events.v1.sms_sinch_event module
- class sinch.domains.sms.sinch_events.v1.sms_sinch_event.SmsSinchEvent(app_secret: str | None = None)[source]
Bases:
object- Parameters:
app_secret (str | None)
- validate_authentication_header(
- headers: Dict[str, str],
- json_payload: str | bytes,
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-Webhook-Signature header is valid
- Return type:
bool
- parse_event(
- event_body: str | bytes | Dict[str, Any],
- headers: Dict[str, str] | None = None,
Parse the event payload into an SMS callback object.
Handles datetime conversion for timestamp fields and routes to the appropriate event type based on the type field.
- 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 SMS Sinch Event payload object.
- Return type:
SmsSinchEventPayload
- Raises:
ValueError – If the event type is unknown or parsing fails.