paddle-python-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- examples/__init__.py +0 -0
- examples/catalog_management.py +166 -0
- examples/event_polling.py +56 -0
- examples/get_products.py +46 -0
- examples/logger.py +31 -0
- paddle_billing/Client.py +201 -0
- paddle_billing/ConditionallyRemoveImportMeta.py +14 -0
- paddle_billing/Entities/Address.py +44 -0
- paddle_billing/Entities/Adjustment.py +45 -0
- paddle_billing/Entities/Adjustments/AdjustmentCustomerBalance.py +18 -0
- paddle_billing/Entities/Adjustments/AdjustmentItem.py +26 -0
- paddle_billing/Entities/Adjustments/__init__.py +2 -0
- paddle_billing/Entities/Business.py +38 -0
- paddle_billing/Entities/Collections/AddressCollection.py +18 -0
- paddle_billing/Entities/Collections/AdjustmentCollection.py +18 -0
- paddle_billing/Entities/Collections/BusinessCollection.py +18 -0
- paddle_billing/Entities/Collections/Collection.py +47 -0
- paddle_billing/Entities/Collections/CreditBalanceCollection.py +18 -0
- paddle_billing/Entities/Collections/CustomerCollection.py +18 -0
- paddle_billing/Entities/Collections/DiscountCollection.py +18 -0
- paddle_billing/Entities/Collections/EventCollection.py +18 -0
- paddle_billing/Entities/Collections/EventTypeCollection.py +18 -0
- paddle_billing/Entities/Collections/NotificationCollection.py +18 -0
- paddle_billing/Entities/Collections/NotificationLogCollection.py +18 -0
- paddle_billing/Entities/Collections/NotificationSettingCollection.py +18 -0
- paddle_billing/Entities/Collections/Paginator.py +29 -0
- paddle_billing/Entities/Collections/PriceCollection.py +18 -0
- paddle_billing/Entities/Collections/ProductCollection.py +18 -0
- paddle_billing/Entities/Collections/ReportCollection.py +18 -0
- paddle_billing/Entities/Collections/SubscriptionCollection.py +18 -0
- paddle_billing/Entities/Collections/SubscriptionPreviewCollection.py +18 -0
- paddle_billing/Entities/Collections/TransactionCollection.py +18 -0
- paddle_billing/Entities/Collections/TransactionPreviewCollection.py +18 -0
- paddle_billing/Entities/Collections/TransactionsDataCollection.py +18 -0
- paddle_billing/Entities/Collections/__init__.py +21 -0
- paddle_billing/Entities/CreditBalance.py +22 -0
- paddle_billing/Entities/Customer.py +36 -0
- paddle_billing/Entities/DateTime.py +43 -0
- paddle_billing/Entities/Discount.py +51 -0
- paddle_billing/Entities/Discounts/DiscountStatus.py +8 -0
- paddle_billing/Entities/Discounts/DiscountType.py +7 -0
- paddle_billing/Entities/Discounts/__init__.py +2 -0
- paddle_billing/Entities/Entity.py +12 -0
- paddle_billing/Entities/Event.py +51 -0
- paddle_billing/Entities/EventType.py +23 -0
- paddle_billing/Entities/Events/EventTypeName.py +52 -0
- paddle_billing/Entities/Events/__init__.py +1 -0
- paddle_billing/Entities/Notification.py +42 -0
- paddle_billing/Entities/NotificationLog.py +25 -0
- paddle_billing/Entities/NotificationSetting.py +34 -0
- paddle_billing/Entities/NotificationSettings/NotificationSettingType.py +6 -0
- paddle_billing/Entities/NotificationSettings/__init__.py +1 -0
- paddle_billing/Entities/Notifications/NotificationOrigin.py +6 -0
- paddle_billing/Entities/Notifications/NotificationPayout.py +24 -0
- paddle_billing/Entities/Notifications/NotificationPayoutStatus.py +6 -0
- paddle_billing/Entities/Notifications/NotificationStatus.py +8 -0
- paddle_billing/Entities/Notifications/__init__.py +4 -0
- paddle_billing/Entities/Price.py +68 -0
- paddle_billing/Entities/PricePreview.py +34 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewDetails.py +15 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewDiscounts.py +20 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewItem.py +16 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewLineItem.py +38 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewTotalsFormatted.py +20 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewUnitTotalsFormatted.py +20 -0
- paddle_billing/Entities/PricingPreviews/__init__.py +6 -0
- paddle_billing/Entities/Product.py +45 -0
- paddle_billing/Entities/Report.py +32 -0
- paddle_billing/Entities/ReportCSV.py +13 -0
- paddle_billing/Entities/Reports/ReportFilter.py +20 -0
- paddle_billing/Entities/Reports/ReportFilterName.py +17 -0
- paddle_billing/Entities/Reports/ReportFilterOperator.py +6 -0
- paddle_billing/Entities/Reports/ReportStatus.py +8 -0
- paddle_billing/Entities/Reports/ReportType.py +10 -0
- paddle_billing/Entities/Reports/__init__.py +5 -0
- paddle_billing/Entities/Shared/Action.py +10 -0
- paddle_billing/Entities/Shared/AddressPreview.py +18 -0
- paddle_billing/Entities/Shared/AdjustmentItemTotals.py +18 -0
- paddle_billing/Entities/Shared/AdjustmentProration.py +18 -0
- paddle_billing/Entities/Shared/AdjustmentStatus.py +8 -0
- paddle_billing/Entities/Shared/AdjustmentTimePeriod.py +17 -0
- paddle_billing/Entities/Shared/AdjustmentTotals.py +26 -0
- paddle_billing/Entities/Shared/AdjustmentType.py +8 -0
- paddle_billing/Entities/Shared/AvailablePaymentMethods.py +11 -0
- paddle_billing/Entities/Shared/BillingDetails.py +22 -0
- paddle_billing/Entities/Shared/BillingDetailsUpdate.py +22 -0
- paddle_billing/Entities/Shared/Card.py +24 -0
- paddle_billing/Entities/Shared/CatalogType.py +6 -0
- paddle_billing/Entities/Shared/ChargebackFee.py +18 -0
- paddle_billing/Entities/Shared/Checkout.py +12 -0
- paddle_billing/Entities/Shared/CollectionMode.py +6 -0
- paddle_billing/Entities/Shared/Contacts.py +16 -0
- paddle_billing/Entities/Shared/CountryCode.py +233 -0
- paddle_billing/Entities/Shared/CurrencyCode.py +34 -0
- paddle_billing/Entities/Shared/CurrencyCodeAdjustments.py +7 -0
- paddle_billing/Entities/Shared/CurrencyCodePayouts.py +17 -0
- paddle_billing/Entities/Shared/CustomData.py +10 -0
- paddle_billing/Entities/Shared/Data.py +9 -0
- paddle_billing/Entities/Shared/ErrorCode.py +21 -0
- paddle_billing/Entities/Shared/ImportMeta.py +16 -0
- paddle_billing/Entities/Shared/Interval.py +8 -0
- paddle_billing/Entities/Shared/Meta.py +7 -0
- paddle_billing/Entities/Shared/MetaPaginated.py +18 -0
- paddle_billing/Entities/Shared/MethodDetails.py +19 -0
- paddle_billing/Entities/Shared/Money.py +28 -0
- paddle_billing/Entities/Shared/Original.py +18 -0
- paddle_billing/Entities/Shared/Pagination.py +20 -0
- paddle_billing/Entities/Shared/PaymentAttemptStatus.py +13 -0
- paddle_billing/Entities/Shared/PaymentMethodType.py +14 -0
- paddle_billing/Entities/Shared/PayoutTotalsAdjustment.py +29 -0
- paddle_billing/Entities/Shared/PriceQuantity.py +16 -0
- paddle_billing/Entities/Shared/Status.py +6 -0
- paddle_billing/Entities/Shared/TaxCategory.py +13 -0
- paddle_billing/Entities/Shared/TaxMode.py +7 -0
- paddle_billing/Entities/Shared/TaxRatesUsed.py +18 -0
- paddle_billing/Entities/Shared/TimePeriod.py +18 -0
- paddle_billing/Entities/Shared/Totals.py +20 -0
- paddle_billing/Entities/Shared/TransactionDetailsPreview.py +22 -0
- paddle_billing/Entities/Shared/TransactionLineItemPreview.py +28 -0
- paddle_billing/Entities/Shared/TransactionOrigin.py +10 -0
- paddle_billing/Entities/Shared/TransactionPaymentAttempt.py +35 -0
- paddle_billing/Entities/Shared/TransactionPayoutTotals.py +36 -0
- paddle_billing/Entities/Shared/TransactionPayoutTotalsAdjusted.py +29 -0
- paddle_billing/Entities/Shared/TransactionStatus.py +11 -0
- paddle_billing/Entities/Shared/TransactionTotals.py +36 -0
- paddle_billing/Entities/Shared/TransactionTotalsAdjusted.py +28 -0
- paddle_billing/Entities/Shared/UnitPriceOverride.py +19 -0
- paddle_billing/Entities/Shared/UnitTotals.py +20 -0
- paddle_billing/Entities/Shared/__init__.py +56 -0
- paddle_billing/Entities/Subscription.py +86 -0
- paddle_billing/Entities/SubscriptionPreview.py +79 -0
- paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentItem.py +24 -0
- paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentPreview.py +22 -0
- paddle_billing/Entities/Subscriptions/SubscriptionCharge.py +18 -0
- paddle_billing/Entities/Subscriptions/SubscriptionCredit.py +18 -0
- paddle_billing/Entities/Subscriptions/SubscriptionDetails.py +34 -0
- paddle_billing/Entities/Subscriptions/SubscriptionDiscount.py +19 -0
- paddle_billing/Entities/Subscriptions/SubscriptionEffectiveFrom.py +6 -0
- paddle_billing/Entities/Subscriptions/SubscriptionItem.py +35 -0
- paddle_billing/Entities/Subscriptions/SubscriptionItemStatus.py +7 -0
- paddle_billing/Entities/Subscriptions/SubscriptionItems.py +20 -0
- paddle_billing/Entities/Subscriptions/SubscriptionItemsWithPrice.py +19 -0
- paddle_billing/Entities/Subscriptions/SubscriptionManagementUrls.py +16 -0
- paddle_billing/Entities/Subscriptions/SubscriptionNextTransaction.py +23 -0
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogPrice.py +30 -0
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogPriceWithProduct.py +32 -0
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogProduct.py +26 -0
- paddle_billing/Entities/Subscriptions/SubscriptionOnPaymentFailure.py +6 -0
- paddle_billing/Entities/Subscriptions/SubscriptionPreviewSubscriptionUpdateSummary.py +22 -0
- paddle_billing/Entities/Subscriptions/SubscriptionPrice.py +28 -0
- paddle_billing/Entities/Subscriptions/SubscriptionProration.py +18 -0
- paddle_billing/Entities/Subscriptions/SubscriptionProrationBillingMode.py +9 -0
- paddle_billing/Entities/Subscriptions/SubscriptionResult.py +22 -0
- paddle_billing/Entities/Subscriptions/SubscriptionResultAction.py +6 -0
- paddle_billing/Entities/Subscriptions/SubscriptionResumeEffectiveFrom.py +5 -0
- paddle_billing/Entities/Subscriptions/SubscriptionScheduledChange.py +21 -0
- paddle_billing/Entities/Subscriptions/SubscriptionScheduledChangeAction.py +7 -0
- paddle_billing/Entities/Subscriptions/SubscriptionStatus.py +10 -0
- paddle_billing/Entities/Subscriptions/SubscriptionTimePeriod.py +17 -0
- paddle_billing/Entities/Subscriptions/SubscriptionTransactionItem.py +23 -0
- paddle_billing/Entities/Subscriptions/SubscriptionTransactionLineItem.py +33 -0
- paddle_billing/Entities/Subscriptions/SubscriptionUpdateItem.py +16 -0
- paddle_billing/Entities/Subscriptions/__init__.py +31 -0
- paddle_billing/Entities/Transaction.py +98 -0
- paddle_billing/Entities/TransactionData.py +15 -0
- paddle_billing/Entities/TransactionPreview.py +40 -0
- paddle_billing/Entities/Transactions/TransactionAdjustmentsTotals.py +30 -0
- paddle_billing/Entities/Transactions/TransactionBreakdown.py +18 -0
- paddle_billing/Entities/Transactions/TransactionCardType.py +14 -0
- paddle_billing/Entities/Transactions/TransactionCreateItem.py +16 -0
- paddle_billing/Entities/Transactions/TransactionCreateItemWithPrice.py +11 -0
- paddle_billing/Entities/Transactions/TransactionDetails.py +32 -0
- paddle_billing/Entities/Transactions/TransactionItem.py +24 -0
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithNonCatalogPrice.py +21 -0
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithPrice.py +24 -0
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithPriceId.py +18 -0
- paddle_billing/Entities/Transactions/TransactionLineItem.py +35 -0
- paddle_billing/Entities/Transactions/TransactionNonCatalogPrice.py +39 -0
- paddle_billing/Entities/Transactions/TransactionNonCatalogPriceWithProduct.py +41 -0
- paddle_billing/Entities/Transactions/TransactionNonCatalogProduct.py +25 -0
- paddle_billing/Entities/Transactions/TransactionProration.py +18 -0
- paddle_billing/Entities/Transactions/TransactionTimePeriod.py +17 -0
- paddle_billing/Entities/Transactions/TransactionUpdateTransactionItem.py +8 -0
- paddle_billing/Entities/Transactions/__init__.py +20 -0
- paddle_billing/Entities/__init__.py +0 -0
- paddle_billing/EnumStringify.py +2 -0
- paddle_billing/Environment.py +14 -0
- paddle_billing/Exceptions/ApiError.py +28 -0
- paddle_billing/Exceptions/ApiErrors/AddressApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/AdjustmentApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/BusinessApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/CustomerApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/DiscountApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/PriceApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/ProductApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/SubscriptionApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/TransactionApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/__init__.py +0 -0
- paddle_billing/Exceptions/FieldError.py +8 -0
- paddle_billing/Exceptions/SdkException.py +2 -0
- paddle_billing/Exceptions/SdkExceptions/InvalidArgumentException.py +8 -0
- paddle_billing/Exceptions/SdkExceptions/MalformedResponse.py +7 -0
- paddle_billing/Exceptions/SdkExceptions/__init__.py +0 -0
- paddle_billing/Exceptions/__init__.py +0 -0
- paddle_billing/FiltersNone.py +8 -0
- paddle_billing/FiltersUndefined.py +11 -0
- paddle_billing/HasParameters.py +11 -0
- paddle_billing/Logger/Formatter.py +18 -0
- paddle_billing/Logger/NullHandler.py +6 -0
- paddle_billing/Logger/__init__.py +30 -0
- paddle_billing/Notifications/Entities/Address.py +44 -0
- paddle_billing/Notifications/Entities/Adjustment.py +45 -0
- paddle_billing/Notifications/Entities/Adjustments/AdjustmentItem.py +26 -0
- paddle_billing/Notifications/Entities/Adjustments/__init__.py +1 -0
- paddle_billing/Notifications/Entities/Business.py +39 -0
- paddle_billing/Notifications/Entities/Businesses/BusinessesContacts.py +16 -0
- paddle_billing/Notifications/Entities/Businesses/__init__.py +1 -0
- paddle_billing/Notifications/Entities/Customer.py +36 -0
- paddle_billing/Notifications/Entities/DateTime.py +43 -0
- paddle_billing/Notifications/Entities/Discount.py +51 -0
- paddle_billing/Notifications/Entities/Discounts/DiscountStatus.py +8 -0
- paddle_billing/Notifications/Entities/Discounts/DiscountType.py +7 -0
- paddle_billing/Notifications/Entities/Discounts/__init__.py +2 -0
- paddle_billing/Notifications/Entities/Entity.py +12 -0
- paddle_billing/Notifications/Entities/Payout.py +24 -0
- paddle_billing/Notifications/Entities/Payouts/PayoutStatus.py +6 -0
- paddle_billing/Notifications/Entities/Payouts/__init__.py +1 -0
- paddle_billing/Notifications/Entities/Price.py +66 -0
- paddle_billing/Notifications/Entities/Product.py +45 -0
- paddle_billing/Notifications/Entities/Report.py +32 -0
- paddle_billing/Notifications/Entities/Reports/ReportFilter.py +20 -0
- paddle_billing/Notifications/Entities/Reports/ReportFilterName.py +17 -0
- paddle_billing/Notifications/Entities/Reports/ReportFilterOperator.py +6 -0
- paddle_billing/Notifications/Entities/Reports/ReportStatus.py +8 -0
- paddle_billing/Notifications/Entities/Reports/ReportType.py +10 -0
- paddle_billing/Notifications/Entities/Reports/__init__.py +5 -0
- paddle_billing/Notifications/Entities/Shared/Action.py +10 -0
- paddle_billing/Notifications/Entities/Shared/AddressPreview.py +18 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentItemTotals.py +18 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentProration.py +18 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentStatus.py +8 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentTimePeriod.py +17 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentTotals.py +26 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentType.py +8 -0
- paddle_billing/Notifications/Entities/Shared/AvailablePaymentMethods.py +11 -0
- paddle_billing/Notifications/Entities/Shared/BillingDetails.py +22 -0
- paddle_billing/Notifications/Entities/Shared/Card.py +24 -0
- paddle_billing/Notifications/Entities/Shared/CatalogType.py +6 -0
- paddle_billing/Notifications/Entities/Shared/ChargebackFee.py +18 -0
- paddle_billing/Notifications/Entities/Shared/Checkout.py +12 -0
- paddle_billing/Notifications/Entities/Shared/CollectionMode.py +6 -0
- paddle_billing/Notifications/Entities/Shared/CountryCode.py +233 -0
- paddle_billing/Notifications/Entities/Shared/CurrencyCode.py +34 -0
- paddle_billing/Notifications/Entities/Shared/CurrencyCodeAdjustments.py +7 -0
- paddle_billing/Notifications/Entities/Shared/CurrencyCodePayouts.py +17 -0
- paddle_billing/Notifications/Entities/Shared/CustomData.py +10 -0
- paddle_billing/Notifications/Entities/Shared/Data.py +9 -0
- paddle_billing/Notifications/Entities/Shared/ErrorCode.py +21 -0
- paddle_billing/Notifications/Entities/Shared/ImportMeta.py +16 -0
- paddle_billing/Notifications/Entities/Shared/Interval.py +8 -0
- paddle_billing/Notifications/Entities/Shared/MethodDetails.py +19 -0
- paddle_billing/Notifications/Entities/Shared/Money.py +28 -0
- paddle_billing/Notifications/Entities/Shared/Original.py +18 -0
- paddle_billing/Notifications/Entities/Shared/PaymentAttemptStatus.py +13 -0
- paddle_billing/Notifications/Entities/Shared/PaymentMethodType.py +15 -0
- paddle_billing/Notifications/Entities/Shared/PayoutTotalsAdjustment.py +29 -0
- paddle_billing/Notifications/Entities/Shared/PriceQuantity.py +16 -0
- paddle_billing/Notifications/Entities/Shared/Status.py +6 -0
- paddle_billing/Notifications/Entities/Shared/TaxCategory.py +13 -0
- paddle_billing/Notifications/Entities/Shared/TaxMode.py +7 -0
- paddle_billing/Notifications/Entities/Shared/TaxRatesUsed.py +18 -0
- paddle_billing/Notifications/Entities/Shared/TimePeriod.py +18 -0
- paddle_billing/Notifications/Entities/Shared/Totals.py +20 -0
- paddle_billing/Notifications/Entities/Shared/TransactionOrigin.py +10 -0
- paddle_billing/Notifications/Entities/Shared/TransactionPaymentAttempt.py +35 -0
- paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotals.py +36 -0
- paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotalsAdjusted.py +29 -0
- paddle_billing/Notifications/Entities/Shared/TransactionStatus.py +11 -0
- paddle_billing/Notifications/Entities/Shared/TransactionTotals.py +36 -0
- paddle_billing/Notifications/Entities/Shared/TransactionTotalsAdjusted.py +28 -0
- paddle_billing/Notifications/Entities/Shared/UnitPriceOverride.py +19 -0
- paddle_billing/Notifications/Entities/Shared/UnitTotals.py +20 -0
- paddle_billing/Notifications/Entities/Shared/__init__.py +46 -0
- paddle_billing/Notifications/Entities/Subscription.py +76 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionAdjustmentItem.py +24 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionCharge.py +18 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionCredit.py +18 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionDiscount.py +19 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionEffectiveFrom.py +6 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionItem.py +35 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionItemStatus.py +7 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionOnPaymentFailure.py +6 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionPrice.py +28 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionScheduledChange.py +21 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionScheduledChangeAction.py +7 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionStatus.py +10 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionTimePeriod.py +17 -0
- paddle_billing/Notifications/Entities/Subscriptions/__init__.py +13 -0
- paddle_billing/Notifications/Entities/Transaction.py +75 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionAdjustmentsTotals.py +30 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionBreakdown.py +18 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionCardType.py +14 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionDetails.py +32 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionItem.py +24 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionLineItem.py +35 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionProration.py +18 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionTimePeriod.py +17 -0
- paddle_billing/Notifications/Entities/Transactions/__init__.py +11 -0
- paddle_billing/Notifications/Entities/__init__.py +0 -0
- paddle_billing/Notifications/Events/AddressCreated.py +17 -0
- paddle_billing/Notifications/Events/AddressUpdated.py +17 -0
- paddle_billing/Notifications/Events/AdjustmentCreated.py +17 -0
- paddle_billing/Notifications/Events/AdjustmentUpdated.py +17 -0
- paddle_billing/Notifications/Events/BusinessCreated.py +17 -0
- paddle_billing/Notifications/Events/BusinessUpdated.py +17 -0
- paddle_billing/Notifications/Events/CustomerCreated.py +17 -0
- paddle_billing/Notifications/Events/CustomerUpdated.py +17 -0
- paddle_billing/Notifications/Events/DiscountCreated.py +17 -0
- paddle_billing/Notifications/Events/DiscountImported.py +17 -0
- paddle_billing/Notifications/Events/DiscountUpdated.py +17 -0
- paddle_billing/Notifications/Events/PayoutCreated.py +17 -0
- paddle_billing/Notifications/Events/PayoutPaid.py +17 -0
- paddle_billing/Notifications/Events/PriceCreated.py +17 -0
- paddle_billing/Notifications/Events/PriceUpdated.py +17 -0
- paddle_billing/Notifications/Events/ProductCreated.py +17 -0
- paddle_billing/Notifications/Events/ProductUpdated.py +17 -0
- paddle_billing/Notifications/Events/ReportCreated.py +17 -0
- paddle_billing/Notifications/Events/ReportUpdated.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionActivated.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionCanceled.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionCreated.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionImported.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionPastDue.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionPaused.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionResumed.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionTrialing.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionUpdated.py +17 -0
- paddle_billing/Notifications/Events/TransactionBilled.py +17 -0
- paddle_billing/Notifications/Events/TransactionCanceled.py +17 -0
- paddle_billing/Notifications/Events/TransactionCompleted.py +16 -0
- paddle_billing/Notifications/Events/TransactionCreated.py +17 -0
- paddle_billing/Notifications/Events/TransactionPaid.py +17 -0
- paddle_billing/Notifications/Events/TransactionPastDue.py +17 -0
- paddle_billing/Notifications/Events/TransactionPaymentFailed.py +17 -0
- paddle_billing/Notifications/Events/TransactionReady.py +17 -0
- paddle_billing/Notifications/Events/TransactionUpdated.py +17 -0
- paddle_billing/Notifications/Events/__init__.py +0 -0
- paddle_billing/Notifications/PaddleSignature.py +128 -0
- paddle_billing/Notifications/Secret.py +8 -0
- paddle_billing/Notifications/Verifier.py +55 -0
- paddle_billing/Notifications/__init__.py +3 -0
- paddle_billing/Options.py +10 -0
- paddle_billing/PaddleStrEnum.py +44 -0
- paddle_billing/RecursivelyRemoveKey.py +14 -0
- paddle_billing/Resources/Addresses/AddressesClient.py +58 -0
- paddle_billing/Resources/Addresses/Operations/CreateAddress.py +20 -0
- paddle_billing/Resources/Addresses/Operations/ListAddresses.py +42 -0
- paddle_billing/Resources/Addresses/Operations/UpdateAddress.py +21 -0
- paddle_billing/Resources/Addresses/Operations/__init__.py +3 -0
- paddle_billing/Resources/Addresses/__init__.py +0 -0
- paddle_billing/Resources/Adjustments/AdjustmentsClient.py +36 -0
- paddle_billing/Resources/Adjustments/Operations/Create/AdjustmentItem.py +11 -0
- paddle_billing/Resources/Adjustments/Operations/Create/__init__.py +0 -0
- paddle_billing/Resources/Adjustments/Operations/CreateAdjustment.py +28 -0
- paddle_billing/Resources/Adjustments/Operations/ListAdjustments.py +60 -0
- paddle_billing/Resources/Adjustments/Operations/__init__.py +3 -0
- paddle_billing/Resources/Adjustments/__init__.py +0 -0
- paddle_billing/Resources/Businesses/BusinessesClient.py +58 -0
- paddle_billing/Resources/Businesses/Operations/CreateBusiness.py +17 -0
- paddle_billing/Resources/Businesses/Operations/ListBusinesses.py +45 -0
- paddle_billing/Resources/Businesses/Operations/UpdateBusiness.py +18 -0
- paddle_billing/Resources/Businesses/Operations/__init__.py +3 -0
- paddle_billing/Resources/Businesses/__init__.py +0 -0
- paddle_billing/Resources/Customers/CustomersClient.py +65 -0
- paddle_billing/Resources/Customers/Operations/CreateCustomer.py +16 -0
- paddle_billing/Resources/Customers/Operations/ListCreditBalances.py +28 -0
- paddle_billing/Resources/Customers/Operations/ListCustomers.py +50 -0
- paddle_billing/Resources/Customers/Operations/UpdateCustomer.py +17 -0
- paddle_billing/Resources/Customers/Operations/__init__.py +4 -0
- paddle_billing/Resources/Customers/__init__.py +0 -0
- paddle_billing/Resources/Discounts/DiscountsClient.py +55 -0
- paddle_billing/Resources/Discounts/Operations/CreateDiscount.py +24 -0
- paddle_billing/Resources/Discounts/Operations/ListDiscounts.py +46 -0
- paddle_billing/Resources/Discounts/Operations/UpdateDiscount.py +25 -0
- paddle_billing/Resources/Discounts/Operations/__init__.py +3 -0
- paddle_billing/Resources/Discounts/__init__.py +0 -0
- paddle_billing/Resources/EventTypes/EventTypesClient.py +22 -0
- paddle_billing/Resources/EventTypes/__init__.py +0 -0
- paddle_billing/Resources/Events/EventsClient.py +26 -0
- paddle_billing/Resources/Events/Operations/ListEvents.py +12 -0
- paddle_billing/Resources/Events/Operations/__init__.py +1 -0
- paddle_billing/Resources/Events/__init__.py +0 -0
- paddle_billing/Resources/NotificationLogs/NotificationLogsClient.py +26 -0
- paddle_billing/Resources/NotificationLogs/Operations/ListNotificationLogs.py +11 -0
- paddle_billing/Resources/NotificationLogs/Operations/__init__.py +1 -0
- paddle_billing/Resources/NotificationLogs/__init__.py +0 -0
- paddle_billing/Resources/NotificationSettings/NotificationSettingsClient.py +54 -0
- paddle_billing/Resources/NotificationSettings/Operations/CreateNotificationSetting.py +21 -0
- paddle_billing/Resources/NotificationSettings/Operations/UpdateNotificationSetting.py +20 -0
- paddle_billing/Resources/NotificationSettings/Operations/__init__.py +2 -0
- paddle_billing/Resources/NotificationSettings/__init__.py +0 -0
- paddle_billing/Resources/Notifications/NotificationsClient.py +44 -0
- paddle_billing/Resources/Notifications/Operations/ListNotifications.py +58 -0
- paddle_billing/Resources/Notifications/Operations/__init__.py +1 -0
- paddle_billing/Resources/Notifications/__init__.py +0 -0
- paddle_billing/Resources/Prices/Operations/CreatePrice.py +23 -0
- paddle_billing/Resources/Prices/Operations/List/Includes.py +5 -0
- paddle_billing/Resources/Prices/Operations/List/__init__.py +0 -0
- paddle_billing/Resources/Prices/Operations/ListPrices.py +62 -0
- paddle_billing/Resources/Prices/Operations/UpdatePrice.py +23 -0
- paddle_billing/Resources/Prices/Operations/__init__.py +4 -0
- paddle_billing/Resources/Prices/PricesClient.py +65 -0
- paddle_billing/Resources/Prices/__init__.py +0 -0
- paddle_billing/Resources/PricingPreviews/Operations/PreviewPrice.py +20 -0
- paddle_billing/Resources/PricingPreviews/Operations/__init__.py +1 -0
- paddle_billing/Resources/PricingPreviews/PricingPreviewsClient.py +20 -0
- paddle_billing/Resources/PricingPreviews/__init__.py +0 -0
- paddle_billing/Resources/Products/Operations/CreateProduct.py +18 -0
- paddle_billing/Resources/Products/Operations/List/Includes.py +5 -0
- paddle_billing/Resources/Products/Operations/List/__init__.py +0 -0
- paddle_billing/Resources/Products/Operations/ListProducts.py +59 -0
- paddle_billing/Resources/Products/Operations/UpdateProduct.py +19 -0
- paddle_billing/Resources/Products/Operations/__init__.py +4 -0
- paddle_billing/Resources/Products/ProductsClient.py +70 -0
- paddle_billing/Resources/Products/__init__.py +0 -0
- paddle_billing/Resources/Reports/Operations/CreateReport.py +27 -0
- paddle_billing/Resources/Reports/Operations/ListReports.py +35 -0
- paddle_billing/Resources/Reports/Operations/__init__.py +2 -0
- paddle_billing/Resources/Reports/ReportsClient.py +51 -0
- paddle_billing/Resources/Reports/__init__.py +0 -0
- paddle_billing/Resources/Shared/Operations/List/Comparator.py +8 -0
- paddle_billing/Resources/Shared/Operations/List/DateComparison.py +31 -0
- paddle_billing/Resources/Shared/Operations/List/OrderBy.py +21 -0
- paddle_billing/Resources/Shared/Operations/List/Pager.py +24 -0
- paddle_billing/Resources/Shared/Operations/List/__init__.py +0 -0
- paddle_billing/Resources/Shared/Operations/__init__.py +4 -0
- paddle_billing/Resources/Shared/__init__.py +0 -0
- paddle_billing/Resources/Subscriptions/Operations/CancelSubscription.py +12 -0
- paddle_billing/Resources/Subscriptions/Operations/CreateOneTimeCharge.py +22 -0
- paddle_billing/Resources/Subscriptions/Operations/Get/Includes.py +6 -0
- paddle_billing/Resources/Subscriptions/Operations/Get/__init__.py +0 -0
- paddle_billing/Resources/Subscriptions/Operations/ListSubscriptions.py +59 -0
- paddle_billing/Resources/Subscriptions/Operations/PauseSubscription.py +19 -0
- paddle_billing/Resources/Subscriptions/Operations/PreviewOneTimeCharge.py +22 -0
- paddle_billing/Resources/Subscriptions/Operations/PreviewUpdateSubscription.py +37 -0
- paddle_billing/Resources/Subscriptions/Operations/ResumeSubscription.py +17 -0
- paddle_billing/Resources/Subscriptions/Operations/Update/SubscriptionDiscount.py +9 -0
- paddle_billing/Resources/Subscriptions/Operations/Update/__init__.py +0 -0
- paddle_billing/Resources/Subscriptions/Operations/UpdateSubscription.py +37 -0
- paddle_billing/Resources/Subscriptions/Operations/__init__.py +10 -0
- paddle_billing/Resources/Subscriptions/SubscriptionsClient.py +121 -0
- paddle_billing/Resources/Subscriptions/__init__.py +0 -0
- paddle_billing/Resources/Transactions/Operations/CreateTransaction.py +25 -0
- paddle_billing/Resources/Transactions/Operations/List/Includes.py +11 -0
- paddle_billing/Resources/Transactions/Operations/List/Origin.py +10 -0
- paddle_billing/Resources/Transactions/Operations/List/__init__.py +0 -0
- paddle_billing/Resources/Transactions/Operations/ListTransactions.py +86 -0
- paddle_billing/Resources/Transactions/Operations/PreviewTransaction.py +24 -0
- paddle_billing/Resources/Transactions/Operations/UpdateTransaction.py +25 -0
- paddle_billing/Resources/Transactions/Operations/__init__.py +6 -0
- paddle_billing/Resources/Transactions/TransactionsClient.py +90 -0
- paddle_billing/Resources/Transactions/__init__.py +0 -0
- paddle_billing/Resources/__init__.py +0 -0
- paddle_billing/ResponseParser.py +65 -0
- paddle_billing/Undefined.py +2 -0
- paddle_billing/__init__.py +4 -0
- paddle_python_sdk-0.1.0.dist-info/LICENSE +190 -0
- paddle_python_sdk-0.1.0.dist-info/METADATA +184 -0
- paddle_python_sdk-0.1.0.dist-info/RECORD +517 -0
- paddle_python_sdk-0.1.0.dist-info/WHEEL +5 -0
- paddle_python_sdk-0.1.0.dist-info/top_level.txt +3 -0
- tests/Functional/Resources/Addresses/__init__.py +0 -0
- tests/Functional/Resources/Addresses/test_AddressesClient.py +274 -0
- tests/Functional/Resources/Adjustments/__init__.py +0 -0
- tests/Functional/Resources/Adjustments/test_AdjustmentsClient.py +188 -0
- tests/Functional/Resources/Businesses/__init__.py +0 -0
- tests/Functional/Resources/Businesses/test_BusinessesClient.py +279 -0
- tests/Functional/Resources/Customers/__init__.py +0 -0
- tests/Functional/Resources/Customers/test_CustomersClient.py +291 -0
- tests/Functional/Resources/Discounts/__init__.py +0 -0
- tests/Functional/Resources/Discounts/test_DiscountsClient.py +280 -0
- tests/Functional/Resources/EventTypes/__init__.py +0 -0
- tests/Functional/Resources/EventTypes/test_EventTypesClient.py +43 -0
- tests/Functional/Resources/Events/__init__.py +0 -0
- tests/Functional/Resources/Events/test_EventsClient.py +64 -0
- tests/Functional/Resources/NotificationLogs/__init__.py +0 -0
- tests/Functional/Resources/NotificationLogs/test_NotificationLogsClient.py +68 -0
- tests/Functional/Resources/NotificationSettings/__init__.py +0 -0
- tests/Functional/Resources/NotificationSettings/test_NotificationSettingsClient.py +287 -0
- tests/Functional/Resources/Notifications/__init__.py +0 -0
- tests/Functional/Resources/Notifications/test_NotificationsClient.py +202 -0
- tests/Functional/Resources/Prices/__init__.py +0 -0
- tests/Functional/Resources/Prices/test_PricesClient.py +307 -0
- tests/Functional/Resources/PricingPreviews/__init__.py +0 -0
- tests/Functional/Resources/PricingPreviews/test_PricingPreviewsClient.py +92 -0
- tests/Functional/Resources/Products/__init__.py +0 -0
- tests/Functional/Resources/Products/test_ProductsClient.py +271 -0
- tests/Functional/Resources/Reports/__init__.py +0 -0
- tests/Functional/Resources/Reports/test_ReportsClient.py +197 -0
- tests/Functional/Resources/Subscriptions/__init__.py +0 -0
- tests/Functional/Resources/Subscriptions/test_SubscriptionsClient.py +758 -0
- tests/Functional/Resources/Transactions/__init__.py +0 -0
- tests/Functional/Resources/Transactions/test_TransactionsClient.py +585 -0
- tests/Functional/Resources/__init__.py +0 -0
- tests/Functional/__init__.py +0 -0
- tests/Unit/Logger/__init__.py +0 -0
- tests/Unit/Logger/test_Logger.py +10 -0
- tests/Unit/Notification/__init__.py +0 -0
- tests/Unit/Notification/test_Verifier.py +63 -0
- tests/Unit/PaddleStrEnum/__init__.py +0 -0
- tests/Unit/PaddleStrEnum/test_PaddleStrEnum.py +52 -0
- tests/Unit/__init__.py +0 -0
- tests/Utils/FakeResponse.py +6 -0
- tests/Utils/ReadsFixture.py +33 -0
- tests/Utils/TestClient.py +48 -0
- tests/Utils/__init__.py +1 -0
- tests/__init__.py +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
from json import loads
|
|
2
|
+
from pytest import mark
|
|
3
|
+
from urllib.parse import unquote
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Address import Address
|
|
6
|
+
from paddle_billing.Entities.Collections import AddressCollection
|
|
7
|
+
from paddle_billing.Entities.Shared import CountryCode, CustomData, Status
|
|
8
|
+
|
|
9
|
+
from paddle_billing.Resources.Addresses.Operations import CreateAddress, ListAddresses, UpdateAddress
|
|
10
|
+
from paddle_billing.Resources.Shared.Operations import Pager
|
|
11
|
+
|
|
12
|
+
from tests.Utils.TestClient import mock_requests, test_client
|
|
13
|
+
from tests.Utils.ReadsFixture import ReadsFixtures
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TestAddressesClient:
|
|
17
|
+
@mark.parametrize(
|
|
18
|
+
'customer_id, operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
|
|
19
|
+
[
|
|
20
|
+
(
|
|
21
|
+
'ctm_01h844p3h41s12zs5mn4axja51',
|
|
22
|
+
CreateAddress(CountryCode.AG),
|
|
23
|
+
ReadsFixtures.read_raw_json_fixture('request/create_basic'),
|
|
24
|
+
200,
|
|
25
|
+
ReadsFixtures.read_raw_json_fixture('response/minimal_entity'),
|
|
26
|
+
'/customers/ctm_01h844p3h41s12zs5mn4axja51/addresses',
|
|
27
|
+
), (
|
|
28
|
+
'ctm_01h844p3h41s12zs5mn4axja51',
|
|
29
|
+
CreateAddress(
|
|
30
|
+
country_code = CountryCode.US,
|
|
31
|
+
description = 'Head Office',
|
|
32
|
+
first_line = '4050 Jefferson Plaza, 41st Floor',
|
|
33
|
+
second_line = None,
|
|
34
|
+
city = 'New York',
|
|
35
|
+
postal_code = '10021',
|
|
36
|
+
region = 'NY',
|
|
37
|
+
custom_data = CustomData({'shippable': True}),
|
|
38
|
+
),
|
|
39
|
+
ReadsFixtures.read_raw_json_fixture('request/create_full'),
|
|
40
|
+
200,
|
|
41
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
42
|
+
'/customers/ctm_01h844p3h41s12zs5mn4axja51/addresses',
|
|
43
|
+
),
|
|
44
|
+
],
|
|
45
|
+
ids=[
|
|
46
|
+
"Create address with basic data",
|
|
47
|
+
"Create address with full data",
|
|
48
|
+
],
|
|
49
|
+
)
|
|
50
|
+
def test_create_address_uses_expected_payload(
|
|
51
|
+
self,
|
|
52
|
+
test_client,
|
|
53
|
+
mock_requests,
|
|
54
|
+
customer_id,
|
|
55
|
+
operation,
|
|
56
|
+
expected_request_body,
|
|
57
|
+
expected_response_status,
|
|
58
|
+
expected_response_body,
|
|
59
|
+
expected_url,
|
|
60
|
+
):
|
|
61
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
62
|
+
mock_requests.post(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
63
|
+
|
|
64
|
+
response = test_client.client.addresses.create(customer_id, operation)
|
|
65
|
+
response_json = test_client.client.addresses.response.json()
|
|
66
|
+
request_json = test_client.client.payload
|
|
67
|
+
last_request = mock_requests.last_request
|
|
68
|
+
|
|
69
|
+
assert isinstance(response, Address)
|
|
70
|
+
assert last_request is not None
|
|
71
|
+
assert last_request.method == 'POST'
|
|
72
|
+
assert test_client.client.status_code == expected_response_status
|
|
73
|
+
assert unquote(last_request.url) == expected_url, \
|
|
74
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
75
|
+
assert loads(request_json) == loads(expected_request_body), \
|
|
76
|
+
"The request JSON doesn't match the expected fixture JSON"
|
|
77
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
78
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@mark.parametrize(
|
|
82
|
+
'customer_id, address_id, operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
|
|
83
|
+
[
|
|
84
|
+
(
|
|
85
|
+
'ctm_01h844p3h41s12zs5mn4axja51',
|
|
86
|
+
'add_01h848pep46enq8y372x7maj0p',
|
|
87
|
+
UpdateAddress(description='Head Office'),
|
|
88
|
+
ReadsFixtures.read_raw_json_fixture('request/update_single'),
|
|
89
|
+
200,
|
|
90
|
+
ReadsFixtures.read_raw_json_fixture('response/minimal_entity'),
|
|
91
|
+
'/customers/ctm_01h844p3h41s12zs5mn4axja51/addresses/add_01h848pep46enq8y372x7maj0p',
|
|
92
|
+
), (
|
|
93
|
+
'ctm_01h844p3h41s12zs5mn4axja51',
|
|
94
|
+
'add_01h848pep46enq8y372x7maj0p',
|
|
95
|
+
UpdateAddress(description='Head Office', city='New York'),
|
|
96
|
+
ReadsFixtures.read_raw_json_fixture('request/update_partial'),
|
|
97
|
+
200,
|
|
98
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
99
|
+
'/customers/ctm_01h844p3h41s12zs5mn4axja51/addresses/add_01h848pep46enq8y372x7maj0p',
|
|
100
|
+
), (
|
|
101
|
+
'ctm_01h844p3h41s12zs5mn4axja51',
|
|
102
|
+
'add_01h848pep46enq8y372x7maj0p',
|
|
103
|
+
UpdateAddress(
|
|
104
|
+
description = 'Head Office',
|
|
105
|
+
first_line = '4050 Jefferson Plaza, 41st Floor',
|
|
106
|
+
second_line = None,
|
|
107
|
+
city = 'New York',
|
|
108
|
+
postal_code = '10021',
|
|
109
|
+
region = 'NY',
|
|
110
|
+
country_code = CountryCode.US,
|
|
111
|
+
custom_data = CustomData({'shippable': True}),
|
|
112
|
+
status = Status.Active,
|
|
113
|
+
),
|
|
114
|
+
ReadsFixtures.read_raw_json_fixture('request/update_full'),
|
|
115
|
+
200,
|
|
116
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
117
|
+
'/customers/ctm_01h844p3h41s12zs5mn4axja51/addresses/add_01h848pep46enq8y372x7maj0p',
|
|
118
|
+
),
|
|
119
|
+
],
|
|
120
|
+
ids=[
|
|
121
|
+
"Update address with basic data",
|
|
122
|
+
"Update address with partial data",
|
|
123
|
+
"Update address with full data",
|
|
124
|
+
],
|
|
125
|
+
)
|
|
126
|
+
def test_update_address_uses_expected_payload(
|
|
127
|
+
self,
|
|
128
|
+
test_client,
|
|
129
|
+
mock_requests,
|
|
130
|
+
customer_id,
|
|
131
|
+
address_id,
|
|
132
|
+
operation,
|
|
133
|
+
expected_request_body,
|
|
134
|
+
expected_response_status,
|
|
135
|
+
expected_response_body,
|
|
136
|
+
expected_url,
|
|
137
|
+
):
|
|
138
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
139
|
+
mock_requests.patch(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
140
|
+
|
|
141
|
+
response = test_client.client.addresses.update(customer_id, address_id, operation)
|
|
142
|
+
response_json = test_client.client.addresses.response.json()
|
|
143
|
+
request_json = test_client.client.payload
|
|
144
|
+
last_request = mock_requests.last_request
|
|
145
|
+
|
|
146
|
+
assert isinstance(response, Address)
|
|
147
|
+
assert last_request is not None
|
|
148
|
+
assert last_request.method == 'PATCH'
|
|
149
|
+
assert test_client.client.status_code == expected_response_status
|
|
150
|
+
assert unquote(last_request.url) == expected_url, \
|
|
151
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
152
|
+
assert loads(request_json) == loads(expected_request_body), \
|
|
153
|
+
"The request JSON doesn't match the expected fixture JSON"
|
|
154
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
155
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@mark.parametrize(
|
|
159
|
+
'customer_id, operation, expected_response_status, expected_response_body, expected_url',
|
|
160
|
+
[
|
|
161
|
+
(
|
|
162
|
+
'ctm_01h8441jn5pcwrfhwh78jqt8hk',
|
|
163
|
+
ListAddresses(),
|
|
164
|
+
200,
|
|
165
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
166
|
+
'/customers/ctm_01h8441jn5pcwrfhwh78jqt8hk/addresses',
|
|
167
|
+
), (
|
|
168
|
+
'ctm_01h8441jn5pcwrfhwh78jqt8hk',
|
|
169
|
+
ListAddresses(Pager()),
|
|
170
|
+
200,
|
|
171
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
172
|
+
'/customers/ctm_01h8441jn5pcwrfhwh78jqt8hk/addresses?order_by=id[asc]&per_page=50',
|
|
173
|
+
), (
|
|
174
|
+
'ctm_01h8441jn5pcwrfhwh78jqt8hk',
|
|
175
|
+
ListAddresses(Pager(after='add_01h848pep46enq8y372x7maj0p')),
|
|
176
|
+
200,
|
|
177
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
178
|
+
'/customers/ctm_01h8441jn5pcwrfhwh78jqt8hk/addresses?after=add_01h848pep46enq8y372x7maj0p&order_by=id[asc]&per_page=50',
|
|
179
|
+
), (
|
|
180
|
+
'ctm_01h8441jn5pcwrfhwh78jqt8hk',
|
|
181
|
+
ListAddresses(statuses=[Status.Archived]),
|
|
182
|
+
200,
|
|
183
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
184
|
+
'/customers/ctm_01h8441jn5pcwrfhwh78jqt8hk/addresses?status=archived',
|
|
185
|
+
), (
|
|
186
|
+
'ctm_01h8441jn5pcwrfhwh78jqt8hk',
|
|
187
|
+
ListAddresses(ids=['add_01h848pep46enq8y372x7maj0p']),
|
|
188
|
+
200,
|
|
189
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
190
|
+
'/customers/ctm_01h8441jn5pcwrfhwh78jqt8hk/addresses?id=add_01h848pep46enq8y372x7maj0p',
|
|
191
|
+
), (
|
|
192
|
+
'ctm_01h8441jn5pcwrfhwh78jqt8hk',
|
|
193
|
+
ListAddresses(ids=['add_01h8494f4w5rwfp8b12yqh8fp1', 'add_01h848pep46enq8y372x7maj0p']),
|
|
194
|
+
200,
|
|
195
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
196
|
+
'/customers/ctm_01h8441jn5pcwrfhwh78jqt8hk/addresses?id=add_01h8494f4w5rwfp8b12yqh8fp1,add_01h848pep46enq8y372x7maj0p',
|
|
197
|
+
), (
|
|
198
|
+
'ctm_01h8441jn5pcwrfhwh78jqt8hk',
|
|
199
|
+
ListAddresses(search='Office'),
|
|
200
|
+
200,
|
|
201
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
202
|
+
'/customers/ctm_01h8441jn5pcwrfhwh78jqt8hk/addresses?search=Office',
|
|
203
|
+
),
|
|
204
|
+
],
|
|
205
|
+
ids=[
|
|
206
|
+
"List addresses without pagination",
|
|
207
|
+
"List addresses with default pagination",
|
|
208
|
+
"List paginated addresses after specified product id",
|
|
209
|
+
"List addresses filtered by status",
|
|
210
|
+
"List addresses filtered by id",
|
|
211
|
+
"List addresses filtered by multiple ids",
|
|
212
|
+
"List addresses with includes",
|
|
213
|
+
],
|
|
214
|
+
)
|
|
215
|
+
def test_list_addresses_returns_expected_response(
|
|
216
|
+
self,
|
|
217
|
+
test_client,
|
|
218
|
+
mock_requests,
|
|
219
|
+
customer_id,
|
|
220
|
+
operation,
|
|
221
|
+
expected_response_status,
|
|
222
|
+
expected_response_body,
|
|
223
|
+
expected_url,
|
|
224
|
+
):
|
|
225
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
226
|
+
mock_requests.get(expected_url, status_code=expected_response_status)
|
|
227
|
+
|
|
228
|
+
response = test_client.client.addresses.list(customer_id, operation)
|
|
229
|
+
last_request = mock_requests.last_request
|
|
230
|
+
|
|
231
|
+
assert isinstance(response, AddressCollection)
|
|
232
|
+
assert last_request is not None
|
|
233
|
+
assert last_request.method == 'GET'
|
|
234
|
+
assert test_client.client.status_code == expected_response_status
|
|
235
|
+
assert unquote(last_request.url) == expected_url, \
|
|
236
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@mark.parametrize(
|
|
240
|
+
'customer_id, address_id, expected_response_status, expected_response_body, expected_url',
|
|
241
|
+
[(
|
|
242
|
+
'ctm_01h844p3h41s12zs5mn4axja51',
|
|
243
|
+
'add_01h848pep46enq8y372x7maj0p',
|
|
244
|
+
200,
|
|
245
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
246
|
+
'/customers/ctm_01h844p3h41s12zs5mn4axja51/addresses/add_01h848pep46enq8y372x7maj0p',
|
|
247
|
+
)],
|
|
248
|
+
ids=[ "Get address"],
|
|
249
|
+
)
|
|
250
|
+
def test_get_addresses_returns_expected_response(
|
|
251
|
+
self,
|
|
252
|
+
test_client,
|
|
253
|
+
mock_requests,
|
|
254
|
+
customer_id,
|
|
255
|
+
address_id,
|
|
256
|
+
expected_response_status,
|
|
257
|
+
expected_response_body,
|
|
258
|
+
expected_url,
|
|
259
|
+
):
|
|
260
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
261
|
+
mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
262
|
+
|
|
263
|
+
response = test_client.client.addresses.get(customer_id, address_id)
|
|
264
|
+
response_json = test_client.client.addresses.response.json()
|
|
265
|
+
last_request = mock_requests.last_request
|
|
266
|
+
|
|
267
|
+
assert isinstance(response, Address)
|
|
268
|
+
assert last_request is not None
|
|
269
|
+
assert last_request.method == 'GET'
|
|
270
|
+
assert test_client.client.status_code == expected_response_status
|
|
271
|
+
assert unquote(last_request.url) == expected_url, \
|
|
272
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
273
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
274
|
+
"The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
|
|
File without changes
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
from json import loads
|
|
2
|
+
from pytest import mark
|
|
3
|
+
from urllib.parse import unquote
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Adjustment import Adjustment
|
|
6
|
+
from paddle_billing.Entities.Collections import AdjustmentCollection
|
|
7
|
+
from paddle_billing.Entities.Shared import Action, AdjustmentStatus, AdjustmentType
|
|
8
|
+
|
|
9
|
+
from paddle_billing.Resources.Adjustments.Operations import CreateAdjustment, CreateAdjustmentItem, ListAdjustments
|
|
10
|
+
from paddle_billing.Resources.Shared.Operations import Pager
|
|
11
|
+
|
|
12
|
+
from tests.Utils.TestClient import mock_requests, test_client
|
|
13
|
+
from tests.Utils.ReadsFixture import ReadsFixtures
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TestAdjustmentsClient:
|
|
17
|
+
@mark.parametrize(
|
|
18
|
+
'operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
|
|
19
|
+
[
|
|
20
|
+
(
|
|
21
|
+
CreateAdjustment(
|
|
22
|
+
Action.Refund,
|
|
23
|
+
[CreateAdjustmentItem('txnitm_01h8bxryv3065dyh6103p3yg28', AdjustmentType.Partial, '100')],
|
|
24
|
+
'error',
|
|
25
|
+
'txn_01h8bxpvx398a7zbawb77y0kp5',
|
|
26
|
+
),
|
|
27
|
+
ReadsFixtures.read_raw_json_fixture('request/create_basic'),
|
|
28
|
+
200,
|
|
29
|
+
ReadsFixtures.read_raw_json_fixture('response/minimal_entity'),
|
|
30
|
+
'/adjustments',
|
|
31
|
+
), (
|
|
32
|
+
CreateAdjustment(
|
|
33
|
+
Action.Refund,
|
|
34
|
+
[
|
|
35
|
+
CreateAdjustmentItem('txnitm_01h8bxryv3065dyh6103p3yg28', AdjustmentType.Partial, '100'),
|
|
36
|
+
CreateAdjustmentItem('txnitm_01h8bxryv3065dyh6103p3yg29', AdjustmentType.Full, '1949'),
|
|
37
|
+
],
|
|
38
|
+
'error',
|
|
39
|
+
'txn_01h8bxpvx398a7zbawb77y0kp5',
|
|
40
|
+
),
|
|
41
|
+
ReadsFixtures.read_raw_json_fixture('request/create_full'),
|
|
42
|
+
200,
|
|
43
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
44
|
+
'/adjustments',
|
|
45
|
+
),
|
|
46
|
+
],
|
|
47
|
+
ids=[
|
|
48
|
+
"Create adjustment with basic data",
|
|
49
|
+
"Create adjustment with full data",
|
|
50
|
+
],
|
|
51
|
+
)
|
|
52
|
+
def test_create_adjustment_uses_expected_payload(
|
|
53
|
+
self,
|
|
54
|
+
test_client,
|
|
55
|
+
mock_requests,
|
|
56
|
+
operation,
|
|
57
|
+
expected_request_body,
|
|
58
|
+
expected_response_status,
|
|
59
|
+
expected_response_body,
|
|
60
|
+
expected_url,
|
|
61
|
+
):
|
|
62
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
63
|
+
mock_requests.post(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
64
|
+
|
|
65
|
+
response = test_client.client.adjustments.create(operation)
|
|
66
|
+
response_json = test_client.client.adjustments.response.json()
|
|
67
|
+
request_json = test_client.client.payload
|
|
68
|
+
last_request = mock_requests.last_request
|
|
69
|
+
|
|
70
|
+
assert isinstance(response, Adjustment)
|
|
71
|
+
assert last_request is not None
|
|
72
|
+
assert last_request.method == 'POST'
|
|
73
|
+
assert test_client.client.status_code == expected_response_status
|
|
74
|
+
assert unquote(last_request.url) == expected_url, \
|
|
75
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
76
|
+
assert loads(request_json) == loads(expected_request_body), \
|
|
77
|
+
"The request JSON doesn't match the expected fixture JSON"
|
|
78
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
79
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@mark.parametrize(
|
|
83
|
+
'operation, expected_response_status, expected_response_body, expected_url',
|
|
84
|
+
[
|
|
85
|
+
(
|
|
86
|
+
ListAdjustments(),
|
|
87
|
+
200,
|
|
88
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
89
|
+
'/adjustments',
|
|
90
|
+
), (
|
|
91
|
+
ListAdjustments(Pager()),
|
|
92
|
+
200,
|
|
93
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
94
|
+
'/adjustments?order_by=id[asc]&per_page=50',
|
|
95
|
+
), (
|
|
96
|
+
ListAdjustments(Pager(after='adj_01h8c65c2ggq5nxswnnwv78e75')),
|
|
97
|
+
200,
|
|
98
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
99
|
+
'/adjustments?after=adj_01h8c65c2ggq5nxswnnwv78e75&order_by=id[asc]&per_page=50',
|
|
100
|
+
), (
|
|
101
|
+
ListAdjustments(statuses=[AdjustmentStatus.PendingApproval]),
|
|
102
|
+
200,
|
|
103
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
104
|
+
'/adjustments?status=pending_approval',
|
|
105
|
+
), (
|
|
106
|
+
ListAdjustments(ids=['adj_01h8c65c2ggq5nxswnnwv78e75']),
|
|
107
|
+
200,
|
|
108
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
109
|
+
'/adjustments?id=adj_01h8c65c2ggq5nxswnnwv78e75',
|
|
110
|
+
), (
|
|
111
|
+
ListAdjustments(ids=['add_01h8494f4w5rwfp8b12yqh8fp1', 'adj_01h8c65c2ggq5nxswnnwv78e75']),
|
|
112
|
+
200,
|
|
113
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
114
|
+
'/adjustments?id=add_01h8494f4w5rwfp8b12yqh8fp1,adj_01h8c65c2ggq5nxswnnwv78e75',
|
|
115
|
+
), (
|
|
116
|
+
ListAdjustments(customer_ids=['ctm_01h8441jn5pcwrfhwh78jqt8hk']),
|
|
117
|
+
200,
|
|
118
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
119
|
+
'/adjustments?customer_id=ctm_01h8441jn5pcwrfhwh78jqt8hk',
|
|
120
|
+
), (
|
|
121
|
+
ListAdjustments(customer_ids=['ctm_01h8441jn5pcwrfhwh78jqt8hk', 'ctm_01h7hswb86rtps5ggbq7ybydcw']),
|
|
122
|
+
200,
|
|
123
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
124
|
+
'/adjustments?customer_id=ctm_01h8441jn5pcwrfhwh78jqt8hk,ctm_01h7hswb86rtps5ggbq7ybydcw',
|
|
125
|
+
), (
|
|
126
|
+
ListAdjustments(transaction_ids=['txn_01h8bxpvx398a7zbawb77y0kp5']),
|
|
127
|
+
200,
|
|
128
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
129
|
+
'/adjustments?transaction_id=txn_01h8bxpvx398a7zbawb77y0kp5',
|
|
130
|
+
), (
|
|
131
|
+
ListAdjustments(transaction_ids=['ctm_01h8441jn5pcwrfhwh78jqt8hk', 'txn_01h8bx69629a16wwm9z8rjmak3']),
|
|
132
|
+
200,
|
|
133
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
134
|
+
'/adjustments?transaction_id=ctm_01h8441jn5pcwrfhwh78jqt8hk,txn_01h8bx69629a16wwm9z8rjmak3',
|
|
135
|
+
), (
|
|
136
|
+
ListAdjustments(subscription_ids=['sub_01h8bxswamxysj44zt5n48njwh']),
|
|
137
|
+
200,
|
|
138
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
139
|
+
'/adjustments?subscription_id=sub_01h8bxswamxysj44zt5n48njwh',
|
|
140
|
+
), (
|
|
141
|
+
ListAdjustments(subscription_ids=['sub_01h8bxswamxysj44zt5n48njwh', 'sub_01h8bx8fmywym11t6swgzba704']),
|
|
142
|
+
200,
|
|
143
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
144
|
+
'/adjustments?subscription_id=sub_01h8bxswamxysj44zt5n48njwh,sub_01h8bx8fmywym11t6swgzba704',
|
|
145
|
+
), (
|
|
146
|
+
ListAdjustments(action=Action.Refund),
|
|
147
|
+
200,
|
|
148
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
149
|
+
'/adjustments?action=refund',
|
|
150
|
+
),
|
|
151
|
+
],
|
|
152
|
+
ids=[
|
|
153
|
+
"List adjustments without pagination",
|
|
154
|
+
"List adjustments with default pagination",
|
|
155
|
+
"List paginated adjustments after specified adjustment id",
|
|
156
|
+
"List adjustments filtered by notification status",
|
|
157
|
+
"List adjustments filtered by id",
|
|
158
|
+
"List adjustments filtered by multiple ids",
|
|
159
|
+
"List adjustments filtered by customer id",
|
|
160
|
+
"List adjustments filtered by multiple customer ids",
|
|
161
|
+
"List adjustments filtered by transaction id",
|
|
162
|
+
"List adjustments filtered by multiple transaction ids",
|
|
163
|
+
"List adjustments filtered by subscription id",
|
|
164
|
+
"List adjustments filtered by multiple subscription ids",
|
|
165
|
+
"List adjustments filtered by action",
|
|
166
|
+
],
|
|
167
|
+
)
|
|
168
|
+
def test_list_adjustments_returns_expected_response(
|
|
169
|
+
self,
|
|
170
|
+
test_client,
|
|
171
|
+
mock_requests,
|
|
172
|
+
operation,
|
|
173
|
+
expected_response_status,
|
|
174
|
+
expected_response_body,
|
|
175
|
+
expected_url,
|
|
176
|
+
):
|
|
177
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
178
|
+
mock_requests.get(expected_url, status_code=expected_response_status)
|
|
179
|
+
|
|
180
|
+
response = test_client.client.adjustments.list(operation)
|
|
181
|
+
last_request = mock_requests.last_request
|
|
182
|
+
|
|
183
|
+
assert isinstance(response, AdjustmentCollection)
|
|
184
|
+
assert last_request is not None
|
|
185
|
+
assert last_request.method == 'GET'
|
|
186
|
+
assert test_client.client.status_code == expected_response_status
|
|
187
|
+
assert unquote(last_request.url) == expected_url, \
|
|
188
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
File without changes
|