This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bf3ae4
commit e03d8b7
Showing
13 changed files
with
451 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
setup( | ||
name='paddle-billing-python-sdk', | ||
version='0.0.1a15', | ||
version='0.0.1a16', | ||
author='Corey Regan', | ||
author_email='[email protected]', | ||
description='A Python wrapper for the Paddle Billing API', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
|
||
from src.Entities.Entity import Entity | ||
|
||
|
||
@dataclass | ||
class NotificationLog(Entity): | ||
id: str | ||
responseCode: int | ||
responseContentType: str | None | ||
responseBody: str | ||
attempted_at: datetime | ||
|
||
|
||
@classmethod | ||
def from_dict(cls, data: dict) -> NotificationLog: | ||
return NotificationLog( | ||
id = data['id'], | ||
responseCode = data['response_code'], | ||
responseContentType = data.get('response_content_type'), | ||
responseBody = data['response_body'], | ||
attempted_at = datetime.fromisoformat(data['attempted_at']), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
|
||
from src.Entities.Entity import Entity | ||
|
||
from src.Entities.Collections.EventTypeCollection import EventTypeCollection | ||
|
||
from src.Entities.NotificationSettings.NotificationSettingType import NotificationSettingType | ||
|
||
|
||
@dataclass | ||
class NotificationSetting(Entity): | ||
id: str | ||
description: str | ||
type: NotificationSettingType | ||
destination: str | ||
active: bool | ||
apiVersion: int | ||
includeSensitiveFields: bool | ||
subscribedEvents: EventTypeCollection | ||
endpointSecretKey: str | ||
|
||
|
||
@classmethod | ||
def from_dict(cls, data: dict) -> NotificationSetting: | ||
return NotificationSetting( | ||
id = data['id'], | ||
description = data['description'], | ||
type = NotificationSettingType(data['type']), | ||
destination = data['destination'], | ||
active = data['active'], | ||
apiVersion = data['api_version'], | ||
includeSensitiveFields = data['include_sensitive_fields'], | ||
subscribedEvents = EventTypeCollection.from_dict(data['subscribed_events']), | ||
endpointSecretKey = data['endpoint_secret_key'], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
|
||
from src.Entities.Entity import Entity | ||
from src.Entities.ProductWithIncludes import ProductWithIncludes | ||
|
||
from src.Entities.Shared.CatalogType import CatalogType | ||
from src.Entities.Shared.CustomData import CustomData | ||
from src.Entities.Shared.Money import Money | ||
from src.Entities.Shared.PriceQuantity import PriceQuantity | ||
from src.Entities.Shared.Status import Status | ||
from src.Entities.Shared.TaxMode import TaxMode | ||
from src.Entities.Shared.TimePeriod import TimePeriod | ||
from src.Entities.Shared.UnitPriceOverride import UnitPriceOverride | ||
|
||
|
||
@dataclass | ||
class PriceWithIncludes(Entity): | ||
id: str | ||
productId: str | ||
name: str | None | ||
description: str | ||
type: CatalogType | None | ||
billingCycle: TimePeriod | None | ||
trialPeriod: TimePeriod | None | ||
taxMode: TaxMode | None | ||
unitPrice: Money | ||
unitPriceOverrides: list[UnitPriceOverride] | ||
quantity: PriceQuantity | ||
status: Status | ||
customData: CustomData | None | ||
product: ProductWithIncludes | None | ||
|
||
|
||
@classmethod | ||
def from_dict(cls, data: dict) -> PriceWithIncludes: | ||
return PriceWithIncludes( | ||
id = data['id'], | ||
productId = data['product_id'], | ||
name = data.get('name'), | ||
description = data['description'], | ||
type = CatalogType(data['type']) if 'type' in data else None, | ||
billingCycle = TimePeriod.from_dict(data['billing_cycle']) if 'billing_cycle' in data else None, | ||
trialPeriod = TimePeriod.from_dict(data['trial_period']) if 'trial_period' in data else None, | ||
taxMode = TaxMode(data['tax_mode']) if 'tax_mode' in data else None, | ||
unitPrice = Money.from_dict(data['unit_price']), | ||
unitPriceOverrides = [UnitPriceOverride.from_dict(override) for override in data.get('unit_price_overrides', [])], | ||
quantity = PriceQuantity.from_dict(data['quantity']), | ||
status = Status(data['status']), | ||
customData = CustomData(data['custom_data']) if 'custom_data' in data else None, | ||
product = ProductWithIncludes.from_dict(data['product']) if 'product' in data else None, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
|
||
from src.Entities.Entity import Entity | ||
|
||
from src.Entities.Reports.ReportFilters import ReportFilters | ||
from src.Entities.Reports.ReportStatus import ReportStatus | ||
from src.Entities.Reports.ReportType import ReportType | ||
|
||
|
||
@dataclass | ||
class Report(Entity): | ||
id: str | ||
status: ReportStatus | ||
rows: int | None | ||
type: ReportType | ||
filters: list[ReportFilters] | ||
expiresAt: datetime | None | ||
createdAt: datetime | ||
updatedAt: datetime | ||
|
||
|
||
@classmethod | ||
def from_dict(cls, data: dict) -> Report: | ||
return Report( | ||
id = data['id'], | ||
status = ReportStatus(data['status']), | ||
rows = data.get('rows'), | ||
type = ReportType(data['type']), | ||
filters = [ReportFilters.from_dict(a_filter) for a_filter in data.get('filters', [])], | ||
expiresAt = datetime.fromisoformat(data['expires_at']) if 'expires_at' in data else None, | ||
createdAt = datetime.fromisoformat(data['created_at']), | ||
updatedAt = datetime.fromisoformat(data['updated_at']), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
|
||
from src.Entities.Entity import Entity | ||
|
||
|
||
@dataclass | ||
class ReportCSV(Entity): | ||
url: str | ||
|
||
@classmethod | ||
def from_dict(cls, data: dict) -> ReportCSV: | ||
return ReportCSV(url=data['url']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
|
||
from src.Entities.Entity import Entity | ||
|
||
from src.Entities.Shared.BillingDetails import BillingDetails | ||
from src.Entities.Shared.CollectionMode import CollectionMode | ||
from src.Entities.Shared.CurrencyCode import CurrencyCode | ||
from src.Entities.Shared.CustomData import CustomData | ||
from src.Entities.Shared.TimePeriod import TimePeriod | ||
from src.Entities.Shared.TransactionDetailsPreview import TransactionDetailsPreview | ||
|
||
from src.Entities.Subscriptions.SubscriptionDiscount import SubscriptionDiscount | ||
from src.Entities.Subscriptions.SubscriptionItem import SubscriptionItem | ||
from src.Entities.Subscriptions.SubscriptionManagementUrls import SubscriptionManagementUrls | ||
from src.Entities.Subscriptions.SubscriptionNextTransaction import SubscriptionNextTransaction | ||
from src.Entities.Subscriptions.SubscriptionPreviewSubscriptionUpdateSummary import SubscriptionPreviewSubscriptionUpdateSummary | ||
from src.Entities.Subscriptions.SubscriptionScheduledChange import SubscriptionScheduledChange | ||
from src.Entities.Subscriptions.SubscriptionStatus import SubscriptionStatus | ||
from src.Entities.Subscriptions.SubscriptionTimePeriod import SubscriptionTimePeriod | ||
|
||
|
||
@dataclass | ||
class SubscriptionPreview(Entity): | ||
status: SubscriptionStatus | ||
customerId: str | ||
addressId: str | ||
businessId: str | None | ||
currencyCode: CurrencyCode | ||
createdAt: datetime | ||
updatedAt: datetime | ||
startedAt: datetime | None | ||
firstBilledAt: datetime | None | ||
nextBilledAt: datetime | None | ||
pausedAt: datetime | None | ||
canceledAt: datetime | None | ||
discount: SubscriptionDiscount | None | ||
collectionMode: CollectionMode | ||
billingDetails: BillingDetails | None | ||
currentBillingPeriod: SubscriptionTimePeriod | None | ||
billingCycle: TimePeriod | ||
scheduledChange: SubscriptionScheduledChange | None | ||
managementUrls: SubscriptionManagementUrls | ||
items: list[SubscriptionItem] | ||
customData: CustomData | None | ||
immediateTransaction: SubscriptionNextTransaction | None | ||
nextTransaction: SubscriptionNextTransaction | None | ||
recurringTransactionDetails: TransactionDetailsPreview | None | ||
updateSummary: SubscriptionPreviewSubscriptionUpdateSummary | None | ||
|
||
|
||
@classmethod | ||
def from_dict(cls, data: dict) -> SubscriptionPreview: | ||
return SubscriptionPreview( | ||
status = SubscriptionStatus(data['status']), | ||
customerId = data['customer_id'], | ||
addressId = data['address_id'], | ||
businessId = data.get('business_id'), | ||
currencyCode = CurrencyCode(data['currency_code']), | ||
createdAt = datetime.fromisoformat(data['created_at']), | ||
updatedAt = datetime.fromisoformat(data['updated_at']), | ||
startedAt = datetime.fromisoformat(data['started_at']) if 'started_at' in data else None, | ||
firstBilledAt = datetime.fromisoformat(data['first_billed_at']) if 'first_billed_at' in data else None, | ||
nextBilledAt = datetime.fromisoformat(data['next_billed_at']) if 'next_billed_at' in data else None, | ||
pausedAt = datetime.fromisoformat(data['paused_at']) if 'paused_at' in data else None, | ||
canceledAt = datetime.fromisoformat(data['canceled_at']) if 'canceled_at' in data else None, | ||
discount = SubscriptionDiscount.from_dict(data['discount']) if 'discount' in data else None, | ||
collectionMode = CollectionMode(data['collection_mode']), | ||
billingDetails = BillingDetails.from_dict(data['billing_details']) if 'billing_details' in data else None, | ||
currentBillingPeriod = SubscriptionTimePeriod.from_dict(data['current_billing_period']) if 'current_billing_period' in data else None, | ||
billingCycle = TimePeriod.from_dict(data['billing_cycle']), | ||
scheduledChange = SubscriptionScheduledChange.from_dict(data['scheduled_change']) if 'scheduled_change' in data else None, | ||
managementUrls = SubscriptionManagementUrls.from_dict(data['management_urls']) if 'management_urls' in data else None, | ||
items = [SubscriptionItem.from_dict(item) for item in data['items']], | ||
customData = CustomData(data['custom_data']) if 'custom_data' in data else None, | ||
immediateTransaction = SubscriptionNextTransaction.from_dict(data['immediate_transaction']) if 'immediate_transaction' in data else None, | ||
nextTransaction = SubscriptionNextTransaction.from_dict(data['next_transaction']) if 'next_transaction' in data else None, | ||
recurringTransactionDetails = TransactionDetailsPreview.from_dict(data['recurring_transaction_details']) if 'recurring_transaction_details' in data else None, | ||
updateSummary = SubscriptionPreviewSubscriptionUpdateSummary.from_dict(data['update_summary']) if 'update_summary' in data else None, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
|
||
from src.Entities.Address import Address | ||
from src.Entities.Business import Business | ||
from src.Entities.Customer import Customer | ||
from src.Entities.Discount import Discount | ||
from src.Entities.Entity import Entity | ||
|
||
from src.Entities.Shared.BillingDetails import BillingDetails | ||
from src.Entities.Shared.Checkout import Checkout | ||
from src.Entities.Shared.CollectionMode import CollectionMode | ||
from src.Entities.Shared.CurrencyCode import CurrencyCode | ||
from src.Entities.Shared.CustomData import CustomData | ||
from src.Entities.Shared.StatusTransaction import StatusTransaction | ||
from src.Entities.Shared.TransactionOrigin import TransactionOrigin | ||
from src.Entities.Shared.TransactionPaymentAttempt import TransactionPaymentAttempt | ||
|
||
from src.Entities.Subscriptions.SubscriptionAdjustment import SubscriptionAdjustment | ||
from src.Entities.Subscriptions.SubscriptionDetails import SubscriptionDetails | ||
from src.Entities.Subscriptions.SubscriptionTimePeriod import SubscriptionTimePeriod | ||
from src.Entities.Subscriptions.SubscriptionTransactionItem import SubscriptionTransactionItem | ||
|
||
|
||
@dataclass | ||
class SubscriptionTransaction(Entity): | ||
id: str | ||
status: StatusTransaction | ||
customerId: str | None | ||
addressId: str | None | ||
businessId: str | None | ||
customData: CustomData | None | ||
currencyCode: CurrencyCode | ||
origin: TransactionOrigin | ||
subscriptionId: str | None | ||
invoiceId: str | None | ||
invoiceNumber: str | None | ||
collectionMode: CollectionMode | ||
discountId: str | None | ||
billingDetails: BillingDetails | None | ||
billingPeriod: SubscriptionTimePeriod | ||
items: list[SubscriptionTransactionItem] | ||
details: SubscriptionDetails | ||
payments: list[TransactionPaymentAttempt] | ||
checkout: Checkout | ||
createdAt: datetime | ||
updatedAt: datetime | ||
billedAt: datetime | None | ||
customer: Customer | ||
address: Address | ||
business: Business | ||
discount: Discount | ||
adjustments: list[SubscriptionAdjustment] | ||
|
||
|
||
@classmethod | ||
def from_dict(cls, data: dict) -> SubscriptionTransaction: | ||
return SubscriptionTransaction( | ||
id = data['id'], | ||
status = StatusTransaction(data['status']), | ||
customerId = data.get('customer_id'), | ||
addressId = data.get('address_id'), | ||
businessId = data.get('business_id'), | ||
customData = CustomData(data['custom_data']) if 'custom_data' in data else None, | ||
currencyCode = CurrencyCode(data['currency_code']), | ||
origin = TransactionOrigin(data['origin']), | ||
subscriptionId = data.get('subscription_id'), | ||
invoiceId = data.get('invoice_id'), | ||
invoiceNumber = data.get('invoice_number'), | ||
collectionMode = CollectionMode(data['collection_mode']), | ||
discountId = data.get('discount_id'), | ||
billingDetails = BillingDetails.from_dict(data['billing_details']) if 'billing_details' in data else None, | ||
billingPeriod = SubscriptionTimePeriod.from_dict(data['billing_period']), | ||
items = [SubscriptionTransactionItem.from_dict(item) for item in data['items']], | ||
details = SubscriptionDetails.from_dict(data['details']), | ||
payments = [TransactionPaymentAttempt.from_dict(payment) for payment in data['payments']], | ||
checkout = Checkout.from_dict(data['checkout']), | ||
createdAt = datetime.fromisoformat(data['created_at']), | ||
updatedAt = datetime.fromisoformat(data['updated_at']), | ||
billedAt = datetime.fromisoformat(data['billed_at']) if 'billed_at' in data else None, | ||
customer = Customer.from_dict(data['customer']), | ||
address = Address.from_dict(data['address']), | ||
business = Business.from_dict(data['business']), | ||
discount = Discount.from_dict(data['discount']), | ||
adjustments = [SubscriptionAdjustment.from_dict(adjustment) for adjustment in data['adjustments']], | ||
) |
Oops, something went wrong.