# Path: pyuploadcare/api/entities.py
# class Webhook(Entity):
#     id: int
#     created: Optional[datetime]
#     updated: Optional[datetime]
#     event: Optional[str]
#     target_url: Optional[str]
#     project: Optional[str]
#     is_active: Optional[bool]
#     signing_secret: Optional[str]


import pytest
from pyuploadcare.api.entities import Webhook



@pytest.mark.vcr
def test_create_webhook(uploadcare):
    webhook = uploadcare.webhooks_api.create(
        {
            "event": "file.uploaded",
            "target_url": "https://webhook.site/699ba5a4-b178-41c7-b416-5d1b6739d052",
            "is_active": True,
        }
    )
    assert isinstance(webhook, Webhook)


@pytest.mark.vcr
def test_list_webhooks(uploadcare):
    webhooks = list(uploadcare.webhooks_api.list(limit=1))
    assert len(webhooks) == 1

# Path: pyuploadcare/api/entities.py
# class Webhook(Entity):
#     id: int
#     created: Optional[datetime]
#     updated: Optional[datetime]
#     event: Optional[str]
#     target_url: Optional[str]
#     project: Optional[str]
#     is_active: Optional[bool]
#     signing_secret: Optional[str]


# Path: tests/functional/api/test_webhooks_api.py
import pytest
from pyuploadcare.api.entities import Webhook




@pytest.mark.vcr
def test_create_webhook(uploadcare):
    webhook = uploadcare.webhooks_api.create(
        {
            "event": "file.uploaded",
            "target_url": "https://webhook.site/699ba5a4-b178-41c7-b416-5d1b6739d052",
            "is_active": True,
        }
    )
    assert isinstance(webhook, Webhook)


@pytest.mark.vcr
def test_list_webhooks(uploadcare):
    webhooks = list(uploadcare.webhooks_api.list(limit=1))
    assert len(webhooks) == 1

    assert isinstance(webhooks[0], Webhook)