- Implement tests for basic and bearer authentication headers in `test_auth.py`. - Create tests for the `EasybillWebhookParser` in `test_webhooks.py`, covering JSON and form-encoded payloads, as well as a generic parse and acknowledgement method.
208 lines
12 KiB
Python
208 lines
12 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
easybill REST API
|
|
|
|
The first version of the easybill REST API. [CHANGELOG](https://api.easybill.de/rest/v1/CHANGELOG.md) ## Authentication You can choose between two available methods: `Basic Auth` or `Bearer Token`. In each HTTP request, one of the following HTTP headers is required: ``` # Basic Auth Authorization: Basic base64_encode('<email>:<api_key>') # Bearer Token Authorization: Bearer <api_key> ``` ## Limitations ### Request Limit * PLUS: 10 requests per minute * BUSINESS: 60 requests per minute If the limit is exceeded, you will receive the HTTP error: `429 Too Many Requests` ### Result Limit All result lists are limited to 100 by default. This limit can be increased by the query parameter `limit` to a maximum of 1000. ## Query filter Many list resources can be filtered. In `/documents` you can filter e.g. by number with `/documents?number=111028654`. If you want to filter multiple numbers, you can either enter them separated by commas `/documents?number=111028654,222006895` or as an array `/documents?number[]=111028654&number[]=222006895`. **Warning**: The maximum size of an HTTP request line in bytes is 4094. If this limit is exceeded, you will receive the HTTP error: `414 Request-URI Too Large` ### Escape commas in query You can escape commans in query `name=Patrick\\, Peter` if you submit the header `X-Easybill-Escape: true` in your request. ## Property login_id This is the login of your admin or employee account. ## Date and Date-Time format Please use the timezone `Europe/Berlin`. * **date** = *Y-m-d* = `2016-12-31` * **date-time** = *Y-m-d H:i:s* = `2016-12-31 03:13:37` Date or datetime can be `null` because the attributes have been added later and the entry is older.
|
|
|
|
The version of the OpenAPI document: 1.96.0
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
|
|
from __future__ import annotations
|
|
import pprint
|
|
import re # noqa: F401
|
|
import json
|
|
|
|
from datetime import date, datetime
|
|
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
|
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
from typing_extensions import Annotated
|
|
from typing import Optional, Set
|
|
from typing_extensions import Self
|
|
from pydantic_core import to_jsonable_python
|
|
|
|
class SEPAPayment(BaseModel):
|
|
"""
|
|
SEPAPayment
|
|
""" # noqa: E501
|
|
amount: StrictInt = Field(description="Amount in cents (e.g. \"150\" = 1.50€)")
|
|
created_at: Optional[datetime] = None
|
|
creditor_bic: Optional[StrictStr] = Field(default='null', description="If type is DEBIT, this field is overwritten with the selected bank account data on export.")
|
|
creditor_iban: Optional[StrictStr] = Field(default=None, description="Mandatory if type is CREDIT. If type is DEBIT, this field is overwritten with the selected bank account data on export.")
|
|
creditor_name: Optional[StrictStr] = Field(default=None, description="Mandatory if type is CREDIT. If type is DEBIT, this field is overwritten with the selected bank account data on export.")
|
|
debitor_bic: Optional[StrictStr] = Field(default='null', description="If type is CREDIT, this field is overwritten with the selected bank account data on export.")
|
|
debitor_iban: Optional[StrictStr] = Field(description="Mandatory if type is DEBIT. If type is CREDIT, this field is overwritten with the selected bank account data on export.")
|
|
debitor_name: Optional[StrictStr] = Field(description="Mandatory if type is DEBIT. If type is CREDIT, this field is overwritten with the selected bank account data on export.")
|
|
debitor_address_line_1: Optional[Annotated[str, Field(strict=True, max_length=70)]] = Field(default=None, description="Mandatory if type is DEBIT and the debitor's IBAN belongs to a country outside the EEA")
|
|
debitor_address_line2: Optional[Annotated[str, Field(strict=True, max_length=70)]] = Field(default=None, description="string")
|
|
debitor_country: Optional[Annotated[str, Field(strict=True, max_length=2)]] = Field(default=None, description="Mandatory if type is DEBIT and the debitor's IBAN belongs to a country outside the EEA")
|
|
document_id: StrictInt
|
|
export_at: Optional[datetime] = Field(default=None, description="If a date is set, this record is marked as exported")
|
|
export_error: Optional[StrictStr] = None
|
|
id: Optional[StrictInt] = None
|
|
local_instrument: StrictStr = Field(description="CORE: SEPA Core Direct Debit<br/> COR1: SEPA-Basislastschrift COR1 (deprecated use CORE instead)<br/> B2B: SEPA Business to Business Direct Debit")
|
|
mandate_date_of_signature: date
|
|
mandate_id: Annotated[str, Field(strict=True, max_length=34)]
|
|
reference: Annotated[str, Field(strict=True, max_length=35)]
|
|
remittance_information: Optional[Annotated[str, Field(strict=True, max_length=140)]] = 'null'
|
|
requested_at: Optional[date] = Field(default=None, description="Booking date")
|
|
sequence_type: StrictStr = Field(description="FRST: Erstlastschrift<br/> RCUR: Folgelastschrift<br/> OOFF: Einmallastschrift<br/> FNAL: Letztmalige Lastschrift")
|
|
updated_at: Optional[StrictStr] = None
|
|
type: Optional[StrictStr] = 'DEBIT'
|
|
__properties: ClassVar[List[str]] = ["amount", "created_at", "creditor_bic", "creditor_iban", "creditor_name", "debitor_bic", "debitor_iban", "debitor_name", "debitor_address_line_1", "debitor_address_line2", "debitor_country", "document_id", "export_at", "export_error", "id", "local_instrument", "mandate_date_of_signature", "mandate_id", "reference", "remittance_information", "requested_at", "sequence_type", "updated_at", "type"]
|
|
|
|
@field_validator('local_instrument')
|
|
def local_instrument_validate_enum(cls, value):
|
|
"""Validates the enum"""
|
|
if value not in set(['CORE', 'COR1', 'B2B']):
|
|
raise ValueError("must be one of enum values ('CORE', 'COR1', 'B2B')")
|
|
return value
|
|
|
|
@field_validator('sequence_type')
|
|
def sequence_type_validate_enum(cls, value):
|
|
"""Validates the enum"""
|
|
if value not in set(['FRST', 'OOFF', 'FNAL', 'RCUR']):
|
|
raise ValueError("must be one of enum values ('FRST', 'OOFF', 'FNAL', 'RCUR')")
|
|
return value
|
|
|
|
@field_validator('type')
|
|
def type_validate_enum(cls, value):
|
|
"""Validates the enum"""
|
|
if value is None:
|
|
return value
|
|
|
|
if value not in set(['DEBIT', 'CREDIT']):
|
|
raise ValueError("must be one of enum values ('DEBIT', 'CREDIT')")
|
|
return value
|
|
|
|
model_config = ConfigDict(
|
|
validate_by_name=True,
|
|
validate_by_alias=True,
|
|
validate_assignment=True,
|
|
protected_namespaces=(),
|
|
)
|
|
|
|
|
|
def to_str(self) -> str:
|
|
"""Returns the string representation of the model using alias"""
|
|
return pprint.pformat(self.model_dump(by_alias=True))
|
|
|
|
def to_json(self) -> str:
|
|
"""Returns the JSON representation of the model using alias"""
|
|
return json.dumps(to_jsonable_python(self.to_dict()))
|
|
|
|
@classmethod
|
|
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
"""Create an instance of SEPAPayment from a JSON string"""
|
|
return cls.from_dict(json.loads(json_str))
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
"""Return the dictionary representation of the model using alias.
|
|
|
|
This has the following differences from calling pydantic's
|
|
`self.model_dump(by_alias=True)`:
|
|
|
|
* `None` is only added to the output dict for nullable fields that
|
|
were set at model initialization. Other fields with value `None`
|
|
are ignored.
|
|
* OpenAPI `readOnly` fields are excluded.
|
|
* OpenAPI `readOnly` fields are excluded.
|
|
* OpenAPI `readOnly` fields are excluded.
|
|
* OpenAPI `readOnly` fields are excluded.
|
|
"""
|
|
excluded_fields: Set[str] = set([
|
|
"created_at",
|
|
"export_error",
|
|
"id",
|
|
"updated_at",
|
|
])
|
|
|
|
_dict = self.model_dump(
|
|
by_alias=True,
|
|
exclude=excluded_fields,
|
|
exclude_none=True,
|
|
)
|
|
# set to None if creditor_bic (nullable) is None
|
|
# and model_fields_set contains the field
|
|
if self.creditor_bic is None and "creditor_bic" in self.model_fields_set:
|
|
_dict['creditor_bic'] = None
|
|
|
|
# set to None if creditor_iban (nullable) is None
|
|
# and model_fields_set contains the field
|
|
if self.creditor_iban is None and "creditor_iban" in self.model_fields_set:
|
|
_dict['creditor_iban'] = None
|
|
|
|
# set to None if creditor_name (nullable) is None
|
|
# and model_fields_set contains the field
|
|
if self.creditor_name is None and "creditor_name" in self.model_fields_set:
|
|
_dict['creditor_name'] = None
|
|
|
|
# set to None if debitor_bic (nullable) is None
|
|
# and model_fields_set contains the field
|
|
if self.debitor_bic is None and "debitor_bic" in self.model_fields_set:
|
|
_dict['debitor_bic'] = None
|
|
|
|
# set to None if debitor_iban (nullable) is None
|
|
# and model_fields_set contains the field
|
|
if self.debitor_iban is None and "debitor_iban" in self.model_fields_set:
|
|
_dict['debitor_iban'] = None
|
|
|
|
# set to None if debitor_name (nullable) is None
|
|
# and model_fields_set contains the field
|
|
if self.debitor_name is None and "debitor_name" in self.model_fields_set:
|
|
_dict['debitor_name'] = None
|
|
|
|
# set to None if export_at (nullable) is None
|
|
# and model_fields_set contains the field
|
|
if self.export_at is None and "export_at" in self.model_fields_set:
|
|
_dict['export_at'] = None
|
|
|
|
# set to None if remittance_information (nullable) is None
|
|
# and model_fields_set contains the field
|
|
if self.remittance_information is None and "remittance_information" in self.model_fields_set:
|
|
_dict['remittance_information'] = None
|
|
|
|
return _dict
|
|
|
|
@classmethod
|
|
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
"""Create an instance of SEPAPayment from a dict"""
|
|
if obj is None:
|
|
return None
|
|
|
|
if not isinstance(obj, dict):
|
|
return cls.model_validate(obj)
|
|
|
|
_obj = cls.model_validate({
|
|
"amount": obj.get("amount"),
|
|
"created_at": obj.get("created_at"),
|
|
"creditor_bic": obj.get("creditor_bic") if obj.get("creditor_bic") is not None else 'null',
|
|
"creditor_iban": obj.get("creditor_iban"),
|
|
"creditor_name": obj.get("creditor_name"),
|
|
"debitor_bic": obj.get("debitor_bic") if obj.get("debitor_bic") is not None else 'null',
|
|
"debitor_iban": obj.get("debitor_iban"),
|
|
"debitor_name": obj.get("debitor_name"),
|
|
"debitor_address_line_1": obj.get("debitor_address_line_1"),
|
|
"debitor_address_line2": obj.get("debitor_address_line2"),
|
|
"debitor_country": obj.get("debitor_country"),
|
|
"document_id": obj.get("document_id"),
|
|
"export_at": obj.get("export_at"),
|
|
"export_error": obj.get("export_error"),
|
|
"id": obj.get("id"),
|
|
"local_instrument": obj.get("local_instrument"),
|
|
"mandate_date_of_signature": obj.get("mandate_date_of_signature"),
|
|
"mandate_id": obj.get("mandate_id"),
|
|
"reference": obj.get("reference"),
|
|
"remittance_information": obj.get("remittance_information") if obj.get("remittance_information") is not None else 'null',
|
|
"requested_at": obj.get("requested_at"),
|
|
"sequence_type": obj.get("sequence_type"),
|
|
"updated_at": obj.get("updated_at"),
|
|
"type": obj.get("type") if obj.get("type") is not None else 'DEBIT'
|
|
})
|
|
return _obj
|
|
|
|
|