paddle-python-sdk 1.1.0__py3-none-any.whl → 1.1.2__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
@@ -202,7 +202,7 @@ class Client:
202
202
  "Authorization": f"Bearer {self.__api_key}",
203
203
  "Content-Type": "application/json",
204
204
  "Paddle-Version": str(self.use_api_version),
205
- "User-Agent": "PaddleSDK/python 1.1.0",
205
+ "User-Agent": "PaddleSDK/python 1.1.2",
206
206
  }
207
207
  )
208
208
 
@@ -3,7 +3,7 @@ from dataclasses import dataclass
3
3
 
4
4
  from paddle_billing.Entities.Entity import Entity
5
5
  from paddle_billing.Entities.EventType import EventType
6
- from paddle_billing.Entities.NotificationSettings import NotificationSettingType
6
+ from paddle_billing.Entities.NotificationSettings import NotificationSettingType, NotificationSettingTrafficSource
7
7
 
8
8
 
9
9
  @dataclass
@@ -17,6 +17,7 @@ class NotificationSetting(Entity):
17
17
  include_sensitive_fields: bool
18
18
  subscribed_events: list[EventType]
19
19
  endpoint_secret_key: str
20
+ traffic_source: NotificationSettingTrafficSource
20
21
 
21
22
  @staticmethod
22
23
  def from_dict(data: dict) -> NotificationSetting:
@@ -30,4 +31,5 @@ class NotificationSetting(Entity):
30
31
  include_sensitive_fields=data["include_sensitive_fields"],
31
32
  subscribed_events=[EventType.from_dict(event) for event in data.get("subscribed_events", [])],
32
33
  endpoint_secret_key=data["endpoint_secret_key"],
34
+ traffic_source=NotificationSettingTrafficSource(data["traffic_source"]),
33
35
  )
@@ -0,0 +1,7 @@
1
+ from paddle_billing.PaddleStrEnum import PaddleStrEnum, PaddleStrEnumMeta
2
+
3
+
4
+ class NotificationSettingTrafficSource(PaddleStrEnum, metaclass=PaddleStrEnumMeta):
5
+ All: "NotificationSettingTrafficSource" = "all"
6
+ Platform: "NotificationSettingTrafficSource" = "platform"
7
+ Simulation: "NotificationSettingTrafficSource" = "simulation"
@@ -1 +1,4 @@
1
+ from paddle_billing.Entities.NotificationSettings.NotificationSettingTrafficSource import (
2
+ NotificationSettingTrafficSource,
3
+ )
1
4
  from paddle_billing.Entities.NotificationSettings.NotificationSettingType import NotificationSettingType
@@ -16,7 +16,7 @@ class PaymentMethod(Entity):
16
16
  id: str
17
17
  customer_id: str
18
18
  address_id: str
19
- type: SavedPaymentMethodType | None
19
+ type: SavedPaymentMethodType
20
20
  card: Card | None
21
21
  paypal: Paypal | None
22
22
  origin: SavedPaymentMethodOrigin
@@ -14,7 +14,7 @@ class PaymentMethod(Entity):
14
14
  id: str
15
15
  customer_id: str
16
16
  address_id: str
17
- type: SavedPaymentMethodType | None
17
+ type: SavedPaymentMethodType
18
18
  origin: SavedPaymentMethodOrigin
19
19
  saved_at: datetime
20
20
  updated_at: datetime
@@ -15,7 +15,7 @@ class PaymentMethodDeleted(Entity):
15
15
  id: str
16
16
  customer_id: str
17
17
  address_id: str
18
- type: SavedPaymentMethodType | None
18
+ type: SavedPaymentMethodType
19
19
  origin: SavedPaymentMethodOrigin
20
20
  saved_at: datetime
21
21
  updated_at: datetime
@@ -69,7 +69,7 @@ class Subscription(Entity):
69
69
  paused_at=datetime.fromisoformat(data["paused_at"]) if data.get("paused_at") else None,
70
70
  started_at=datetime.fromisoformat(data["started_at"]) if data.get("started_at") else None,
71
71
  current_billing_period=(
72
- TimePeriod.from_dict(data["current_billing_period"]) if data.get("billing_details") else None
72
+ TimePeriod.from_dict(data["current_billing_period"]) if data.get("current_billing_period") else None
73
73
  ),
