Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
PricingPreviewsClient.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Invincibear committed Jan 26, 2024
1 parent 89da742 commit 93d4b79
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
4 changes: 2 additions & 2 deletions paddle_billing_python_sdk/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from paddle_billing_python_sdk.Resources.NotificationLogs.NotificationLogsClient import NotificationLogsClient
from paddle_billing_python_sdk.Resources.NotificationSettings.NotificationSettingsClient import NotificationSettingsClient
from paddle_billing_python_sdk.Resources.Prices.PricesClient import PricesClient
# from paddle_billing_python_sdk.Resources.PricingPreviews.PricingPreviewsClient import PricingPreviewsClient
from paddle_billing_python_sdk.Resources.PricingPreviews.PricingPreviewsClient import PricingPreviewsClient
from paddle_billing_python_sdk.Resources.Products.ProductsClient import ProductsClient
# from paddle_billing_python_sdk.Resources.Reports.ReportsClient import ReportsClient
# from paddle_billing_python_sdk.Resources.Subscriptions.SubscriptionsClient import SubscriptionsClient
Expand Down Expand Up @@ -68,7 +68,7 @@ def __init__(
self.notification_logs = NotificationLogsClient(self)
self.notification_settings = NotificationSettingsClient(self)
self.prices = PricesClient(self)
# self.pricing_previews = PricingPreviewsClient(self)
self.pricing_previews = PricingPreviewsClient(self)
self.products = ProductsClient(self)
# self.reports = ReportsClient(self)
# self.subscriptions = SubscriptionsClient(self)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from dataclasses import dataclass, asdict

from paddle_billing_python_sdk.Undefined import Undefined

from paddle_billing_python_sdk.Entities.PricingPreviews.PricePreviewItem import PricePreviewItem
from paddle_billing_python_sdk.Entities.Shared.CurrencyCode import CurrencyCode
from paddle_billing_python_sdk.Entities.Shared.AddressPreview import AddressPreview


@dataclass
class PreviewPrice:
items: list[PricePreviewItem]
customer_id: str | None | Undefined = Undefined()
address_id: str | None | Undefined = Undefined()
business_id: str | None | Undefined = Undefined()
currency_code: CurrencyCode | Undefined = Undefined()
discount_id: str | None | Undefined = Undefined()
address: AddressPreview | None | Undefined = Undefined()
customer_ip_address: str | None | Undefined = Undefined()

def get_parameters(self) -> dict:
return asdict(self)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from typing import TYPE_CHECKING

from paddle_billing_python_sdk.ResponseParser import ResponseParser

from paddle_billing_python_sdk.Entities.PricePreview import PricePreview

from paddle_billing_python_sdk.Resources.PricingPreviews.Operations.PreviewPrice import PreviewPrice


if TYPE_CHECKING:
from paddle_billing_python_sdk.Client import Client


class PricingPreviewsClient:
def __init__(self, client: 'Client'):
self.client = client


def preview_prices(self, operation: PreviewPrice) -> PricePreview:
response = self.client.post_raw('/pricing-preview', operation.get_parameters())
parser = ResponseParser(response)

return PricePreview.from_dict(parser.get_data())
2 changes: 1 addition & 1 deletion paddle_billing_python_sdk/__VERSION__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__VERSION__ = '0.0.1a51'
__VERSION__ = '0.0.1a52'

0 comments on commit 93d4b79

Please sign in to comment.