Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 25 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A list method returns its first page, such as a `AddOnsListPage`: a subclass of
model (`AddOnListResponse`) with the paging members `items`, `has_next_page()`, `get_next_page()`,
`iter_pages()` and `body`, which iterates every item. The page classes are in `meteroid.api`.

[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Checkout sessions](#checkout-sessions) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage)
[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Checkout sessions](#checkout-sessions) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints)

## Add ons

Expand Down Expand Up @@ -113,7 +113,7 @@ model (`AddOnListResponse`) with the paging members `items`, `has_next_page()`,
| Method | Request | Returns |
| --- | --- | --- |
| `client.customers.list(*, order_by=..., page=..., per_page=..., search=..., archived=...) -> CustomersListPage` | `GET /api/v1/customers` | [`CustomerListResponse`](meteroid/models/customer_list_response.py) pages of [`Customer`](meteroid/models/customer.py) |
| `client.customers.create(*, currency: Currency, custom_taxes: list[CustomTaxRate], invoicing_emails: list[str], alias=..., billing_address=..., billing_email=..., buyer_reference=..., connected_account_id=..., custom_properties=..., customer_type=..., exemption_reason=..., first_name=..., invoicing_entity_id=..., invoicing_language=..., is_tax_exempt=..., last_name=..., legal_number=..., name=..., phone=..., preferred_locales=..., shipping_address=..., vat_number=...) -> Customer` | `POST /api/v1/customers` | [`Customer`](meteroid/models/customer.py) |
| `client.customers.create(*, currency: Currency, alias=..., billing_address=..., billing_email=..., buyer_reference=..., connected_account_id=..., custom_properties=..., custom_taxes=..., customer_type=..., exemption_reason=..., first_name=..., invoicing_emails=..., invoicing_entity_id=..., invoicing_language=..., is_tax_exempt=..., last_name=..., legal_number=..., name=..., phone=..., preferred_locales=..., shipping_address=..., vat_number=...) -> Customer` | `POST /api/v1/customers` | [`Customer`](meteroid/models/customer.py) |
| `client.customers.retrieve(id_or_alias: str) -> Customer` | `GET /api/v1/customers/{id_or_alias}` | [`Customer`](meteroid/models/customer.py) |
| `client.customers.replace(id_or_alias: str, *, currency: Currency, custom_taxes: list[CustomTaxRate], invoicing_emails: list[str], invoicing_entity_id: InvoicingEntityId, alias=..., billing_address=..., billing_email=..., buyer_reference=..., custom_properties=..., customer_type=..., exemption_reason=..., first_name=..., invoicing_language=..., is_tax_exempt=..., last_name=..., legal_number=..., name=..., phone=..., preferred_locales=..., shipping_address=..., vat_number=...) -> Customer` | `PUT /api/v1/customers/{id_or_alias}` | [`Customer`](meteroid/models/customer.py) |
| `client.customers.archive(id_or_alias: str) -> None` | `DELETE /api/v1/customers/{id_or_alias}` | nothing |
Expand Down Expand Up @@ -283,3 +283,26 @@ model (`AddOnListResponse`) with the paging members `items`, `has_next_page()`,
| `client.usage.retrieve_customer(customer_id: str, *, start_date: date, end_date: date, metric_id=...) -> UsageResponse` | `GET /api/v1/usage/customer/{customer_id}` | [`UsageResponse`](meteroid/models/usage_response.py) |
| `client.usage.retrieve_subscription(subscription_id: str, *, start_date=..., end_date=..., metric_id=...) -> UsageResponse` | `GET /api/v1/usage/subscription/{subscription_id}` | [`UsageResponse`](meteroid/models/usage_response.py) |
| `client.usage.retrieve_summary(*, start_date: date, end_date: date, metric_id=...) -> UsageResponse` | `GET /api/v1/usage/summary` | [`UsageResponse`](meteroid/models/usage_response.py) |

## Webhook endpoints

[`client.webhook_endpoints`](meteroid/api/webhook_endpoints.py)

| Method | Request | Returns |
| --- | --- | --- |
| `client.webhook_endpoints.resend_webhook_delivery(delivery_id: str) -> WebhookDelivery` | `POST /api/v1/webhooks/deliveries/{delivery_id}/resend` | [`WebhookDelivery`](meteroid/models/webhook_delivery.py) |

### Webhook endpoints endpoints

[`client.webhook_endpoints.endpoints`](meteroid/api/webhook_endpoints_endpoints.py)

| Method | Request | Returns |
| --- | --- | --- |
| `client.webhook_endpoints.endpoints.list() -> WebhookEndpointListResponse` | `GET /api/v1/webhooks/endpoints` | [`WebhookEndpointListResponse`](meteroid/models/webhook_endpoint_list_response.py) |
| `client.webhook_endpoints.endpoints.create(*, url: str, description=..., event_types=..., headers=..., rate_limit_per_sec=...) -> CreatedWebhookEndpoint` | `POST /api/v1/webhooks/endpoints` | [`CreatedWebhookEndpoint`](meteroid/models/created_webhook_endpoint.py) |
| `client.webhook_endpoints.endpoints.retrieve(endpoint_id: str) -> WebhookEndpoint` | `GET /api/v1/webhooks/endpoints/{endpoint_id}` | [`WebhookEndpoint`](meteroid/models/webhook_endpoint.py) |
| `client.webhook_endpoints.endpoints.delete(endpoint_id: str) -> None` | `DELETE /api/v1/webhooks/endpoints/{endpoint_id}` | nothing |
| `client.webhook_endpoints.endpoints.update(endpoint_id: str, *, description=..., disabled=..., event_types=..., headers=..., rate_limit_per_sec=..., url=...) -> WebhookEndpoint` | `PATCH /api/v1/webhooks/endpoints/{endpoint_id}` | [`WebhookEndpoint`](meteroid/models/webhook_endpoint.py) |
| `client.webhook_endpoints.endpoints.list_deliveries(endpoint_id: str, *, status=..., page=..., per_page=...) -> WebhookEndpointsEndpointsListDeliveriesPage` | `GET /api/v1/webhooks/endpoints/{endpoint_id}/deliveries` | [`WebhookDeliveryListResponse`](meteroid/models/webhook_delivery_list_response.py) pages of [`WebhookDelivery`](meteroid/models/webhook_delivery.py) |
| `client.webhook_endpoints.endpoints.rotate_secret(endpoint_id: str) -> WebhookEndpointSecret` | `POST /api/v1/webhooks/endpoints/{endpoint_id}/rotate-secret` | [`WebhookEndpointSecret`](meteroid/models/webhook_endpoint_secret.py) |
| `client.webhook_endpoints.endpoints.retrieve_secret(endpoint_id: str) -> WebhookEndpointSecret` | `GET /api/v1/webhooks/endpoints/{endpoint_id}/secret` | [`WebhookEndpointSecret`](meteroid/models/webhook_endpoint_secret.py) |
19 changes: 19 additions & 0 deletions meteroid/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
AsyncProductFamiliesListPage,
AsyncProductsListPage,
AsyncSubscriptionsListPage,
AsyncWebhookEndpointsEndpointsListDeliveriesPage,
BatchJobsListFailuresPage,
BatchJobsListPage,
CouponsListPage,
Expand All @@ -69,6 +70,7 @@
ProductFamiliesListPage,
ProductsListPage,
SubscriptionsListPage,
WebhookEndpointsEndpointsListDeliveriesPage,
)
from .add_ons import AddOns, AsyncAddOns
from .add_ons_entitlements import AddOnsEntitlements, AsyncAddOnsEntitlements
Expand All @@ -93,6 +95,11 @@
from .products_entitlements import AsyncProductsEntitlements, ProductsEntitlements
from .subscriptions import AsyncSubscriptions, Subscriptions
from .usage import AsyncUsage, Usage
from .webhook_endpoints import AsyncWebhookEndpoints, WebhookEndpoints
from .webhook_endpoints_endpoints import (
AsyncWebhookEndpointsEndpoints,
WebhookEndpointsEndpoints,
)

# Each resource's module is imported the first time it is used.
_MODULES: dict[str, str] = {
Expand Down Expand Up @@ -142,6 +149,10 @@
"Subscriptions": "subscriptions",
"AsyncUsage": "usage",
"Usage": "usage",
"AsyncWebhookEndpoints": "webhook_endpoints",
"WebhookEndpoints": "webhook_endpoints",
"AsyncWebhookEndpointsEndpoints": "webhook_endpoints_endpoints",
"WebhookEndpointsEndpoints": "webhook_endpoints_endpoints",
"AsyncAddOnsListPage": "_pages",
"AddOnsListPage": "_pages",
"AsyncBatchJobsListPage": "_pages",
Expand Down Expand Up @@ -172,6 +183,8 @@
"ProductsListPage": "_pages",
"AsyncSubscriptionsListPage": "_pages",
"SubscriptionsListPage": "_pages",
"AsyncWebhookEndpointsEndpointsListDeliveriesPage": "_pages",
"WebhookEndpointsEndpointsListDeliveriesPage": "_pages",
}


Expand Down Expand Up @@ -262,6 +275,10 @@ def __dir__() -> list[str]:
"Subscriptions",
"AsyncUsage",
"Usage",
"AsyncWebhookEndpoints",
"WebhookEndpoints",
"AsyncWebhookEndpointsEndpoints",
"WebhookEndpointsEndpoints",
"AsyncAddOnsListPage",
"AddOnsListPage",
"AsyncBatchJobsListPage",
Expand Down Expand Up @@ -292,4 +309,6 @@ def __dir__() -> list[str]:
"ProductsListPage",
"AsyncSubscriptionsListPage",
"SubscriptionsListPage",
"AsyncWebhookEndpointsEndpointsListDeliveriesPage",
"WebhookEndpointsEndpointsListDeliveriesPage",
]
16 changes: 16 additions & 0 deletions meteroid/api/_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
ProductListResponse,
Subscription,
SubscriptionListResponse,
WebhookDelivery,
WebhookDeliveryListResponse,
)
from ._pagination import AsyncPage, SyncPage

