# Path: mollie/api/error.py
# class IdentifierError(RequestSetupError):
#     """Errors related to invalid resource identifiers that will be requested from the API."""
# 
#     pass
# 
# Path: mollie/api/objects/payment_link.py
# class PaymentLink(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.payment_links import PaymentLinks
# 
#         return PaymentLinks(client)
# 
#     @classmethod
#     def get_object_name(cls):
#         return "payment_links"
# 
#     # Documented properties
# 
#     @property
#     def resource(self):
#         return self._get_property("resource")
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def description(self):
#         return self._get_property("description")
# 
#     @property
#     def mode(self):
#         return self._get_property("mode")
# 
#     @property
#     def profile_id(self):
#         return self._get_property("profileId")
# 
#     @property
#     def amount(self):
#         return self._get_property("amount")
# 
#     @property
#     def redirect_url(self):
#         return self._get_property("redirectUrl")
# 
#     @property
#     def webhook_url(self):
#         return self._get_property("webhookUrl")
# 
#     @property
#     def created_at(self):
#         return self._get_property("createdAt")
# 
#     @property
#     def paid_at(self):
#         return self._get_property("paidAt")
# 
#     @property
#     def updated_at(self):
#         return self._get_property("updatedAt")
# 
#     @property
#     def expires_at(self):
#         return self._get_property("expiresAt")
# 
#     # documented _links
# 
#     @property
#     def payment_link(self):
#         return self._get_link("paymentLink")
# 
#     # additional methods
# 
#     def is_paid(self):
#         return self._get_property("paidAt") is not None
# 
#     def has_expiration_date(self):
#         return self._get_property("expiresAt") is not None
# 
# Path: tests/utils.py
# def assert_list_object(obj, object_type, count=None):
#     """Assert that a List object is correctly working, and has sane contents."""
#     assert isinstance(obj, ObjectList), f"Object {obj} is not a ObjectList instance."
#     assert isinstance(obj.count, int), "ObjectList count is not an integer."
#     if count is not None:
#         assert obj.count == count, "ObjectList does not contain the expected number of items."
#     else:
#         assert obj.count > 0, "ObjectList has no items."
# 
#     # verify items in list
#     items = []
#     for item in obj:
#         assert isinstance(item, object_type)
#         assert item.id is not None
#         items.append(item.id)
# 
#     assert len(items) == obj.count, "Items in ObjectList don't match list count."
#     assert len(set(items)) == obj.count, "Not all object ids in the ObjectList are unique."


import pytest
from mollie.api.error import IdentifierError
from mollie.api.objects.payment_link import PaymentLink
from .utils import assert_list_object

PAYMENT_LINK_ID = "pl_4Y0eZitmBnQ6IDoMqZQKh"


def test_list_payment_links(client, response):
    """Retrieve the list of payment links."""
    response.get("https://api.mollie.com/v2/payment-links", "payment_links_list")
    payment_links = client.payment_links.list()
    assert_list_object(payment_links, PaymentLink)


def test_create_payment_link(client, response):
    response.post("https://api.mollie.com/v2/payment-links", "payment_link_single")

    payment_link = client.payment_links.create(
        {
            "amount": {"currency": "EUR", "value": "10.00"},
            "description": "Some description",
            "redirectUrl": "https://webshop.example.org/order/12345/",
            "webhookUrl": "https://webshop.example.org/payment-links/webhook/",
            "expiresAt": "2022-12-05T18:00:00+01:00",
        }
    )
    assert payment_link.id == PAYMENT_LINK_ID


def test_get_single_payment_link(client, response):
    response.get(f"https://api.mollie.com/v2/payment-links/{PAYMENT_LINK_ID}", "payment_link_single")

    payment_link = client.payment_links.get(PAYMENT_LINK_ID)

# Path: mollie/api/error.py
# class IdentifierError(RequestSetupError):
#     """Errors related to invalid resource identifiers that will be requested from the API."""
# 
#     pass
# 
# Path: mollie/api/objects/payment_link.py
# class PaymentLink(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.payment_links import PaymentLinks
# 
#         return PaymentLinks(client)
# 
#     @classmethod
#     def get_object_name(cls):
#         return "payment_links"
# 
#     # Documented properties
# 
#     @property
#     def resource(self):
#         return self._get_property("resource")
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def description(self):
#         return self._get_property("description")
# 
#     @property
#     def mode(self):
#         return self._get_property("mode")
# 
#     @property
#     def profile_id(self):
#         return self._get_property("profileId")
# 
#     @property
#     def amount(self):
#         return self._get_property("amount")
# 
#     @property
#     def redirect_url(self):
#         return self._get_property("redirectUrl")
# 
#     @property
#     def webhook_url(self):
#         return self._get_property("webhookUrl")
# 
#     @property
#     def created_at(self):
#         return self._get_property("createdAt")
# 
#     @property
#     def paid_at(self):
#         return self._get_property("paidAt")
# 
#     @property
#     def updated_at(self):
#         return self._get_property("updatedAt")
# 
#     @property
#     def expires_at(self):
#         return self._get_property("expiresAt")
# 
#     # documented _links
# 
#     @property
#     def payment_link(self):
#         return self._get_link("paymentLink")
# 
#     # additional methods
# 
#     def is_paid(self):
#         return self._get_property("paidAt") is not None
# 
#     def has_expiration_date(self):
#         return self._get_property("expiresAt") is not None
# 
# Path: tests/utils.py
# def assert_list_object(obj, object_type, count=None):
#     """Assert that a List object is correctly working, and has sane contents."""
#     assert isinstance(obj, ObjectList), f"Object {obj} is not a ObjectList instance."
#     assert isinstance(obj.count, int), "ObjectList count is not an integer."
#     if count is not None:
#         assert obj.count == count, "ObjectList does not contain the expected number of items."
#     else:
#         assert obj.count > 0, "ObjectList has no items."
# 
#     # verify items in list
#     items = []
#     for item in obj:
#         assert isinstance(item, object_type)
#         assert item.id is not None
#         items.append(item.id)
# 
#     assert len(items) == obj.count, "Items in ObjectList don't match list count."
#     assert len(set(items)) == obj.count, "Not all object ids in the ObjectList are unique."


# Path: tests/test_payment_links.py
import pytest
from mollie.api.error import IdentifierError
from mollie.api.objects.payment_link import PaymentLink
from .utils import assert_list_object


PAYMENT_LINK_ID = "pl_4Y0eZitmBnQ6IDoMqZQKh"


def test_list_payment_links(client, response):
    """Retrieve the list of payment links."""
    response.get("https://api.mollie.com/v2/payment-links", "payment_links_list")
    payment_links = client.payment_links.list()
    assert_list_object(payment_links, PaymentLink)


def test_create_payment_link(client, response):
    response.post("https://api.mollie.com/v2/payment-links", "payment_link_single")

    payment_link = client.payment_links.create(
        {
            "amount": {"currency": "EUR", "value": "10.00"},
            "description": "Some description",
            "redirectUrl": "https://webshop.example.org/order/12345/",
            "webhookUrl": "https://webshop.example.org/payment-links/webhook/",
            "expiresAt": "2022-12-05T18:00:00+01:00",
        }
    )
    assert payment_link.id == PAYMENT_LINK_ID


def test_get_single_payment_link(client, response):
    response.get(f"https://api.mollie.com/v2/payment-links/{PAYMENT_LINK_ID}", "payment_link_single")

    payment_link = client.payment_links.get(PAYMENT_LINK_ID)

    assert isinstance(payment_link, PaymentLink)