paddle-python-sdk 1.8.0__py3-none-any.whl → 1.9.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.
paddle_billing/Client.py CHANGED
@@ -200,7 +200,7 @@ class Client:
200
200
  "Authorization": f"Bearer {self.__api_key}",
201
201
  "Content-Type": "application/json",
202
202
  "Paddle-Version": str(self.use_api_version),
203
- "User-Agent": "PaddleSDK/python 1.8.0",
203
+ "User-Agent": "PaddleSDK/python 1.9.0",
204
204
  }
205
205
  )
206
206
 
@@ -25,6 +25,7 @@ class EventTypeName(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
25
25
  DiscountImported: "EventTypeName" = "discount.imported"
26
26
  DiscountUpdated: "EventTypeName" = "discount.updated"
27
27
  DiscountGroupCreated: "EventTypeName" = "discount_group.created"
28
+ DiscountGroupUpdated: "EventTypeName" = "discount_group.updated"
28
29
  InvoiceCanceled: "EventTypeName" = "invoice.canceled"
29
30
  InvoiceCreated: "EventTypeName" = "invoice.created"
30
31
  InvoiceIssued: "EventTypeName" = "invoice.issued"
@@ -18,6 +18,8 @@ class TransactionPayoutTotals:
18
18
  earnings: str | None
19
19
  currency_code: CurrencyCodePayouts
20
20
  credit_to_balance: str
21
+ exchange_rate: str
22
+ fee_rate: str
21
23
 
22
24
  @staticmethod
23
25
  def from_dict(data: dict[str, Any]) -> TransactionPayoutTotals:
@@ -33,4 +35,6 @@ class TransactionPayoutTotals:
33
35
  earnings=data.get("earnings"),
34
36
  currency_code=CurrencyCodePayouts(data["currency_code"]),
35
37
  credit_to_balance=data["credit_to_balance"],
38
+ exchange_rate=data["exchange_rate"],
39
+ fee_rate=data["fee_rate"],
36
40
  )
@@ -15,6 +15,7 @@ class TransactionPayoutTotalsAdjusted:
15
15
  chargeback_fee: ChargebackFee
16
16
  earnings: str
17
17
  currency_code: CurrencyCodePayouts
18
+ exchange_rate: str
18
19
 
19
20
  @staticmethod
20
21
  def from_dict(data: dict[str, Any]) -> TransactionPayoutTotalsAdjusted:
@@ -26,4 +27,5 @@ class TransactionPayoutTotalsAdjusted:
26
27
  chargeback_fee=ChargebackFee.from_dict(data["chargeback_fee"]),
27
28
  earnings=data["earnings"],
28
29
  currency_code=CurrencyCodePayouts(data["currency_code"]),
30
+ exchange_rate=data["exchange_rate"],
29
31
  )
@@ -18,6 +18,8 @@ class TransactionPayoutTotals:
18
18
  earnings: str | None
19
19
  currency_code: CurrencyCodePayouts
20
20
  credit_to_balance: str
21
+ exchange_rate: str | None
22
+ fee_rate: str | None
21
23
 
22
24
  @staticmethod
23
25
  def from_dict(data: dict[str, Any]) -> TransactionPayoutTotals:
@@ -33,4 +35,6 @@ class TransactionPayoutTotals:
33
35
  earnings=data.get("earnings"),
34
36
  currency_code=CurrencyCodePayouts(data["currency_code"]),
35
37
  credit_to_balance=data["credit_to_balance"],
38
+ exchange_rate=data.get("exchange_rate"),
39
+ fee_rate=data.get("fee_rate"),
36
40
  )
@@ -15,6 +15,7 @@ class TransactionPayoutTotalsAdjusted:
15
15
  chargeback_fee: ChargebackFee
16
16
  earnings: str
17
17
  currency_code: CurrencyCodePayouts
18
+ exchange_rate: str | None
18
19
 
19
20
  @staticmethod
