dime-python-sdk 1.0.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.
Files changed (48) hide show
  1. dime_payments/__init__.py +29 -0
  2. dime_payments/client.py +30 -0
  3. dime_payments/config.py +32 -0
  4. dime_payments/data_objects/__init__.py +31 -0
  5. dime_payments/data_objects/address.py +30 -0
  6. dime_payments/data_objects/customer.py +37 -0
  7. dime_payments/data_objects/deposit.py +31 -0
  8. dime_payments/data_objects/deposit_group.py +25 -0
  9. dime_payments/data_objects/deposit_with_transactions.py +37 -0
  10. dime_payments/data_objects/form_link.py +13 -0
  11. dime_payments/data_objects/merchant.py +55 -0
  12. dime_payments/data_objects/message_result.py +13 -0
  13. dime_payments/data_objects/payment_method.py +63 -0
  14. dime_payments/data_objects/recurring_payment.py +53 -0
  15. dime_payments/data_objects/recurring_payment_method.py +17 -0
  16. dime_payments/data_objects/tokenize_result.py +13 -0
  17. dime_payments/data_objects/transaction.py +57 -0
  18. dime_payments/data_objects/transaction_address.py +27 -0
  19. dime_payments/exceptions/__init__.py +21 -0
  20. dime_payments/exceptions/api_exception.py +5 -0
  21. dime_payments/exceptions/authentication_exception.py +5 -0
  22. dime_payments/exceptions/connection_exception.py +5 -0
  23. dime_payments/exceptions/dime_exception.py +19 -0
  24. dime_payments/exceptions/not_found_exception.py +5 -0
  25. dime_payments/exceptions/permission_denied_exception.py +5 -0
  26. dime_payments/exceptions/rate_limit_exception.py +18 -0
  27. dime_payments/exceptions/server_exception.py +5 -0
  28. dime_payments/exceptions/validation_exception.py +24 -0
  29. dime_payments/http/__init__.py +0 -0
  30. dime_payments/http/error_handler.py +76 -0
  31. dime_payments/http/transport.py +80 -0
  32. dime_payments/pagination/__init__.py +3 -0
  33. dime_payments/pagination/cursor_page.py +72 -0
  34. dime_payments/resources/__init__.py +0 -0
  35. dime_payments/resources/abstract_resource.py +49 -0
  36. dime_payments/resources/addresses.py +37 -0
  37. dime_payments/resources/customers.py +32 -0
  38. dime_payments/resources/deposits.py +31 -0
  39. dime_payments/resources/merchants.py +31 -0
  40. dime_payments/resources/payment_methods.py +37 -0
  41. dime_payments/resources/recurring_payments.py +53 -0
  42. dime_payments/resources/transactions.py +53 -0
  43. dime_payments/support/__init__.py +0 -0
  44. dime_payments/support/arr.py +60 -0
  45. dime_python_sdk-1.0.0.dist-info/METADATA +288 -0
  46. dime_python_sdk-1.0.0.dist-info/RECORD +48 -0
  47. dime_python_sdk-1.0.0.dist-info/WHEEL +4 -0
  48. dime_python_sdk-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,29 @@