Expand Down Expand Up @@ -68,6 +70,8 @@
"ProductsListPage",
"AsyncSubscriptionsListPage",
"SubscriptionsListPage",
"AsyncWebhookEndpointsEndpointsListDeliveriesPage",
"WebhookEndpointsEndpointsListDeliveriesPage",
]


Expand Down Expand Up @@ -231,3 +235,15 @@ class AsyncSubscriptionsListPage(
AsyncPage[Subscription, SubscriptionListResponse], SubscriptionListResponse
):
"""A page of :class:`Subscription`, and the :class:`SubscriptionListResponse` response of its request."""


class WebhookEndpointsEndpointsListDeliveriesPage(
SyncPage[WebhookDelivery, WebhookDeliveryListResponse], WebhookDeliveryListResponse
):
"""A page of :class:`WebhookDelivery`, and the :class:`WebhookDeliveryListResponse` response of its request."""


class AsyncWebhookEndpointsEndpointsListDeliveriesPage(
AsyncPage[WebhookDelivery, WebhookDeliveryListResponse], WebhookDeliveryListResponse
):
"""A page of :class:`WebhookDelivery`, and the :class:`WebhookDeliveryListResponse` response of its request."""
34 changes: 34 additions & 0 deletions meteroid/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@
Usage,
UsageWithRawResponse,
)
from .webhook_endpoints import (
AsyncWebhookEndpoints,
AsyncWebhookEndpointsWithRawResponse,
WebhookEndpoints,
WebhookEndpointsWithRawResponse,
)