74
74
  scheduled_change=(
75
75
  SubscriptionScheduledChange.from_dict(data["scheduled_change"])
@@ -71,7 +71,7 @@ class SubscriptionCreated(Entity):
71
71
  paused_at=datetime.fromisoformat(data["paused_at"]) if data.get("paused_at") else None,
72
72
  started_at=datetime.fromisoformat(data["started_at"]) if data.get("started_at") else None,
73
73
  current_billing_period=(
74
- TimePeriod.from_dict(data["current_billing_period"]) if data.get("billing_details") else None
74
+ TimePeriod.from_dict(data["current_billing_period"]) if data.get("current_billing_period") else None
75
75
  ),
76
76
  scheduled_change=(
77
77
  SubscriptionScheduledChange.from_dict(data["scheduled_change"])
@@ -3,7 +3,7 @@ from dataclasses import dataclass
3
3
  from paddle_billing.Operation import Operation
4
4
  from paddle_billing.Undefined import Undefined
5
5
  from paddle_billing.Entities.Events import EventTypeName
6
- from paddle_billing.Entities.NotificationSettings import NotificationSettingType
6
+ from paddle_billing.Entities.NotificationSettings import NotificationSettingType, NotificationSettingTrafficSource
7
7
 
8
8
 
9
9
  @dataclass
@@ -14,3 +14,4 @@ class CreateNotificationSetting(Operation):
14
14
  type: NotificationSettingType
15
15
  include_sensitive_fields: bool
16
16
  api_version: int | Undefined = Undefined()
17
+ traffic_source: NotificationSettingTrafficSource | Undefined = Undefined()
@@ -2,15 +2,19 @@ from paddle_billing.HasParameters import HasParameters
2
2
 
3
3
  from paddle_billing.Resources.Shared.Operations import Pager
4
4
 
5
+ from paddle_billing.Entities.NotificationSettings import NotificationSettingTrafficSource
6
+
5
7
 
6
8
  class ListNotificationSettings(HasParameters):
7
9
  def __init__(
8
10
  self,
9
11
  pager: Pager | None = None,
10
12
  active: bool | None = None,
13
+ traffic_source: NotificationSettingTrafficSource | None = None,
11
14
  ):
12
15
  self.pager = pager
13
16
  self.active = active
17
+ self.traffic_source = traffic_source
14
18
 
15
19
  def get_parameters(self) -> dict:
16
20
  parameters = {}
@@ -18,5 +22,7 @@ class ListNotificationSettings(HasParameters):
18
22
  parameters.update(self.pager.get_parameters())
19
23
  if self.active is not None:
20
24
  parameters["active"] = "true" if self.active else "false"
25
+ if self.traffic_source is not None:
26
+ parameters["traffic_source"] = self.traffic_source.value
21
27
 
22
28
  return parameters
@@ -3,6 +3,7 @@ from dataclasses import dataclass
3
3
  from paddle_billing.Operation import Operation
4
4
  from paddle_billing.Undefined import Undefined
5
5
  from paddle_billing.Entities.Events import EventTypeName
6
+ from paddle_billing.Entities.NotificationSettings import NotificationSettingTrafficSource
6
7
 
7
8
 
8
9
  @dataclass
@@ -13,3 +14,4 @@ class UpdateNotificationSetting(Operation):
13
14
  api_version: int | Undefined = Undefined()
14
15
  include_sensitive_fields: bool | Undefined = Undefined()
15
16
  subscribed_events: list[EventTypeName] | Undefined = Undefined()
17
+ traffic_source: NotificationSettingTrafficSource | Undefined = Undefined()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: paddle-python-sdk
3
- Version: 1.1.0
3
+ Version: 1.1.2
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
@@ -4,7 +4,7 @@ examples/event_polling.py,sha256=580dg_8CFrSCA89Mr1ny4V1gtB3-hk-LfePTbI7DT5w,217
4
4
  examples/get_products.py,sha256=4V7ZG1SH6Oxojufbtzm_TMySw4cOBMQ99mgQK_hlwFQ,1875
5
5
  examples/logger.py,sha256=AxmQmMrsM0ZqMIUnh6iARiczL4S4F9OqQcOu-67owNg,1042
6
6
  examples/webhook_verification.py,sha256=qkNscNdNZUAgxEIk83tCiljN2VmfePZ_k8zTliKz2QY,1205
7
- paddle_billing/Client.py,sha256=kzzT-4wDo9Xxeqb6MjBOef0whF2siXMJHnJpcowHDV8,8594
7
+ paddle_billing/Client.py,sha256=bf6vfthuEdA_-1pATS7qmxGkmDwrYfaB1UJ-tEdgKJo,8594
8
8
  paddle_billing/EnumStringify.py,sha256=iDvKULZat3jx9A-_PhvoN6CbFGf2pyxrQeYZxqX9n8M,48
9
9
  paddle_billing/Environment.py,sha256=sY4nrJUwlTugsZKncieAnvfCojqCcKWi4X7rFzjFeSQ,417
10
10
  paddle_billing/FiltersNone.py,sha256=HxjE6RJb7sy6txphpZSrCTQZt1Ua0XpIz8NDLHC43zo,268
@@ -32,8 +32,8 @@ paddle_billing/Entities/EventType.py,sha256=tBKeM6hWSbbcLLSWR4yuuRBV3Y2kPNmOU_29
32
32
  paddle_billing/Entities/IPAddresses.py,sha256=ElpiJi-YSDXz7vc7OT908XL3qQH4BxrpjGZo3SJOIO8,339
33
33
  paddle_billing/Entities/Notification.py,sha256=pfFpwziRegGfr4cb5QMFZqtPafpP7AASHAmv6Ab6of4,1745
34
34
  paddle_billing/Entities/NotificationLog.py,sha256=ezWhRCVPFu1S-p-bvbWL1zxN_52dOe0loZCVGn83XFc,693
35
- paddle_billing/Entities/NotificationSetting.py,sha256=a4D9Sugwe6X2XDqicJ1aOyW7se2H5iiy5m3T0Mvu_D8,1145
36
- paddle_billing/Entities/PaymentMethod.py,sha256=GpI5s9ZqSNd6BkKhNFzEFNSMAI9O7HDdczNH96uNnZE,1175
35
+ paddle_billing/Entities/NotificationSetting.py,sha256=Gyav9M8EQ6zawLlshmpLdmjxyKaZ4KCZf2XJ8oXhQyE,1317
36
+ paddle_billing/Entities/PaymentMethod.py,sha256=aZf4lCinK7rPeWRuIUBEa_mLQ72zASAzkqfESVlKzEY,1168
37
37
  paddle_billing/Entities/Price.py,sha256=mE2n4ajmjCAXZN9BJoJtIewIreLvwGTNOJUm-VzsnOA,2256
38
38
  paddle_billing/Entities/PricePreview.py,sha256=8EJ9Li4cQrWtYoDm0088pZJbnplCs35w9mrW2zRMf7A,1328
39
39
  paddle_billing/Entities/Product.py,sha256=MUtkd80wUzj2P-osXaxltSmSnvyZ0s2ELvR7zAar0vk,1550
@@ -78,8 +78,9 @@ paddle_billing/Entities/Discounts/DiscountType.py,sha256=7JQCM_dN2PGHSiA-jzBHTIR
78
78
  paddle_billing/Entities/Discounts/__init__.py,sha256=2zGGjrklZaaWj0iAwFRvTs_87yl8TOYy6R2RcH2kT_4,148
79
79
  paddle_billing/Entities/Events/EventTypeName.py,sha256=K4JCac5Ib7xDEMedCJ2ZzRtsTFcOHsa-qLFRUAqurJ8,3022
80
80
  paddle_billing/Entities/Events/__init__.py,sha256=DBvU5TZXroY6IACIhh26VV8TWoagJAkne8e9Pz9YdPs,71
81
+ paddle_billing/Entities/NotificationSettings/NotificationSettingTrafficSource.py,sha256=5jga7qMivQXyU55XOPMGvwsLO1wEPA0Mur40knDgEks,340
81
82
  paddle_billing/Entities/NotificationSettings/NotificationSettingType.py,sha256=zm3kpN5T5QkKp3-3JUpZphUrXCD992OkClAIahqxbns,241
82
- paddle_billing/Entities/NotificationSettings/__init__.py,sha256=RtvGSG7pvbHWv7LwyoeHV7VKxzHWGILnWVDUPF1y44U,105
83
+ paddle_billing/Entities/NotificationSettings/__init__.py,sha256=OTmdXcuJiirwGjTvUkz5ZnT3wLPCszzUcbskRpMdYhU,237
83
84
  paddle_billing/Entities/Notifications/NotificationEvent.py,sha256=uehDqPUWmuIZfhGsk8oQcqAO9w5TSPlpM1iuvEjT6H0,1488
84
85
  paddle_billing/Entities/Notifications/NotificationOrigin.py,sha256=pFqjHhIlqMZZn81F-rILrRGZnJy6bv1Hr6C9hiR3eXg,232
85
86
  paddle_billing/Entities/Notifications/NotificationPayout.py,sha256=EMLVwHDnCFhjWUxtUJBUhnnRVi6Gx_kRusHfeY3V1q4,719
@@ -220,14 +221,14 @@ paddle_billing/Notifications/Entities/DateTime.py,sha256=iJLwbDZwmfHW2TgE8HRPpkw
220
221
  paddle_billing/Notifications/Entities/Discount.py,sha256=__FiaKUrfVVUDglDPbtgU3vg8kEXiOb9VG7CGjFFk7A,2046
221
222
  paddle_billing/Notifications/Entities/Entity.py,sha256=Fek0uj5QgGfLtJuRn5CJ0jXRTsxQRO6gIS5GngrCYMI,1918
222
223
  paddle_billing/Notifications/Entities/EntityDict.py,sha256=EPYzfWxPHu8uf5mbV_Fs7lkUdLXD7gCEsGq3NLzWH3I,128
223
- paddle_billing/Notifications/Entities/PaymentMethod.py,sha256=IIkEXECIojST58XdY3kmWAbWxRmP3XnI-aJb4BpGC3s,971
224
- paddle_billing/Notifications/Entities/PaymentMethodDeleted.py,sha256=84c3stm3Yc40IQ-oY5IkKngyObSZAP3ANN6DH1A9THg,1171
224
+ paddle_billing/Notifications/Entities/PaymentMethod.py,sha256=h9UuMCwfIVssnTCLdD27AW-PTHmY6BiAUcFTanJlTa4,964
225
+ paddle_billing/Notifications/Entities/PaymentMethodDeleted.py,sha256=J8H3XTnJCOJUxOKT5zlD6ZUoCHKYBPryEo_o0U4owX0,1164
225
226
  paddle_billing/Notifications/Entities/Payout.py,sha256=Zezrof-earP-RFiFopjRIIPysFOD53U1zPxmqiphZ28,683
226
227
  paddle_billing/Notifications/Entities/Price.py,sha256=CNrkC_2JabAzMFqNtTevgfCGT8lIZgxpwNDK9vkIuH8,2257
227
228
  paddle_billing/Notifications/Entities/Product.py,sha256=9JnGoO3uhcb73pv3FcPr3FMLpmZMiAmdamhrBNlgmM8,1678
228
229
  paddle_billing/Notifications/Entities/Report.py,sha256=3y31hAwPjtKLeXrkvdr6Xzqi2_C924y6nCk100KfpOw,1069
229
- paddle_billing/Notifications/Entities/Subscription.py,sha256=oCTN8t-39xIezzDTJDuAfXfNza5jFkPjRfhldhtPO0E,3428
230
- paddle_billing/Notifications/Entities/SubscriptionCreated.py,sha256=3tig0K-_WwQHqJZlv1Uqr80MtEoCa2NJxKuYhMi60R8,3542
230
+ paddle_billing/Notifications/Entities/Subscription.py,sha256=DWqzvSRLgB-GPvAaNfFXZpiXTVTFsuo_RTSXCULpQEk,3435
231
+ paddle_billing/Notifications/Entities/SubscriptionCreated.py,sha256=3bjut0UsAQuRWUQUSJJM77WU6bh8pZdU4j0_kzqeaF8,3549
231
232
  paddle_billing/Notifications/Entities/Transaction.py,sha256=R_35BgHAv6AWFy-ppGmAraTj84dMI3pEK7M66BdlhKU,2956
232
233
  paddle_billing/Notifications/Entities/UndefinedEntity.py,sha256=pvqWMXLkGXzHysRqYppYAN8MXqoE81Hth1zkkwDzY9U,287
233
234
  paddle_billing/Notifications/Entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -409,9 +410,9 @@ paddle_billing/Resources/NotificationLogs/Operations/ListNotificationLogs.py,sha
409
410
  paddle_billing/Resources/NotificationLogs/Operations/__init__.py,sha256=l1v_KIPhYuzh_A6iQqMV7qAwsXVA7ZUmJ9rj5I0dXwY,107
410
411
  paddle_billing/Resources/NotificationSettings/NotificationSettingsClient.py,sha256=H2WellbE39sWqe0fw4eGfLlWwyQAhhe2zKGGY0SORvY,2207
411
412
  paddle_billing/Resources/NotificationSettings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
412
- paddle_billing/Resources/NotificationSettings/Operations/CreateNotificationSetting.py,sha256=HgdTNmxQJ6XkgNgjcG4Eeo66wgpuHBwqOkjbCy2rfHg,525
413
- paddle_billing/Resources/NotificationSettings/Operations/ListNotificationSettings.py,sha256=zrFaeqguZyP3wwuunOMUbe03FRQMtTriVXMmBafVBAY,611
414
- paddle_billing/Resources/NotificationSettings/Operations/UpdateNotificationSetting.py,sha256=mm4xFqUPlcab_aU1MxAlLCObkv79Tbesb4v5K3T5F8k,557
413
+ paddle_billing/Resources/NotificationSettings/Operations/CreateNotificationSetting.py,sha256=eSCFN3WDAA0c57PJcCASNQb74ImU4BV0f3vT8ZyW0Uk,638
414
+ paddle_billing/Resources/NotificationSettings/Operations/ListNotificationSettings.py,sha256=sz2TT0dKYPG8UJbueuvjfXJkzIgqDQmA6JnjgHHPHVs,932
415
+ paddle_billing/Resources/NotificationSettings/Operations/UpdateNotificationSetting.py,sha256=6CV3u0LphqLuE4f8rQix2zikzv2W1YbZpNSYTfg-LCg,726
415
416
  paddle_billing/Resources/NotificationSettings/Operations/__init__.py,sha256=qdVp3OkbMefkvJ-fOuYxNtN02Oj6kskQ1QD8MCBcxXc,361
416
417
  paddle_billing/Resources/Notifications/NotificationsClient.py,sha256=k11E2qp1OIRzB9XpurN1gCMH85H5EKUHQD1d5uPycJ4,1475
417
418
  paddle_billing/Resources/Notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -552,11 +553,11 @@ tests/Functional/Resources/IPAddresses/test_IPAddressesClient.py,sha256=XpEdHyjd
552
553
  tests/Functional/Resources/NotificationLogs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
553
554
  tests/Functional/Resources/NotificationLogs/test_NotificationLogsClient.py,sha256=O70t8-DDawumaHvwiazENl2bcLabivS24MJDcpLPljc,2666
554
555
  tests/Functional/Resources/NotificationSettings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
555
- tests/Functional/Resources/NotificationSettings/test_NotificationSettingsClient.py,sha256=EbRqcQ0e1M8lfrsLKfWhzyhs4gYoZfVQzFPyDOo_qxk,16538
556
+ tests/Functional/Resources/NotificationSettings/test_NotificationSettingsClient.py,sha256=3anSxEUd4pi7r4PHA_DfLbEApsFd3n4paN6KJHuaRxU,22409
556
557
  tests/Functional/Resources/Notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
557
558
  tests/Functional/Resources/Notifications/test_NotificationsClient.py,sha256=JgGw5NV6kHi4lsh5wWM0LAilpnWZX-3xT994GaRxoqg,12734
558
559
  tests/Functional/Resources/PaymentMethods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
559
- tests/Functional/Resources/PaymentMethods/test_PaymentMethodsClient.py,sha256=U9dYiAVXcY6K-NL4lYamz7tPpGeo6OZcCnxcR6EH8LE,12046
560
+ tests/Functional/Resources/PaymentMethods/test_PaymentMethodsClient.py,sha256=wIDGk0TPg6QoFySpLulsGE4ui9ucF5dpal8QQeygCtY,12183
560
561
  tests/Functional/Resources/Prices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
561
562
  tests/Functional/Resources/Prices/test_PricesClient.py,sha256=48EtY6zhChPIel57xGQdMsfQEy3mhgMqQ5_nkwnMS6s,13024
562
563
  tests/Functional/Resources/PricingPreviews/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -581,8 +582,8 @@ tests/Utils/ReadsFixture.py,sha256=M3Ot3xHXp_C7vwttna9deLPHBAO8ml2Jb4thhHOJJ38,1
581
582
  tests/Utils/TestClient.py,sha256=-wc7hJMuR6WC-ukw0c7I59b5-8hj_-nzq__-2M81elg,1453
582
583
  tests/Utils/TestLogger.py,sha256=pFO9x711buRmg-8DAqpzIJP_hr21JPty1_ZQRcwoGKk,554
583
584
  tests/Utils/__init__.py,sha256=JtqJNPKqbNZ9exlpXlF3yj_9cfylPGlvopjQYi7yYTA,37
584
- paddle_python_sdk-1.1.0.dist-info/LICENSE,sha256=e5Sn9mzCdpjnqCLxXpGHNKdYB6JlRSTLhN_CD4WSO6w,10770
585
- paddle_python_sdk-1.1.0.dist-info/METADATA,sha256=7mC1TTC4ghCUhNms-i_U3n7Z1QpDaovdj_g7XFSaA6k,7392
586
- paddle_python_sdk-1.1.0.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
587
- paddle_python_sdk-1.1.0.dist-info/top_level.txt,sha256=9a07VPng7o5wK8VAXkl6NC30xrNbW9zff_02jHyHi4c,30
588
- paddle_python_sdk-1.1.0.dist-info/RECORD,,
585
+ paddle_python_sdk-1.1.2.dist-info/LICENSE,sha256=e5Sn9mzCdpjnqCLxXpGHNKdYB6JlRSTLhN_CD4WSO6w,10770
586
+ paddle_python_sdk-1.1.2.dist-info/METADATA,sha256=06dDCKvNoN0Bnzq2YtwPWhnxk7AN8a0KgH6oJ-VbLWs,7392
587
+ paddle_python_sdk-1.1.2.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
588
+ paddle_python_sdk-1.1.2.dist-info/top_level.txt,sha256=9a07VPng7o5wK8VAXkl6NC30xrNbW9zff_02jHyHi4c,30
589
+ paddle_python_sdk-1.1.2.dist-info/RECORD,,
@@ -5,7 +5,7 @@ from urllib.parse import unquote
5
5
  from paddle_billing.Entities.Collections import NotificationSettingCollection
6
6
  from paddle_billing.Entities.Events import EventTypeName
7
7
  from paddle_billing.Entities.NotificationSetting import NotificationSetting
8
- from paddle_billing.Entities.NotificationSettings import NotificationSettingType
8
+ from paddle_billing.Entities.NotificationSettings import NotificationSettingType, NotificationSettingTrafficSource
9
9
 
10
10
  from paddle_billing.Resources.Shared.Operations import Pager
11
11
 
@@ -71,10 +71,61 @@ class TestNotificationSettingsClient:
71
71
  ReadsFixtures.read_raw_json_fixture("response/full_entity"),
72
72
  "/notification-settings",
73
73
  ),
74
+ (
75
+ CreateNotificationSetting(
76
+ description="Slack notifications",
77
+ type=NotificationSettingType.Url,
78
+ destination="https://hooks.slack.com/example",
79
+ include_sensitive_fields=False,
80
+ subscribed_events=[
81
+ EventTypeName.TransactionCreated,
82
+ ],
83
+ traffic_source=NotificationSettingTrafficSource.All,
84
+ ),
85
+ ReadsFixtures.read_raw_json_fixture("request/create_traffic_all"),
86
+ 200,
87
+ ReadsFixtures.read_raw_json_fixture("response/minimal_entity"),
88
+ "/notification-settings",
89
+ ),
90
+ (
91
+ CreateNotificationSetting(
92
+ description="Slack notifications",
93
+ type=NotificationSettingType.Url,
94
+ destination="https://hooks.slack.com/example",
95
+ include_sensitive_fields=False,
96
+ subscribed_events=[
97
+ EventTypeName.TransactionCreated,
98
+ ],
99
+ traffic_source=NotificationSettingTrafficSource.Platform,
100
+ ),
101
+ ReadsFixtures.read_raw_json_fixture("request/create_traffic_platform"),
102
+ 200,
103
+ ReadsFixtures.read_raw_json_fixture("response/minimal_entity"),
104
+ "/notification-settings",
105
+ ),
106
+ (
107
+ CreateNotificationSetting(
108
+ description="Slack notifications",
109
+ type=NotificationSettingType.Url,
110
+ destination="https://hooks.slack.com/example",
111
+ include_sensitive_fields=False,
112
+ subscribed_events=[
113
+ EventTypeName.TransactionCreated,
114
+ ],
115
+ traffic_source=NotificationSettingTrafficSource.Simulation,
116
+ ),
117
+ ReadsFixtures.read_raw_json_fixture("request/create_traffic_simulation"),
118
+ 200,
119
+ ReadsFixtures.read_raw_json_fixture("response/minimal_entity"),
120
+ "/notification-settings",
121
+ ),
74
122
  ],
