# 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/invoice.py
# class Invoice(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.invoices import Invoices
# 
#         return Invoices(client)
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def reference(self):
#         return self._get_property("reference")
# 
#     @property
#     def vat_number(self):
#         return self._get_property("vatNumber")
# 
#     @property
#     def status(self):
#         return self._get_property("status")
# 
#     @property
#     def issued_at(self):
#         return self._get_property("issuedAt")
# 
#     @property
#     def paid_at(self):
#         return self._get_property("paidAt")
# 
#     @property
#     def due_at(self):
#         return self._get_property("dueAt")
# 
#     @property
#     def resource(self):
#         return self._get_property("resource")
# 
#     @property
#     def net_amount(self):
#         return self._get_property("netAmount")
# 
#     @property
#     def vat_amount(self):
#         return self._get_property("vatAmount")
# 
#     @property
#     def gross_amount(self):
#         return self._get_property("grossAmount")
# 
#     @property
#     def lines(self):
#         return self._get_property("lines") or []
# 
#     @property
#     def pdf(self):
#         return self._get_link("pdf")
# 
# Path: mollie/api/resources/base.py
# class ResourceBase(object):
#     REST_CREATE = "POST"
#     REST_UPDATE = "PATCH"
#     REST_READ = "GET"
#     REST_LIST = "GET"
#     REST_DELETE = "DELETE"
#     DEFAULT_LIMIT = 10
# 
#     def __init__(self, client):
#         self.client = client
# 
#     def get_resource_object(self, result):
#         raise NotImplementedError()  # pragma: no cover
# 
#     def get_resource_name(self):
#         return self.__class__.__name__.lower()
# 
#     def create(self, data=None, **params):
#         path = self.get_resource_name()
#         result = self.perform_api_call(self.REST_CREATE, path, data, params)
#         return self.get_resource_object(result)
# 
#     def get(self, resource_id, **params):
#         path = self.get_resource_name() + "/" + str(resource_id)
#         result = self.perform_api_call(self.REST_READ, path, params=params)
#         return self.get_resource_object(result)
# 
#     def update(self, resource_id, data=None, **params):
#         path = self.get_resource_name() + "/" + str(resource_id)
#         result = self.perform_api_call(self.REST_UPDATE, path, data, params)
#         return self.get_resource_object(result)
# 
#     def delete(self, resource_id, data=None):
#         path = self.get_resource_name() + "/" + str(resource_id)
#         return self.perform_api_call(self.REST_DELETE, path, data)
# 
#     def list(self, **params):
#         path = self.get_resource_name()
#         result = self.perform_api_call(self.REST_LIST, path, params=params)
#         return ObjectList(result, self.get_resource_object({}).__class__, self.client)
# 
#     def perform_api_call(self, http_method, path, data=None, params=None):
#         resp = self.client.perform_http_call(http_method, path, data, params)
#         if "application/hal+json" in resp.headers.get("Content-Type", ""):
#             # set the content type according to the media type definition
#             resp.encoding = "utf-8"
#         try:
#             result = resp.json() if resp.status_code != 204 else {}
#         except Exception:
#             raise ResponseHandlingError(
#                 f"Unable to decode Mollie API response (status code: {resp.status_code}): '{resp.text}'."
#             )
#         if resp.status_code < 200 or resp.status_code > 299:
#             if "status" in result and (result["status"] < 200 or result["status"] > 299):
#                 # the factory will return the appropriate ResponseError subclass based on the result
#                 raise ResponseError.factory(result)
#             else:
#                 raise ResponseHandlingError(
#                     "Received HTTP error from Mollie API, but no status in payload "
#                     f"(status code: {resp.status_code}): '{resp.text}'."
#                 )
#         return result
# 
#     def from_url(self, url, data=None, params=None):
#         """Utility method to return an object from a full URL (such as from _links).
# 
#         This method always does a GET request and returns a single Object.
#         """
#         result = self.perform_api_call(self.REST_READ, url, data, params)
#         return self.get_resource_object(result)
# 
#     @staticmethod
#     def extract_embed(params):
#         """Extract and parse the embed parameter from the request."""
#         if "embed" not in params:
#             return
#         return params["embed"].split(",")


from ..error import IdentifierError
from ..objects.invoice import Invoice
from .base import ResourceBase


class Invoices(ResourceBase):
    RESOURCE_ID_PREFIX = "inv_"

    def get_resource_object(self, result):
        return Invoice(result, self.client)

    def get(self, invoice_id, **params):
        if not invoice_id or not invoice_id.startswith(self.RESOURCE_ID_PREFIX):
            raise IdentifierError(
                f"Invalid invoice ID: '{invoice_id}'. An invoice ID should start with '{self.RESOURCE_ID_PREFIX}'."
            )

