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
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 136
configured_endpoints: 137
10 changes: 8 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,21 @@ Methods:
Types:

```python
from dodopayments.types import Brand, BrandListResponse, BrandUpdateImagesResponse
from dodopayments.types import (
Brand,
BrandListResponse,
BrandArchiveResponse,
BrandUpdateImagesResponse,
)
```

Methods:

- <code title="post /brands">client.brands.<a href="./src/dodopayments/resources/brands.py">create</a>(\*\*<a href="src/dodopayments/types/brand_create_params.py">params</a>) -> <a href="./src/dodopayments/types/brand.py">Brand</a></code>
- <code title="get /brands/{id}">client.brands.<a href="./src/dodopayments/resources/brands.py">retrieve</a>(id) -> <a href="./src/dodopayments/types/brand.py">Brand</a></code>
- <code title="patch /brands/{id}">client.brands.<a href="./src/dodopayments/resources/brands.py">update</a>(id, \*\*<a href="src/dodopayments/types/brand_update_params.py">params</a>) -> <a href="./src/dodopayments/types/brand.py">Brand</a></code>
- <code title="get /brands">client.brands.<a href="./src/dodopayments/resources/brands.py">list</a>() -> <a href="./src/dodopayments/types/brand_list_response.py">BrandListResponse</a></code>
- <code title="get /brands">client.brands.<a href="./src/dodopayments/resources/brands.py">list</a>(\*\*<a href="src/dodopayments/types/brand_list_params.py">params</a>) -> <a href="./src/dodopayments/types/brand_list_response.py">BrandListResponse</a></code>
- <code title="post /brands/{id}/archive">client.brands.<a href="./src/dodopayments/resources/brands.py">archive</a>(id, \*\*<a href="src/dodopayments/types/brand_archive_params.py">params</a>) -> <a href="./src/dodopayments/types/brand_archive_response.py">BrandArchiveResponse</a></code>
- <code title="put /brands/{id}/images">client.brands.<a href="./src/dodopayments/resources/brands.py">update_images</a>(id) -> <a href="./src/dodopayments/types/brand_update_images_response.py">BrandUpdateImagesResponse</a></code>

# Webhooks
Expand Down
2 changes: 1 addition & 1 deletion scripts/mock

Large diffs are not rendered by default.

143 changes: 140 additions & 3 deletions src/dodopayments/resources/brands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import httpx

from ..types import brand_create_params, brand_update_params
from ..types import brand_list_params, brand_create_params, brand_update_params, brand_archive_params
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from .._utils import path_template, maybe_transform, async_maybe_transform
from .._compat import cached_property
Expand All @@ -20,6 +20,7 @@
from ..types.brand import Brand
from .._base_client import make_request_options
from ..types.brand_list_response import BrandListResponse
from ..types.brand_archive_response import BrandArchiveResponse
from ..types.brand_update_images_response import BrandUpdateImagesResponse