75
123
  ids=[
76
124
  "Create notification-setting with basic data",
77
125
  "Create notification-setting with full data",
126
+ "Create notification-setting for all traffic",
127
+ "Create notification-setting for platform traffic",
128
+ "Create notification-setting for simulation traffic",
78
129
  ],
79
130
  )
80
131
  def test_create_notification_setting_uses_expected_payload(
@@ -158,11 +209,44 @@ class TestNotificationSettingsClient:
158
209
  ReadsFixtures.read_raw_json_fixture("response/full_entity"),
159
210
  "/notification-settings/ntfset_01gkpjp8bkm3tm53kdgkx6sms7",
160
211
  ),
212
+ (
213
+ "ntfset_01gkpjp8bkm3tm53kdgkx6sms7",
214
+ UpdateNotificationSetting(
215
+ traffic_source=NotificationSettingTrafficSource.All,
216
+ ),
217
+ ReadsFixtures.read_raw_json_fixture("request/update_traffic_all"),
218
+ 200,
219
+ ReadsFixtures.read_raw_json_fixture("response/full_entity"),
220
+ "/notification-settings/ntfset_01gkpjp8bkm3tm53kdgkx6sms7",
221
+ ),
222
+ (
223
+ "ntfset_01gkpjp8bkm3tm53kdgkx6sms7",
224
+ UpdateNotificationSetting(
225
+ traffic_source=NotificationSettingTrafficSource.Platform,
226
+ ),
227
+ ReadsFixtures.read_raw_json_fixture("request/update_traffic_platform"),
228
+ 200,
229
+ ReadsFixtures.read_raw_json_fixture("response/full_entity"),
230
+ "/notification-settings/ntfset_01gkpjp8bkm3tm53kdgkx6sms7",
231
+ ),
232
+ (
233
+ "ntfset_01gkpjp8bkm3tm53kdgkx6sms7",
234
+ UpdateNotificationSetting(
235
+ traffic_source=NotificationSettingTrafficSource.Simulation,
236
+ ),
237
+ ReadsFixtures.read_raw_json_fixture("request/update_traffic_simulation"),
238
+ 200,
239
+ ReadsFixtures.read_raw_json_fixture("response/full_entity"),
240
+ "/notification-settings/ntfset_01gkpjp8bkm3tm53kdgkx6sms7",
241
+ ),
161
242
  ],
