Skip to content

Commit

Permalink
Add client link
Browse files Browse the repository at this point in the history
  • Loading branch information
allcaps committed Jul 19, 2024
1 parent 625b079 commit e076676
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mollie/api/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 44 additions & 0 deletions mollie/api/objects/client_link.py
Original file line number Diff line number Diff line change
@@ -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")
24 changes: 24 additions & 0 deletions mollie/api/resources/client_links.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit e076676

Please sign in to comment.