1
+ from .client import Client
2
+ from .config import Config
3
+ from .exceptions import (
4
+ ApiException,
5
+ AuthenticationException,
6
+ ConnectionException,
7
+ DimeException,
8
+ NotFoundException,
9
+ PermissionDeniedException,
10
+ RateLimitException,
11
+ ServerException,
12
+ ValidationException,
13
+ )
14
+ from .pagination.cursor_page import CursorPage
15
+
16
+ __all__ = [
17
+ 'Client',
18
+ 'Config',
19
+ 'CursorPage',
20
+ 'DimeException',
21
+ 'ValidationException',
22
+ 'AuthenticationException',
23
+ 'PermissionDeniedException',
24
+ 'NotFoundException',
25
+ 'RateLimitException',
26
+ 'ServerException',
27
+ 'ApiException',
28
+ 'ConnectionException',
29
+ ]
@@ -0,0 +1,30 @@
1
+ from .config import Config
2
+ from .http.transport import Transport
3
+ from .resources.addresses import Addresses
4
+ from .resources.customers import Customers
5
+ from .resources.deposits import Deposits
6
+ from .resources.merchants import Merchants
7
+ from .resources.payment_methods import PaymentMethods
8
+ from .resources.recurring_payments import RecurringPayments
9
+ from .resources.transactions import Transactions
10
+
11
+
12
+ class Client:
13
+ def __init__(self, token: str | Config, base_url: str = Config.DEFAULT_BASE_URL) -> None:
14
+ if isinstance(token, Config):
15
+ self._config = token
16
+ else:
17
+ self._config = Config(token=token, base_url=base_url)
18
+
19
+ transport = Transport(self._config)
20
+
21
+ self.transactions = Transactions(transport)
22
+ self.customers = Customers(transport)
23
+ self.payment_methods = PaymentMethods(transport)
24
+ self.merchants = Merchants(transport)
25
+ self.addresses = Addresses(transport)
26
+ self.deposits = Deposits(transport)
27
+ self.recurring_payments = RecurringPayments(transport)
28
+
29
+ def config(self) -> Config:
30
+ return self._config
@@ -0,0 +1,32 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Callable
4
+
5
+ if TYPE_CHECKING:
6
+ import requests
7
+
8
+
9
+ class Config:
10
+ DEFAULT_BASE_URL = 'https://app.dimepayments.com'
11
+ VERSION = '1.0.0'
12
+
13
+ def __init__(
14
+ self,
15
+ token: str,
16
+ base_url: str = DEFAULT_BASE_URL,
17
+ timeout: float = 30.0,
18
+ max_retries: int = 2,
19
+ retry_base_delay: float = 0.5,
20
+ session: 'requests.Session | None' = None,
21
+ sleep: Callable[[float], None] | None = None,
22
+ ) -> None:
23
+ self.token = token
24
+ self.base_url = base_url
25
+ self.timeout = timeout
26
+ self.max_retries = max_retries
27
+ self.retry_base_delay = retry_base_delay
28
+ self._session = session
29
+ self._sleep = sleep
30
+
31
+ def base_uri(self) -> str:
32
+ return self.base_url.rstrip('/') + '/api/'
@@ -0,0 +1,31 @@
1
+ from .address import Address
2
+ from .customer import Customer
3
+ from .deposit import Deposit
4
+ from .deposit_group import DepositGroup
5
+ from .deposit_with_transactions import DepositWithTransactions
6
+ from .form_link import FormLink
7
+ from .merchant import Merchant
8
+ from .message_result import MessageResult
9
+ from .payment_method import PaymentMethod
10
+ from .recurring_payment import RecurringPayment
11
+ from .recurring_payment_method import RecurringPaymentMethod
12
+ from .tokenize_result import TokenizeResult
13
+ from .transaction import Transaction
14
+ from .transaction_address import TransactionAddress
15
+
16
+ __all__ = [
17
+ 'Transaction',
18
+ 'TransactionAddress',
19
+ 'Customer',
20
+ 'PaymentMethod',
21
+ 'Merchant',
22
+ 'Address',
23
+ 'Deposit',
24
+ 'DepositGroup',
25
+ 'DepositWithTransactions',
26
+ 'RecurringPayment',
27
+ 'RecurringPaymentMethod',
28
+ 'TokenizeResult',
29
+ 'MessageResult',
30
+ 'FormLink',
31
+ ]
@@ -0,0 +1,30 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_int, arr_string
5
+
6
+
7
+ @dataclass
8
+ class Address:
9
+ id: int | None = None
10
+ recipient: str | None = None
11
+ line_one: str | None = None
12
+ line_two: str | None = None
13
+ line_three: str | None = None
14
+ city: str | None = None
15
+ state: str | None = None
16
+ zip: str | None = None
17
+
18
+ @classmethod
19
+ def from_dict(cls, data: dict[str, Any]) -> 'Address':
20
+ return cls(
21
+ # API returns address_id on show, id on list items.
22
+ id=arr_int(data, 'address_id') or arr_int(data, 'id'),
23
+ recipient=arr_string(data, 'recipient'),
24
+ line_one=arr_string(data, 'line_one'),
25
+ line_two=arr_string(data, 'line_two'),
26
+ line_three=arr_string(data, 'line_three'),
27
+ city=arr_string(data, 'city'),
28
+ state=arr_string(data, 'state'),
29
+ zip=arr_string(data, 'zip'),
30
+ )
@@ -0,0 +1,37 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_string
5
+
6
+
7
+ @dataclass
8
+ class Customer:
9
+ uuid: str | None = None
10
+ first_name: str | None = None
11
+ last_name: str | None = None
12
+ phone: str | None = None
13
+ email: str | None = None
14
+ addr1: str | None = None
15
+ addr2: str | None = None
16
+ addr3: str | None = None
17
+ city: str | None = None
18
+ state: str | None = None
19
+ zip: str | None = None
20
+ country: str | None = None
21
+
22
+ @classmethod
23
+ def from_dict(cls, data: dict[str, Any]) -> 'Customer':
24
+ return cls(
25
+ uuid=arr_string(data, 'uuid'),
26
+ first_name=arr_string(data, 'first_name'),
27
+ last_name=arr_string(data, 'last_name'),
28
+ phone=arr_string(data, 'phone'),
29
+ email=arr_string(data, 'email'),
30
+ addr1=arr_string(data, 'addr1'),
31
+ addr2=arr_string(data, 'addr2'),
32
+ addr3=arr_string(data, 'addr3'),
33
+ city=arr_string(data, 'city'),
34
+ state=arr_string(data, 'state'),
35
+ zip=arr_string(data, 'zip'),
36
+ country=arr_string(data, 'country'),
37
+ )
@@ -0,0 +1,31 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_string
5
+
6
+
7
+ @dataclass
8
+ class Deposit:
9
+ transaction_date: str | None = None
10
+ fund_date: str | None = None
11
+ transaction_info_id: str | None = None
12
+ transaction_id: str | None = None
13
+ transaction_detail_account: str | None = None
14
+ authorization_amount: str | None = None
15
+ net_amount: str | None = None
16
+ sweep_id: str | None = None
17
+ type: str | None = None
18
+
19
+ @classmethod
20
+ def from_dict(cls, data: dict[str, Any]) -> 'Deposit':
21
+ return cls(
22
+ transaction_date=arr_string(data, 'transaction_date'),
23
+ fund_date=arr_string(data, 'fund_date'),
24
+ transaction_info_id=arr_string(data, 'transaction_info_id'),
25
+ transaction_id=arr_string(data, 'transaction_id'),
26
+ transaction_detail_account=arr_string(data, 'transaction_detail_account'),
27
+ authorization_amount=arr_string(data, 'authorization_amount'),
28
+ net_amount=arr_string(data, 'net_amount'),
29
+ sweep_id=arr_string(data, 'sweep_id'),
30
+ type=arr_string(data, 'type'),
31
+ )
@@ -0,0 +1,25 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_int, arr_string
5
+ from .deposit_with_transactions import DepositWithTransactions
6
+
7
+
8
+ @dataclass
9
+ class DepositGroup:
10
+ sid: str | None = None
11
+ count: int | None = None
12
+ deposits: list[DepositWithTransactions] = field(default_factory=list)
13
+
14
+ @classmethod
15
+ def from_dict(cls, data: dict[str, Any]) -> 'DepositGroup':
16
+ raw_deposits = data.get('deposits', {})
17
+ if isinstance(raw_deposits, dict):
18
+ raw_deposits = list(raw_deposits.values())
19
+ deposits = [DepositWithTransactions.from_dict(d) for d in raw_deposits if isinstance(d, dict)]
20
+
21
+ return cls(
22
+ sid=arr_string(data, 'sid'),
23
+ count=arr_int(data, 'count'),
24
+ deposits=deposits,
25
+ )
@@ -0,0 +1,37 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_int, arr_object_from, arr_string
5
+ from .transaction import Transaction
6
+
7
+
8
+ @dataclass
9
+ class DepositWithTransactions:
10
+ sid: str | None = None
11
+ transaction_info_id: str | None = None
12
+ transaction_id: str | None = None
13
+ transaction_date: str | None = None
14
+ fund_date: str | None = None
15
+ type: str | None = None
16
+ count_of_transactions: int | None = None
17
+ trans_total: str | None = None
18
+ transactions: list[Transaction] = field(default_factory=list)
19
+
20
+ @classmethod
21
+ def from_dict(cls, data: dict[str, Any]) -> 'DepositWithTransactions':
22
+ raw_txns = data.get('transactions', [])
23
+ if isinstance(raw_txns, dict):
24
+ raw_txns = list(raw_txns.values())
25
+ transactions = [Transaction.from_dict(t) for t in raw_txns if isinstance(t, dict)]
26
+
27
+ return cls(
28
+ sid=arr_string(data, 'sid'),
29
+ transaction_info_id=arr_string(data, 'transaction_info_id'),
30
+ transaction_id=arr_string(data, 'transaction_id'),
31
+ transaction_date=arr_string(data, 'transaction_date'),
32
+ fund_date=arr_string(data, 'fund_date'),
33
+ type=arr_string(data, 'type'),
34
+ count_of_transactions=arr_int(data, 'countOfTransactions'),
35
+ trans_total=arr_string(data, 'transTotal'),
36
+ transactions=transactions,
37
+ )
@@ -0,0 +1,13 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_string
5
+
6
+
7
+ @dataclass
8
+ class FormLink:
9
+ link: str | None = None
10
+
11
+ @classmethod
12
+ def from_dict(cls, data: dict[str, Any]) -> 'FormLink':
13
+ return cls(link=arr_string(data, 'link'))
@@ -0,0 +1,55 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_bool, arr_string
5
+
6
+
7
+ @dataclass
8
+ class Merchant:
9
+ name: str | None = None
10
+ sid: str | None = None
11
+ mcc: str | None = None
12
+ slug: str | None = None
13
+ pub_api_key: str | None = None
14
+ processor_mid: str | None = None
15
+ active: bool = False
16
+ active_at: str | None = None
17
+ g_pay: bool = False
18
+ a_pay: bool = False
19
+ pci_compliance: bool = False
20
+ website: str | None = None
21
+ addr1: str | None = None
22
+ addr2: str | None = None
23
+ city: str | None = None
24
+ state: str | None = None
25
+ zip: str | None = None
26
+ phone: str | None = None
27
+ primary_phone: str | None = None
28
+ primary_email: str | None = None
29
+ primary_name: str | None = None
30
+
31
+ @classmethod
32
+ def from_dict(cls, data: dict[str, Any]) -> 'Merchant':
33
+ return cls(
34
+ name=arr_string(data, 'name'),
35
+ sid=arr_string(data, 'sid'),
36
+ mcc=arr_string(data, 'mcc'),
37
+ slug=arr_string(data, 'slug'),
38
+ pub_api_key=arr_string(data, 'pub_api_key'),
39
+ processor_mid=arr_string(data, 'processor_mid'),
40
+ active=arr_bool(data, 'active'),
41
+ active_at=arr_string(data, 'active_at'),
42
+ g_pay=arr_bool(data, 'g_pay'),
43
+ a_pay=arr_bool(data, 'a_pay'),
44
+ pci_compliance=arr_bool(data, 'pci_compliance'),
45
+ website=arr_string(data, 'website'),
46
+ addr1=arr_string(data, 'addr1'),
47
+ addr2=arr_string(data, 'addr2'),
48
+ city=arr_string(data, 'city'),
49
+ state=arr_string(data, 'state'),
50
+ zip=arr_string(data, 'zip'),
51
+ phone=arr_string(data, 'phone'),
52
+ primary_phone=arr_string(data, 'primary_phone'),
53
+ primary_email=arr_string(data, 'primary_email'),
54
+ primary_name=arr_string(data, 'primary_name'),
55
+ )
@@ -0,0 +1,13 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_string
5
+
6
+
7
+ @dataclass
8
+ class MessageResult:
9
+ message: str | None = None
10
+
11
+ @classmethod
12
+ def from_dict(cls, data: dict[str, Any]) -> 'MessageResult':
13
+ return cls(message=arr_string(data, 'message'))
@@ -0,0 +1,63 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_bool, arr_int, arr_string
5
+
6
+
7
+ @dataclass
8
+ class PaymentMethod:
9
+ id: int | None = None
10
+ type: str | None = None
11
+ token: str | None = None
12
+ first_name: str | None = None
13
+ last_name: str | None = None
14
+ cc_name_on_card: str | None = None
15
+ cc_last_four: str | None = None
16
+ cc_expiration_date: str | None = None
17
+ cc_brand: str | None = None
18
+ ach_bank_account_name: str | None = None
19
+ ach_routing_number: str | None = None
20
+ ach_account_number: str | None = None
21
+ ach_ownership_type: str | None = None
22
+ ach_account_type: str | None = None
23
+ ach_bank_name: str | None = None
24
+ status: str | None = None
25
+ status_date: str | None = None
26
+ enabled: bool = False
27
+ is_default: bool = False
28
+ addr1: str | None = None
29
+ addr2: str | None = None
30
+ addr3: str | None = None
31
+ city: str | None = None
32
+ state: str | None = None
33
+ zip: str | None = None
34
+
35
+ @classmethod
36
+ def from_dict(cls, data: dict[str, Any]) -> 'PaymentMethod':
37
+ return cls(
38
+ id=arr_int(data, 'id'),
39
+ type=arr_string(data, 'type'),
40
+ token=arr_string(data, 'token'),
41
+ first_name=arr_string(data, 'first_name'),
42
+ last_name=arr_string(data, 'last_name'),
43
+ cc_name_on_card=arr_string(data, 'cc_name_on_card'),
44
+ cc_last_four=arr_string(data, 'cc_last_four'),
45
+ cc_expiration_date=arr_string(data, 'cc_expiration_date'),
46
+ cc_brand=arr_string(data, 'cc_brand'),
47
+ ach_bank_account_name=arr_string(data, 'ach_bank_account_name'),
48
+ ach_routing_number=arr_string(data, 'ach_routing_number'),
49
+ ach_account_number=arr_string(data, 'ach_account_number'),
50
+ ach_ownership_type=arr_string(data, 'ach_ownership_type'),
51
+ ach_account_type=arr_string(data, 'ach_account_type'),
52
+ ach_bank_name=arr_string(data, 'ach_bank_name'),
53
+ status=arr_string(data, 'status'),
54
+ status_date=arr_string(data, 'status_date'),
55
+ enabled=arr_bool(data, 'enabled'),
56
+ is_default=arr_bool(data, 'default'),
57
+ addr1=arr_string(data, 'addr1'),
58
+ addr2=arr_string(data, 'addr2'),
59
+ addr3=arr_string(data, 'addr3'),
60
+ city=arr_string(data, 'city'),
61
+ state=arr_string(data, 'state'),
62
+ zip=arr_string(data, 'zip'),
63
+ )
@@ -0,0 +1,53 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_int, arr_object_from, arr_string
5
+ from .recurring_payment_method import RecurringPaymentMethod
6
+ from .transaction_address import TransactionAddress
7
+
8
+
9
+ @dataclass
10
+ class RecurringPayment:
11
+ id: int | None = None
12
+ name: str | None = None
13
+ amount: str | None = None
14
+ start_date: str | None = None
15
+ end_date: str | None = None
16
+ recurrence_schedule: str | None = None
17
+ last_run_date: str | None = None
18
+ last_run_status: str | None = None
19
+ last_run_failed_count: int | None = None
20
+ next_run_date: str | None = None
21
+ status: str | None = None
22
+ paused_until_date: str | None = None
23
+ customer_uuid: str | None = None
24
+ cancelled_at: str | None = None
25
+ error: str | None = None
26
+ payment_method: RecurringPaymentMethod = field(default_factory=RecurringPaymentMethod)
27
+ shipping_address: TransactionAddress = field(default_factory=TransactionAddress)
28
+
29
+ @classmethod
30
+ def from_dict(cls, data: dict[str, Any]) -> 'RecurringPayment':
31
+ return cls(
32
+ id=arr_int(data, 'id'),
33
+ name=arr_string(data, 'name'),
34
+ amount=arr_string(data, 'amount'),
35
+ start_date=arr_string(data, 'start_date'),
36
+ end_date=arr_string(data, 'end_date'),
37
+ recurrence_schedule=arr_string(data, 'recurrence_schedule'),
38
+ last_run_date=arr_string(data, 'last_run_date'),
39
+ last_run_status=arr_string(data, 'last_run_status'),
40
+ last_run_failed_count=arr_int(data, 'last_run_failed_count'),
41
+ next_run_date=arr_string(data, 'next_run_date'),
42
+ status=arr_string(data, 'status'),
43
+ paused_until_date=arr_string(data, 'paused_until_date'),
44
+ customer_uuid=arr_string(data, 'customer_uuid'),
45
+ cancelled_at=arr_string(data, 'cancelled_at'),
46
+ error=arr_string(data, 'error'),
47
+ payment_method=RecurringPaymentMethod.from_dict(
48
+ arr_object_from(data, ['payment_method'])
49
+ ),
50
+ shipping_address=TransactionAddress.from_dict(
51
+ arr_object_from(data, ['shipping_address'])
52
+ ),
53
+ )
@@ -0,0 +1,17 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_int, arr_string
5
+
6
+
7
+ @dataclass
8
+ class RecurringPaymentMethod:
9
+ id: int | None = None
10
+ type: str | None = None
11
+
12
+ @classmethod
13
+ def from_dict(cls, data: dict[str, Any]) -> 'RecurringPaymentMethod':
14
+ return cls(
15
+ id=arr_int(data, 'id'),
16
+ type=arr_string(data, 'type'),
17
+ )
@@ -0,0 +1,13 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_string
5
+
6
+
7
+ @dataclass
8
+ class TokenizeResult:
9
+ token: str | None = None
10
+
11
+ @classmethod
12
+ def from_dict(cls, data: dict[str, Any]) -> 'TokenizeResult':
13
+ return cls(token=arr_string(data, 'token'))
@@ -0,0 +1,57 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_bool, arr_object_from, arr_string
5
+ from .transaction_address import TransactionAddress
6
+
7
+
8
+ @dataclass
9
+ class Transaction:
10
+ transaction_type: str | None = None
11
+ transaction_status: str | None = None
12
+ transaction_status_description: str | None = None
13
+ transaction_number: str | None = None
14
+ transaction_date: str | None = None
15
+ fund_date: str | None = None
16
+ settle_date: str | None = None
17
+ amount: str | None = None
18
+ description: str | None = None
19
+ status_code: str | None = None
20
+ status_text: str | None = None
21
+ email: str | None = None
22
+ phone: str | None = None
23
+ customer_uuid: str | None = None
24
+ multi_use_token: str | None = None
25
+ pending: bool = False
26
+ transaction_info_id: str | None = None
27
+ parent_transaction_info_id: str | None = None
28
+ billing_address: TransactionAddress = field(default_factory=TransactionAddress)
29
+ shipping_address: TransactionAddress = field(default_factory=TransactionAddress)
30
+
31
+ @classmethod
32
+ def from_dict(cls, data: dict[str, Any]) -> 'Transaction':
33
+ return cls(
34
+ transaction_type=arr_string(data, 'transaction_type'),
35
+ transaction_status=arr_string(data, 'transaction_status'),
36
+ transaction_status_description=arr_string(data, 'transaction_status_description'),
37
+ transaction_number=arr_string(data, 'transaction_number'),
38
+ transaction_date=arr_string(data, 'transaction_date'),
39
+ fund_date=arr_string(data, 'fund_date'),
40
+ settle_date=arr_string(data, 'settle_date'),
41
+ amount=arr_string(data, 'amount'),
42
+ description=arr_string(data, 'description'),
43
+ status_code=arr_string(data, 'status_code'),
44
+ status_text=arr_string(data, 'status_text'),
45
+ email=arr_string(data, 'email'),
46
+ phone=arr_string(data, 'phone'),
47
+ customer_uuid=arr_string(data, 'customer_uuid'),
48
+ multi_use_token=arr_string(data, 'multi_use_token'),
49
+ pending=arr_bool(data, 'pending'),
50
+ transaction_info_id=arr_string(data, 'transaction_info_id'),
51
+ parent_transaction_info_id=arr_string(data, 'parent_transaction_info_id'),
52
+ billing_address=TransactionAddress.from_dict(arr_object_from(data, ['billing_address'])),
53
+ # API sometimes returns shipping under camelCase key; accept both.
54
+ shipping_address=TransactionAddress.from_dict(
55
+ arr_object_from(data, ['shippingAddress', 'shipping_address'])
56
+ ),
57
+ )
@@ -0,0 +1,27 @@
1
+ from dataclasses import dataclass
2
+ from typing import Any
3
+
4
+ from ..support.arr import arr_string
5
+
6
+
7
+ @dataclass
8
+ class TransactionAddress:
9
+ first_name: str | None = None
10
+ last_name: str | None = None
11
+ addr1: str | None = None
12
+ addr2: str | None = None
13
+ city: str | None = None
14
+ state: str | None = None
15
+ zip: str | None = None
16
+
17
+ @classmethod
18
+ def from_dict(cls, data: dict[str, Any]) -> 'TransactionAddress':
19
+ return cls(
20
+ first_name=arr_string(data, 'first_name'),
21
+ last_name=arr_string(data, 'last_name'),
22
+ addr1=arr_string(data, 'addr1'),
23
+ addr2=arr_string(data, 'addr2'),
24
+ city=arr_string(data, 'city'),
25
+ state=arr_string(data, 'state'),
26
+ zip=arr_string(data, 'zip'),
27
+ )
@@ -0,0 +1,21 @@
1
+ from .api_exception import ApiException
2
+ from .authentication_exception import AuthenticationException
3
+ from .connection_exception import ConnectionException
4
+ from .dime_exception import DimeException
5
+ from .not_found_exception import NotFoundException
6
+ from .permission_denied_exception import PermissionDeniedException
7
+ from .rate_limit_exception import RateLimitException
8
+ from .server_exception import ServerException
9
+ from .validation_exception import ValidationException
10
+
11
+ __all__ = [
12
+ 'DimeException',
13
+ 'ValidationException',
14
+ 'AuthenticationException',
15
+ 'PermissionDeniedException',
16
+ 'NotFoundException',
17
+ 'RateLimitException',
18
+ 'ServerException',
19
+ 'ApiException',
20
+ 'ConnectionException',
21
+ ]
@@ -0,0 +1,5 @@
1
+ from .dime_exception import DimeException
2
+
3
+
4
+ class ApiException(DimeException):
5
+ pass
@@ -0,0 +1,5 @@
1
+ from .dime_exception import DimeException
2
+
3
+
4
+ class AuthenticationException(DimeException):
5
+ pass
@@ -0,0 +1,5 @@
1
+ from .dime_exception import DimeException
2
+
3
+
4
+ class ConnectionException(DimeException):
5
+ pass
@@ -0,0 +1,19 @@
1
+ from typing import Any
2
+
3
+
4
+ class DimeException(Exception):
5
+ def __init__(
6
+ self,
7
+ message: str,
8
+ status_code: int | None = None,
9
+ response_body: dict[str, Any] | None = None,
10
+ ) -> None:
11
+ super().__init__(message)
12
+ self.status_code = status_code
13
+ self.response_body: dict[str, Any] = response_body or {}
14
+
15
+ def get_status_code(self) -> int | None:
16
+ return self.status_code
17
+
18
+ def get_response_body(self) -> dict[str, Any]:
19
+ return self.response_body