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

Commit

Permalink
Entities, entities, entities...
Browse files Browse the repository at this point in the history
  • Loading branch information
Invincibear committed Jan 23, 2024
1 parent f376ab2 commit 6b5a25c
Show file tree
Hide file tree
Showing 39 changed files with 258 additions and 142 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
extras_require={
'dev': [
'pytest>=7.0.0',
'pylint>=3.0.3',
'setuptools>=69.0.3',
],
},
Expand Down
51 changes: 51 additions & 0 deletions src/Entities/Adjustment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime
from typing import Optional, List

from src.Entities.Entity import Entity

from src.Entities.Shared.Action import Action
from src.Entities.Shared.AdjustmentItemTotals import AdjustmentItemTotals
from src.Entities.Shared.CurrencyCode import CurrencyCode
from src.Entities.Shared.PayoutTotalsAdjustment import PayoutTotalsAdjustment
from src.Entities.Shared.StatusAdjustment import StatusAdjustment
from src.Entities.Shared.TotalAdjustments import TotalAdjustments


@dataclass
class Adjustment(Entity):
id: str
action: Action
transactionId: str
subscriptionId: Optional[str]
customerId: str
reason: str
creditAppliedToBalance: Optional[bool]
currencyCode: CurrencyCode
status: StatusAdjustment
items: List[AdjustmentItemTotals]
totals: TotalAdjustments
payoutTotals: Optional[PayoutTotalsAdjustment]
createdAt: datetime
updatedAt: Optional[datetime]


@classmethod
def from_dict(cls, data: dict) -> Adjustment:
return Adjustment(
id = data['id'],
action = Action(data['action']),
transactionId = data['transaction_id'],
subscriptionId = data.get('subscription_id'),
customerId = data['customer_id'],
reason = data['reason'],
creditAppliedToBalance = data.get('credit_applied_to_balance'),
currencyCode = CurrencyCode(data['currency_code']),
status = StatusAdjustment(data['status']),
items = [AdjustmentItemTotals(item) for item in data['items']],
totals = TotalAdjustments.from_dict(data['totals']),
payoutTotals = PayoutTotalsAdjustment.from_dict(data['payout_totals']) if 'payout_totals' in data else None,
createdAt = datetime.fromisoformat(data['created_at']),
updatedAt = datetime.fromisoformat(data['updated_at']) if 'updated_at' in data else None,
)
11 changes: 6 additions & 5 deletions src/Entities/Reports/ReportFilters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations
from dataclasses import dataclass
from .ReportName import ReportName
from .ReportOperator import ReportOperator
from typing import Union, Optional
from __future__ import annotations
from dataclasses import dataclass
from typing import Union, Optional

from src.Entities.Reports.ReportName import ReportName
from src.Entities.Reports.ReportOperator import ReportOperator


@dataclass
Expand Down
9 changes: 5 additions & 4 deletions src/Entities/Shared/AddressPreview.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .CountryCode import CountryCode
from dataclasses import dataclass
from typing import Optional
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.CountryCode import CountryCode


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion src/Entities/Shared/BillingDetails.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations
from .TimePeriod import TimePeriod
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.TimePeriod import TimePeriod


@dataclass
class BillingDetails:
Expand Down
3 changes: 2 additions & 1 deletion src/Entities/Shared/BillingDetailsUpdate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .TimePeriod import TimePeriod
from dataclasses import dataclass

from src.Entities.Shared.TimePeriod import TimePeriod


@dataclass
class BillingDetailsUpdate:
Expand Down
7 changes: 4 additions & 3 deletions src/Entities/Shared/Card.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional

from src.Entities.Transactions.TransactionCardType import TransactionCardType
from dataclasses import dataclass
from typing import Optional


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion src/Entities/Shared/ChargebackFee.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations
from .Original import Original
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.Original import Original


@dataclass
class ChargebackFee:
Expand Down
17 changes: 17 additions & 0 deletions src/Entities/Shared/ImportMeta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional


@dataclass(frozen=True)
class ImportMeta:
externalId: Optional[str]
importedFrom: str


@classmethod
def from_dict(cls, data: dict) -> ImportMeta:
return ImportMeta(
externalId = data.get('external_id'),
importedFrom = data['imported_from']
)
3 changes: 2 additions & 1 deletion src/Entities/Shared/MetaPaginated.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .Pagination import Pagination
from dataclasses import dataclass

from src.Entities.Shared.Pagination import Pagination


@dataclass
class MetaPaginated:
Expand Down
5 changes: 3 additions & 2 deletions src/Entities/Shared/MethodDetails.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations
from .Card import Card
from .Type import Type
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.Card import Card
from src.Entities.Shared.Type import Type


@dataclass
class MethodDetails:
Expand Down
9 changes: 5 additions & 4 deletions src/Entities/Shared/Money.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .CurrencyCode import CurrencyCode
from dataclasses import dataclass
from typing import Optional
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.CurrencyCode import CurrencyCode


@dataclass
Expand Down
7 changes: 4 additions & 3 deletions src/Entities/Shared/Original.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from .CurrencyCodeAdjustments import CurrencyCodeAdjustments
from dataclasses import dataclass
from __future__ import annotations
from dataclasses import dataclass

from src.Entities.Shared.CurrencyCodeAdjustments import CurrencyCodeAdjustments


@dataclass
Expand Down
11 changes: 6 additions & 5 deletions src/Entities/Shared/PayoutTotalsAdjustment.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations
from .ChargebackFee import ChargebackFee
from .CurrencyCodePayouts import CurrencyCodePayouts
from dataclasses import dataclass
from typing import Optional
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.ChargebackFee import ChargebackFee
from src.Entities.Shared.CurrencyCodePayouts import CurrencyCodePayouts


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion src/Entities/Shared/TaxRatesUsed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .Totals import Totals
from dataclasses import dataclass

