diff --git a/nylas/models/webhooks.py b/nylas/models/webhooks.py index 36ea508..71b6582 100644 --- a/nylas/models/webhooks.py +++ b/nylas/models/webhooks.py @@ -11,10 +11,16 @@ class WebhookTriggers(str, Enum): """Enum representing the available webhook triggers.""" - + BOOKING_CREATED = "booking.created" + BOOKING_PENDING = "booking.pending" + BOOKING_RESCHEDULED = "booking.rescheduled" + BOOKING_CANCELLED = "booking.cancelled" + BOOKING_REMINDER = "booking.reminder" CALENDAR_CREATED = "calendar.created" CALENDAR_UPDATED = "calendar.updated" CALENDAR_DELETED = "calendar.deleted" + CONTACT_UPDATED = "contact.updated" + CONTACT_DELETED = "contact.deleted" EVENT_CREATED = "event.created" EVENT_UPDATED = "event.updated" EVENT_DELETED = "event.deleted" @@ -29,7 +35,13 @@ class WebhookTriggers(str, Enum): MESSAGE_UPDATED = "message.updated" MESSAGE_OPENED = "message.opened" MESSAGE_LINK_CLICKED = "message.link_clicked" + MESSAGE_OPENED_LEGACY = "message.opened.legacy" + MESSAGE_LINK_CLICKED_LEGACY = "message.link_clicked.legacy" + MESSAGE_INTELLIGENCE_ORDER = "message.intelligence.order" + MESSAGE_INTELLIGENCE_TRACKING = "message.intelligence.tracking" + MESSAGE_INTELLIGENCE_RETURN = "message.intelligence.return" THREAD_REPLIED = "thread.replied" + THREAD_REPLIED_LEGACY = "thread.replied.legacy" FOLDER_CREATED = "folder.created" FOLDER_UPDATED = "folder.updated" FOLDER_DELETED = "folder.deleted" diff --git a/tests/resources/test_webhooks.py b/tests/resources/test_webhooks.py index d474906..98f016d 100644 --- a/tests/resources/test_webhooks.py +++ b/tests/resources/test_webhooks.py @@ -33,6 +33,71 @@ def test_webhook_deserialization(self, http_client): assert webhook.created_at == 1234567890 assert webhook.updated_at == 1234567890 + def test_webhook_deserialization_all(self, http_client): + trigger_types = [ + "booking.created", + "booking.pending", + "booking.rescheduled", + "booking.cancelled", + "booking.reminder", + "calendar.created", + "calendar.updated", + "calendar.deleted", + "contact.updated", + "contact.deleted", + "event.created", + "event.updated", + "event.deleted", + "grant.created", + "grant.updated", + "grant.deleted", + "grant.expired", + "message.send_success", + "message.send_failed", + "message.bounce_detected", + "message.created", + "message.updated", + "message.opened", + "message.link_clicked", + "message.opened.legacy", + "message.link_clicked.legacy", + "message.intelligence.order", + "message.intelligence.tracking", + "message.intelligence.return", + "thread.replied", + "thread.replied.legacy", + "folder.created", + "folder.updated", + "folder.deleted" + ] + + webhook_json = { + "id": "UMWjAjMeWQ4D8gYF2moonK4486", + "description": "Production webhook destination", + "trigger_types": trigger_types, + "webhook_url": "https://example.com/webhooks", + "status": "active", + "notification_email_addresses": ["jane@example.com", "joe@example.com"], + "status_updated_at": 1234567890, + "created_at": 1234567890, + "updated_at": 1234567890, + } + + webhook = Webhook.from_dict(webhook_json) + + assert webhook.id == "UMWjAjMeWQ4D8gYF2moonK4486" + assert webhook.description == "Production webhook destination" + assert webhook.trigger_types == trigger_types + assert webhook.webhook_url == "https://example.com/webhooks" + assert webhook.status == "active" + assert webhook.notification_email_addresses == [ + "jane@example.com", + "joe@example.com", + ] + assert webhook.status_updated_at == 1234567890 + assert webhook.created_at == 1234567890 + assert webhook.updated_at == 1234567890 + def test_list_webhooks(self, http_client_list_response): webhooks = Webhooks(http_client_list_response)