20
21
  def from_dict(data: dict[str, Any]) -> TransactionPayoutTotalsAdjusted:
@@ -26,4 +27,5 @@ class TransactionPayoutTotalsAdjusted:
26
27
  chargeback_fee=ChargebackFee.from_dict(data["chargeback_fee"]),
27
28
  earnings=data["earnings"],
28
29
  currency_code=CurrencyCodePayouts(data["currency_code"]),
30
+ exchange_rate=data.get("exchange_rate"),
29
31
  )
@@ -0,0 +1,17 @@
1
+ from datetime import datetime
2
+
3
+ from paddle_billing.Entities.Event import Event
4
+ from paddle_billing.Entities.Events import EventTypeName
5
+
6
+ from paddle_billing.Notifications.Entities.DiscountGroup import DiscountGroup
7
+
8
+
9
+ class DiscountGroupUpdated(Event):
10
+ def __init__(
11
+ self,
12
+ event_id: str,
13
+ event_type: EventTypeName,
14
+ occurred_at: datetime,
15
+ data: DiscountGroup,
16
+ ):
17
+ super().__init__(event_id, event_type, occurred_at, data)
@@ -1,8 +1,12 @@
1
- from paddle_billing.Resources.DiscountGroups.Operations import CreateDiscountGroup, ListDiscountGroups
1
+ from paddle_billing.Resources.DiscountGroups.Operations import (
2
+ CreateDiscountGroup,
3
+ ListDiscountGroups,
4
+ UpdateDiscountGroup,
5
+ )
2
6
  from paddle_billing.ResponseParser import ResponseParser
3
7
 
4
8
  from paddle_billing.Entities.Collections import Paginator, DiscountGroupCollection
5
- from paddle_billing.Entities.DiscountGroup import DiscountGroup
9
+ from paddle_billing.Entities.DiscountGroup import DiscountGroup, DiscountGroupStatus
6
10
 
7
11
  from typing import TYPE_CHECKING
8
12
 
@@ -26,8 +30,23 @@ class DiscountGroupsClient:
26
30
  parser.get_list(), Paginator(self.client, parser.get_pagination(), DiscountGroupCollection)
27
31
  )
28
32
 
33
+ def get(self, discount_group_id: str) -> DiscountGroup:
34
+ self.response = self.client.get_raw(f"/discount-groups/{discount_group_id}")
35
+ parser = ResponseParser(self.response)
36
+
37
+ return DiscountGroup.from_dict(parser.get_dict())
38
+
29
39
  def create(self, operation: CreateDiscountGroup) -> DiscountGroup:
30
40
  self.response = self.client.post_raw("/discount-groups", operation)
31
41
  parser = ResponseParser(self.response)
32
42
 
33
43
  return DiscountGroup.from_dict(parser.get_dict())
44
+
45
+ def update(self, discount_group_id: str, operation: UpdateDiscountGroup) -> DiscountGroup:
46
+ self.response = self.client.patch_raw(f"/discount-groups/{discount_group_id}", operation)
47
+ parser = ResponseParser(self.response)
48
+
49
+ return DiscountGroup.from_dict(parser.get_dict())
50
+
51
+ def archive(self, discount_group_id: str) -> DiscountGroup:
52
+ return self.update(discount_group_id, UpdateDiscountGroup(status=DiscountGroupStatus.Archived))
@@ -0,0 +1,11 @@
1
+ from dataclasses import dataclass
2
+
3
+ from paddle_billing.Undefined import Undefined
4
+ from paddle_billing.Entities.DiscountGroup import DiscountGroupStatus
5
+ from paddle_billing.Operation import Operation
6
+
7
+
8
+ @dataclass
9
+ class UpdateDiscountGroup(Operation):
10
+ name: str | Undefined = Undefined()
11
+ status: DiscountGroupStatus | Undefined = Undefined()
@@ -1,2 +1,3 @@
1
1
  from paddle_billing.Resources.DiscountGroups.Operations.CreateDiscountGroup import CreateDiscountGroup