# 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/invoice.py
# class Invoice(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.invoices import Invoices
# 
#         return Invoices(client)
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def reference(self):
#         return self._get_property("reference")
# 
#     @property
#     def vat_number(self):
#         return self._get_property("vatNumber")
# 
#     @property
#     def status(self):
#         return self._get_property("status")
# 
#     @property
#     def issued_at(self):
#         return self._get_property("issuedAt")
# 
#     @property
#     def paid_at(self):
#         return self._get_property("paidAt")
# 
#     @property
#     def due_at(self):
#         return self._get_property("dueAt")
# 
#     @property
#     def resource(self):
#         return self._get_property("resource")
# 
#     @property
#     def net_amount(self):
#         return self._get_property("netAmount")
# 
#     @property
#     def vat_amount(self):
#         return self._get_property("vatAmount")
# 
#     @property
#     def gross_amount(self):
#         return self._get_property("grossAmount")
# 
#     @property
#     def lines(self):
#         return self._get_property("lines") or []
# 
#     @property
#     def pdf(self):
#         return self._get_link("pdf")
# 
# Path: mollie/api/resources/base.py
# class ResourceBase(object):
#     REST_CREATE = "POST"
#     REST_UPDATE = "PATCH"
#     REST_READ = "GET"
#     REST_LIST = "GET"
#     REST_DELETE = "DELETE"
#     DEFAULT_LIMIT = 10
# 
#     def __init__(self, client):
#         self.client = client
# 
#     def get_resource_object(self, result):
#         raise NotImplementedError()  # pragma: no cover
# 
#     def get_resource_name(self):
#         return self.__class__.__name__.lower()
# 
#     def create(self, data=None, **params):
#         path = self.get_resource_name()
#         result = self.perform_api_call(self.REST_CREATE, path, data, params)
#         return self.get_resource_object(result)
# 
#     def get(self, resource_id, **params):
#         path = self.get_resource_name() + "/" + str(resource_id)
#         result = self.perform_api_call(self.REST_READ, path, params=params)
#         return self.get_resource_object(result)
# 
#     def update(self, resource_id, data=None, **params):
#         path = self.get_resource_name() + "/" + str(resource_id)
#         result = self.perform_api_call(self.REST_UPDATE, path, data, params)
#         return self.get_resource_object(result)
# 
#     def delete(self, resource_id, data=None):
#         path = self.get_resource_name() + "/" + str(resource_id)
#         return self.perform_api_call(self.REST_DELETE, path, data)
# 
#     def list(self, **params):
#         path = self.get_resource_name()
#         result = self.perform_api_call(self.REST_LIST, path, params=params)
#         return ObjectList(result, self.get_resource_object({}).__class__, self.client)
# 
#     def perform_api_call(self, http_method, path, data=None, params=None):
#         resp = self.client.perform_http_call(http_method, path, data, params)
#         if "application/hal+json" in resp.headers.get("Content-Type", ""):
#             # set the content type according to the media type definition
#             resp.encoding = "utf-8"
#         try:
#             result = resp.json() if resp.status_code != 204 else {}
#         except Exception:
#             raise ResponseHandlingError(
#                 f"Unable to decode Mollie API response (status code: {resp.status_code}): '{resp.text}'."
#             )
#         if resp.status_code < 200 or resp.status_code > 299:
#             if "status" in result and (result["status"] < 200 or result["status"] > 299):
#                 # the factory will return the appropriate ResponseError subclass based on the result
#                 raise ResponseError.factory(result)
#             else:
#                 raise ResponseHandlingError(
#                     "Received HTTP error from Mollie API, but no status in payload "
#                     f"(status code: {resp.status_code}): '{resp.text}'."
#                 )
#         return result
# 
#     def from_url(self, url, data=None, params=None):
#         """Utility method to return an object from a full URL (such as from _links).
# 
#         This method always does a GET request and returns a single Object.
#         """
#         result = self.perform_api_call(self.REST_READ, url, data, params)
#         return self.get_resource_object(result)
# 
#     @staticmethod
#     def extract_embed(params):
#         """Extract and parse the embed parameter from the request."""
#         if "embed" not in params:
#             return
#         return params["embed"].split(",")


# Path: mollie/api/resources/invoices.py
from ..error import IdentifierError
from ..objects.invoice import Invoice
from .base import ResourceBase



class Invoices(ResourceBase):
    RESOURCE_ID_PREFIX = "inv_"

    def get_resource_object(self, result):
        return Invoice(result, self.client)

    def get(self, invoice_id, **params):
        if not invoice_id or not invoice_id.startswith(self.RESOURCE_ID_PREFIX):
            raise IdentifierError(
                f"Invalid invoice ID: '{invoice_id}'. An invoice ID should start with '{self.RESOURCE_ID_PREFIX}'."
            )

        return super().get(invoice_id, **params)