Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(customers): Add checkout_url endpoint #210

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lago_python_client/customers/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin
from ..models.customer import CustomerResponse
from ..models.customer_usage import CustomerUsageResponse
from ..services.request import make_headers, make_url, send_get_request
from ..services.request import make_headers, make_url, send_get_request, send_post_request
from ..services.response import get_response_data, prepare_index_response, prepare_object_response, Response

if sys.version_info >= (3, 9):
Expand Down Expand Up @@ -73,3 +73,15 @@ def portal_url(self, resource_id: str) -> str:

response_data = get_response_data(response=api_response, key=self.ROOT_NAME)
return response_data.get('portal_url', '') if isinstance(response_data, Mapping) else ''

def checkout_url(self, resource_id: str) -> str:
api_response: Response = send_post_request(
url=make_url(
origin=self.base_url,
path_parts=(self.API_RESOURCE, resource_id, 'checkout_url'),
),
headers=make_headers(api_key=self.api_key),
)

response_data = get_response_data(response=api_response, key=self.ROOT_NAME)
return response_data.get('checkout_url', '') if isinstance(response_data, Mapping) else ''