2
2
  from paddle_billing.Resources.DiscountGroups.Operations.ListDiscountGroups import ListDiscountGroups
3
+ from paddle_billing.Resources.DiscountGroups.Operations.UpdateDiscountGroup import UpdateDiscountGroup
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: paddle-python-sdk
3
- Version: 1.8.0
3
+ Version: 1.9.0
4
4
  Summary: Paddle's Python SDK for Paddle Billing
5
5
  Home-page: https://developer.paddle.com/api-reference/overview
6
6
  Author: Paddle and contributors
@@ -5,7 +5,7 @@ examples/event_polling.py,sha256=580dg_8CFrSCA89Mr1ny4V1gtB3-hk-LfePTbI7DT5w,217
5
5
  examples/get_products.py,sha256=4V7ZG1SH6Oxojufbtzm_TMySw4cOBMQ99mgQK_hlwFQ,1875
6
6
  examples/logger.py,sha256=AxmQmMrsM0ZqMIUnh6iARiczL4S4F9OqQcOu-67owNg,1042
7
7
  examples/webhook_verification.py,sha256=qkNscNdNZUAgxEIk83tCiljN2VmfePZ_k8zTliKz2QY,1205
8
- paddle_billing/Client.py,sha256=SUq5XIRZFWssz0hTRWMkmJZ_iV6s6FYKYMy54oH19Co,9270
8
+ paddle_billing/Client.py,sha256=295xfeguUuIjVCrSgQUgAjXhT_PYABvFzNr97LR0Viw,9270
9
9
  paddle_billing/EnumStringify.py,sha256=iDvKULZat3jx9A-_PhvoN6CbFGf2pyxrQeYZxqX9n8M,48
10
10
  paddle_billing/Environment.py,sha256=sY4nrJUwlTugsZKncieAnvfCojqCcKWi4X7rFzjFeSQ,417
11
11
  paddle_billing/FiltersNone.py,sha256=ErOjaTfxtELXrXdxUvFF9DJI_Yl31iseO4K56qTDR54,303
@@ -99,7 +99,7 @@ paddle_billing/Entities/Discounts/DiscountMode.py,sha256=hzk_00WsxvhJOFfbBywzlSH
99
99
  paddle_billing/Entities/Discounts/DiscountStatus.py,sha256=ss0Btu04U7NEXYgWxlnkUOWINjSXILu67LWEgLb1DaA,304
100
100
  paddle_billing/Entities/Discounts/DiscountType.py,sha256=7JQCM_dN2PGHSiA-jzBHTIRVMVTRFKdHAMKxDxpQgf0,270
101
101
  paddle_billing/Entities/Discounts/__init__.py,sha256=tmYgP8Cw5hVZ_fe1yxeR53AIGmdeXzjYKYxudeqG-SU,220
102
- paddle_billing/Entities/Events/EventTypeName.py,sha256=nbvPGbQEMvrlrDBjQfvq94sjlf0KTfQPK2QX7l0L7II,3761
102
+ paddle_billing/Entities/Events/EventTypeName.py,sha256=jnDzmqYyXep3f-vhwPQ6RJRPhwOMBDybc6vd9Q6PUVM,3830
103
103
  paddle_billing/Entities/Events/__init__.py,sha256=DBvU5TZXroY6IACIhh26VV8TWoagJAkne8e9Pz9YdPs,71
104
104
  paddle_billing/Entities/NotificationSettings/NotificationSettingTrafficSource.py,sha256=5jga7qMivQXyU55XOPMGvwsLO1wEPA0Mur40knDgEks,340
105
105
  paddle_billing/Entities/NotificationSettings/NotificationSettingType.py,sha256=zm3kpN5T5QkKp3-3JUpZphUrXCD992OkClAIahqxbns,241