__all__ = ["BrandsResource", "AsyncBrandsResource"]
Expand Down Expand Up @@ -174,21 +175,81 @@ def update(
def list(
self,
*,
include_archived: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> BrandListResponse:
"""Args:
include_archived: Set to true to also list archived brands.

Default false.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get(
"/brands",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"include_archived": include_archived}, brand_list_params.BrandListParams),
),
cast_to=BrandListResponse,
)

def archive(
self,
id: str,
*,
move_products_to: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> BrandArchiveResponse:
"""Archive a brand.

Its products, live subscriptions, and product collections move
to the `move_products_to` brand. Archive is permanent.

Args:
move_products_to: Brand that takes over the products and the live subscriptions of the brand you
archive. It must be a brand of the same business, and it must not be archived.
The primary brand (its brand id is the business id) is a valid target. Omit this
field only when the brand holds no products and no live subscriptions.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return self._post(
path_template("/brands/{id}/archive", id=id),
body=maybe_transform({"move_products_to": move_products_to}, brand_archive_params.BrandArchiveParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=BrandArchiveResponse,
)

def update_images(
self,
id: str,
Expand Down Expand Up @@ -370,21 +431,85 @@ async def update(
async def list(
self,
*,
include_archived: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> BrandListResponse:
"""Args:
include_archived: Set to true to also list archived brands.

Default false.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._get(
"/brands",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{"include_archived": include_archived}, brand_list_params.BrandListParams
),
),
cast_to=BrandListResponse,
)

async def archive(
self,
id: str,
*,
move_products_to: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> BrandArchiveResponse:
"""Archive a brand.

Its products, live subscriptions, and product collections move
to the `move_products_to` brand. Archive is permanent.

Args:
move_products_to: Brand that takes over the products and the live subscriptions of the brand you
archive. It must be a brand of the same business, and it must not be archived.
The primary brand (its brand id is the business id) is a valid target. Omit this
field only when the brand holds no products and no live subscriptions.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return await self._post(
path_template("/brands/{id}/archive", id=id),
body=await async_maybe_transform(
{"move_products_to": move_products_to}, brand_archive_params.BrandArchiveParams
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=BrandArchiveResponse,
)

async def update_images(
self,
id: str,
Expand Down Expand Up @@ -433,6 +558,9 @@ def __init__(self, brands: BrandsResource) -> None:
self.list = to_raw_response_wrapper(
brands.list,
)
self.archive = to_raw_response_wrapper(
brands.archive,
)
self.update_images = to_raw_response_wrapper(
brands.update_images,
)
Expand All @@ -454,6 +582,9 @@ def __init__(self, brands: AsyncBrandsResource) -> None:
self.list = async_to_raw_response_wrapper(
brands.list,
)
self.archive = async_to_raw_response_wrapper(
brands.archive,
)
self.update_images = async_to_raw_response_wrapper(
brands.update_images,
)
Expand All @@ -475,6 +606,9 @@ def __init__(self, brands: BrandsResource) -> None:
self.list = to_streamed_response_wrapper(
brands.list,
)
self.archive = to_streamed_response_wrapper(
brands.archive,
)
self.update_images = to_streamed_response_wrapper(
brands.update_images,
)
Expand All @@ -496,6 +630,9 @@ def __init__(self, brands: AsyncBrandsResource) -> None:
self.list = async_to_streamed_response_wrapper(
brands.list,
)
self.archive = async_to_streamed_response_wrapper(
brands.archive,
)
self.update_images = async_to_streamed_response_wrapper(
brands.update_images,
)
3 changes: 3 additions & 0 deletions src/dodopayments/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from .webhook_details import WebhookDetails as WebhookDetails
from .refund_list_item import RefundListItem as RefundListItem
from .addon_list_params import AddonListParams as AddonListParams
from .brand_list_params import BrandListParams as BrandListParams
from .event_input_param import EventInputParam as EventInputParam
from .filter_type_param import FilterTypeParam as FilterTypeParam
from .github_permission import GitHubPermission as GitHubPermission
Expand Down Expand Up @@ -71,6 +72,7 @@
from .subscription_status import SubscriptionStatus as SubscriptionStatus
from .webhook_list_params import WebhookListParams as WebhookListParams
from .balance_ledger_entry import BalanceLedgerEntry as BalanceLedgerEntry
from .brand_archive_params import BrandArchiveParams as BrandArchiveParams
from .cbb_overage_behavior import CbbOverageBehavior as CbbOverageBehavior
from .customer_list_params import CustomerListParams as CustomerListParams
from .discount_list_params import DiscountListParams as DiscountListParams
Expand All @@ -93,6 +95,7 @@
from .scheduled_plan_change import ScheduledPlanChange as ScheduledPlanChange
from .webhook_create_params import WebhookCreateParams as WebhookCreateParams
from .webhook_update_params import WebhookUpdateParams as WebhookUpdateParams
from .brand_archive_response import BrandArchiveResponse as BrandArchiveResponse
from .cbb_proration_behavior import CbbProrationBehavior as CbbProrationBehavior
from .customer_create_params import CustomerCreateParams as CustomerCreateParams
from .customer_request_param import CustomerRequestParam as CustomerRequestParam
Expand Down
4 changes: 4 additions & 0 deletions src/dodopayments/types/brand.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from datetime import datetime
from typing_extensions import Literal

from .._models import BaseModel
Expand All @@ -21,6 +22,9 @@ class Brand(BaseModel):

verification_status: Literal["Success", "Fail", "Review", "Hold"]

archived_at: Optional[datetime] = None
"""Time the brand was archived. Null for an active brand."""

description: Optional[str] = None

image: Optional[str] = None
Expand Down
18 changes: 18 additions & 0 deletions src/dodopayments/types/brand_archive_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Optional
from typing_extensions import TypedDict

__all__ = ["BrandArchiveParams"]


class BrandArchiveParams(TypedDict, total=False):
move_products_to: Optional[str]
"""
Brand that takes over the products and the live subscriptions of the brand you
archive. It must be a brand of the same business, and it must not be archived.
The primary brand (its brand id is the business id) is a valid target. Omit this
field only when the brand holds no products and no live subscriptions.
"""
28 changes: 28 additions & 0 deletions src/dodopayments/types/brand_archive_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from datetime import datetime

from .._models import BaseModel

__all__ = ["BrandArchiveResponse"]


class BrandArchiveResponse(BaseModel):
archived_at: datetime
"""Time the brand was archived."""

brand_id: str
"""The archived brand."""

collections_moved: int
"""Count of product collections moved to the target brand."""

products_moved: int
"""Count of products moved to the target brand."""

subscriptions_moved: int
"""Count of live subscriptions moved to the target brand."""

moved_to_brand_id: Optional[str] = None
"""Brand that received the moved records. Null when no target was given."""
12 changes: 12 additions & 0 deletions src/dodopayments/types/brand_list_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing_extensions import TypedDict

__all__ = ["BrandListParams"]


class BrandListParams(TypedDict, total=False):
include_archived: bool
"""Set to true to also list archived brands. Default false."""
9 changes: 9 additions & 0 deletions src/dodopayments/types/checkout_session_flags_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,12 @@ class CheckoutSessionFlagsParam(TypedDict, total=False):

Default is false
"""

single_page: bool
"""
If true, the session uses the single-page checkout flow: the page initializes
the payment at load time and confirms it in place, with no separate payment
page.

Default is false
"""
Loading
Loading