diff --git a/dkb_robo/exemptionorder.py b/dkb_robo/exemptionorder.py index e9b4fef..563559b 100644 --- a/dkb_robo/exemptionorder.py +++ b/dkb_robo/exemptionorder.py @@ -1,6 +1,6 @@ """ Module for handling dkb standing orders """ -from typing import Dict, List -from dataclasses import dataclass, field +from typing import Dict, List, Optional +from dataclasses import dataclass import logging import requests from dkb_robo.utilities import Amount, DKBRoboError, filter_unexpected_fields, object2dictionary @@ -13,25 +13,28 @@ @dataclass class PartnerItem: """ class for a single partner """ - dateOfBirth: str = None - firstName: str = None - lastName: str = None - salutation: str = None - taxId: str = None + # pylint: disable=C0103 + dateOfBirth: Optional[str] = None + firstName: Optional[str] = None + lastName: Optional[str] = None + salutation: Optional[str] = None + taxId: Optional[str] = None @filter_unexpected_fields @dataclass class ExemptionOrderItem: """ class for a single exemption order """ - exemptionAmount: str = None - exemptionOrderType: str = None - partner: str = None - receivedAt: str = None - utilizedAmount: str = None - remainingAmount: str = None - validFrom: str = None - validUntil: str = None + # pylint: disable=C0103 + exemptionAmount: Optional[str] = None + exemptionOrderType: Optional[str] = None + partner: Optional[str] = None + receivedAt: Optional[str] = None + utilizedAmount: Optional[str] = None + remainingAmount: Optional[str] = None + validFrom: Optional[str] = None + validUntil: Optional[str] = None + def __post_init__(self): self.exemptionAmount = Amount(**self.exemptionAmount) self.remainingAmount = Amount(**self.remainingAmount) diff --git a/dkb_robo/standingorder.py b/dkb_robo/standingorder.py index 9bc2cbc..b9b18b8 100644 --- a/dkb_robo/standingorder.py +++ b/dkb_robo/standingorder.py @@ -13,28 +13,28 @@ @dataclass class CreditorAccount: """ class for a single creditor account """ - iban: str = None - bic: str = None - name: str = None + iban: Optional[str] = None + bic: Optional[str] = None + name: Optional[str] = None @filter_unexpected_fields @dataclass class DebtorAccount: """ class for a single debitor account """ - iban: str = None - accountId: str = None # pylint: disable=C0103 # NOSONAR + iban: Optional[str] = None + accountId: Optional[str] = None # pylint: disable=C0103 # NOSONAR @filter_unexpected_fields @dataclass class Recurrence: """ class for frequency account """ - frm: str = None - frequency: str = None - holidayExecutionStrategy: str = None # pylint: disable=C0103 # NOSONAR - nextExecutionAt: str = None # pylint: disable=C0103 # NOSONAR - until: str = None + frm: Optional[str] = None + frequency: Optional[str] = None + holidayExecutionStrategy: Optional[str] = None # pylint: disable=C0103 # NOSONAR + nextExecutionAt: Optional[str] = None # pylint: disable=C0103 # NOSONAR + until: Optional[str] = None @filter_unexpected_fields @@ -44,10 +44,10 @@ class StandingOrderItem: amount: Optional[Amount] = None creditor: Optional[CreditorAccount] = None debtor: Optional[DebtorAccount] = None - description: str = None + description: Optional[str] = None messages: List[str] = field(default_factory=list) recurrence: Optional[Recurrence] = None - status: str = None + status: Optional[str] = None def __post_init__(self): self.amount = Amount(**self.amount) diff --git a/dkb_robo/utilities.py b/dkb_robo/utilities.py index 714b8a9..0697f71 100644 --- a/dkb_robo/utilities.py +++ b/dkb_robo/utilities.py @@ -26,6 +26,7 @@ def get_dateformat(): @dataclass class Amount: """ Amount data class, roughly based on the JSON API response. """ + # pylint: disable=c0103 value: float = None currencyCode: str = None @@ -94,13 +95,13 @@ def get_valid_filename(name): s = f'{generate_random_string(8)}.pdf' return s + p.suffix -def object2dictionary(obj, key_lc=False, skip_list = []): + +def object2dictionary(obj, key_lc=False, skip_list=None): """ convert object to dict """ output_dict = {} - for k, v in asdict(obj).items(): - if k in skip_list: + if isinstance(skip_list, list) and k in skip_list: continue if isinstance(v, dict): output_dict[k] = object2dictionary(v, key_lc=key_lc)