@@ -181,8 +181,8 @@ paddle_billing/Entities/Shared/TransactionDetailsPreview.py,sha256=zyP9-3e5nUxW6
181
181
  paddle_billing/Entities/Shared/TransactionLineItemPreview.py,sha256=wwJLdac1t2EQ0CTUxamy6cw-qbFa2XUkbrHDhyIytUk,1154
182
182
  paddle_billing/Entities/Shared/TransactionOrigin.py,sha256=ITifdfn7H7a7LWQaztQO3H2jwba1EcDlkQSQHI580_8,525
183
183
  paddle_billing/Entities/Shared/TransactionPaymentAttempt.py,sha256=rGlKVdXk6rbxo8jo0uOyhHSzAYI9R_9M5h384BR5T3c,1421
184
- paddle_billing/Entities/Shared/TransactionPayoutTotals.py,sha256=fHVeMbbdyZbRUll95-Njs2IG3rSVcU6AYle7JvGMXKk,1046
185
- paddle_billing/Entities/Shared/TransactionPayoutTotalsAdjusted.py,sha256=9oH6Lv8kmKDVPJSYszlXVCDyZt6HkatDtcz9Q_-2Ibs,917
184
+ paddle_billing/Entities/Shared/TransactionPayoutTotals.py,sha256=ZnJQee1MkfSl_5bzRe6mEdF446agTIh3ObYtxuldrO0,1175
185
+ paddle_billing/Entities/Shared/TransactionPayoutTotalsAdjusted.py,sha256=1N0ffpZ6d6ewiej7TCuSZD58bsnbiFycA47_cdKSi8E,989
186
186
  paddle_billing/Entities/Shared/TransactionPreviewProduct.py,sha256=dfIJ_rjkUx_6UAo2vzjdYyYsRCUvRA3M65kiE1rr_vg,1439
187
187
  paddle_billing/Entities/Shared/TransactionStatus.py,sha256=k3ul97LauZd7KKIlh4IrL_RMVlzAH2aVScFCJ4WycvU,451
188
188
  paddle_billing/Entities/Shared/TransactionTotals.py,sha256=bHBEVWSRmfN0RBfREMweMRsu1o8RBP-IUORD-8Bi3DI,1011
@@ -381,8 +381,8 @@ paddle_billing/Notifications/Entities/Shared/TimePeriod.py,sha256=XimCvD9XGWISic
381
381
  paddle_billing/Notifications/Entities/Shared/Totals.py,sha256=TgZeniIflgtxvl2-5LOx3Ujpqz3jW0walV6y0I5xfgM,426
382
382
  paddle_billing/Notifications/Entities/Shared/TransactionOrigin.py,sha256=ITifdfn7H7a7LWQaztQO3H2jwba1EcDlkQSQHI580_8,525
383
383
  paddle_billing/Notifications/Entities/Shared/TransactionPaymentAttempt.py,sha256=QQhNm8USTjbwtj5fl2fN4Ab9CAqthEHV4VLqKTW8BtY,1452
384
- paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotals.py,sha256=yc5MRWhOTMnCpbSbAVRusaPI62DsowCpehWe9ed-UAg,1060
385
- paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotalsAdjusted.py,sha256=KKgISz10OhXS-hid9lZzQgAhIgw574OfI_IcOQO90Zk,945
384
+ paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotals.py,sha256=WiVxTP8LUv20DXYrb7Kmv5p2dJVYHeG7l_nyv2Wrdmc,1211
385
+ paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotalsAdjusted.py,sha256=7VfJxFklM91utJ7AF1HoZXKT50ZIaH-ZBJHMn_r9UlQ,1028
386
386
  paddle_billing/Notifications/Entities/Shared/TransactionStatus.py,sha256=k3ul97LauZd7KKIlh4IrL_RMVlzAH2aVScFCJ4WycvU,451
387
387
  paddle_billing/Notifications/Entities/Shared/TransactionTotals.py,sha256=trWwH-OL4J3FJ2qEsynyDGlJ7i2P0n2McKKntO-6PrU,1025