162
243
  ids=[
163
244
  "Update notification setting with basic data",
164
245
  "Update notification setting with partial data",
165
246
  "Update notification setting with full data",
247
+ "Create notification-setting for all traffic",
248
+ "Create notification-setting for platform traffic",
249
+ "Create notification-setting for simulation traffic",
166
250
  ],
167
251
  )
168
252
  def test_update_notification_setting_uses_expected_payload(
@@ -272,6 +356,24 @@ class TestNotificationSettingsClient:
272
356
  ),
273
357
  "/notification-settings?after=ntfset_01gkpjp8bkm3tm53kdgkx6sms7&order_by=id[desc]&per_page=100",
274
358
  ),
359
+ (
360
+ ListNotificationSettings(
361
+ traffic_source=NotificationSettingTrafficSource.All,
362
+ ),
363
+ "/notification-settings?traffic_source=all",
364
+ ),
365
+ (
366
+ ListNotificationSettings(
367
+ traffic_source=NotificationSettingTrafficSource.Platform,
368
+ ),
369
+ "/notification-settings?traffic_source=platform",
370
+ ),
371
+ (
372
+ ListNotificationSettings(
373
+ traffic_source=NotificationSettingTrafficSource.Simulation,
374
+ ),
375
+ "/notification-settings?traffic_source=simulation",
376
+ ),
275
377
  ],
