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.
Files changed (517) hide show
  1. examples/__init__.py +0 -0
  2. examples/catalog_management.py +166 -0
  3. examples/event_polling.py +56 -0
  4. examples/get_products.py +46 -0
  5. examples/logger.py +31 -0
  6. paddle_billing/Client.py +201 -0
  7. paddle_billing/ConditionallyRemoveImportMeta.py +14 -0
  8. paddle_billing/Entities/Address.py +44 -0
  9. paddle_billing/Entities/Adjustment.py +45 -0
  10. paddle_billing/Entities/Adjustments/AdjustmentCustomerBalance.py +18 -0
  11. paddle_billing/Entities/Adjustments/AdjustmentItem.py +26 -0
  12. paddle_billing/Entities/Adjustments/__init__.py +2 -0
  13. paddle_billing/Entities/Business.py +38 -0
  14. paddle_billing/Entities/Collections/AddressCollection.py +18 -0
  15. paddle_billing/Entities/Collections/AdjustmentCollection.py +18 -0
  16. paddle_billing/Entities/Collections/BusinessCollection.py +18 -0
  17. paddle_billing/Entities/Collections/Collection.py +47 -0
  18. paddle_billing/Entities/Collections/CreditBalanceCollection.py +18 -0
  19. paddle_billing/Entities/Collections/CustomerCollection.py +18 -0
  20. paddle_billing/Entities/Collections/DiscountCollection.py +18 -0
  21. paddle_billing/Entities/Collections/EventCollection.py +18 -0
  22. paddle_billing/Entities/Collections/EventTypeCollection.py +18 -0
  23. paddle_billing/Entities/Collections/NotificationCollection.py +18 -0
  24. paddle_billing/Entities/Collections/NotificationLogCollection.py +18 -0
  25. paddle_billing/Entities/Collections/NotificationSettingCollection.py +18 -0
  26. paddle_billing/Entities/Collections/Paginator.py +29 -0
  27. paddle_billing/Entities/Collections/PriceCollection.py +18 -0
  28. paddle_billing/Entities/Collections/ProductCollection.py +18 -0
  29. paddle_billing/Entities/Collections/ReportCollection.py +18 -0
  30. paddle_billing/Entities/Collections/SubscriptionCollection.py +18 -0
  31. paddle_billing/Entities/Collections/SubscriptionPreviewCollection.py +18 -0
  32. paddle_billing/Entities/Collections/TransactionCollection.py +18 -0
  33. paddle_billing/Entities/Collections/TransactionPreviewCollection.py +18 -0
  34. paddle_billing/Entities/Collections/TransactionsDataCollection.py +18 -0
  35. paddle_billing/Entities/Collections/__init__.py +21 -0
  36. paddle_billing/Entities/CreditBalance.py +22 -0
  37. paddle_billing/Entities/Customer.py +36 -0
  38. paddle_billing/Entities/DateTime.py +43 -0
  39. paddle_billing/Entities/Discount.py +51 -0
  40. paddle_billing/Entities/Discounts/DiscountStatus.py +8 -0
  41. paddle_billing/Entities/Discounts/DiscountType.py +7 -0
  42. paddle_billing/Entities/Discounts/__init__.py +2 -0
  43. paddle_billing/Entities/Entity.py +12 -0
  44. paddle_billing/Entities/Event.py +51 -0
  45. paddle_billing/Entities/EventType.py +23 -0
  46. paddle_billing/Entities/Events/EventTypeName.py +52 -0
  47. paddle_billing/Entities/Events/__init__.py +1 -0
  48. paddle_billing/Entities/Notification.py +42 -0
  49. paddle_billing/Entities/NotificationLog.py +25 -0
  50. paddle_billing/Entities/NotificationSetting.py +34 -0
  51. paddle_billing/Entities/NotificationSettings/NotificationSettingType.py +6 -0
  52. paddle_billing/Entities/NotificationSettings/__init__.py +1 -0
  53. paddle_billing/Entities/Notifications/NotificationOrigin.py +6 -0
  54. paddle_billing/Entities/Notifications/NotificationPayout.py +24 -0
  55. paddle_billing/Entities/Notifications/NotificationPayoutStatus.py +6 -0
  56. paddle_billing/Entities/Notifications/NotificationStatus.py +8 -0
  57. paddle_billing/Entities/Notifications/__init__.py +4 -0
  58. paddle_billing/Entities/Price.py +68 -0
  59. paddle_billing/Entities/PricePreview.py +34 -0
  60. paddle_billing/Entities/PricingPreviews/PricePreviewDetails.py +15 -0
  61. paddle_billing/Entities/PricingPreviews/PricePreviewDiscounts.py +20 -0
  62. paddle_billing/Entities/PricingPreviews/PricePreviewItem.py +16 -0
  63. paddle_billing/Entities/PricingPreviews/PricePreviewLineItem.py +38 -0
  64. paddle_billing/Entities/PricingPreviews/PricePreviewTotalsFormatted.py +20 -0
  65. paddle_billing/Entities/PricingPreviews/PricePreviewUnitTotalsFormatted.py +20 -0
  66. paddle_billing/Entities/PricingPreviews/__init__.py +6 -0
  67. paddle_billing/Entities/Product.py +45 -0
  68. paddle_billing/Entities/Report.py +32 -0
  69. paddle_billing/Entities/ReportCSV.py +13 -0
  70. paddle_billing/Entities/Reports/ReportFilter.py +20 -0
  71. paddle_billing/Entities/Reports/ReportFilterName.py +17 -0
  72. paddle_billing/Entities/Reports/ReportFilterOperator.py +6 -0
  73. paddle_billing/Entities/Reports/ReportStatus.py +8 -0
  74. paddle_billing/Entities/Reports/ReportType.py +10 -0
  75. paddle_billing/Entities/Reports/__init__.py +5 -0
  76. paddle_billing/Entities/Shared/Action.py +10 -0
  77. paddle_billing/Entities/Shared/AddressPreview.py +18 -0
  78. paddle_billing/Entities/Shared/AdjustmentItemTotals.py +18 -0
  79. paddle_billing/Entities/Shared/AdjustmentProration.py +18 -0
  80. paddle_billing/Entities/Shared/AdjustmentStatus.py +8 -0
  81. paddle_billing/Entities/Shared/AdjustmentTimePeriod.py +17 -0
  82. paddle_billing/Entities/Shared/AdjustmentTotals.py +26 -0
  83. paddle_billing/Entities/Shared/AdjustmentType.py +8 -0
  84. paddle_billing/Entities/Shared/AvailablePaymentMethods.py +11 -0
  85. paddle_billing/Entities/Shared/BillingDetails.py +22 -0
  86. paddle_billing/Entities/Shared/BillingDetailsUpdate.py +22 -0
  87. paddle_billing/Entities/Shared/Card.py +24 -0
  88. paddle_billing/Entities/Shared/CatalogType.py +6 -0
  89. paddle_billing/Entities/Shared/ChargebackFee.py +18 -0
  90. paddle_billing/Entities/Shared/Checkout.py +12 -0
  91. paddle_billing/Entities/Shared/CollectionMode.py +6 -0
  92. paddle_billing/Entities/Shared/Contacts.py +16 -0
  93. paddle_billing/Entities/Shared/CountryCode.py +233 -0
  94. paddle_billing/Entities/Shared/CurrencyCode.py +34 -0
  95. paddle_billing/Entities/Shared/CurrencyCodeAdjustments.py +7 -0
  96. paddle_billing/Entities/Shared/CurrencyCodePayouts.py +17 -0
  97. paddle_billing/Entities/Shared/CustomData.py +10 -0
  98. paddle_billing/Entities/Shared/Data.py +9 -0
  99. paddle_billing/Entities/Shared/ErrorCode.py +21 -0
  100. paddle_billing/Entities/Shared/ImportMeta.py +16 -0
  101. paddle_billing/Entities/Shared/Interval.py +8 -0
  102. paddle_billing/Entities/Shared/Meta.py +7 -0
  103. paddle_billing/Entities/Shared/MetaPaginated.py +18 -0
  104. paddle_billing/Entities/Shared/MethodDetails.py +19 -0
  105. paddle_billing/Entities/Shared/Money.py +28 -0
  106. paddle_billing/Entities/Shared/Original.py +18 -0
  107. paddle_billing/Entities/Shared/Pagination.py +20 -0
  108. paddle_billing/Entities/Shared/PaymentAttemptStatus.py +13 -0
  109. paddle_billing/Entities/Shared/PaymentMethodType.py +14 -0
  110. paddle_billing/Entities/Shared/PayoutTotalsAdjustment.py +29 -0
  111. paddle_billing/Entities/Shared/PriceQuantity.py +16 -0
  112. paddle_billing/Entities/Shared/Status.py +6 -0
  113. paddle_billing/Entities/Shared/TaxCategory.py +13 -0
  114. paddle_billing/Entities/Shared/TaxMode.py +7 -0
  115. paddle_billing/Entities/Shared/TaxRatesUsed.py +18 -0
  116. paddle_billing/Entities/Shared/TimePeriod.py +18 -0
  117. paddle_billing/Entities/Shared/Totals.py +20 -0
  118. paddle_billing/Entities/Shared/TransactionDetailsPreview.py +22 -0
  119. paddle_billing/Entities/Shared/TransactionLineItemPreview.py +28 -0
  120. paddle_billing/Entities/Shared/TransactionOrigin.py +10 -0
  121. paddle_billing/Entities/Shared/TransactionPaymentAttempt.py +35 -0
  122. paddle_billing/Entities/Shared/TransactionPayoutTotals.py +36 -0
  123. paddle_billing/Entities/Shared/TransactionPayoutTotalsAdjusted.py +29 -0
  124. paddle_billing/Entities/Shared/TransactionStatus.py +11 -0
  125. paddle_billing/Entities/Shared/TransactionTotals.py +36 -0
  126. paddle_billing/Entities/Shared/TransactionTotalsAdjusted.py +28 -0
  127. paddle_billing/Entities/Shared/UnitPriceOverride.py +19 -0
  128. paddle_billing/Entities/Shared/UnitTotals.py +20 -0
  129. paddle_billing/Entities/Shared/__init__.py +56 -0
  130. paddle_billing/Entities/Subscription.py +86 -0
  131. paddle_billing/Entities/SubscriptionPreview.py +79 -0
  132. paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentItem.py +24 -0
  133. paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentPreview.py +22 -0
  134. paddle_billing/Entities/Subscriptions/SubscriptionCharge.py +18 -0
  135. paddle_billing/Entities/Subscriptions/SubscriptionCredit.py +18 -0
  136. paddle_billing/Entities/Subscriptions/SubscriptionDetails.py +34 -0
  137. paddle_billing/Entities/Subscriptions/SubscriptionDiscount.py +19 -0
  138. paddle_billing/Entities/Subscriptions/SubscriptionEffectiveFrom.py +6 -0
  139. paddle_billing/Entities/Subscriptions/SubscriptionItem.py +35 -0
  140. paddle_billing/Entities/Subscriptions/SubscriptionItemStatus.py +7 -0
  141. paddle_billing/Entities/Subscriptions/SubscriptionItems.py +20 -0
  142. paddle_billing/Entities/Subscriptions/SubscriptionItemsWithPrice.py +19 -0
  143. paddle_billing/Entities/Subscriptions/SubscriptionManagementUrls.py +16 -0
  144. paddle_billing/Entities/Subscriptions/SubscriptionNextTransaction.py +23 -0
  145. paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogPrice.py +30 -0
  146. paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogPriceWithProduct.py +32 -0
  147. paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogProduct.py +26 -0
  148. paddle_billing/Entities/Subscriptions/SubscriptionOnPaymentFailure.py +6 -0
  149. paddle_billing/Entities/Subscriptions/SubscriptionPreviewSubscriptionUpdateSummary.py +22 -0
  150. paddle_billing/Entities/Subscriptions/SubscriptionPrice.py +28 -0
  151. paddle_billing/Entities/Subscriptions/SubscriptionProration.py +18 -0
  152. paddle_billing/Entities/Subscriptions/SubscriptionProrationBillingMode.py +9 -0
  153. paddle_billing/Entities/Subscriptions/SubscriptionResult.py +22 -0
  154. paddle_billing/Entities/Subscriptions/SubscriptionResultAction.py +6 -0
  155. paddle_billing/Entities/Subscriptions/SubscriptionResumeEffectiveFrom.py +5 -0
  156. paddle_billing/Entities/Subscriptions/SubscriptionScheduledChange.py +21 -0
  157. paddle_billing/Entities/Subscriptions/SubscriptionScheduledChangeAction.py +7 -0
  158. paddle_billing/Entities/Subscriptions/SubscriptionStatus.py +10 -0
  159. paddle_billing/Entities/Subscriptions/SubscriptionTimePeriod.py +17 -0
  160. paddle_billing/Entities/Subscriptions/SubscriptionTransactionItem.py +23 -0
  161. paddle_billing/Entities/Subscriptions/SubscriptionTransactionLineItem.py +33 -0
  162. paddle_billing/Entities/Subscriptions/SubscriptionUpdateItem.py +16 -0
  163. paddle_billing/Entities/Subscriptions/__init__.py +31 -0
  164. paddle_billing/Entities/Transaction.py +98 -0
  165. paddle_billing/Entities/TransactionData.py +15 -0
  166. paddle_billing/Entities/TransactionPreview.py +40 -0
  167. paddle_billing/Entities/Transactions/TransactionAdjustmentsTotals.py +30 -0
  168. paddle_billing/Entities/Transactions/TransactionBreakdown.py +18 -0
  169. paddle_billing/Entities/Transactions/TransactionCardType.py +14 -0
  170. paddle_billing/Entities/Transactions/TransactionCreateItem.py +16 -0
  171. paddle_billing/Entities/Transactions/TransactionCreateItemWithPrice.py +11 -0
  172. paddle_billing/Entities/Transactions/TransactionDetails.py +32 -0
  173. paddle_billing/Entities/Transactions/TransactionItem.py +24 -0
  174. paddle_billing/Entities/Transactions/TransactionItemPreviewWithNonCatalogPrice.py +21 -0
  175. paddle_billing/Entities/Transactions/TransactionItemPreviewWithPrice.py +24 -0
  176. paddle_billing/Entities/Transactions/TransactionItemPreviewWithPriceId.py +18 -0
  177. paddle_billing/Entities/Transactions/TransactionLineItem.py +35 -0
  178. paddle_billing/Entities/Transactions/TransactionNonCatalogPrice.py +39 -0
  179. paddle_billing/Entities/Transactions/TransactionNonCatalogPriceWithProduct.py +41 -0
  180. paddle_billing/Entities/Transactions/TransactionNonCatalogProduct.py +25 -0
  181. paddle_billing/Entities/Transactions/TransactionProration.py +18 -0
  182. paddle_billing/Entities/Transactions/TransactionTimePeriod.py +17 -0
  183. paddle_billing/Entities/Transactions/TransactionUpdateTransactionItem.py +8 -0
  184. paddle_billing/Entities/Transactions/__init__.py +20 -0
  185. paddle_billing/Entities/__init__.py +0 -0
  186. paddle_billing/EnumStringify.py +2 -0
  187. paddle_billing/Environment.py +14 -0
  188. paddle_billing/Exceptions/ApiError.py +28 -0
  189. paddle_billing/Exceptions/ApiErrors/AddressApiError.py +5 -0
  190. paddle_billing/Exceptions/ApiErrors/AdjustmentApiError.py +5 -0
  191. paddle_billing/Exceptions/ApiErrors/BusinessApiError.py +5 -0
  192. paddle_billing/Exceptions/ApiErrors/CustomerApiError.py +5 -0
  193. paddle_billing/Exceptions/ApiErrors/DiscountApiError.py +5 -0
  194. paddle_billing/Exceptions/ApiErrors/PriceApiError.py +5 -0
  195. paddle_billing/Exceptions/ApiErrors/ProductApiError.py +5 -0
  196. paddle_billing/Exceptions/ApiErrors/SubscriptionApiError.py +5 -0
  197. paddle_billing/Exceptions/ApiErrors/TransactionApiError.py +5 -0
  198. paddle_billing/Exceptions/ApiErrors/__init__.py +0 -0
  199. paddle_billing/Exceptions/FieldError.py +8 -0
  200. paddle_billing/Exceptions/SdkException.py +2 -0
  201. paddle_billing/Exceptions/SdkExceptions/InvalidArgumentException.py +8 -0
  202. paddle_billing/Exceptions/SdkExceptions/MalformedResponse.py +7 -0
  203. paddle_billing/Exceptions/SdkExceptions/__init__.py +0 -0
  204. paddle_billing/Exceptions/__init__.py +0 -0
  205. paddle_billing/FiltersNone.py +8 -0
  206. paddle_billing/FiltersUndefined.py +11 -0
  207. paddle_billing/HasParameters.py +11 -0
  208. paddle_billing/Logger/Formatter.py +18 -0
  209. paddle_billing/Logger/NullHandler.py +6 -0
  210. paddle_billing/Logger/__init__.py +30 -0
  211. paddle_billing/Notifications/Entities/Address.py +44 -0
  212. paddle_billing/Notifications/Entities/Adjustment.py +45 -0
  213. paddle_billing/Notifications/Entities/Adjustments/AdjustmentItem.py +26 -0
  214. paddle_billing/Notifications/Entities/Adjustments/__init__.py +1 -0
  215. paddle_billing/Notifications/Entities/Business.py +39 -0
  216. paddle_billing/Notifications/Entities/Businesses/BusinessesContacts.py +16 -0
  217. paddle_billing/Notifications/Entities/Businesses/__init__.py +1 -0
  218. paddle_billing/Notifications/Entities/Customer.py +36 -0
  219. paddle_billing/Notifications/Entities/DateTime.py +43 -0
  220. paddle_billing/Notifications/Entities/Discount.py +51 -0
  221. paddle_billing/Notifications/Entities/Discounts/DiscountStatus.py +8 -0
  222. paddle_billing/Notifications/Entities/Discounts/DiscountType.py +7 -0
  223. paddle_billing/Notifications/Entities/Discounts/__init__.py +2 -0
  224. paddle_billing/Notifications/Entities/Entity.py +12 -0
  225. paddle_billing/Notifications/Entities/Payout.py +24 -0
  226. paddle_billing/Notifications/Entities/Payouts/PayoutStatus.py +6 -0
  227. paddle_billing/Notifications/Entities/Payouts/__init__.py +1 -0
  228. paddle_billing/Notifications/Entities/Price.py +66 -0
  229. paddle_billing/Notifications/Entities/Product.py +45 -0
  230. paddle_billing/Notifications/Entities/Report.py +32 -0
  231. paddle_billing/Notifications/Entities/Reports/ReportFilter.py +20 -0
  232. paddle_billing/Notifications/Entities/Reports/ReportFilterName.py +17 -0
  233. paddle_billing/Notifications/Entities/Reports/ReportFilterOperator.py +6 -0
  234. paddle_billing/Notifications/Entities/Reports/ReportStatus.py +8 -0
  235. paddle_billing/Notifications/Entities/Reports/ReportType.py +10 -0
  236. paddle_billing/Notifications/Entities/Reports/__init__.py +5 -0
  237. paddle_billing/Notifications/Entities/Shared/Action.py +10 -0
  238. paddle_billing/Notifications/Entities/Shared/AddressPreview.py +18 -0
  239. paddle_billing/Notifications/Entities/Shared/AdjustmentItemTotals.py +18 -0
  240. paddle_billing/Notifications/Entities/Shared/AdjustmentProration.py +18 -0
  241. paddle_billing/Notifications/Entities/Shared/AdjustmentStatus.py +8 -0
  242. paddle_billing/Notifications/Entities/Shared/AdjustmentTimePeriod.py +17 -0
  243. paddle_billing/Notifications/Entities/Shared/AdjustmentTotals.py +26 -0
  244. paddle_billing/Notifications/Entities/Shared/AdjustmentType.py +8 -0
  245. paddle_billing/Notifications/Entities/Shared/AvailablePaymentMethods.py +11 -0
  246. paddle_billing/Notifications/Entities/Shared/BillingDetails.py +22 -0
  247. paddle_billing/Notifications/Entities/Shared/Card.py +24 -0
  248. paddle_billing/Notifications/Entities/Shared/CatalogType.py +6 -0
  249. paddle_billing/Notifications/Entities/Shared/ChargebackFee.py +18 -0
  250. paddle_billing/Notifications/Entities/Shared/Checkout.py +12 -0
  251. paddle_billing/Notifications/Entities/Shared/CollectionMode.py +6 -0
  252. paddle_billing/Notifications/Entities/Shared/CountryCode.py +233 -0
  253. paddle_billing/Notifications/Entities/Shared/CurrencyCode.py +34 -0
  254. paddle_billing/Notifications/Entities/Shared/CurrencyCodeAdjustments.py +7 -0
  255. paddle_billing/Notifications/Entities/Shared/CurrencyCodePayouts.py +17 -0
  256. paddle_billing/Notifications/Entities/Shared/CustomData.py +10 -0
  257. paddle_billing/Notifications/Entities/Shared/Data.py +9 -0
  258. paddle_billing/Notifications/Entities/Shared/ErrorCode.py +21 -0
  259. paddle_billing/Notifications/Entities/Shared/ImportMeta.py +16 -0
  260. paddle_billing/Notifications/Entities/Shared/Interval.py +8 -0
  261. paddle_billing/Notifications/Entities/Shared/MethodDetails.py +19 -0
  262. paddle_billing/Notifications/Entities/Shared/Money.py +28 -0
  263. paddle_billing/Notifications/Entities/Shared/Original.py +18 -0
  264. paddle_billing/Notifications/Entities/Shared/PaymentAttemptStatus.py +13 -0
  265. paddle_billing/Notifications/Entities/Shared/PaymentMethodType.py +15 -0
  266. paddle_billing/Notifications/Entities/Shared/PayoutTotalsAdjustment.py +29 -0
  267. paddle_billing/Notifications/Entities/Shared/PriceQuantity.py +16 -0
  268. paddle_billing/Notifications/Entities/Shared/Status.py +6 -0
  269. paddle_billing/Notifications/Entities/Shared/TaxCategory.py +13 -0
  270. paddle_billing/Notifications/Entities/Shared/TaxMode.py +7 -0
  271. paddle_billing/Notifications/Entities/Shared/TaxRatesUsed.py +18 -0
  272. paddle_billing/Notifications/Entities/Shared/TimePeriod.py +18 -0
  273. paddle_billing/Notifications/Entities/Shared/Totals.py +20 -0
  274. paddle_billing/Notifications/Entities/Shared/TransactionOrigin.py +10 -0
  275. paddle_billing/Notifications/Entities/Shared/TransactionPaymentAttempt.py +35 -0
  276. paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotals.py +36 -0
  277. paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotalsAdjusted.py +29 -0
  278. paddle_billing/Notifications/Entities/Shared/TransactionStatus.py +11 -0
  279. paddle_billing/Notifications/Entities/Shared/TransactionTotals.py +36 -0
  280. paddle_billing/Notifications/Entities/Shared/TransactionTotalsAdjusted.py +28 -0
  281. paddle_billing/Notifications/Entities/Shared/UnitPriceOverride.py +19 -0
  282. paddle_billing/Notifications/Entities/Shared/UnitTotals.py +20 -0
  283. paddle_billing/Notifications/Entities/Shared/__init__.py +46 -0
  284. paddle_billing/Notifications/Entities/Subscription.py +76 -0
  285. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionAdjustmentItem.py +24 -0
  286. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionCharge.py +18 -0
  287. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionCredit.py +18 -0
  288. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionDiscount.py +19 -0
  289. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionEffectiveFrom.py +6 -0
  290. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionItem.py +35 -0
  291. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionItemStatus.py +7 -0
  292. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionOnPaymentFailure.py +6 -0
  293. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionPrice.py +28 -0
  294. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionScheduledChange.py +21 -0
  295. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionScheduledChangeAction.py +7 -0
  296. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionStatus.py +10 -0
  297. paddle_billing/Notifications/Entities/Subscriptions/SubscriptionTimePeriod.py +17 -0
  298. paddle_billing/Notifications/Entities/Subscriptions/__init__.py +13 -0
  299. paddle_billing/Notifications/Entities/Transaction.py +75 -0
  300. paddle_billing/Notifications/Entities/Transactions/TransactionAdjustmentsTotals.py +30 -0
  301. paddle_billing/Notifications/Entities/Transactions/TransactionBreakdown.py +18 -0
  302. paddle_billing/Notifications/Entities/Transactions/TransactionCardType.py +14 -0
  303. paddle_billing/Notifications/Entities/Transactions/TransactionDetails.py +32 -0
  304. paddle_billing/Notifications/Entities/Transactions/TransactionItem.py +24 -0
  305. paddle_billing/Notifications/Entities/Transactions/TransactionLineItem.py +35 -0
  306. paddle_billing/Notifications/Entities/Transactions/TransactionProration.py +18 -0
  307. paddle_billing/Notifications/Entities/Transactions/TransactionTimePeriod.py +17 -0
  308. paddle_billing/Notifications/Entities/Transactions/__init__.py +11 -0
  309. paddle_billing/Notifications/Entities/__init__.py +0 -0
  310. paddle_billing/Notifications/Events/AddressCreated.py +17 -0
  311. paddle_billing/Notifications/Events/AddressUpdated.py +17 -0
  312. paddle_billing/Notifications/Events/AdjustmentCreated.py +17 -0
  313. paddle_billing/Notifications/Events/AdjustmentUpdated.py +17 -0
  314. paddle_billing/Notifications/Events/BusinessCreated.py +17 -0
  315. paddle_billing/Notifications/Events/BusinessUpdated.py +17 -0
  316. paddle_billing/Notifications/Events/CustomerCreated.py +17 -0
  317. paddle_billing/Notifications/Events/CustomerUpdated.py +17 -0
  318. paddle_billing/Notifications/Events/DiscountCreated.py +17 -0
  319. paddle_billing/Notifications/Events/DiscountImported.py +17 -0
  320. paddle_billing/Notifications/Events/DiscountUpdated.py +17 -0
  321. paddle_billing/Notifications/Events/PayoutCreated.py +17 -0
  322. paddle_billing/Notifications/Events/PayoutPaid.py +17 -0
  323. paddle_billing/Notifications/Events/PriceCreated.py +17 -0
  324. paddle_billing/Notifications/Events/PriceUpdated.py +17 -0
  325. paddle_billing/Notifications/Events/ProductCreated.py +17 -0
  326. paddle_billing/Notifications/Events/ProductUpdated.py +17 -0
  327. paddle_billing/Notifications/Events/ReportCreated.py +17 -0
  328. paddle_billing/Notifications/Events/ReportUpdated.py +17 -0
  329. paddle_billing/Notifications/Events/SubscriptionActivated.py +17 -0
  330. paddle_billing/Notifications/Events/SubscriptionCanceled.py +17 -0
  331. paddle_billing/Notifications/Events/SubscriptionCreated.py +17 -0
  332. paddle_billing/Notifications/Events/SubscriptionImported.py +17 -0
  333. paddle_billing/Notifications/Events/SubscriptionPastDue.py +17 -0
  334. paddle_billing/Notifications/Events/SubscriptionPaused.py +17 -0
  335. paddle_billing/Notifications/Events/SubscriptionResumed.py +17 -0
  336. paddle_billing/Notifications/Events/SubscriptionTrialing.py +17 -0
  337. paddle_billing/Notifications/Events/SubscriptionUpdated.py +17 -0
  338. paddle_billing/Notifications/Events/TransactionBilled.py +17 -0
  339. paddle_billing/Notifications/Events/TransactionCanceled.py +17 -0
  340. paddle_billing/Notifications/Events/TransactionCompleted.py +16 -0
  341. paddle_billing/Notifications/Events/TransactionCreated.py +17 -0
  342. paddle_billing/Notifications/Events/TransactionPaid.py +17 -0
  343. paddle_billing/Notifications/Events/TransactionPastDue.py +17 -0
  344. paddle_billing/Notifications/Events/TransactionPaymentFailed.py +17 -0
  345. paddle_billing/Notifications/Events/TransactionReady.py +17 -0
  346. paddle_billing/Notifications/Events/TransactionUpdated.py +17 -0
  347. paddle_billing/Notifications/Events/__init__.py +0 -0
  348. paddle_billing/Notifications/PaddleSignature.py +128 -0
  349. paddle_billing/Notifications/Secret.py +8 -0
  350. paddle_billing/Notifications/Verifier.py +55 -0
  351. paddle_billing/Notifications/__init__.py +3 -0
  352. paddle_billing/Options.py +10 -0
  353. paddle_billing/PaddleStrEnum.py +44 -0
  354. paddle_billing/RecursivelyRemoveKey.py +14 -0
  355. paddle_billing/Resources/Addresses/AddressesClient.py +58 -0
  356. paddle_billing/Resources/Addresses/Operations/CreateAddress.py +20 -0
  357. paddle_billing/Resources/Addresses/Operations/ListAddresses.py +42 -0
  358. paddle_billing/Resources/Addresses/Operations/UpdateAddress.py +21 -0
  359. paddle_billing/Resources/Addresses/Operations/__init__.py +3 -0
  360. paddle_billing/Resources/Addresses/__init__.py +0 -0
  361. paddle_billing/Resources/Adjustments/AdjustmentsClient.py +36 -0
  362. paddle_billing/Resources/Adjustments/Operations/Create/AdjustmentItem.py +11 -0
  363. paddle_billing/Resources/Adjustments/Operations/Create/__init__.py +0 -0
  364. paddle_billing/Resources/Adjustments/Operations/CreateAdjustment.py +28 -0
  365. paddle_billing/Resources/Adjustments/Operations/ListAdjustments.py +60 -0
  366. paddle_billing/Resources/Adjustments/Operations/__init__.py +3 -0
  367. paddle_billing/Resources/Adjustments/__init__.py +0 -0
  368. paddle_billing/Resources/Businesses/BusinessesClient.py +58 -0
  369. paddle_billing/Resources/Businesses/Operations/CreateBusiness.py +17 -0
  370. paddle_billing/Resources/Businesses/Operations/ListBusinesses.py +45 -0
  371. paddle_billing/Resources/Businesses/Operations/UpdateBusiness.py +18 -0
  372. paddle_billing/Resources/Businesses/Operations/__init__.py +3 -0
  373. paddle_billing/Resources/Businesses/__init__.py +0 -0
  374. paddle_billing/Resources/Customers/CustomersClient.py +65 -0
  375. paddle_billing/Resources/Customers/Operations/CreateCustomer.py +16 -0
  376. paddle_billing/Resources/Customers/Operations/ListCreditBalances.py +28 -0
  377. paddle_billing/Resources/Customers/Operations/ListCustomers.py +50 -0
  378. paddle_billing/Resources/Customers/Operations/UpdateCustomer.py +17 -0
  379. paddle_billing/Resources/Customers/Operations/__init__.py +4 -0
  380. paddle_billing/Resources/Customers/__init__.py +0 -0
  381. paddle_billing/Resources/Discounts/DiscountsClient.py +55 -0
  382. paddle_billing/Resources/Discounts/Operations/CreateDiscount.py +24 -0
  383. paddle_billing/Resources/Discounts/Operations/ListDiscounts.py +46 -0
  384. paddle_billing/Resources/Discounts/Operations/UpdateDiscount.py +25 -0
  385. paddle_billing/Resources/Discounts/Operations/__init__.py +3 -0
  386. paddle_billing/Resources/Discounts/__init__.py +0 -0
  387. paddle_billing/Resources/EventTypes/EventTypesClient.py +22 -0
  388. paddle_billing/Resources/EventTypes/__init__.py +0 -0
  389. paddle_billing/Resources/Events/EventsClient.py +26 -0
  390. paddle_billing/Resources/Events/Operations/ListEvents.py +12 -0
  391. paddle_billing/Resources/Events/Operations/__init__.py +1 -0
  392. paddle_billing/Resources/Events/__init__.py +0 -0
  393. paddle_billing/Resources/NotificationLogs/NotificationLogsClient.py +26 -0
  394. paddle_billing/Resources/NotificationLogs/Operations/ListNotificationLogs.py +11 -0
  395. paddle_billing/Resources/NotificationLogs/Operations/__init__.py +1 -0
  396. paddle_billing/Resources/NotificationLogs/__init__.py +0 -0
  397. paddle_billing/Resources/NotificationSettings/NotificationSettingsClient.py +54 -0
  398. paddle_billing/Resources/NotificationSettings/Operations/CreateNotificationSetting.py +21 -0
  399. paddle_billing/Resources/NotificationSettings/Operations/UpdateNotificationSetting.py +20 -0
  400. paddle_billing/Resources/NotificationSettings/Operations/__init__.py +2 -0
  401. paddle_billing/Resources/NotificationSettings/__init__.py +0 -0
  402. paddle_billing/Resources/Notifications/NotificationsClient.py +44 -0
  403. paddle_billing/Resources/Notifications/Operations/ListNotifications.py +58 -0
  404. paddle_billing/Resources/Notifications/Operations/__init__.py +1 -0
  405. paddle_billing/Resources/Notifications/__init__.py +0 -0
  406. paddle_billing/Resources/Prices/Operations/CreatePrice.py +23 -0
  407. paddle_billing/Resources/Prices/Operations/List/Includes.py +5 -0
  408. paddle_billing/Resources/Prices/Operations/List/__init__.py +0 -0
  409. paddle_billing/Resources/Prices/Operations/ListPrices.py +62 -0
  410. paddle_billing/Resources/Prices/Operations/UpdatePrice.py +23 -0
  411. paddle_billing/Resources/Prices/Operations/__init__.py +4 -0
  412. paddle_billing/Resources/Prices/PricesClient.py +65 -0
  413. paddle_billing/Resources/Prices/__init__.py +0 -0
  414. paddle_billing/Resources/PricingPreviews/Operations/PreviewPrice.py +20 -0
  415. paddle_billing/Resources/PricingPreviews/Operations/__init__.py +1 -0
  416. paddle_billing/Resources/PricingPreviews/PricingPreviewsClient.py +20 -0
  417. paddle_billing/Resources/PricingPreviews/__init__.py +0 -0
  418. paddle_billing/Resources/Products/Operations/CreateProduct.py +18 -0
  419. paddle_billing/Resources/Products/Operations/List/Includes.py +5 -0
  420. paddle_billing/Resources/Products/Operations/List/__init__.py +0 -0
  421. paddle_billing/Resources/Products/Operations/ListProducts.py +59 -0
  422. paddle_billing/Resources/Products/Operations/UpdateProduct.py +19 -0
  423. paddle_billing/Resources/Products/Operations/__init__.py +4 -0
  424. paddle_billing/Resources/Products/ProductsClient.py +70 -0
  425. paddle_billing/Resources/Products/__init__.py +0 -0
  426. paddle_billing/Resources/Reports/Operations/CreateReport.py +27 -0
  427. paddle_billing/Resources/Reports/Operations/ListReports.py +35 -0
  428. paddle_billing/Resources/Reports/Operations/__init__.py +2 -0
  429. paddle_billing/Resources/Reports/ReportsClient.py +51 -0
  430. paddle_billing/Resources/Reports/__init__.py +0 -0
  431. paddle_billing/Resources/Shared/Operations/List/Comparator.py +8 -0
  432. paddle_billing/Resources/Shared/Operations/List/DateComparison.py +31 -0
  433. paddle_billing/Resources/Shared/Operations/List/OrderBy.py +21 -0
  434. paddle_billing/Resources/Shared/Operations/List/Pager.py +24 -0
  435. paddle_billing/Resources/Shared/Operations/List/__init__.py +0 -0
  436. paddle_billing/Resources/Shared/Operations/__init__.py +4 -0
  437. paddle_billing/Resources/Shared/__init__.py +0 -0
  438. paddle_billing/Resources/Subscriptions/Operations/CancelSubscription.py +12 -0
  439. paddle_billing/Resources/Subscriptions/Operations/CreateOneTimeCharge.py +22 -0
  440. paddle_billing/Resources/Subscriptions/Operations/Get/Includes.py +6 -0
  441. paddle_billing/Resources/Subscriptions/Operations/Get/__init__.py +0 -0
  442. paddle_billing/Resources/Subscriptions/Operations/ListSubscriptions.py +59 -0
  443. paddle_billing/Resources/Subscriptions/Operations/PauseSubscription.py +19 -0
  444. paddle_billing/Resources/Subscriptions/Operations/PreviewOneTimeCharge.py +22 -0
  445. paddle_billing/Resources/Subscriptions/Operations/PreviewUpdateSubscription.py +37 -0
  446. paddle_billing/Resources/Subscriptions/Operations/ResumeSubscription.py +17 -0
  447. paddle_billing/Resources/Subscriptions/Operations/Update/SubscriptionDiscount.py +9 -0
  448. paddle_billing/Resources/Subscriptions/Operations/Update/__init__.py +0 -0
  449. paddle_billing/Resources/Subscriptions/Operations/UpdateSubscription.py +37 -0
  450. paddle_billing/Resources/Subscriptions/Operations/__init__.py +10 -0
  451. paddle_billing/Resources/Subscriptions/SubscriptionsClient.py +121 -0
  452. paddle_billing/Resources/Subscriptions/__init__.py +0 -0
  453. paddle_billing/Resources/Transactions/Operations/CreateTransaction.py +25 -0
  454. paddle_billing/Resources/Transactions/Operations/List/Includes.py +11 -0
  455. paddle_billing/Resources/Transactions/Operations/List/Origin.py +10 -0
  456. paddle_billing/Resources/Transactions/Operations/List/__init__.py +0 -0
  457. paddle_billing/Resources/Transactions/Operations/ListTransactions.py +86 -0
  458. paddle_billing/Resources/Transactions/Operations/PreviewTransaction.py +24 -0
  459. paddle_billing/Resources/Transactions/Operations/UpdateTransaction.py +25 -0
  460. paddle_billing/Resources/Transactions/Operations/__init__.py +6 -0
  461. paddle_billing/Resources/Transactions/TransactionsClient.py +90 -0
  462. paddle_billing/Resources/Transactions/__init__.py +0 -0
  463. paddle_billing/Resources/__init__.py +0 -0
  464. paddle_billing/ResponseParser.py +65 -0
  465. paddle_billing/Undefined.py +2 -0
  466. paddle_billing/__init__.py +4 -0
  467. paddle_python_sdk-0.1.0.dist-info/LICENSE +190 -0
  468. paddle_python_sdk-0.1.0.dist-info/METADATA +184 -0
  469. paddle_python_sdk-0.1.0.dist-info/RECORD +517 -0
  470. paddle_python_sdk-0.1.0.dist-info/WHEEL +5 -0
  471. paddle_python_sdk-0.1.0.dist-info/top_level.txt +3 -0
  472. tests/Functional/Resources/Addresses/__init__.py +0 -0
  473. tests/Functional/Resources/Addresses/test_AddressesClient.py +274 -0
  474. tests/Functional/Resources/Adjustments/__init__.py +0 -0
  475. tests/Functional/Resources/Adjustments/test_AdjustmentsClient.py +188 -0
  476. tests/Functional/Resources/Businesses/__init__.py +0 -0
  477. tests/Functional/Resources/Businesses/test_BusinessesClient.py +279 -0
  478. tests/Functional/Resources/Customers/__init__.py +0 -0
  479. tests/Functional/Resources/Customers/test_CustomersClient.py +291 -0
  480. tests/Functional/Resources/Discounts/__init__.py +0 -0
  481. tests/Functional/Resources/Discounts/test_DiscountsClient.py +280 -0
  482. tests/Functional/Resources/EventTypes/__init__.py +0 -0
  483. tests/Functional/Resources/EventTypes/test_EventTypesClient.py +43 -0
  484. tests/Functional/Resources/Events/__init__.py +0 -0
  485. tests/Functional/Resources/Events/test_EventsClient.py +64 -0
  486. tests/Functional/Resources/NotificationLogs/__init__.py +0 -0
  487. tests/Functional/Resources/NotificationLogs/test_NotificationLogsClient.py +68 -0
  488. tests/Functional/Resources/NotificationSettings/__init__.py +0 -0
  489. tests/Functional/Resources/NotificationSettings/test_NotificationSettingsClient.py +287 -0
  490. tests/Functional/Resources/Notifications/__init__.py +0 -0
  491. tests/Functional/Resources/Notifications/test_NotificationsClient.py +202 -0
  492. tests/Functional/Resources/Prices/__init__.py +0 -0
  493. tests/Functional/Resources/Prices/test_PricesClient.py +307 -0
  494. tests/Functional/Resources/PricingPreviews/__init__.py +0 -0
  495. tests/Functional/Resources/PricingPreviews/test_PricingPreviewsClient.py +92 -0
  496. tests/Functional/Resources/Products/__init__.py +0 -0
  497. tests/Functional/Resources/Products/test_ProductsClient.py +271 -0
  498. tests/Functional/Resources/Reports/__init__.py +0 -0
  499. tests/Functional/Resources/Reports/test_ReportsClient.py +197 -0
  500. tests/Functional/Resources/Subscriptions/__init__.py +0 -0
  501. tests/Functional/Resources/Subscriptions/test_SubscriptionsClient.py +758 -0
  502. tests/Functional/Resources/Transactions/__init__.py +0 -0
  503. tests/Functional/Resources/Transactions/test_TransactionsClient.py +585 -0
  504. tests/Functional/Resources/__init__.py +0 -0
  505. tests/Functional/__init__.py +0 -0
  506. tests/Unit/Logger/__init__.py +0 -0
  507. tests/Unit/Logger/test_Logger.py +10 -0
  508. tests/Unit/Notification/__init__.py +0 -0
  509. tests/Unit/Notification/test_Verifier.py +63 -0
  510. tests/Unit/PaddleStrEnum/__init__.py +0 -0
  511. tests/Unit/PaddleStrEnum/test_PaddleStrEnum.py +52 -0
  512. tests/Unit/__init__.py +0 -0
  513. tests/Utils/FakeResponse.py +6 -0
  514. tests/Utils/ReadsFixture.py +33 -0
  515. tests/Utils/TestClient.py +48 -0
  516. tests/Utils/__init__.py +1 -0
  517. tests/__init__.py +0 -0