388
388
  paddle_billing/Notifications/Entities/Shared/TransactionTotalsAdjusted.py,sha256=Y8MEwpWycMcVfCLo5Gj5qtyMu_octISku6-p4cGwpHY,792
@@ -446,6 +446,7 @@ paddle_billing/Notifications/Events/CustomerCreated.py,sha256=vmbI3yn2jL2fVDamOY
446
446
  paddle_billing/Notifications/Events/CustomerUpdated.py,sha256=nC7X_bCLb7j4uo_ZJ_HQcHKUiYp554rHwkDzurLwFqE,455
447
447
  paddle_billing/Notifications/Events/DiscountCreated.py,sha256=w8r8aMdrPPMT4VKWq-S4S07QLFPUvT2QdO98i3TbXHE,455
448
448
  paddle_billing/Notifications/Events/DiscountGroupCreated.py,sha256=jRujwHNE3l-fYyCQLlHWY9pv5cA7IJo6Trs4kHRRth4,475
449
+ paddle_billing/Notifications/Events/DiscountGroupUpdated.py,sha256=UclrTzlsntmvLVssA-7AmyIn87yKYhFHmfQl1Eu74-c,475
449
450
  paddle_billing/Notifications/Events/DiscountImported.py,sha256=u3YbYPBIiKRly7f8KMiWGVkvzjo4lA4lDNM6kIinxv0,456
450
451
  paddle_billing/Notifications/Events/DiscountUpdated.py,sha256=aWd3IiyiuxtpxkkPhmGmZe56h0LsAGPAu800miODoR4,455
451
452
  paddle_billing/Notifications/Events/PaymentMethodDeleted.py,sha256=nSkwVe3qVZP0CGPfN_al7e8TGW-NZqNy-eEQp1qlfW4,470
@@ -519,11 +520,12 @@ paddle_billing/Resources/Customers/Operations/ListCreditBalances.py,sha256=xJ5mV
519
520
  paddle_billing/Resources/Customers/Operations/ListCustomers.py,sha256=Aqt-Y_71PYqJrR_zcBkoXbWmUQOk2jMi6J56Wlw6giE,1840
520
521
  paddle_billing/Resources/Customers/Operations/UpdateCustomer.py,sha256=fgbr9FsvdU3x8aFiQ_d-tA6GFmHOCCttJF_TC6LzmC0,473
521
522
  paddle_billing/Resources/Customers/Operations/__init__.py,sha256=-ue0-Etc7TgWe-ShIGaK428Uj_6Joj-33h9SHEa49Jg,358
522
- paddle_billing/Resources/DiscountGroups/DiscountGroupsClient.py,sha256=F9I8ff7wY8_0y3twPWS70rdcQhSF3CrG1FE5PHPkMQU,1263
523
+ paddle_billing/Resources/DiscountGroups/DiscountGroupsClient.py,sha256=RkQ246ad41jtmNPdwsVZQv-19x-kkhcGVeLUY5n9bVw,2043
523
524
  paddle_billing/Resources/DiscountGroups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
524
525
  paddle_billing/Resources/DiscountGroups/Operations/CreateDiscountGroup.py,sha256=w9GVFW3E7S7HLGUNW71LOcz3su0Z1RSamS60LcXXuaE,147
525
526
  paddle_billing/Resources/DiscountGroups/Operations/ListDiscountGroups.py,sha256=Rtf5UPkmKEcVftkulr97qnio2By1smURV6XeaR_iX-g,1115
526
- paddle_billing/Resources/DiscountGroups/Operations/__init__.py,sha256=0VXVvynwJP2dM2qMX3NbtO0TiTDwSV5UIKzFo2lAlls,204
527
+ paddle_billing/Resources/DiscountGroups/Operations/UpdateDiscountGroup.py,sha256=FR8KcgXUGDfrve7YTBG7OoCXdnSFL0NmTXqjk9UoWOA,348
528
+ paddle_billing/Resources/DiscountGroups/Operations/__init__.py,sha256=yWI79jp80fZXlwI_8eCzdmQ6k-83UVonUNbExWM-4po,307
527
529
  paddle_billing/Resources/Discounts/DiscountsClient.py,sha256=XvLZXAeubdg3dprUSiTGzOqnjk7L1cjm6fxYlnvtUYc,2035