__all__ = [
"AsyncMeteroid",
Expand Down Expand Up @@ -424,6 +430,13 @@ def usage(self) -> Usage:

return Usage(self._cfg, self._httpx_client)

@functools.cached_property
def webhook_endpoints(self) -> WebhookEndpoints:
"""The webhook endpoints API."""
from .webhook_endpoints import WebhookEndpoints

return WebhookEndpoints(self._cfg, self._httpx_client)


class MeteroidWithRawResponse:
"""The resources of :class:`Meteroid`, whose methods return an :class:`APIResponse`."""
Expand Down Expand Up @@ -571,6 +584,13 @@ def usage(self) -> UsageWithRawResponse:

return UsageWithRawResponse(self._client.usage)

@property
def webhook_endpoints(self) -> WebhookEndpointsWithRawResponse:
"""The webhook endpoints API."""
from .webhook_endpoints import WebhookEndpointsWithRawResponse

return WebhookEndpointsWithRawResponse(self._client.webhook_endpoints)


class AsyncMeteroid:
"""Asyncio Meteroid API client.
Expand Down Expand Up @@ -818,6 +838,13 @@ def usage(self) -> AsyncUsage:

return AsyncUsage(self._cfg, self._httpx_client)

@functools.cached_property
def webhook_endpoints(self) -> AsyncWebhookEndpoints:
"""The webhook endpoints API."""
from .webhook_endpoints import AsyncWebhookEndpoints

return AsyncWebhookEndpoints(self._cfg, self._httpx_client)


class AsyncMeteroidWithRawResponse:
"""The resources of :class:`AsyncMeteroid`, whose methods return an :class:`APIResponse`."""
Expand Down Expand Up @@ -964,3 +991,10 @@ def usage(self) -> AsyncUsageWithRawResponse:
from .usage import AsyncUsageWithRawResponse

return AsyncUsageWithRawResponse(self._client.usage)

@property
def webhook_endpoints(self) -> AsyncWebhookEndpointsWithRawResponse:
"""The webhook endpoints API."""
from .webhook_endpoints import AsyncWebhookEndpointsWithRawResponse

return AsyncWebhookEndpointsWithRawResponse(self._client.webhook_endpoints)
8 changes: 4 additions & 4 deletions meteroid/api/customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ async def create(
self,
*,
currency: Currency | CurrencyLiteral,
custom_taxes: builtins.list[CustomTaxRate],
invoicing_emails: builtins.list[str],
alias: str | None | Unset = UNSET,
billing_address: Address | None | Unset = UNSET,
billing_email: str | None | Unset = UNSET,
buyer_reference: str | None | Unset = UNSET,
connected_account_id: str | None | Unset = UNSET,
custom_properties: t.Any = None,
custom_taxes: builtins.list[CustomTaxRate] | None = None,
customer_type: CustomerType | CustomerTypeLiteral | None = None,
exemption_reason: str | None | Unset = UNSET,
first_name: str | None | Unset = UNSET,
invoicing_emails: builtins.list[str] | None = None,
invoicing_entity_id: InvoicingEntityId | None | Unset = UNSET,
invoicing_language: str | None | Unset = UNSET,
is_tax_exempt: bool | None | Unset = UNSET,
Expand Down Expand Up @@ -626,17 +626,17 @@ def create(
self,
*,
currency: Currency | CurrencyLiteral,
custom_taxes: builtins.list[CustomTaxRate],
invoicing_emails: builtins.list[str],
alias: str | None | Unset = UNSET,
billing_address: Address | None | Unset = UNSET,
billing_email: str | None | Unset = UNSET,
buyer_reference: str | None | Unset = UNSET,
connected_account_id: str | None | Unset = UNSET,
custom_properties: t.Any = None,
custom_taxes: builtins.list[CustomTaxRate] | None = None,
customer_type: CustomerType | CustomerTypeLiteral | None = None,
exemption_reason: str | None | Unset = UNSET,
first_name: str | None | Unset = UNSET,
invoicing_emails: builtins.list[str] | None = None,
invoicing_entity_id: InvoicingEntityId | None | Unset = UNSET,
invoicing_language: str | None | Unset = UNSET,
is_tax_exempt: bool | None | Unset = UNSET,
Expand Down
Loading
Loading