"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from .basesdk import BaseSDK
from flexprice_py import errors, models, utils
from flexprice_py._hooks import HookContext
from flexprice_py.types import OptionalNullable, UNSET
from flexprice_py.utils.unmarshal_json_response import unmarshal_json_response
from typing import Any, Dict, List, Mapping, Optional, Union


class Prices(BaseSDK):
    def create_price(
        self,
        *,
        billing_cadence: models.components.BillingCadence,
        billing_model: models.components.BillingModel,
        billing_period: models.components.BillingPeriod,
        currency: str,
        entity_id: str,
        entity_type: models.components.PriceEntityType,
        invoice_cadence: models.components.InvoiceCadence,
        price_unit_type: models.components.PriceUnitType,
        type_: models.components.PriceType,
        amount: Optional[str] = None,
        billing_period_count: Optional[int] = None,
        description: Optional[str] = None,
        display_name: Optional[str] = None,
        end_date: Optional[str] = None,
        filter_values: Optional[Dict[str, List[str]]] = None,
        group_id: Optional[str] = None,
        lookup_key: Optional[str] = None,
        metadata: Optional[Dict[str, str]] = None,
        meter_id: Optional[str] = None,
        min_quantity: Optional[int] = None,
        price_unit_config: Optional[
            Union[
                models.components.DtoPriceUnitConfig,
                models.components.DtoPriceUnitConfigTypedDict,
            ]
        ] = None,
        start_date: Optional[str] = None,
        tier_mode: Optional[models.components.BillingTier] = None,
        tiers: Optional[
            Union[
                List[models.components.DtoCreatePriceTier],
                List[models.components.DtoCreatePriceTierTypedDict],
            ]
        ] = None,
        transform_quantity: Optional[
            Union[
                models.components.PriceTransformQuantity,
                models.components.PriceTransformQuantityTypedDict,
            ]
        ] = None,
        trial_period: Optional[int] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoPriceResponse:
        r"""Create price

        Use when adding a new price to a plan or catalog (e.g. per-seat, flat, or metered). Ideal for both simple and usage-based pricing.

        :param billing_cadence:
        :param billing_model:
        :param billing_period:
        :param currency:
        :param entity_id:
        :param entity_type:
        :param invoice_cadence:
        :param price_unit_type:
        :param type:
        :param amount:
        :param billing_period_count:
        :param description:
        :param display_name:
        :param end_date:
        :param filter_values:
        :param group_id: GroupID is the id of the group to add the price to
        :param lookup_key:
        :param metadata:
        :param meter_id:
        :param min_quantity: MinQuantity is the minimum quantity of the price
        :param price_unit_config:
        :param start_date:
        :param tier_mode:
        :param tiers:
        :param transform_quantity:
        :param trial_period:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.components.DtoCreatePriceRequest(
            amount=amount,
            billing_cadence=billing_cadence,
            billing_model=billing_model,
            billing_period=billing_period,
            billing_period_count=billing_period_count,
            currency=currency,
            description=description,
            display_name=display_name,
            end_date=end_date,
            entity_id=entity_id,
            entity_type=entity_type,
            filter_values=filter_values,
            group_id=group_id,
            invoice_cadence=invoice_cadence,
            lookup_key=lookup_key,
            metadata=metadata,
            meter_id=meter_id,
            min_quantity=min_quantity,
            price_unit_config=utils.get_pydantic_model(
                price_unit_config, Optional[models.components.DtoPriceUnitConfig]
            ),
            price_unit_type=price_unit_type,
            start_date=start_date,
            tier_mode=tier_mode,
            tiers=utils.get_pydantic_model(
                tiers, Optional[List[models.components.DtoCreatePriceTier]]
            ),
            transform_quantity=utils.get_pydantic_model(
                transform_quantity, Optional[models.components.PriceTransformQuantity]
            ),
            trial_period=trial_period,
            type=type_,
        )

        req = self._build_request(
            method="POST",
            path="/prices",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request, False, False, "json", models.components.DtoCreatePriceRequest
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="createPrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "201", "application/json"):
            return unmarshal_json_response(models.components.DtoPriceResponse, http_res)
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    async def create_price_async(
        self,
        *,
        billing_cadence: models.components.BillingCadence,
        billing_model: models.components.BillingModel,
        billing_period: models.components.BillingPeriod,
        currency: str,
        entity_id: str,
        entity_type: models.components.PriceEntityType,
        invoice_cadence: models.components.InvoiceCadence,
        price_unit_type: models.components.PriceUnitType,
        type_: models.components.PriceType,
        amount: Optional[str] = None,
        billing_period_count: Optional[int] = None,
        description: Optional[str] = None,
        display_name: Optional[str] = None,
        end_date: Optional[str] = None,
        filter_values: Optional[Dict[str, List[str]]] = None,
        group_id: Optional[str] = None,
        lookup_key: Optional[str] = None,
        metadata: Optional[Dict[str, str]] = None,
        meter_id: Optional[str] = None,
        min_quantity: Optional[int] = None,
        price_unit_config: Optional[
            Union[
                models.components.DtoPriceUnitConfig,
                models.components.DtoPriceUnitConfigTypedDict,
            ]
        ] = None,
        start_date: Optional[str] = None,
        tier_mode: Optional[models.components.BillingTier] = None,
        tiers: Optional[
            Union[
                List[models.components.DtoCreatePriceTier],
                List[models.components.DtoCreatePriceTierTypedDict],
            ]
        ] = None,
        transform_quantity: Optional[
            Union[
                models.components.PriceTransformQuantity,
                models.components.PriceTransformQuantityTypedDict,
            ]
        ] = None,
        trial_period: Optional[int] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoPriceResponse:
        r"""Create price

        Use when adding a new price to a plan or catalog (e.g. per-seat, flat, or metered). Ideal for both simple and usage-based pricing.

        :param billing_cadence:
        :param billing_model:
        :param billing_period:
        :param currency:
        :param entity_id:
        :param entity_type:
        :param invoice_cadence:
        :param price_unit_type:
        :param type:
        :param amount:
        :param billing_period_count:
        :param description:
        :param display_name:
        :param end_date:
        :param filter_values:
        :param group_id: GroupID is the id of the group to add the price to
        :param lookup_key:
        :param metadata:
        :param meter_id:
        :param min_quantity: MinQuantity is the minimum quantity of the price
        :param price_unit_config:
        :param start_date:
        :param tier_mode:
        :param tiers:
        :param transform_quantity:
        :param trial_period:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.components.DtoCreatePriceRequest(
            amount=amount,
            billing_cadence=billing_cadence,
            billing_model=billing_model,
            billing_period=billing_period,
            billing_period_count=billing_period_count,
            currency=currency,
            description=description,
            display_name=display_name,
            end_date=end_date,
            entity_id=entity_id,
            entity_type=entity_type,
            filter_values=filter_values,
            group_id=group_id,
            invoice_cadence=invoice_cadence,
            lookup_key=lookup_key,
            metadata=metadata,
            meter_id=meter_id,
            min_quantity=min_quantity,
            price_unit_config=utils.get_pydantic_model(
                price_unit_config, Optional[models.components.DtoPriceUnitConfig]
            ),
            price_unit_type=price_unit_type,
            start_date=start_date,
            tier_mode=tier_mode,
            tiers=utils.get_pydantic_model(
                tiers, Optional[List[models.components.DtoCreatePriceTier]]
            ),
            transform_quantity=utils.get_pydantic_model(
                transform_quantity, Optional[models.components.PriceTransformQuantity]
            ),
            trial_period=trial_period,
            type=type_,
        )

        req = self._build_request_async(
            method="POST",
            path="/prices",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request, False, False, "json", models.components.DtoCreatePriceRequest
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="createPrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "201", "application/json"):
            return unmarshal_json_response(models.components.DtoPriceResponse, http_res)
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    def create_prices_bulk(
        self,
        *,
        items: Union[
            List[models.components.DtoCreatePriceRequest],
            List[models.components.DtoCreatePriceRequestTypedDict],
        ],
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoCreateBulkPriceResponse:
        r"""Create prices in bulk

        Use when creating many prices at once (e.g. importing a catalog or setting up a plan with multiple tiers).

        :param items:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.components.DtoCreateBulkPriceRequest(
            items=utils.get_pydantic_model(
                items, List[models.components.DtoCreatePriceRequest]
            ),
        )

        req = self._build_request(
            method="POST",
            path="/prices/bulk",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request,
                False,
                False,
                "json",
                models.components.DtoCreateBulkPriceRequest,
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="createPricesBulk",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "201", "application/json"):
            return unmarshal_json_response(
                models.components.DtoCreateBulkPriceResponse, http_res
            )
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    async def create_prices_bulk_async(
        self,
        *,
        items: Union[
            List[models.components.DtoCreatePriceRequest],
            List[models.components.DtoCreatePriceRequestTypedDict],
        ],
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoCreateBulkPriceResponse:
        r"""Create prices in bulk

        Use when creating many prices at once (e.g. importing a catalog or setting up a plan with multiple tiers).

        :param items:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.components.DtoCreateBulkPriceRequest(
            items=utils.get_pydantic_model(
                items, List[models.components.DtoCreatePriceRequest]
            ),
        )

        req = self._build_request_async(
            method="POST",
            path="/prices/bulk",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request,
                False,
                False,
                "json",
                models.components.DtoCreateBulkPriceRequest,
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="createPricesBulk",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "201", "application/json"):
            return unmarshal_json_response(
                models.components.DtoCreateBulkPriceResponse, http_res
            )
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    def get_price_by_lookup_key(
        self,
        *,
        lookup_key: str,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoPriceResponse:
        r"""Get price by lookup key

        Use when resolving a price by external id (e.g. from your catalog or CMS). Ideal for integrations.

        :param lookup_key: Lookup key
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.operations.GetPriceByLookupKeyRequest(
            lookup_key=lookup_key,
        )

        req = self._build_request(
            method="GET",
            path="/prices/lookup/{lookup_key}",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=True,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="getPriceByLookupKey",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(models.components.DtoPriceResponse, http_res)
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    async def get_price_by_lookup_key_async(
        self,
        *,
        lookup_key: str,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoPriceResponse:
        r"""Get price by lookup key

        Use when resolving a price by external id (e.g. from your catalog or CMS). Ideal for integrations.

        :param lookup_key: Lookup key
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.operations.GetPriceByLookupKeyRequest(
            lookup_key=lookup_key,
        )

        req = self._build_request_async(
            method="GET",
            path="/prices/lookup/{lookup_key}",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=True,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="getPriceByLookupKey",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(models.components.DtoPriceResponse, http_res)
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    def query_price(
        self,
        *,
        allow_expired_prices: Optional[bool] = False,
        end_time: Optional[str] = None,
        entity_ids: Optional[List[str]] = None,
        entity_type: Optional[models.components.PriceEntityType] = None,
        expand: Optional[str] = None,
        filters: Optional[
            Union[
                List[models.components.FilterCondition],
                List[models.components.FilterConditionTypedDict],
            ]
        ] = None,
        limit: Optional[int] = None,
        meter_ids: Optional[List[str]] = None,
        offset: Optional[int] = None,
        order: Optional[models.components.PriceFilterOrder] = None,
        parent_price_id: Optional[str] = None,
        plan_ids: Optional[List[str]] = None,
        price_ids: Optional[List[str]] = None,
        sort: Optional[str] = None,
        start_date_lt: Optional[str] = None,
        start_time: Optional[str] = None,
        status: Optional[models.components.Status] = None,
        subscription_id: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoListPricesResponse:
        r"""Query prices

        Use when listing or searching prices (e.g. plan builder or catalog). Returns a paginated list; supports filtering and sorting.

        :param allow_expired_prices:
        :param end_time:
        :param entity_ids:
        :param entity_type:
        :param expand:
        :param filters: DSL filters
        :param limit:
        :param meter_ids:
        :param offset:
        :param order:
        :param parent_price_id:
        :param plan_ids: Price override filtering fields
        :param price_ids:
        :param sort:
        :param start_date_lt:
        :param start_time:
        :param status:
        :param subscription_id:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.components.PriceFilter(
            allow_expired_prices=allow_expired_prices,
            end_time=end_time,
            entity_ids=entity_ids,
            entity_type=entity_type,
            expand=expand,
            filters=utils.get_pydantic_model(
                filters, Optional[List[models.components.FilterCondition]]
            ),
            limit=limit,
            meter_ids=meter_ids,
            offset=offset,
            order=order,
            parent_price_id=parent_price_id,
            plan_ids=plan_ids,
            price_ids=price_ids,
            sort=sort,
            start_date_lt=start_date_lt,
            start_time=start_time,
            status=status,
            subscription_id=subscription_id,
        )

        req = self._build_request(
            method="POST",
            path="/prices/search",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request, False, False, "json", models.components.PriceFilter
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="queryPrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(
                models.components.DtoListPricesResponse, http_res
            )
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    async def query_price_async(
        self,
        *,
        allow_expired_prices: Optional[bool] = False,
        end_time: Optional[str] = None,
        entity_ids: Optional[List[str]] = None,
        entity_type: Optional[models.components.PriceEntityType] = None,
        expand: Optional[str] = None,
        filters: Optional[
            Union[
                List[models.components.FilterCondition],
                List[models.components.FilterConditionTypedDict],
            ]
        ] = None,
        limit: Optional[int] = None,
        meter_ids: Optional[List[str]] = None,
        offset: Optional[int] = None,
        order: Optional[models.components.PriceFilterOrder] = None,
        parent_price_id: Optional[str] = None,
        plan_ids: Optional[List[str]] = None,
        price_ids: Optional[List[str]] = None,
        sort: Optional[str] = None,
        start_date_lt: Optional[str] = None,
        start_time: Optional[str] = None,
        status: Optional[models.components.Status] = None,
        subscription_id: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoListPricesResponse:
        r"""Query prices

        Use when listing or searching prices (e.g. plan builder or catalog). Returns a paginated list; supports filtering and sorting.

        :param allow_expired_prices:
        :param end_time:
        :param entity_ids:
        :param entity_type:
        :param expand:
        :param filters: DSL filters
        :param limit:
        :param meter_ids:
        :param offset:
        :param order:
        :param parent_price_id:
        :param plan_ids: Price override filtering fields
        :param price_ids:
        :param sort:
        :param start_date_lt:
        :param start_time:
        :param status:
        :param subscription_id:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.components.PriceFilter(
            allow_expired_prices=allow_expired_prices,
            end_time=end_time,
            entity_ids=entity_ids,
            entity_type=entity_type,
            expand=expand,
            filters=utils.get_pydantic_model(
                filters, Optional[List[models.components.FilterCondition]]
            ),
            limit=limit,
            meter_ids=meter_ids,
            offset=offset,
            order=order,
            parent_price_id=parent_price_id,
            plan_ids=plan_ids,
            price_ids=price_ids,
            sort=sort,
            start_date_lt=start_date_lt,
            start_time=start_time,
            status=status,
            subscription_id=subscription_id,
        )

        req = self._build_request_async(
            method="POST",
            path="/prices/search",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request, False, False, "json", models.components.PriceFilter
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="queryPrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(
                models.components.DtoListPricesResponse, http_res
            )
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    def get_price(
        self,
        *,
        id: str,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoPriceResponse:
        r"""Get price

        Use when you need to load a single price (e.g. for display or editing). Response includes expanded meter and price unit when applicable.

        :param id: Price ID
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.operations.GetPriceRequest(
            id=id,
        )

        req = self._build_request(
            method="GET",
            path="/prices/{id}",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=True,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="getPrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(models.components.DtoPriceResponse, http_res)
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    async def get_price_async(
        self,
        *,
        id: str,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoPriceResponse:
        r"""Get price

        Use when you need to load a single price (e.g. for display or editing). Response includes expanded meter and price unit when applicable.

        :param id: Price ID
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.operations.GetPriceRequest(
            id=id,
        )

        req = self._build_request_async(
            method="GET",
            path="/prices/{id}",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=True,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="getPrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(models.components.DtoPriceResponse, http_res)
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    def update_price(
        self,
        *,
        id: str,
        amount: Optional[str] = None,
        billing_model: Optional[models.components.BillingModel] = None,
        description: Optional[str] = None,
        display_name: Optional[str] = None,
        effective_from: Optional[str] = None,
        group_id: Optional[str] = None,
        lookup_key: Optional[str] = None,
        metadata: Optional[Dict[str, str]] = None,
        price_unit_amount: Optional[str] = None,
        price_unit_tiers: Optional[
            Union[
                List[models.components.DtoCreatePriceTier],
                List[models.components.DtoCreatePriceTierTypedDict],
            ]
        ] = None,
        tier_mode: Optional[models.components.BillingTier] = None,
        tiers: Optional[
            Union[
                List[models.components.DtoCreatePriceTier],
                List[models.components.DtoCreatePriceTierTypedDict],
            ]
        ] = None,
        transform_quantity: Optional[
            Union[
                models.components.PriceTransformQuantity,
                models.components.PriceTransformQuantityTypedDict,
            ]
        ] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoPriceResponse:
        r"""Update price

        Use when changing price configuration (e.g. amount, billing scheme, or metadata).

        :param id: Price ID
        :param amount: Amount is the new price amount that overrides the original price (optional)
        :param billing_model:
        :param description:
        :param display_name:
        :param effective_from:
        :param group_id: GroupID is the id of the group to update the price in
        :param lookup_key: All price fields that can be updated
            Non-critical fields (can be updated directly)
        :param metadata:
        :param price_unit_amount: PriceUnitAmount is the price unit amount (for CUSTOM price unit type, FLAT_FEE/PACKAGE billing models)
        :param price_unit_tiers: PriceUnitTiers are the price unit tiers (for CUSTOM price unit type, TIERED billing model)
        :param tier_mode:
        :param tiers: Tiers determines the pricing tiers for this line item
        :param transform_quantity:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.operations.UpdatePriceRequest(
            id=id,
            body=models.components.DtoUpdatePriceRequest(
                amount=amount,
                billing_model=billing_model,
                description=description,
                display_name=display_name,
                effective_from=effective_from,
                group_id=group_id,
                lookup_key=lookup_key,
                metadata=metadata,
                price_unit_amount=price_unit_amount,
                price_unit_tiers=utils.get_pydantic_model(
                    price_unit_tiers,
                    Optional[List[models.components.DtoCreatePriceTier]],
                ),
                tier_mode=tier_mode,
                tiers=utils.get_pydantic_model(
                    tiers, Optional[List[models.components.DtoCreatePriceTier]]
                ),
                transform_quantity=utils.get_pydantic_model(
                    transform_quantity,
                    Optional[models.components.PriceTransformQuantity],
                ),
            ),
        )

        req = self._build_request(
            method="PUT",
            path="/prices/{id}",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=True,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.body,
                False,
                False,
                "json",
                models.components.DtoUpdatePriceRequest,
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="updatePrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(models.components.DtoPriceResponse, http_res)
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    async def update_price_async(
        self,
        *,
        id: str,
        amount: Optional[str] = None,
        billing_model: Optional[models.components.BillingModel] = None,
        description: Optional[str] = None,
        display_name: Optional[str] = None,
        effective_from: Optional[str] = None,
        group_id: Optional[str] = None,
        lookup_key: Optional[str] = None,
        metadata: Optional[Dict[str, str]] = None,
        price_unit_amount: Optional[str] = None,
        price_unit_tiers: Optional[
            Union[
                List[models.components.DtoCreatePriceTier],
                List[models.components.DtoCreatePriceTierTypedDict],
            ]
        ] = None,
        tier_mode: Optional[models.components.BillingTier] = None,
        tiers: Optional[
            Union[
                List[models.components.DtoCreatePriceTier],
                List[models.components.DtoCreatePriceTierTypedDict],
            ]
        ] = None,
        transform_quantity: Optional[
            Union[
                models.components.PriceTransformQuantity,
                models.components.PriceTransformQuantityTypedDict,
            ]
        ] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoPriceResponse:
        r"""Update price

        Use when changing price configuration (e.g. amount, billing scheme, or metadata).

        :param id: Price ID
        :param amount: Amount is the new price amount that overrides the original price (optional)
        :param billing_model:
        :param description:
        :param display_name:
        :param effective_from:
        :param group_id: GroupID is the id of the group to update the price in
        :param lookup_key: All price fields that can be updated
            Non-critical fields (can be updated directly)
        :param metadata:
        :param price_unit_amount: PriceUnitAmount is the price unit amount (for CUSTOM price unit type, FLAT_FEE/PACKAGE billing models)
        :param price_unit_tiers: PriceUnitTiers are the price unit tiers (for CUSTOM price unit type, TIERED billing model)
        :param tier_mode:
        :param tiers: Tiers determines the pricing tiers for this line item
        :param transform_quantity:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.operations.UpdatePriceRequest(
            id=id,
            body=models.components.DtoUpdatePriceRequest(
                amount=amount,
                billing_model=billing_model,
                description=description,
                display_name=display_name,
                effective_from=effective_from,
                group_id=group_id,
                lookup_key=lookup_key,
                metadata=metadata,
                price_unit_amount=price_unit_amount,
                price_unit_tiers=utils.get_pydantic_model(
                    price_unit_tiers,
                    Optional[List[models.components.DtoCreatePriceTier]],
                ),
                tier_mode=tier_mode,
                tiers=utils.get_pydantic_model(
                    tiers, Optional[List[models.components.DtoCreatePriceTier]]
                ),
                transform_quantity=utils.get_pydantic_model(
                    transform_quantity,
                    Optional[models.components.PriceTransformQuantity],
                ),
            ),
        )

        req = self._build_request_async(
            method="PUT",
            path="/prices/{id}",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=True,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.body,
                False,
                False,
                "json",
                models.components.DtoUpdatePriceRequest,
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="updatePrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(models.components.DtoPriceResponse, http_res)
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    def delete_price(
        self,
        *,
        id: str,
        end_date: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoSuccessResponse:
        r"""Delete price

        Use when retiring a price (e.g. end-of-life or replacement). Optional effective date or cascade for subscriptions.

        :param id: Price ID
        :param end_date:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.operations.DeletePriceRequest(
            id=id,
            body=models.components.DtoDeletePriceRequest(
                end_date=end_date,
            ),
        )

        req = self._build_request(
            method="DELETE",
            path="/prices/{id}",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=True,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.body,
                False,
                False,
                "json",
                models.components.DtoDeletePriceRequest,
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="deletePrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(
                models.components.DtoSuccessResponse, http_res
            )
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)

    async def delete_price_async(
        self,
        *,
        id: str,
        end_date: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.components.DtoSuccessResponse:
        r"""Delete price

        Use when retiring a price (e.g. end-of-life or replacement). Optional effective date or cascade for subscriptions.

        :param id: Price ID
        :param end_date:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.operations.DeletePriceRequest(
            id=id,
            body=models.components.DtoDeletePriceRequest(
                end_date=end_date,
            ),
        )

        req = self._build_request_async(
            method="DELETE",
            path="/prices/{id}",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=True,
            request_has_path_params=True,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value="application/json",
            http_headers=http_headers,
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.body,
                False,
                False,
                "json",
                models.components.DtoDeletePriceRequest,
            ),
            allow_empty_value=None,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["429", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="deletePrice",
                oauth2_scopes=None,
                security_source=self.sdk_configuration.security,
            ),
            request=req,
            error_status_codes=["400", "4XX", "500", "5XX"],
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            return unmarshal_json_response(
                models.components.DtoSuccessResponse, http_res
            )
        if utils.match_response(http_res, "400", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "500", "application/json"):
            response_data = unmarshal_json_response(
                errors.ErrorsErrorResponseData, http_res
            )
            raise errors.ErrorsErrorResponse(response_data, http_res)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise errors.FlexpriceDefaultError(
                "API error occurred", http_res, http_res_text
            )

        raise errors.FlexpriceDefaultError("Unexpected response received", http_res)