528
530
  paddle_billing/Resources/Discounts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
529
531
  paddle_billing/Resources/Discounts/Operations/CreateDiscount.py,sha256=3qn0o_sovdwY_n8SNARRv2mPPSeb_4jYtjYCaVdwJKA,975
@@ -713,7 +715,7 @@ paddle_billing/Resources/Transactions/Operations/Update/TransactionUpdateItem.py
713
715
  paddle_billing/Resources/Transactions/Operations/Update/TransactionUpdateItemWithPrice.py,sha256=3MIhPl85ZTen-9RLLlrX-s9pktno3Eb32X8tW6hyXSg,490
714
716
  paddle_billing/Resources/Transactions/Operations/Update/UpdateBillingDetails.py,sha256=NAfwUJrT3slphzWfVQjDMElwjljde72wwMBX25Qe9YA,447
715
717
  paddle_billing/Resources/Transactions/Operations/Update/__init__.py,sha256=VL03L8n4r2ZuxGI6l7kpHksSYJSmZL6cKaO9ToTu2jo,361
716
- paddle_python_sdk-1.8.0.dist-info/licenses/LICENSE,sha256=e5Sn9mzCdpjnqCLxXpGHNKdYB6JlRSTLhN_CD4WSO6w,10770
718
+ paddle_python_sdk-1.9.0.dist-info/licenses/LICENSE,sha256=e5Sn9mzCdpjnqCLxXpGHNKdYB6JlRSTLhN_CD4WSO6w,10770
717
719
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
718
720
  tests/conftest.py,sha256=K_rWFm4jOBGVpoQP9llOwQwyYrXThbF3CBvood_hNRU,127
719
721
  tests/Functional/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -733,7 +735,7 @@ tests/Functional/Resources/CustomerPortalSessions/test_CustomerPortalSessionsCli
733
735
  tests/Functional/Resources/Customers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
734
736
  tests/Functional/Resources/Customers/test_CustomersClient.py,sha256=tWDmre025VMQuUGcK6UE12Ulh7Ju_BeprKon2bM-OLk,14755
735
737
  tests/Functional/Resources/DiscountGroups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
736
- tests/Functional/Resources/DiscountGroups/test_DiscountGroupsClient.py,sha256=cW69VzzoLfkcMqmceXw-cIfVhKafILVlljYzHBBXsco,5145
738
+ tests/Functional/Resources/DiscountGroups/test_DiscountGroupsClient.py,sha256=CwKUB-ibgfxaB8h0ibo1pqOStfb3dg_pYqq_VkwF4T4,11212
737
739
  tests/Functional/Resources/Discounts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
738
740
  tests/Functional/Resources/Discounts/test_DiscountsClient.py,sha256=vldZ40MaYw_jtyEJulbhf2bu2zdZoxo5LFndygqg6EA,17416
739
741
  tests/Functional/Resources/EventTypes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -782,7 +784,7 @@ tests/Utils/ReadsFixture.py,sha256=3CQ_8XHji3kuR28Ktlmw1Kip565UycocUytldWtuAyw,1
782
784
  tests/Utils/TestClient.py,sha256=-wc7hJMuR6WC-ukw0c7I59b5-8hj_-nzq__-2M81elg,1453
783
785
  tests/Utils/TestLogger.py,sha256=pFO9x711buRmg-8DAqpzIJP_hr21JPty1_ZQRcwoGKk,554
784
786
  tests/Utils/__init__.py,sha256=JtqJNPKqbNZ9exlpXlF3yj_9cfylPGlvopjQYi7yYTA,37
