Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
test_NotificationsClient.py works
Browse files Browse the repository at this point in the history
  • Loading branch information
Invincibear committed Jan 31, 2024
1 parent c5508ce commit cb8c015
Show file tree
Hide file tree
Showing 13 changed files with 754 additions and 41 deletions.
5 changes: 2 additions & 3 deletions paddle_billing_python_sdk/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
from requests import Response, RequestException, Session
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
from urllib.parse import unquote, urljoin, urlencode
from urllib.parse import unquote, urljoin, urlencode # unquote used for debug
from uuid import uuid4

from paddle_billing_python_sdk.__VERSION__ import __VERSION__
from paddle_billing_python_sdk.FiltersNone import FiltersNone
from paddle_billing_python_sdk.FiltersUndefined import FiltersUndefined
from paddle_billing_python_sdk.HasParameters import HasParameters
from paddle_billing_python_sdk.Options import Options

# from paddle_billing_python_sdk.Logger.Formatter import CustomLogger
# from paddle_billing_python_sdk.Logger.Formatter import CustomLogger # TODO
from paddle_billing_python_sdk.Logger.NullHandler import NullHandler

from paddle_billing_python_sdk.Resources.Addresses.AddressesClient import AddressesClient
Expand Down
12 changes: 6 additions & 6 deletions paddle_billing_python_sdk/Entities/Business.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

@dataclass
class Business(Entity):
id: str
name: str
id: str
name: str
company_number: str | None
tax_identifier: str | None
status: Status
contacts: list[Contacts]
status: Status
contacts: list[Contacts]
created_at: datetime
updated_at: datetime
custom_data: CustomData | None
import_meta: ImportMeta | None
custom_data: CustomData | None = None
import_meta: ImportMeta | None = None


@classmethod
Expand Down
4 changes: 2 additions & 2 deletions paddle_billing_python_sdk/Entities/Customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class Customer(Entity):
email: str
marketing_consent: bool
status: Status
custom_data: CustomData | None
locale: str
created_at: datetime
updated_at: datetime
import_meta: ImportMeta | None
custom_data: CustomData | None = None
import_meta: ImportMeta | None = None


@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from paddle_billing_python_sdk.Entities.Shared.CollectionMode import CollectionMode
from paddle_billing_python_sdk.Entities.Shared.CurrencyCode import CurrencyCode
from paddle_billing_python_sdk.Entities.Shared.CustomData import CustomData
from paddle_billing_python_sdk.Entities.Shared.ImportMeta import ImportMeta
from paddle_billing_python_sdk.Entities.Shared.TimePeriod import TimePeriod

from paddle_billing_python_sdk.Entities.Subscriptions.SubscriptionDiscount import SubscriptionDiscount
Expand All @@ -28,19 +27,19 @@ class NotificationSubscription(Entity):
currency_code: CurrencyCode
created_at: datetime
updated_at: datetime
started_at: datetime | None
first_billed_at: datetime | None
next_billed_at: datetime | None
paused_at: datetime | None
canceled_at: datetime | None
discount: SubscriptionDiscount | None
collection_mode: CollectionMode
billing_details: BillingDetails | None
current_billing_period: SubscriptionTimePeriod
billing_cycle: TimePeriod
scheduled_change: SubscriptionScheduledChange | None
items: list[SubscriptionItem]
custom_data: CustomData | None
started_at: datetime | None = None
first_billed_at: datetime | None = None
next_billed_at: datetime | None = None
paused_at: datetime | None = None
canceled_at: datetime | None = None
discount: SubscriptionDiscount | None = None
billing_details: BillingDetails | None = None
scheduled_change: SubscriptionScheduledChange | None = None
custom_data: CustomData | None = None


@classmethod
Expand Down
8 changes: 4 additions & 4 deletions paddle_billing_python_sdk/Entities/Product.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class Product(Entity):
name: str
status: Status
tax_category: TaxCategory
created_at: datetime | None
custom_data: CustomData | None
description: str | None
image_url: str | None
import_meta: ImportMeta | None
type: CatalogType | None
created_at: datetime | None = None
custom_data: CustomData | None = None
import_meta: ImportMeta | None = None
type: CatalogType | None = None


@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def list(self, operation: ListNotifications = None) -> NotificationCollection:
)


def get(self, notification_setting_id: str) -> Notification:
self.response = self.client.get_raw(f"/notifications/{notification_setting_id}")
def get(self, notification_id: str) -> Notification:
self.response = self.client.get_raw(f"/notifications/{notification_id}")
parser = ResponseParser(self.response)

return Notification.from_dict(parser.get_data())


def replay(self, notification_setting_id: str) -> str:
self.response = self.client.post_raw(f"/notifications/{notification_setting_id}")
def replay(self, notification_id: str) -> str:
self.response = self.client.post_raw(f"/notifications/{notification_id}")
parser = ResponseParser(self.response)
data = parser.get_data()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from dataclasses import dataclass

from paddle_billing_python_sdk.EnumStringify import enum_stringify
from paddle_billing_python_sdk.HasParameters import HasParameters

Expand All @@ -23,8 +21,8 @@ def __init__(
self.pager = pager
self.search = search
self.filter = filter
self.end = DateTime.from_datetime(end)
self.start = DateTime.from_datetime(start)
self.end = end # DateTime.from_datetime(end)
self.start = start # DateTime.from_datetime(start)
self.notification_setting_id = notification_setting_id if notification_setting_id is not None else []
self.statuses = statuses if statuses is not None else []

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"data": {
"id": "ntf_01h8bzam1z32agrxjwhjgqk8w6",
"type": "business.updated",
"status": "failed",
"payload": {
"data": {
"id": "biz_01h84a7hr4pzhsajkm8tev89ev",
"name": "ChatApp Inc.",
"status": "active",
"contacts": [
{
"name": "Parker Jones",
"email": "[email protected]"
},
{
"name": "Jo Riley",
"email": "[email protected]"
},
{
"name": "Jesse Garcia",
"email": "[email protected]"
}
],
"created_at": "2023-08-18T12:34:25.668Z",
"updated_at": "2023-08-21T11:57:47.03542Z",
"company_number": "555775291485",
"tax_identifier": null
},
"event_id": "evt_01h8bzakzx3hm2fmen703n5q45",
"event_type": "business.updated",
"occurred_at": "2023-08-21T11:57:47.390028Z",
"notification_id": "ntf_01h8bzam1z32agrxjwhjgqk8w6"
},
"occurred_at": "2023-08-21T11:57:47.390028Z",
"delivered_at": null,
"replayed_at": null,
"origin": "event",
"last_attempt_at": "2023-08-21T12:15:53.620185Z",
"retry_at": null,
"times_attempted": 10,
"notification_setting_id": "ntfset_01h126ps19rp06wn89v9797mab"
},
"meta": {
"request_id": "d14081ea-0062-491e-9035-0010f2216046"
}
}
Loading

0 comments on commit cb8c015

Please sign in to comment.