276
378
  ids=[
277
379
  "List all notification-settings",
@@ -279,6 +381,9 @@ class TestNotificationSettingsClient:
279
381
  "List inactive notification-settings",
280
382
  "List notification-settings with pagination",
281
383
  "List notification-settings with pagination after",
384
+ "List notification-settings for all traffic",
385
+ "List notification-settings for platform traffic",
386
+ "List notification-settings for simulation traffic",
282
387
  ],
283
388
  )
284
389
  def test_list_notification_settings_hits_expected_url(
@@ -331,6 +436,24 @@ class TestNotificationSettingsClient:
331
436
 
332
437
  assert len(allNotificationSettings) == 2
333
438
 
439
+ def test_list_notification_entities_have_traffic_source(
440
+ self,
441
+ test_client,
442
+ mock_requests,
443
+ ):
444
+ mock_requests.get(
445
+ f"{test_client.base_url}/notification-settings",
446
+ status_code=200,
447
+ text=ReadsFixtures.read_raw_json_fixture("response/list_default"),
448
+ )
449
+
450
+ response = test_client.client.notification_settings.list()
451
+
452
+ assert isinstance(response, NotificationSettingCollection)
453
+ assert response.items[0].traffic_source == NotificationSettingTrafficSource.All
454
+ assert response.items[1].traffic_source == NotificationSettingTrafficSource.Platform
455
+ assert response.items[2].traffic_source == NotificationSettingTrafficSource.Simulation
456
+
334
457
  @mark.parametrize(
335
458
  "notification_setting_id, expected_response_status, expected_response_body, expected_url",
336
459
  [
@@ -370,6 +493,9 @@ class TestNotificationSettingsClient:
370
493
  str(expected_response_body)
371
494
  ), "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
372
495
 
496
+ assert response.type == NotificationSettingType.Url
497
+ assert response.traffic_source == NotificationSettingTrafficSource.Platform
498
+
373
499
  @mark.parametrize(
374
500
  "notification_setting_id, expected_response_status, expected_path",
375
501
  [
@@ -204,6 +204,7 @@ class TestPaymentMethodsClient:
204
204
  str(expected_response_body)
205
205
  ), "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
206
206
 
207
+ assert response.id == "paymtd_01hs8zx6x377xfsfrt2bqsevbw"
207
208
  assert response.customer_id == "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
208
209
  assert response.address_id == "add_01hv8h6jj90jjz0d71m6hj4r9z"
209
210
  assert response.paypal is None
@@ -215,7 +216,7 @@ class TestPaymentMethodsClient:
215
216
  card = response.card
216
217
  assert isinstance(card, Card)
217
218
  assert card.type == "visa"
218
- assert card.last4 == 2
219
+ assert card.last4 == "0002"
219
220
  assert card.expiry_month == 1
220
221
  assert card.expiry_year == 2025
221
222
  assert card.cardholder_name == "Sam Miller"
@@ -249,6 +250,7 @@ class TestPaymentMethodsClient:
249
250
  str(expected_response_body)
250
251
  ), "The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
251
252
 
253
+ assert response.id == "paymtd_01hs8zx6x377xfsfrt2bqsevbw"
252
254
  assert response.customer_id == "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
253
255
  assert response.address_id == "add_01hv8h6jj90jjz0d71m6hj4r9z"
254
256
  assert response.card is None
@@ -269,7 +271,7 @@ class TestPaymentMethodsClient:
269
271
  ):
270
272
  customer_id = "ctm_01hv6y1jedq4p1n0yqn5ba3ky4"
271
273
  payment_method_id = "paymtd_01hs8zx6x377xfsfrt2bqsevbw"
272
- expected_response_status = 200
274
+ expected_response_status = 204
273
275
  expected_path = "/customers/ctm_01hv6y1jedq4p1n0yqn5ba3ky4/payment-methods/paymtd_01hs8zx6x377xfsfrt2bqsevbw"
274
276
 
275
277
  expected_url = f"{test_client.base_url}{expected_path}"