785
- paddle_python_sdk-1.8.0.dist-info/METADATA,sha256=3v-dGeq9hV-v_jR3np4ggfxqsg_fMg5JfSbEIBXRzBo,8045
786
- paddle_python_sdk-1.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
787
- paddle_python_sdk-1.8.0.dist-info/top_level.txt,sha256=9a07VPng7o5wK8VAXkl6NC30xrNbW9zff_02jHyHi4c,30
788
- paddle_python_sdk-1.8.0.dist-info/RECORD,,
787
+ paddle_python_sdk-1.9.0.dist-info/METADATA,sha256=JzoNkuVGZVzQsTcEvmQ_RyDgnoKjtBXdn-1yTsp26r8,8045
788
+ paddle_python_sdk-1.9.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
789
+ paddle_python_sdk-1.9.0.dist-info/top_level.txt,sha256=9a07VPng7o5wK8VAXkl6NC30xrNbW9zff_02jHyHi4c,30
790
+ paddle_python_sdk-1.9.0.dist-info/RECORD,,
@@ -3,10 +3,14 @@ from pytest import mark
3
3
  from urllib.parse import unquote
4
4
 
5
5
  from paddle_billing.Client import PayloadEncoder
6
- from paddle_billing.Entities.DiscountGroup import DiscountGroup
6
+ from paddle_billing.Entities.DiscountGroup import DiscountGroup, DiscountGroupStatus
7
7
  from paddle_billing.Entities.Collections import DiscountGroupCollection
8
8
 
9
- from paddle_billing.Resources.DiscountGroups.Operations import CreateDiscountGroup, ListDiscountGroups
9
+ from paddle_billing.Resources.DiscountGroups.Operations import (
10
+ CreateDiscountGroup,
11
+ ListDiscountGroups,
12
+ UpdateDiscountGroup,
13
+ )
10
14
  from paddle_billing.Resources.Shared.Operations import Pager
11
15
 
12
16
  from tests.Utils.ReadsFixture import ReadsFixtures
@@ -123,3 +127,147 @@ class TestDiscountsClient:
123
127
  assert response_json == loads(
124
128
  str(expected_response_body)
125
129
  ), "The response JSON doesn't match the expected fixture JSON"
