diff --git a/.sdk.json b/.sdk.json index aece541..022e914 100644 --- a/.sdk.json +++ b/.sdk.json @@ -1,5 +1,5 @@ { - "id": "aab0ca2e-7260-4554-80ac-b7d0498e9626", + "id": "32008b50-ddc2-4a62-a401-51fd86c63158", "tracked_paths": [ { "editable": true, @@ -37,6 +37,18 @@ "editable": true, "path": "magic_hour/resources/v1/account/__init__.py" }, + { + "editable": true, + "path": "magic_hour/resources/v1/account/checkout/README.md" + }, + { + "editable": true, + "path": "magic_hour/resources/v1/account/checkout/__init__.py" + }, + { + "editable": true, + "path": "magic_hour/resources/v1/account/checkout/client.py" + }, { "editable": true, "path": "magic_hour/resources/v1/account/client.py" @@ -517,6 +529,10 @@ "editable": true, "path": "magic_hour/types/models/__init__.py" }, + { + "editable": false, + "path": "magic_hour/types/models/v1_account_checkout_create_response.py" + }, { "editable": false, "path": "magic_hour/types/models/v1_account_list_response.py" @@ -745,6 +761,10 @@ "editable": true, "path": "magic_hour/types/params/__init__.py" }, + { + "editable": false, + "path": "magic_hour/types/params/v1_account_checkout_create_body.py" + }, { "editable": false, "path": "magic_hour/types/params/v1_ai_clothes_changer_create_body.py" @@ -1097,6 +1117,10 @@ "editable": true, "path": "pyproject.toml" }, + { + "editable": false, + "path": "tests/test_v1_account_checkout_client.py" + }, { "editable": false, "path": "tests/test_v1_account_client.py" diff --git a/README.md b/README.md index 6eb5880..ff7df32 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,10 @@ download_urls = result.downloads - [list](magic_hour/resources/v1/account/README.md#list) - Get account details +### [v1.account.checkout](magic_hour/resources/v1/account/checkout/README.md) + +- [create](magic_hour/resources/v1/account/checkout/README.md#create) - Create checkout + ### [v1.ai_clothes_changer](magic_hour/resources/v1/ai_clothes_changer/README.md) - [create](magic_hour/resources/v1/ai_clothes_changer/README.md#create) - AI Clothes Changer diff --git a/magic_hour/README.md b/magic_hour/README.md index 83ed46b..a9be06e 100644 --- a/magic_hour/README.md +++ b/magic_hour/README.md @@ -2,6 +2,7 @@ ## Submodules +- [checkout](resources/v1/account/checkout/README.md) - checkout - [account](resources/v1/account/README.md) - account - [ai_clothes_changer](resources/v1/ai_clothes_changer/README.md) - ai_clothes_changer - [ai_face_editor](resources/v1/ai_face_editor/README.md) - ai_face_editor diff --git a/magic_hour/environment.py b/magic_hour/environment.py index 2e2e496..06dc039 100644 --- a/magic_hour/environment.py +++ b/magic_hour/environment.py @@ -6,7 +6,7 @@ class Environment(enum.Enum): """Pre-defined base URLs for the API""" ENVIRONMENT = "https://api.magichour.ai" - MOCK_SERVER = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.102.0" + MOCK_SERVER = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.103.0" def _get_base_url( diff --git a/magic_hour/resources/v1/account/README.md b/magic_hour/resources/v1/account/README.md index e58851a..ac90e74 100644 --- a/magic_hour/resources/v1/account/README.md +++ b/magic_hour/resources/v1/account/README.md @@ -39,3 +39,7 @@ res = await client.v1.account.list() ```python {"credits": 12500, "email": "user@example.com", "id": "cuid-example", "subscription": {"billing_interval": "month", "cancel_at_period_end": False, "current_period_end": "2026-10-01T00:00:00.000Z", "discount": {"amount_off": 123, "percent_off": 20.0}, "name": "Pro", "price": {"amount": 4900, "currency": "usd"}, "status": "active"}, "tier": "pro"} ``` + +## Submodules + +- [checkout](checkout/README.md) - checkout diff --git a/magic_hour/resources/v1/account/checkout/README.md b/magic_hour/resources/v1/account/checkout/README.md new file mode 100644 index 0000000..9939dd3 --- /dev/null +++ b/magic_hour/resources/v1/account/checkout/README.md @@ -0,0 +1,53 @@ +# v1.account.checkout + +## Module Functions + +### Create checkout + +Create a Stripe Checkout link for the account that owns the API key. Nothing is charged until the checkout is completed in a browser. + +**API Endpoint**: `POST /v1/account/checkout` + +#### Parameters + +| Parameter | Required | Description | Example | +| ------------------ | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | +| `type_` | ✓ | What to buy. `credit_pack` is a one-time credit purchase. | `"credit_pack"` | +| `credit_shortfall` | ✗ | Credits a blocked request is missing, e.g. `credit_shortfall` from a 402 response. The checkout starts with enough packs to cover it. Defaults to one pack. | `150.0` | +| `pack_count` | ✗ | Number of credit packs the checkout starts with. Takes priority over `credit_shortfall`. | `3` | + +#### Synchronous Client + +```python +from magic_hour import Client +from os import getenv + +client = Client(token=getenv("API_TOKEN")) +res = client.v1.account.checkout.create( + type_="credit_pack", credit_shortfall=150.0, pack_count=3 +) +``` + +#### Asynchronous Client + +```python +from magic_hour import AsyncClient +from os import getenv + +client = AsyncClient(token=getenv("API_TOKEN")) +res = await client.v1.account.checkout.create( + type_="credit_pack", credit_shortfall=150.0, pack_count=3 +) +``` + +#### Response + +##### Type + +[V1AccountCheckoutCreateResponse](/magic_hour/types/models/v1_account_checkout_create_response.py) + +##### Example + +```python +{"checkout_url": "https://pay.magichour.ai/c/pay/cs_live_..."} +``` diff --git a/magic_hour/resources/v1/account/checkout/__init__.py b/magic_hour/resources/v1/account/checkout/__init__.py new file mode 100644 index 0000000..1d4e67f --- /dev/null +++ b/magic_hour/resources/v1/account/checkout/__init__.py @@ -0,0 +1,4 @@ +from .client import AsyncCheckoutClient, CheckoutClient + + +__all__ = ["AsyncCheckoutClient", "CheckoutClient"] diff --git a/magic_hour/resources/v1/account/checkout/client.py b/magic_hour/resources/v1/account/checkout/client.py new file mode 100644 index 0000000..079b89f --- /dev/null +++ b/magic_hour/resources/v1/account/checkout/client.py @@ -0,0 +1,134 @@ +import typing +import typing_extensions + +from magic_hour.types import models, params +from make_api_request import ( + AsyncBaseClient, + RequestOptions, + SyncBaseClient, + default_request_options, + to_encodable, + type_utils, +) + + +class CheckoutClient: + def __init__(self, *, base_client: SyncBaseClient): + self._base_client = base_client + + def create( + self, + *, + type_: typing_extensions.Literal["credit_pack"], + credit_shortfall: typing.Union[ + typing.Optional[float], type_utils.NotGiven + ] = type_utils.NOT_GIVEN, + pack_count: typing.Union[ + typing.Optional[int], type_utils.NotGiven + ] = type_utils.NOT_GIVEN, + request_options: typing.Optional[RequestOptions] = None, + ) -> models.V1AccountCheckoutCreateResponse: + """ + Create checkout + + Create a Stripe Checkout link for the account that owns the API key. Nothing is charged until the checkout is completed in a browser. + + POST /v1/account/checkout + + Args: + credit_shortfall: Credits a blocked request is missing, e.g. `credit_shortfall` from a 402 response. The checkout starts with enough packs to cover it. Defaults to one pack. + pack_count: Number of credit packs the checkout starts with. Takes priority over `credit_shortfall`. + type_: What to buy. `credit_pack` is a one-time credit purchase. + request_options: Additional options to customize the HTTP request + + Returns: + 200 + + Raises: + ApiError: A custom exception class that provides additional context + for API errors, including the HTTP status code and response body. + + Examples: + ```py + client.v1.account.checkout.create( + type_="credit_pack", credit_shortfall=150.0, pack_count=3 + ) + ``` + """ + _json = to_encodable( + item={ + "credit_shortfall": credit_shortfall, + "pack_count": pack_count, + "type_": type_, + }, + dump_with=params._SerializerV1AccountCheckoutCreateBody, + ) + return self._base_client.request( + method="POST", + path="/v1/account/checkout", + auth_names=["bearerAuth"], + json=_json, + cast_to=models.V1AccountCheckoutCreateResponse, + request_options=request_options or default_request_options(), + ) + + +class AsyncCheckoutClient: + def __init__(self, *, base_client: AsyncBaseClient): + self._base_client = base_client + + async def create( + self, + *, + type_: typing_extensions.Literal["credit_pack"], + credit_shortfall: typing.Union[ + typing.Optional[float], type_utils.NotGiven + ] = type_utils.NOT_GIVEN, + pack_count: typing.Union[ + typing.Optional[int], type_utils.NotGiven + ] = type_utils.NOT_GIVEN, + request_options: typing.Optional[RequestOptions] = None, + ) -> models.V1AccountCheckoutCreateResponse: + """ + Create checkout + + Create a Stripe Checkout link for the account that owns the API key. Nothing is charged until the checkout is completed in a browser. + + POST /v1/account/checkout + + Args: + credit_shortfall: Credits a blocked request is missing, e.g. `credit_shortfall` from a 402 response. The checkout starts with enough packs to cover it. Defaults to one pack. + pack_count: Number of credit packs the checkout starts with. Takes priority over `credit_shortfall`. + type_: What to buy. `credit_pack` is a one-time credit purchase. + request_options: Additional options to customize the HTTP request + + Returns: + 200 + + Raises: + ApiError: A custom exception class that provides additional context + for API errors, including the HTTP status code and response body. + + Examples: + ```py + await client.v1.account.checkout.create( + type_="credit_pack", credit_shortfall=150.0, pack_count=3 + ) + ``` + """ + _json = to_encodable( + item={ + "credit_shortfall": credit_shortfall, + "pack_count": pack_count, + "type_": type_, + }, + dump_with=params._SerializerV1AccountCheckoutCreateBody, + ) + return await self._base_client.request( + method="POST", + path="/v1/account/checkout", + auth_names=["bearerAuth"], + json=_json, + cast_to=models.V1AccountCheckoutCreateResponse, + request_options=request_options or default_request_options(), + ) diff --git a/magic_hour/resources/v1/account/client.py b/magic_hour/resources/v1/account/client.py index 9546fc2..dec07fe 100644 --- a/magic_hour/resources/v1/account/client.py +++ b/magic_hour/resources/v1/account/client.py @@ -1,5 +1,6 @@ import typing +from magic_hour.resources.v1.account.checkout import AsyncCheckoutClient, CheckoutClient from magic_hour.types import models from make_api_request import ( AsyncBaseClient, @@ -12,6 +13,7 @@ class AccountClient: def __init__(self, *, base_client: SyncBaseClient): self._base_client = base_client + self.checkout = CheckoutClient(base_client=self._base_client) def list( self, *, request_options: typing.Optional[RequestOptions] = None @@ -50,6 +52,7 @@ def list( class AsyncAccountClient: def __init__(self, *, base_client: AsyncBaseClient): self._base_client = base_client + self.checkout = AsyncCheckoutClient(base_client=self._base_client) async def list( self, *, request_options: typing.Optional[RequestOptions] = None diff --git a/magic_hour/resources/v1/image_to_video/README.md b/magic_hour/resources/v1/image_to_video/README.md index b50d39d..a68d43b 100644 --- a/magic_hour/resources/v1/image_to_video/README.md +++ b/magic_hour/resources/v1/image_to_video/README.md @@ -107,7 +107,7 @@ For detailed examples, see the [product page](https://magichour.ai/products/imag | Parameter | Required | Deprecated | Description | Example | | ------------------------ | :------: | :--------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | | `assets` | ✓ | ✗ | Provide the assets for image-to-video. | `{"end_image_file_path": "api-assets/id/1234.png", "image_file_path": "api-assets/id/1234.png"}` | -| `└─ end_image_file_path` | ✗ | — | The image to use as the last frame of the video. * **`gemini-omni-1.2`**: Supports 360p, 720p, 1080p, 4k. Requires a duration of 10 seconds or less. * **`kling-2.6`**: Supports 1080p. * **`kling-3.0`**: Supports 720p, 1080p, 4k. * **`kling-4.0`**: Supports 720p, 1080p. * **`ltx-2.5`**: Supports 480p, 720p, 1080p. * **`minimax-h3`**: Supports 480p, 720p, 1080p. * **`seedance-1.5`**: Supports 480p, 720p, 1080p. * **`seedance-2.0`**: Supports 480p, 720p, 1080p, 4k. * **`seedance-2.0-fast`**: Supports 480p, 720p. * **`seedance-2.0-mini`**: Supports 480p, 720p. * **`seedance-2.5`**: Supports 480p, 720p, 1080p, 4k. * **`veo3.1`**: Supports 720p, 1080p. Requires a duration of 8 seconds or less. * **`veo3.1-lite`**: Supports 720p, 1080p. Requires a duration of 8 seconds or less. * **`wan-2.2`**: Not supported * **`wan-3.0`**: Supports 480p, 720p, 1080p. This value is either - a direct URL to the file. The URL path must end in a supported file extension. - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. | `"api-assets/id/1234.png"` | +| `└─ end_image_file_path` | ✗ | — | The image to use as the last frame of the video. * **`gemini-omni-1.2`**: Supports 360p, 720p, 1080p, 4k. Requires a duration of 10 seconds or less. * **`kling-2.6`**: Supports 1080p. * **`kling-3.0`**: Supports 720p, 1080p, 4k. * **`kling-4.0`**: Supports 720p, 1080p. * **`ltx-2.5`**: Supports 480p, 720p, 1080p. * **`minimax-h3`**: Supports 480p, 720p, 1080p. * **`seedance-1.5`**: Supports 480p, 720p, 1080p. * **`seedance-2.0`**: Supports 480p, 720p, 1080p, 4k. * **`seedance-2.0-fast`**: Supports 480p, 720p. * **`seedance-2.0-mini`**: Not supported * **`seedance-2.5`**: Supports 480p, 720p, 1080p, 4k. * **`veo3.1`**: Supports 720p, 1080p. Requires a duration of 8 seconds or less. * **`veo3.1-lite`**: Supports 720p, 1080p. Requires a duration of 8 seconds or less. * **`wan-2.2`**: Not supported * **`wan-3.0`**: Supports 480p, 720p, 1080p. This value is either - a direct URL to the file. The URL path must end in a supported file extension. - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. | `"api-assets/id/1234.png"` | | `└─ image_file_path` | ✓ | — | The path of the image file. This value is either - a direct URL to the file. The URL path must end in a supported file extension. - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. | `"api-assets/id/1234.png"` | | `end_seconds` | ✓ | ✗ | The total duration of the output video in seconds. Supported durations depend on the chosen model: * **`gemini-omni-1.2`**: any integer from 3 to 15 * **`kling-2.6`**: 5, 10 * **`kling-3.0`**: any integer from 3 to 15 * **`kling-4.0`**: any integer from 3 to 30 * **`ltx-2.5`**: any integer from 1 to 60 * **`minimax-h3`**: any integer from 1 to 30 * **`seedance-1.5`**: any integer from 4 to 12 * **`seedance-2.0`**: any integer from 4 to 15 * **`seedance-2.0-fast`**: any integer from 4 to 15 * **`seedance-2.0-mini`**: any integer from 4 to 15 * **`seedance-2.5`**: any integer from 4 to 30 * **`veo3.1`**: 4, 6, 8, 16, 24, 32, 40, 48, 56 * **`veo3.1-lite`**: 4, 6, 8, 16, 24, 32, 40, 48, 56 * **`wan-2.2`**: 3, 4, 5, 6, 7, 8, 9, 10, 15 * **`wan-3.0`**: any integer from 2 to 30 | `5.0` | | `audio` | ✗ | ✗ | Whether to include audio in the video. Defaults to `false` if not specified. Audio support varies by model: * **`gemini-omni-1.2`**: Toggle-able: no additional credits for audio * **`kling-2.6`**: Not supported * **`kling-3.0`**: Toggle-able: audio adds extra credits when enabled * **`kling-4.0`**: Toggle-able: no additional credits for audio * **`ltx-2.5`**: Toggle-able: no additional credits for audio * **`minimax-h3`**: Toggle-able: no additional credits for audio * **`seedance-1.5`**: Toggle-able: audio adds extra credits when enabled * **`seedance-2.0`**: Toggle-able: no additional credits for audio * **`seedance-2.0-fast`**: Toggle-able: no additional credits for audio * **`seedance-2.0-mini`**: Toggle-able: no additional credits for audio * **`seedance-2.5`**: Toggle-able: no additional credits for audio * **`veo3.1`**: Toggle-able: audio adds extra credits when enabled * **`veo3.1-lite`**: Toggle-able: audio adds extra credits when enabled * **`wan-2.2`**: Not supported * **`wan-3.0`**: Toggle-able: no additional credits for audio | `True` | diff --git a/magic_hour/types/models/__init__.py b/magic_hour/types/models/__init__.py index 5f50dc0..b8767ef 100644 --- a/magic_hour/types/models/__init__.py +++ b/magic_hour/types/models/__init__.py @@ -1,3 +1,4 @@ +from .v1_account_checkout_create_response import V1AccountCheckoutCreateResponse from .v1_account_list_response import V1AccountListResponse from .v1_account_list_response_subscription import V1AccountListResponseSubscription from .v1_account_list_response_subscription_discount import ( @@ -79,6 +80,7 @@ __all__ = [ + "V1AccountCheckoutCreateResponse", "V1AccountListResponse", "V1AccountListResponseSubscription", "V1AccountListResponseSubscriptionDiscount", diff --git a/magic_hour/types/models/v1_account_checkout_create_response.py b/magic_hour/types/models/v1_account_checkout_create_response.py new file mode 100644 index 0000000..eefc6ce --- /dev/null +++ b/magic_hour/types/models/v1_account_checkout_create_response.py @@ -0,0 +1,19 @@ +import pydantic + + +class V1AccountCheckoutCreateResponse(pydantic.BaseModel): + """ + V1AccountCheckoutCreateResponse + """ + + model_config = pydantic.ConfigDict( + arbitrary_types_allowed=True, + populate_by_name=True, + ) + + checkout_url: str = pydantic.Field( + alias="checkout_url", + ) + """ + Open in a browser to complete the purchase. + """ diff --git a/magic_hour/types/params/__init__.py b/magic_hour/types/params/__init__.py index 6e77ea2..85a021d 100644 --- a/magic_hour/types/params/__init__.py +++ b/magic_hour/types/params/__init__.py @@ -1,3 +1,7 @@ +from .v1_account_checkout_create_body import ( + V1AccountCheckoutCreateBody, + _SerializerV1AccountCheckoutCreateBody, +) from .v1_ai_clothes_changer_create_body import ( V1AiClothesChangerCreateBody, _SerializerV1AiClothesChangerCreateBody, @@ -393,6 +397,7 @@ __all__ = [ + "V1AccountCheckoutCreateBody", "V1AiClothesChangerCreateBody", "V1AiClothesChangerCreateBodyAssets", "V1AiClothesChangerGenerateBodyAssets", @@ -507,6 +512,7 @@ "V1VideoToVideoCreateBodyAssets", "V1VideoToVideoCreateBodyStyle", "V1VideoToVideoGenerateBodyAssets", + "_SerializerV1AccountCheckoutCreateBody", "_SerializerV1AiClothesChangerCreateBody", "_SerializerV1AiClothesChangerCreateBodyAssets", "_SerializerV1AiFaceEditorCreateBody", diff --git a/magic_hour/types/params/v1_account_checkout_create_body.py b/magic_hour/types/params/v1_account_checkout_create_body.py new file mode 100644 index 0000000..91b0591 --- /dev/null +++ b/magic_hour/types/params/v1_account_checkout_create_body.py @@ -0,0 +1,43 @@ +import pydantic +import typing +import typing_extensions + + +class V1AccountCheckoutCreateBody(typing_extensions.TypedDict): + """ + V1AccountCheckoutCreateBody + """ + + credit_shortfall: typing_extensions.NotRequired[float] + """ + Credits a blocked request is missing, e.g. `credit_shortfall` from a 402 response. The checkout starts with enough packs to cover it. Defaults to one pack. + """ + + pack_count: typing_extensions.NotRequired[int] + """ + Number of credit packs the checkout starts with. Takes priority over `credit_shortfall`. + """ + + type_: typing_extensions.Required[typing_extensions.Literal["credit_pack"]] + """ + What to buy. `credit_pack` is a one-time credit purchase. + """ + + +class _SerializerV1AccountCheckoutCreateBody(pydantic.BaseModel): + """ + Serializer for V1AccountCheckoutCreateBody handling case conversions + and file omissions as dictated by the API + """ + + model_config = pydantic.ConfigDict( + populate_by_name=True, + ) + + credit_shortfall: typing.Optional[float] = pydantic.Field( + alias="credit_shortfall", default=None + ) + pack_count: typing.Optional[int] = pydantic.Field(alias="pack_count", default=None) + type_: typing_extensions.Literal["credit_pack"] = pydantic.Field( + alias="type", + ) diff --git a/magic_hour/types/params/v1_image_to_video_create_body_assets.py b/magic_hour/types/params/v1_image_to_video_create_body_assets.py index 4786709..0fb8770 100644 --- a/magic_hour/types/params/v1_image_to_video_create_body_assets.py +++ b/magic_hour/types/params/v1_image_to_video_create_body_assets.py @@ -21,7 +21,7 @@ class V1ImageToVideoCreateBodyAssets(typing_extensions.TypedDict): * **`seedance-1.5`**: Supports 480p, 720p, 1080p. * **`seedance-2.0`**: Supports 480p, 720p, 1080p, 4k. * **`seedance-2.0-fast`**: Supports 480p, 720p. - * **`seedance-2.0-mini`**: Supports 480p, 720p. + * **`seedance-2.0-mini`**: Not supported * **`seedance-2.5`**: Supports 480p, 720p, 1080p, 4k. * **`veo3.1`**: Supports 720p, 1080p. Requires a duration of 8 seconds or less. * **`veo3.1-lite`**: Supports 720p, 1080p. Requires a duration of 8 seconds or less. diff --git a/pyproject.toml b/pyproject.toml index d997b79..a98da6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "magic_hour" -version = "0.101.1" +version = "0.102.0" description = "Python SDK for Magic Hour API" readme = "README.md" authors = ["Magic Hour "] diff --git a/tests/test_v1_account_checkout_client.py b/tests/test_v1_account_checkout_client.py new file mode 100644 index 0000000..364d281 --- /dev/null +++ b/tests/test_v1_account_checkout_client.py @@ -0,0 +1,73 @@ +import pydantic +import pytest + +from magic_hour import AsyncClient, Client +from magic_hour.environment import Environment +from magic_hour.types import models + + +def test_create_200_success_all_params() -> None: + """Tests a POST request to the /v1/account/checkout endpoint. + + Operation: create + Test Case ID: success_all_params + Expected Status: 200 + Mode: Synchronous execution + + Response : models.V1AccountCheckoutCreateResponse + + Validates: + - Authentication requirements are satisfied + - All required input parameters are properly handled + - Response status code is correct + - Response data matches expected schema + + This test uses example data to verify the endpoint behavior. + """ + # tests calling sync method with example data + client = Client(token="API_TOKEN", environment=Environment.MOCK_SERVER) + response = client.v1.account.checkout.create( + type_="credit_pack", credit_shortfall=150.0, pack_count=3 + ) + try: + pydantic.TypeAdapter(models.V1AccountCheckoutCreateResponse).validate_python( + response + ) + is_valid_response_schema = True + except pydantic.ValidationError: + is_valid_response_schema = False + assert is_valid_response_schema, "failed response type check" + + +@pytest.mark.asyncio +async def test_await_create_200_success_all_params() -> None: + """Tests a POST request to the /v1/account/checkout endpoint. + + Operation: create + Test Case ID: success_all_params + Expected Status: 200 + Mode: Asynchronous execution + + Response : models.V1AccountCheckoutCreateResponse + + Validates: + - Authentication requirements are satisfied + - All required input parameters are properly handled + - Response status code is correct + - Response data matches expected schema + + This test uses example data to verify the endpoint behavior. + """ + # tests calling async method with example data + client = AsyncClient(token="API_TOKEN", environment=Environment.MOCK_SERVER) + response = await client.v1.account.checkout.create( + type_="credit_pack", credit_shortfall=150.0, pack_count=3 + ) + try: + pydantic.TypeAdapter(models.V1AccountCheckoutCreateResponse).validate_python( + response + ) + is_valid_response_schema = True + except pydantic.ValidationError: + is_valid_response_schema = False + assert is_valid_response_schema, "failed response type check"