diff --git a/mollie/api/error.py b/mollie/api/error.py index 37fceb4f..4bc25c45 100644 --- a/mollie/api/error.py +++ b/mollie/api/error.py @@ -184,3 +184,15 @@ class APIDeprecationWarning(DeprecationWarning): """ pass + + +""" +Closed beta policy + +The closed beta API may be subject to changes and is not covered by our versioning policy. +""" + +class ClosedBetaWarning(UserWarning): + """Warning for features that are part of the Client Links API closed beta.""" + + pass \ No newline at end of file diff --git a/mollie/api/objects/client_link.py b/mollie/api/objects/client_link.py new file mode 100644 index 00000000..08a1c5ae --- /dev/null +++ b/mollie/api/objects/client_link.py @@ -0,0 +1,44 @@ +import warnings + +from .base import ObjectBase +from ..error import ClosedBetaWarning + + +class ClientLink(ObjectBase): + + def __init__(self, data, client): + warnings.warn( + "The Client Links API is in closed beta and only available to " + "selected partners. Please contact your partner manager if you " + "want to implement this.", + ClosedBetaWarning, + ) + super().__init__(data, client) + + @classmethod + def get_object_name(cls): + return "client_links" + + # Documented properties + + @property + def resource(self): + return self._get_property("resource") + + @property + def id(self): + return self._get_property("id") + + # documented _links + + @property + def link(self): + return self._get_link("self") + + @property + def client_link(self): + return self._get_link("clientLink") + + @property + def documentation_link(self): + return self._get_link("documentation") diff --git a/mollie/api/resources/client_links.py b/mollie/api/resources/client_links.py new file mode 100644 index 00000000..1aa5929e --- /dev/null +++ b/mollie/api/resources/client_links.py @@ -0,0 +1,24 @@ +from typing import Any, Optional, Dict + +from ..error import RequestSetupError +from ..objects.client_link import ClientLink +from .base import ResourceCreateMixin + +__all__ = [ + "ClientLinks", +] + + +class ClientLinks(ResourceCreateMixin): + """Resource handler for the `/client-links` endpoint.""" + + RESOURCE_ID_PREFIX: str = "cl_" + object_type = ClientLink + + def get_resource_path(self) -> str: + return "client-links" + + def create(self, data: Optional[Dict[str, Any]] = None, idempotency_key: str = "", **params: Any) -> ClientLink: + if not hasattr(self, "_oauth_client"): + raise RequestSetupError("Creating client links requires OAuth authorization.") + return super().create(data, idempotency_key, **params)