130
+
131
+ @mark.parametrize(
132
+ "discount_group_id, operation, expected_request_body, expected_response_status, expected_response_body, expected_url",
133
+ [
134
+ (
135
+ "dsg_01gtf15svsqzgp9325ss4ebmwt",
136
+ UpdateDiscountGroup(name="Some Discount Group"),
137
+ ReadsFixtures.read_raw_json_fixture("request/update_partial"),
138
+ 200,
139
+ ReadsFixtures.read_raw_json_fixture("response/full_entity"),
140
+ "/discount-groups/dsg_01gtf15svsqzgp9325ss4ebmwt",
141
+ ),
142
+ (
143
+ "dsg_01gtf15svsqzgp9325ss4ebmwt",
144
+ UpdateDiscountGroup(name="Some Discount Group", status=DiscountGroupStatus.Archived),
145
+ ReadsFixtures.read_raw_json_fixture("request/update_full"),
146
+ 200,
147
+ ReadsFixtures.read_raw_json_fixture("response/full_entity"),
148
+ "/discount-groups/dsg_01gtf15svsqzgp9325ss4ebmwt",
149
+ ),
150
+ ],
151
+ ids=[
152
+ "Update discount group with minimal",
153
+ "Update discount with with full",
154
+ ],
155
+ )
156
+ def test_update_discount_group_uses_expected_payload(
157
+ self,
158
+ test_client,
159
+ mock_requests,
160
+ discount_group_id,
161
+ operation,
162
+ expected_request_body,
163
+ expected_response_status,
164
+ expected_response_body,
165
+ expected_url,
166
+ ):
167
+ expected_url = f"{test_client.base_url}{expected_url}"
168
+ mock_requests.patch(expected_url, status_code=expected_response_status, text=expected_response_body)
169
+
170
+ response = test_client.client.discount_groups.update(discount_group_id, operation)
171
+ response_json = test_client.client.discount_groups.response.json()
172
+ request_json = test_client.client.payload
173
+ last_request = mock_requests.last_request
174
+
175
+ assert isinstance(response, DiscountGroup)
176
+ assert last_request is not None
177
+ assert last_request.method == "PATCH"
178
+ assert test_client.client.status_code == expected_response_status
179
+ assert (
180
+ unquote(last_request.url) == expected_url
181
+ ), "The URL does not match the expected URL, verify the query string is correct"
182
+ assert loads(request_json) == loads(
183
+ expected_request_body
184
+ ), "The request JSON doesn't match the expected fixture JSON"
185
+ assert response_json == loads(
186
+ str(expected_response_body)
187
+ ), "The response JSON doesn't match the expected fixture JSON"
188
+
189
+ @mark.parametrize(
190
+ "discount_group_id, expected_request_body, expected_response_status, expected_response_body, expected_url",
191
+ [
192
+ (
193
+ "dsg_01gtf15svsqzgp9325ss4ebmwt",
194
+ ReadsFixtures.read_raw_json_fixture("request/archive"),
195
+ 200,
196
+ ReadsFixtures.read_raw_json_fixture("response/full_entity"),
197
+ "/discount-groups/dsg_01gtf15svsqzgp9325ss4ebmwt",
198
+ ),
199
+ ],
200
+ ids=[
201
+ "Archive discount group",
202
+ ],
203
+ )
204
+ def test_archive_discount_group_uses_expected_payload(
205
+ self,
206
+ test_client,
207
+ mock_requests,
208
+ discount_group_id,
209
+ expected_request_body,
210
+ expected_response_status,
211
+ expected_response_body,
212
+ expected_url,
213
+ ):
214
+ expected_url = f"{test_client.base_url}{expected_url}"
215
+ mock_requests.patch(expected_url, status_code=expected_response_status, text=expected_response_body)
216
+
217
+ response = test_client.client.discount_groups.archive(discount_group_id)
218
+ response_json = test_client.client.discount_groups.response.json()
219
+ request_json = test_client.client.payload
220
+ last_request = mock_requests.last_request
221
+
222
+ assert isinstance(response, DiscountGroup)
223
+ assert last_request is not None
224
+ assert last_request.method == "PATCH"
225
+ assert test_client.client.status_code == expected_response_status
226
+ assert (
227
+ unquote(last_request.url) == expected_url
228
+ ), "The URL does not match the expected URL, verify the query string is correct"
229
+ assert loads(request_json) == loads(
230
+ expected_request_body
231
+ ), "The request JSON doesn't match the expected fixture JSON"
232
+ assert response_json == loads(
233
+ str(expected_response_body)
234
+ ), "The response JSON doesn't match the expected fixture JSON"
235
+
236
+ @mark.parametrize(
237
+ "discount_group_id, expected_response_status, expected_response_body, expected_url",
238
+ [
239
+ (
240
+ "dsg_01gtf15svsqzgp9325ss4ebmwt",
241
+ 200,
242
+ ReadsFixtures.read_raw_json_fixture("response/full_entity"),
243
+ "/discount-groups/dsg_01gtf15svsqzgp9325ss4ebmwt",
244
+ )
245
+ ],
246
+ ids=["Get discount group"],
247
+ )
248
+ def test_get_discount_group_returns_expected_response(
249
+ self,
250
+ test_client,
251
+ mock_requests,
252
+ discount_group_id,
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.discount_groups.get(discount_group_id)
261
+ response_json = test_client.client.discount_groups.response.json()
262
+ last_request = mock_requests.last_request
263
+
264
+ assert isinstance(response, DiscountGroup)
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 (
269
+ unquote(last_request.url) == expected_url
270
+ ), "The URL does not match the expected URL, verify the query string is correct"
271
+ assert response_json == loads(
272
+ str(expected_response_body)
273
+ ), "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"