@@ -0,0 +1,307 @@
1
+ from json import loads
2
+ from pytest import mark
3
+ from urllib.parse import unquote
4
+
5
+ from paddle_billing.Entities.Collections import PriceCollection
6
+ from paddle_billing.Entities.Price import Price
7
+ from paddle_billing.Entities.Shared import (
8
+ CountryCode,
9
+ CurrencyCode,
10
+ CustomData,
11
+ Interval,
12
+ Money,
13
+ PriceQuantity,
14
+ Status,
15
+ TaxMode,
16
+ TimePeriod,
17
+ UnitPriceOverride
18
+ )
19
+
20
+ from paddle_billing.Resources.Prices.Operations import CreatePrice, ListPrices, UpdatePrice, PriceIncludes
21
+ from paddle_billing.Resources.Shared.Operations import Pager
22
+
23
+ from tests.Utils.TestClient import mock_requests, test_client
24
+ from tests.Utils.ReadsFixture import ReadsFixtures
25
+
26
+
27
+ class TestPricesClient:
28
+ @mark.parametrize(
29
+ 'operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
30
+ [
31
+ (
32
+ CreatePrice(
33
+ description = 'Monthly (per seat)',
34
+ product_id = 'pro_01h7zcgmdc6tmwtjehp3sh7azf',
35
+ unit_price = Money('500', CurrencyCode.USD),
36
+ ),
37
+ ReadsFixtures.read_raw_json_fixture('request/create_basic'),
38
+ 200,
39
+ ReadsFixtures.read_raw_json_fixture('response/minimal_entity'),
40
+ '/prices',
41
+ ), (
42
+ CreatePrice(
43
+ description = "Weekly (per seat)",
44
+ product_id = "pro_01gsz4t5hdjse780zja8vvr7jg",
45
+ unit_price = Money("1000", CurrencyCode.GBP),
46
+ name = "Weekly",
47
+ tax_mode = TaxMode.AccountSetting,
48
+ trial_period = TimePeriod(Interval.Week, 1),
49
+ billing_cycle = TimePeriod(Interval.Year, 1),
50
+ quantity = PriceQuantity(1, 1),
51
+ custom_data = CustomData({"foo": "bar"}),
52
+
53
+ unit_price_overrides = [
54
+ UnitPriceOverride(
55
+ country_codes = [CountryCode.CA, CountryCode.US],
56
+ unit_price = Money("5000", CurrencyCode.USD),
57
+ ),
58
+ ],
59
+ ),
60
+ ReadsFixtures.read_raw_json_fixture('request/create_full'),
61
+ 200,
62
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
63
+ '/prices',
64
+ ),
65
+ ],
66
+ ids=[
67
+ "Create price with basic data",
68
+ "Create price with full data",
69
+ ],
70
+ )
71
+ def test_create_price_uses_expected_payload(
72
+ self,
73
+ test_client,
74
+ mock_requests,
75
+ operation,
76
+ expected_request_body,
77
+ expected_response_status,
78
+ expected_response_body,
79
+ expected_url,
80
+ ):
81
+ expected_url = f"{test_client.base_url}{expected_url}"
82
+ mock_requests.post(expected_url, status_code=expected_response_status, text=expected_response_body)
83
+
84
+ response = test_client.client.prices.create(operation)
85
+ response_json = test_client.client.prices.response.json()
86
+ request_json = test_client.client.payload
87
+ last_request = mock_requests.last_request
88
+
89
+ assert isinstance(response, Price)
90
+ assert last_request is not None
91
+ assert last_request.method == 'POST'
92
+ assert test_client.client.status_code == expected_response_status
93
+ assert unquote(last_request.url) == expected_url, \
94
+ "The URL does not match the expected URL, verify the query string is correct"
95
+ assert loads(request_json) == loads(expected_request_body), \
96
+ "The request JSON doesn't match the expected fixture JSON"
97
+ assert response_json == loads(str(expected_response_body)), \
98
+ "The response JSON doesn't match the expected fixture JSON"
99
+
100
+
101
+ @mark.parametrize(
102
+ 'operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
103
+ [
104
+ (
105
+ UpdatePrice(name='Annually'),
106
+ ReadsFixtures.read_raw_json_fixture('request/update_single'),
107
+ 200,
108
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
109
+ '/prices/pro_01h7zcgmdc6tmwtjehp3sh7azf',
110
+ ), (
111
+ UpdatePrice(name='Annually', unit_price=Money('100000', CurrencyCode.GBP)),
112
+ ReadsFixtures.read_raw_json_fixture('request/update_partial'),
113
+ 200,
114
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
115
+ '/prices/pro_01h7zcgmdc6tmwtjehp3sh7azf',
116
+ ), (
117
+ UpdatePrice(
118
+ name = 'Annually',
119
+ description = 'Annually (per seat)',
120
+ unit_price = Money('100000', CurrencyCode.GBP),
121
+ unit_price_overrides = [UnitPriceOverride([CountryCode.US], Money('200000', CurrencyCode.USD))],
122
+ quantity = PriceQuantity(1, 10),
123
+ trial_period = TimePeriod(Interval.Month, 1),
124
+ billing_cycle = TimePeriod(Interval.Year, 1),
125
+ tax_mode = TaxMode.External,
126
+ custom_data = CustomData({'features': {'reports': True}}),
127
+ ),
128
+ ReadsFixtures.read_raw_json_fixture('request/update_full'),
129
+ 200,
130
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
131
+ '/prices/pro_01h7zcgmdc6tmwtjehp3sh7azf'
132
+ ),
133
+ ],
134
+ ids=[
135
+ "Update price with single new value",
136
+ "Update price with partial new values",
137
+ "Update price with completely new values",
138
+ ],
139
+ )
140
+ def test_update_price_uses_expected_payload(
141
+ self,
142
+ test_client,
143
+ mock_requests,
144
+ operation,
145
+ expected_request_body,
146
+ expected_response_status,
147
+ expected_response_body,
148
+ expected_url,
149
+ ):
150
+ expected_url = f"{test_client.base_url}{expected_url}"
151
+ mock_requests.patch(expected_url, status_code=expected_response_status, text=expected_response_body)
152
+
153
+ response = test_client.client.prices.update('pro_01h7zcgmdc6tmwtjehp3sh7azf', operation)
154
+ response_json = test_client.client.prices.response.json()
155
+ request_json = test_client.client.payload
156
+ last_request = mock_requests.last_request
157
+
158
+ assert isinstance(response, Price)
159
+ assert last_request is not None
160
+ assert last_request.method == 'PATCH'
161
+ assert test_client.client.status_code == expected_response_status
162
+ assert unquote(last_request.url) == expected_url, \
163
+ "The URL does not match the expected URL, verify the query string is correct"
164
+ assert loads(request_json) == loads(expected_request_body), \
165
+ "The request JSON doesn't match the expected fixture JSON"
166
+ assert response_json == loads(str(expected_response_body)), \
167
+ "The response JSON doesn't match the expected fixture JSON"
168
+
169
+
170
+ @mark.parametrize(
171
+ 'operation, expected_response_status, expected_response_body, expected_url',
172
+ [
173
+ (
174
+ ListPrices(),
175
+ 200,
176
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
177
+ '/prices',
178
+ ), (
179
+ ListPrices(Pager()),
180
+ 200,
181
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
182
+ '/prices?order_by=id[asc]&per_page=50',
183
+ ), (
184
+ ListPrices(Pager(after='pro_01gsz4s0w61y0pp88528f1wvvb')),
185
+ 200,
186
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
187
+ '/prices?after=pro_01gsz4s0w61y0pp88528f1wvvb&order_by=id[asc]&per_page=50',
188
+ ), (
189
+ ListPrices(statuses=[Status.Archived]),
190
+ 200,
191
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
192
+ '/prices?status=archived',
193
+ ), (
194
+ ListPrices(ids=['pri_01gsz4s0w61y0pp88528f1wvvb']),
195
+ 200,
196
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
197
+ '/prices?id=pri_01gsz4s0w61y0pp88528f1wvvb',
198
+ ), (
199
+ ListPrices(ids=['pri_01gsz4s0w61y0pp88528f1wvvb', 'pri_01h1vjes1y163xfj1rh1tkfb65']),
200
+ 200,
201
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
202
+ '/prices?id=pri_01gsz4s0w61y0pp88528f1wvvb,pri_01h1vjes1y163xfj1rh1tkfb65',
203
+ ), (
204
+ ListPrices(product_ids=['pro_01gsz4s0w61y0pp88528f1wvvb']),
205
+ 200,
206
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
207
+ '/prices?product_id=pro_01gsz4s0w61y0pp88528f1wvvb',
208
+ ), (
209
+ ListPrices(product_ids=['pro_01gsz4s0w61y0pp88528f1wvvb', 'pro_01h1vjes1y163xfj1rh1tkfb65']),
210
+ 200,
211
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
212
+ '/prices?product_id=pro_01gsz4s0w61y0pp88528f1wvvb,pro_01h1vjes1y163xfj1rh1tkfb65',
213
+ ), (
214
+ ListPrices(recurring=True),
215
+ 200,
216
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
217
+ '/prices?recurring=true',
218
+ ), (
219
+ ListPrices(includes=[PriceIncludes.Product]),
220
+ 200,
221
+ ReadsFixtures.read_raw_json_fixture('response/list_default'),
222
+ '/prices?include=product',
223
+ ),
224
+ ],
225
+ ids=[
226
+ "List prices without pagination",
227
+ "List prices with default pagination",
228
+ "List paginated prices after specified product id",
229
+ "List prices filtered by status",
230
+ "List prices filtered by id",
231
+ "List prices filtered by multiple ids",
232
+ "List prices filtered by product id",
233
+ "List prices filtered by multiple product ids",
234
+ "List prices filtered by recurring prices",
235
+ "List prices with includes",
236
+ ],
237
+ )
238
+ def test_list_prices_returns_expected_response(
239
+ self,
240
+ test_client,
241
+ mock_requests,
242
+ operation,
243
+ expected_response_status,
244
+ expected_response_body,
245
+ expected_url,
246
+ ):
247
+ expected_url = f"{test_client.base_url}{expected_url}"
248
+ mock_requests.get(expected_url, status_code=expected_response_status)
249
+
250
+ response = test_client.client.prices.list(operation)
251
+ last_request = mock_requests.last_request
252
+
253
+ assert isinstance(response, PriceCollection)
254
+ assert last_request is not None
255
+ assert last_request.method == 'GET'
256
+ assert test_client.client.status_code == expected_response_status
257
+ assert unquote(last_request.url) == expected_url, \
258
+ "The URL does not match the expected URL, verify the query string is correct"
259
+
260
+
261
+ @mark.parametrize(
262
+ 'price_id, includes, expected_response_status, expected_response_body, expected_url',
263
+ [
264
+ (
265
+ 'pri_01h7zcgmdc6tmwtjehp3sh7azf',
266
+ None,
267
+ 200,
268
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
269
+ '/prices/pri_01h7zcgmdc6tmwtjehp3sh7azf',
270
+ ), (
271
+ 'pri_01h7zcgmdc6tmwtjehp3sh7azf',
272
+ [PriceIncludes.Product],
273
+ 200,
274
+ ReadsFixtures.read_raw_json_fixture('response/full_entity_with_includes'),
275
+ '/prices/pri_01h7zcgmdc6tmwtjehp3sh7azf?include=product',
276
+ ),
277
+ ],
278
+ ids=[
279
+ "Get price",
280
+ "Get price with includes",
281
+ ],
282
+ )
283
+ def test_get_prices_returns_expected_response(
284
+ self,
285
+ test_client,
286
+ mock_requests,
287
+ price_id,
288
+ includes,
289
+ expected_response_status,
290
+ expected_response_body,
291
+ expected_url,
292
+ ):
293
+ expected_url = f"{test_client.base_url}{expected_url}"
294
+ mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
295
+
296
+ response = test_client.client.prices.get(price_id, includes=includes)
297
+ response_json = test_client.client.prices.response.json()
298
+ last_request = mock_requests.last_request
299
+
300
+ assert isinstance(response, Price)
301
+ assert last_request is not None
302
+ assert last_request.method == 'GET'
303
+ assert test_client.client.status_code == expected_response_status
304
+ assert unquote(last_request.url) == expected_url, \
305
+ "The URL does not match the expected URL, verify the query string is correct"
306
+ assert response_json == loads(str(expected_response_body)), \
307
+ "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
File without changes
@@ -0,0 +1,92 @@
1
+ from json import loads
2
+ from pytest import mark
3
+ from urllib.parse import unquote
4
+
5
+ from paddle_billing.Entities.PricePreview import PricePreview
6
+ from paddle_billing.Entities.PricingPreviews import PricePreviewItem
7
+ from paddle_billing.Entities.Shared import AddressPreview, CountryCode, CurrencyCode
8
+
9
+ from paddle_billing.Resources.PricingPreviews.Operations import PreviewPrice
10
+
11
+ from tests.Utils.TestClient import mock_requests, test_client
12
+ from tests.Utils.ReadsFixture import ReadsFixtures
13
+
14
+
15
+ class TestPricingPreviewsClient:
16
+ @mark.parametrize(
17
+ 'operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
18
+ [
19
+ (
20
+ PreviewPrice([PricePreviewItem('pri_01gsz8z1q1n00f12qt82y31smh', 20)]),
21
+ ReadsFixtures.read_raw_json_fixture('request/preview_prices_minimal'),
22
+ 200,
23
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
24
+ '/pricing-preview',
25
+ ), (
26
+ PreviewPrice(
27
+ [
28
+ PricePreviewItem('pri_01gsz8z1q1n00f12qt82y31smh', 20),
29
+ PricePreviewItem('pri_01gsz98e27ak2tyhexptwc58yk', 1),
30
+ ],
31
+ currency_code = CurrencyCode.USD,
32
+ discount_id = 'dsc_01gtgztp8fpchantd5g1wrksa3',
33
+ customer_ip_address = '34.232.58.13',
34
+ ),
35
+ ReadsFixtures.read_raw_json_fixture('request/preview_prices_multiple'),
36
+ 200,
37
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
38
+ '/pricing-preview',
39
+ ), (
40
+ PreviewPrice(
41
+ [
42
+ PricePreviewItem('pri_01gsz8z1q1n00f12qt82y31smh', 20),
43
+ PricePreviewItem('pri_01gsz98e27ak2tyhexptwc58yk', 1),
44
+ ],
45
+ customer_id = 'ctm_01h25m0sar5845yv5j8zj5xwe1',
46
+ address_id = 'add_01h848pep46enq8y372x7maj0p',
47
+ business_id = 'biz_01hfvpm3fj1my86qqs1c32mzsp',
48
+ currency_code = CurrencyCode.USD,
49
+ discount_id = 'dsc_01gtgztp8fpchantd5g1wrksa3',
50
+ address = AddressPreview('20149', CountryCode.US),
51
+ customer_ip_address = '34.232.58.13',
52
+ ),
53
+ ReadsFixtures.read_raw_json_fixture('request/preview_prices_full'),
54
+ 200,
55
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
56
+ '/pricing-preview',
57
+ ),
58
+ ],
59
+ ids=[
60
+ "Preview a single price",
61
+ "Preview multiple prices",
62
+ "Preview multiple prices with full data",
63
+ ],
64
+ )
65
+ def test_create_discount_uses_expected_payload(
66
+ self,
67
+ test_client,
68
+ mock_requests,
69
+ operation,
70
+ expected_request_body,
71
+ expected_response_status,
72
+ expected_response_body,
73
+ expected_url,
74
+ ):
75
+ expected_url = f"{test_client.base_url}{expected_url}"
76
+ mock_requests.post(expected_url, status_code=expected_response_status, text=expected_response_body)
77
+
78
+ response = test_client.client.pricing_previews.preview_prices(operation)
79
+ response_json = test_client.client.pricing_previews.response.json()
80
+ request_json = test_client.client.payload
81
+ last_request = mock_requests.last_request
82
+
83
+ assert isinstance(response, PricePreview)
84
+ assert last_request is not None
85
+ assert last_request.method == 'POST'
86
+ assert test_client.client.status_code == expected_response_status
87
+ assert unquote(last_request.url) == expected_url, \
88
+ "The URL does not match the expected URL, verify the query string is correct"
89
+ assert loads(request_json) == loads(expected_request_body), \
90
+ "The request JSON doesn't match the expected fixture JSON"
91
+ assert response_json == loads(str(expected_response_body)), \
92
+ "The response JSON doesn't match the expected fixture JSON"
File without changes
@@ -0,0 +1,271 @@
1
+ from json import loads
2
+ from pytest import mark
3
+ from urllib.parse import unquote
4
+
5
+ from paddle_billing.Entities.Collections import ProductCollection
6
+ from paddle_billing.Entities.Product import Product
7
+ from paddle_billing.Entities.Shared import CustomData, Status, TaxCategory
8
+
9
+ from paddle_billing.Resources.Products.Operations import CreateProduct, ListProducts, UpdateProduct, ProductIncludes
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 TestProductsClient:
17
+ @mark.parametrize(
18
+ 'operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
19
+ [
20
+ (
21
+ CreateProduct(
22
+ name = 'ChatApp Basic',
23
+ tax_category = TaxCategory.Standard,
24
+ ),
25
+ ReadsFixtures.read_raw_json_fixture('request/create_basic'),
26
+ 200,
27
+ ReadsFixtures.read_raw_json_fixture('response/minimal_entity'),
28
+ '/products',
29
+ ), (
30
+ CreateProduct(
31
+ name = 'ChatApp Full',
32
+ tax_category = TaxCategory.Standard,
33
+ description = 'Spend more time engaging with students with ChataApp Education.',
34
+ image_url = 'https://paddle-sandbox.s3.amazonaws.com/user/10889/2nmP8MQSret0aWeDemRw_icon1.png',
35
+ custom_data = CustomData({
36
+ 'features': {
37
+ 'reports': True,
38
+ 'crm': False,
39
+ 'data_retention': True,
40
+ },
41
+ }),
42
+ ),
43
+ ReadsFixtures.read_raw_json_fixture('request/create_full'),
44
+ 200,
45
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
46
+ '/products',
47
+ ),
48
+ ],
49
+ ids=[
50
+ "Create product with basic data",
51
+ "Create product with full data",
52
+ ],
53
+ )
54
+ def test_create_product_uses_expected_payload(
55
+ self,
56
+ test_client,
57
+ mock_requests,
58
+ operation,
59
+ expected_request_body,
60
+ expected_response_status,
61
+ expected_response_body,
62
+ expected_url,
63
+ ):
64
+ expected_url = f"{test_client.base_url}{expected_url}"
65
+ mock_requests.post(expected_url, status_code=expected_response_status, text=expected_response_body)
66
+
67
+ response = test_client.client.products.create(operation)
68
+ response_json = test_client.client.products.response.json()
69
+ request_json = test_client.client.payload
70
+ last_request = mock_requests.last_request
71
+
72
+ assert isinstance(response, Product)
73
+ assert last_request is not None
74
+ assert last_request.method == 'POST'
75
+ assert test_client.client.status_code == expected_response_status
76
+ assert unquote(last_request.url) == expected_url, \
77
+ "The URL does not match the expected URL, verify the query string is correct"
78
+ assert loads(request_json) == loads(expected_request_body), \
79
+ "The request JSON doesn't match the expected fixture JSON"
80
+ assert response_json == loads(str(expected_response_body)), \
81
+ "The response JSON doesn't match the expected fixture JSON"
82
+
83
+
84
+ @mark.parametrize(
85
+ 'operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
86
+ [
87
+ (
88
+ UpdateProduct(name='ChatApp Pro'),
89
+ ReadsFixtures.read_raw_json_fixture('request/update_single'),
90
+ 200,
91
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
92
+ '/products/pro_01h7zcgmdc6tmwtjehp3sh7azf',
93
+ ), (
94
+ UpdateProduct(name='ChatApp Pro', tax_category=TaxCategory.Saas),
95
+ ReadsFixtures.read_raw_json_fixture('request/update_partial'),
96
+ 200,
97
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
98
+ '/products/pro_01h7zcgmdc6tmwtjehp3sh7azf',
99
+ ), (
100
+ UpdateProduct(
101
+ name = 'ChatApp Pro',
102
+ tax_category = TaxCategory.Saas,
103
+ description = 'Spend more time engaging with students with ChatApp Pro.',
104
+ image_url = 'https://paddle-sandbox.s3.amazonaws.com/pro.png',
105
+ custom_data = CustomData({
106
+ 'features': {
107
+ 'reports': True,
108
+ 'crm': True,
109
+ 'data_retention': True,
110
+ },
111
+ }),
112
+ ),
113
+ ReadsFixtures.read_raw_json_fixture('request/update_full'),
114
+ 200,
115
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
116
+ '/products/pro_01h7zcgmdc6tmwtjehp3sh7azf',
117
+ ),
118
+ ],
119
+ ids=[
120
+ "Update product with single new value",
121
+ "Update product with partial new values",
122
+ "Update product with completely new values",
123
+ ],
124
+ )
125
+ def test_update_product_uses_expected_payload(
126
+ self,
127
+ test_client,
128
+ mock_requests,
129
+ operation,
130
+ expected_request_body,
131
+ expected_response_status,
132
+ expected_response_body,
133
+ expected_url,
134
+ ):
135
+ expected_url = f"{test_client.base_url}{expected_url}"
136
+ mock_requests.patch(expected_url, status_code=expected_response_status, text=expected_response_body)
137
+
138
+ response = test_client.client.products.update('pro_01h7zcgmdc6tmwtjehp3sh7azf', operation)
139
+ response_json = test_client.client.products.response.json()
140
+ request_json = test_client.client.payload
141
+ last_request = mock_requests.last_request
142
+
143
+ assert isinstance(response, Product)
144
+ assert last_request is not None
145
+ assert last_request.method == 'PATCH'
146
+ assert test_client.client.status_code == expected_response_status
147
+ assert unquote(last_request.url) == expected_url, \
148
+ "The URL does not match the expected URL, verify the query string is correct"
149
+ assert loads(request_json) == loads(expected_request_body), \
150
+ "The request JSON doesn't match the expected fixture JSON"
151
+ assert response_json == loads(str(expected_response_body)), \
152
+ "The response JSON doesn't match the expected fixture JSON"
153
+
154
+
155
+ @mark.parametrize(
156
+ 'operation, expected_response_status, expected_url',
157
+ [
158
+ (
159
+ ListProducts(),
160
+ 200,
161
+ '/products'
162
+ ), (
163
+ ListProducts(Pager()),
164
+ 200,
165
+ '/products?order_by=id[asc]&per_page=50'
166
+ ), (
167
+ ListProducts(Pager(after='pro_01gsz4s0w61y0pp88528f1wvvb')),
168
+ 200,
169
+ '/products?after=pro_01gsz4s0w61y0pp88528f1wvvb&order_by=id[asc]&per_page=50'
170
+ ), (
171
+ ListProducts(statuses=[Status.Archived]),
172
+ 200,
173
+ '/products?status=archived'
174
+ ), (
175
+ ListProducts(ids=['pro_01gsz4s0w61y0pp88528f1wvvb']),
176
+ 200,
177
+ '/products?id=pro_01gsz4s0w61y0pp88528f1wvvb'
178
+ ), (
179
+ ListProducts(ids=['pro_01gsz4s0w61y0pp88528f1wvvb', 'pro_01h1vjes1y163xfj1rh1tkfb65']),
180
+ 200,
181
+ '/products?id=pro_01gsz4s0w61y0pp88528f1wvvb,pro_01h1vjes1y163xfj1rh1tkfb65'
182
+ ), (
183
+ ListProducts(tax_categories=[TaxCategory.DigitalGoods, TaxCategory.Standard]),
184
+ 200,
185
+ '/products?tax_category=digital-goods,standard'
186
+ ), (
187
+ ListProducts(includes=[ProductIncludes.Prices]),
188
+ 200,
189
+ '/products?include=prices'
190
+ ),
191
+ ],
192
+ ids=[
193
+ "List products without pagination",
194
+ "List products with default pagination",
195
+ "List paginated products after specified product id",
196
+ "List products filtered by status",
197
+ "List products filtered by id",
198
+ "List products filtered by multiple ids",
199
+ "List products filtered by tax categories",
200
+ "List products with includes",
201
+ ],
202
+ )
203
+ def test_list_products_returns_expected_response(
204
+ self,
205
+ test_client,
206
+ mock_requests,
207
+ operation,
208
+ expected_response_status,
209
+ expected_url,
210
+ ):
211
+ expected_url = f"{test_client.base_url}{expected_url}"
212
+ mock_requests.get(expected_url, status_code=expected_response_status)
213
+
214
+ response = test_client.client.products.list(operation)
215
+ last_request = mock_requests.last_request
216
+
217
+ assert isinstance(response, ProductCollection)
218
+ assert last_request is not None
219
+ assert last_request.method == 'GET'
220
+ assert test_client.client.status_code == expected_response_status
221
+ assert unquote(last_request.url) == expected_url, \
222
+ "The URL does not match the expected URL, verify the query string is correct"
223
+
224
+
225
+ @mark.parametrize(
226
+ 'product_id, includes, expected_response_status, expected_response_body, expected_url',
227
+ [
228
+ (
229
+ 'pro_01h7zcgmdc6tmwtjehp3sh7azf',
230
+ None,
231
+ 200,
232
+ ReadsFixtures.read_raw_json_fixture('response/full_entity'),
233
+ '/products/pro_01h7zcgmdc6tmwtjehp3sh7azf'
234
+ ), (
235
+ 'pro_01h7zcgmdc6tmwtjehp3sh7azf',
236
+ [ProductIncludes.Prices],
237
+ 200,
238
+ ReadsFixtures.read_raw_json_fixture('response/full_entity_with_includes'),
239
+ '/products/pro_01h7zcgmdc6tmwtjehp3sh7azf?include=prices'
240
+ ),
241
+ ],
242
+ ids=[
243
+ "Get product",
244
+ "Get product with includes",
245
+ ],
246
+ )
247
+ def test_get_products_returns_expected_response(
248
+ self,
249
+ test_client,
250
+ mock_requests,
251
+ product_id,
252
+ includes,
253
+ expected_response_status,
254
+ expected_response_body,
255
+ expected_url,
256
+ ):
257
+ expected_url = f"{test_client.base_url}{expected_url}"
258
+ mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
259
+
260
+ response = test_client.client.products.get(product_id, includes=includes)
261
+ response_json = test_client.client.products.response.json()
262
+ last_request = mock_requests.last_request
263
+
264
+ assert isinstance(response, Product) if includes else isinstance(response, Product)
265
+ assert last_request is not None
266
+ assert last_request.method == 'GET'
267
+ assert test_client.client.status_code == expected_response_status
268
+ assert unquote(last_request.url) == expected_url, \
269
+ "The URL does not match the expected URL, verify the query string is correct"
270
+ assert response_json == loads(str(expected_response_body)), \
271
+ "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
File without changes