from src.Entities.Shared.Totals import Totals


@dataclass
class TaxRatesUsed:
Expand Down
3 changes: 2 additions & 1 deletion src/Entities/Shared/TimePeriod.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .Interval import Interval
from dataclasses import dataclass

from src.Entities.Shared.Interval import Interval


@dataclass
class TimePeriod:
Expand Down
7 changes: 4 additions & 3 deletions src/Entities/Shared/TotalAdjustments.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from .CurrencyCode import CurrencyCode
from dataclasses import dataclass
from __future__ import annotations
from dataclasses import dataclass

from src.Entities.Shared.CurrencyCode import CurrencyCode


@dataclass
Expand Down
13 changes: 7 additions & 6 deletions src/Entities/Shared/TransactionDetailsPreview.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations
from .TaxRatesUsed import TaxRatesUsed
from .TransactionTotals import TransactionTotals
from .TransactionLineItemPreview import TransactionLineItemPreview
from dataclasses import dataclass
from typing import List
from __future__ import annotations
from dataclasses import dataclass
from typing import List

from src.Entities.Shared.TaxRatesUsed import TaxRatesUsed
from src.Entities.Shared.TransactionLineItemPreview import TransactionLineItemPreview
from src.Entities.Shared.TransactionTotals import TransactionTotals


@dataclass
Expand Down
10 changes: 6 additions & 4 deletions src/Entities/Shared/TransactionLineItemPreview.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations
from .UnitTotals import UnitTotals
from .Totals import Totals
from dataclasses import dataclass
from __future__ import annotations
from dataclasses import dataclass

from src.Entities.ProductWithIncludes import ProductWithIncludes

from src.Entities.Shared.Totals import Totals
from src.Entities.Shared.UnitTotals import UnitTotals


@dataclass
class TransactionLineItemPreview:
Expand Down
15 changes: 8 additions & 7 deletions src/Entities/Shared/TransactionPaymentAttempt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations
from .ErrorCode import ErrorCode
from .MethodDetails import MethodDetails
from .StatusPaymentAttempt import StatusPaymentAttempt
from dataclasses import dataclass
from datetime import datetime
from typing import Optional
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime
from typing import Optional

from src.Entities.Shared.ErrorCode import ErrorCode
from src.Entities.Shared.MethodDetails import MethodDetails
from src.Entities.Shared.StatusPaymentAttempt import StatusPaymentAttempt


@dataclass
Expand Down
9 changes: 5 additions & 4 deletions src/Entities/Shared/TransactionPayoutTotals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .CurrencyCodePayouts import CurrencyCodePayouts
from dataclasses import dataclass
from typing import Optional
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.CurrencyCodePayouts import CurrencyCodePayouts


@dataclass
Expand Down
9 changes: 5 additions & 4 deletions src/Entities/Shared/TransactionPayoutTotalsAdjusted.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .ChargebackFee import ChargebackFee
from .CurrencyCodePayouts import CurrencyCodePayouts
from dataclasses import dataclass
from __future__ import annotations
from dataclasses import dataclass

from src.Entities.Shared.ChargebackFee import ChargebackFee
from src.Entities.Shared.CurrencyCodePayouts import CurrencyCodePayouts


@dataclass
Expand Down
9 changes: 5 additions & 4 deletions src/Entities/Shared/TransactionTotals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .CurrencyCode import CurrencyCode
from dataclasses import dataclass
from typing import Optional
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.CurrencyCode import CurrencyCode


@dataclass
Expand Down
9 changes: 5 additions & 4 deletions src/Entities/Shared/TransactionTotalsAdjusted.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from .CurrencyCode import CurrencyCode
from dataclasses import dataclass
from typing import Optional
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional

from src.Entities.Shared.CurrencyCode import CurrencyCode


@dataclass
Expand Down
11 changes: 6 additions & 5 deletions src/Entities/Shared/UnitPriceOverride.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations
from .CountryCode import CountryCode
from .Money import Money
from dataclasses import dataclass
from typing import List
from __future__ import annotations
from dataclasses import dataclass
from typing import List

from src.Entities.Shared.CountryCode import CountryCode
from src.Entities.Shared.Money import Money


@dataclass
Expand Down
14 changes: 8 additions & 6 deletions src/Entities/Subscriptions/SubscriptionDetails.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from __future__ import annotations
from .SubscriptionTransactionLineItem import SubscriptionTransactionLineItem
from dataclasses import dataclass
from __future__ import annotations
from dataclasses import dataclass
from typing import List

from src.Entities.Shared.TaxRatesUsed import TaxRatesUsed
from src.Entities.Shared.TransactionTotals import TransactionTotals
from src.Entities.Shared.TransactionTotalsAdjusted import TransactionTotalsAdjusted
from src.Entities.Shared.TransactionPayoutTotals import TransactionPayoutTotals
from src.Entities.Shared.TransactionPayoutTotalsAdjusted import TransactionPayoutTotalsAdjusted
from typing import List
from src.Entities.Shared.TransactionTotals import TransactionTotals
from src.Entities.Shared.TransactionTotalsAdjusted import TransactionTotalsAdjusted

from src.Entities.Subscriptions.SubscriptionTransactionLineItem import SubscriptionTransactionLineItem


@dataclass
Expand Down
Loading

0 comments on commit 6b5a25c

Please sign in to comment.