82 lines
2.3 KiB
Python
82 lines
2.3 KiB
Python
import json
|
|
from collections.abc import Mapping
|
|
from typing import TYPE_CHECKING, Any, TypeVar
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from .. import types
|
|
|
|
if TYPE_CHECKING:
|
|
from ..models.payrexx_transaction import PayrexxTransaction
|
|
|
|
|
|
T = TypeVar("T", bound="Webhooks")
|
|
|
|
|
|
@_attrs_define
|
|
class Webhooks:
|
|
"""Webhook data containing a transaction
|
|
|
|
Attributes:
|
|
transaction (PayrexxTransaction): Transaction containing info for the webhook.
|
|
|
|
referenceId can't be snake_case because the data is provided from Payrexx.
|
|
"""
|
|
|
|
transaction: "PayrexxTransaction"
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
transaction = self.transaction.to_dict()
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"transaction": transaction,
|
|
}
|
|
)
|
|
|
|
return field_dict
|
|
|
|
def to_multipart(self) -> types.RequestFiles:
|
|
files: types.RequestFiles = []
|
|
|
|
files.append(("transaction", (None, json.dumps(self.transaction.to_dict()).encode(), "application/json")))
|
|
|
|
for prop_name, prop in self.additional_properties.items():
|
|
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
|
|
|
return files
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
from ..models.payrexx_transaction import PayrexxTransaction
|
|
|
|
d = dict(src_dict)
|
|
transaction = PayrexxTransaction.from_dict(d.pop("transaction"))
|
|
|
|
webhooks = cls(
|
|
transaction=transaction,
|
|
)
|
|
|
|
webhooks.additional_properties = d
|
|
return webhooks
|
|
|
|
@property
|
|
def additional_keys(self) -> list[str]:
|
|
return list(self.additional_properties.keys())
|
|
|
|
def __getitem__(self, key: str) -> Any:
|
|
return self.additional_properties[key]
|
|
|
|
def __setitem__(self, key: str, value: Any) -> None:
|
|
self.additional_properties[key] = value
|
|
|
|
def __delitem__(self, key: str) -> None:
|
|
del self.additional_properties[key]
|
|
|
|
def __contains__(self, key: str) -> bool:
|
|
return key in self.additional_properties
|