diff --git a/backend/account/tokens.py b/backend/account/tokens.py index 8fe0b16..7e2015c 100644 --- a/backend/account/tokens.py +++ b/backend/account/tokens.py @@ -20,12 +20,18 @@ password_reset_token = PasswordResetTokenGenerator() from rest_framework_simplejwt.authentication import JWTAuthentication from rest_framework_simplejwt.exceptions import InvalidToken, TokenError -#NEMĚNIT CUSTOM SBÍRANÍ COOKIE TOKENU +#COOKIE + AUTHORIZATION HEADER JWT AUTHENTICATION FOR AXIOS COMPATIBILITY class CookieJWTAuthentication(JWTAuthentication): def authenticate(self, request): - + # First try Authorization header (standard axios pattern) + header_token = self.get_header(request) + if header_token is not None: + validated_token = self.get_validated_token(header_token) + return self.get_user(validated_token), validated_token + + # Fallback to cookie-based authentication raw_token = request.COOKIES.get('access_token') - + if not raw_token: return None diff --git a/backend/commerce/models.py b/backend/commerce/models.py index 7d1ed0c..d6be566 100644 --- a/backend/commerce/models.py +++ b/backend/commerce/models.py @@ -53,7 +53,6 @@ class Product(models.Model): "self", symmetrical=True, blank=True, - related_name="variant_of", help_text=( "Symetrické varianty produktu: pokud přidáte variantu A → B, " "Django automaticky přidá i variantu B → A. " @@ -208,6 +207,7 @@ class Order(models.Model): class Carrier(models.Model): class SHIPPING(models.TextChoices): ZASILKOVNA = "packeta", "cz#Zásilkovna" + DEUTSCHEPOST = "deutschepost", "cz#Deutsche Post" STORE = "store", "cz#Osobní odběr" shipping_method = models.CharField(max_length=20, choices=SHIPPING.choices, default=SHIPPING.STORE) @@ -223,6 +223,11 @@ class Carrier(models.Model): zasilkovna = models.ManyToManyField( ZasilkovnaPacket, blank=True, related_name="carriers" ) + + # Deutsche Post integration (same pattern as zasilkovna) + deutschepost = models.ManyToManyField( + "deutschepost.DeutschePostOrder", blank=True, related_name="carriers" + ) weight = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True, help_text="Hmotnost zásilky v kg") @@ -241,6 +246,8 @@ class Carrier(models.Model): def get_price(self): if self.shipping_method == self.SHIPPING.ZASILKOVNA: return SiteConfiguration.get_solo().zasilkovna_shipping_price + elif self.shipping_method == self.SHIPPING.DEUTSCHEPOST: + return SiteConfiguration.get_solo().deutschepost_shipping_price else: return Decimal('0.0') @@ -255,6 +262,19 @@ class Carrier(models.Model): notify_zasilkovna_sended.delay(order=self.orders.first(), user=self.orders.first().user) + elif self.shipping_method == self.SHIPPING.DEUTSCHEPOST: + # Import here to avoid circular imports + from thirdparty.deutschepost.models import DeutschePostOrder + + # Create new Deutsche Post order and add to carrier (same pattern as zasilkovna) + dp_order = DeutschePostOrder.objects.create() + self.deutschepost.add(dp_order) + self.returning = False + self.save() + + # Order shipping through Deutsche Post API + dp_order.order_shippment() + elif self.shipping_method == self.SHIPPING.STORE: self.state = self.STATE.READY_TO_PICKUP self.save() diff --git a/backend/configuration/models.py b/backend/configuration/models.py index be1085b..0a139d6 100644 --- a/backend/configuration/models.py +++ b/backend/configuration/models.py @@ -29,6 +29,13 @@ class SiteConfiguration(models.Model): #FIXME: není implementováno ↓↓↓ free_shipping_over = models.DecimalField(max_digits=10, decimal_places=2, default=2000) + # Deutsche Post settings + deutschepost_api_url = models.URLField(max_length=255, default="https://gw.sandbox.deutschepost.com", help_text="Deutsche Post API URL (sandbox/production)") + deutschepost_client_id = models.CharField(max_length=255, blank=True, null=True, help_text="Deutsche Post OAuth Client ID") + deutschepost_client_secret = models.CharField(max_length=255, blank=True, null=True, help_text="Deutsche Post OAuth Client Secret") + deutschepost_customer_ekp = models.CharField(max_length=20, blank=True, null=True, help_text="Deutsche Post Customer EKP number") + deutschepost_shipping_price = models.DecimalField(max_digits=10, decimal_places=2, default=150, help_text="Default Deutsche Post shipping price") + #coupon settings multiplying_coupons = models.BooleanField(default=True, help_text="Násobení kupónů v objednávce (ano/ne), pokud ne tak se použije pouze nejvyšší slevový kupón") addition_of_coupons_amount = models.BooleanField(default=False, help_text="Sčítání slevových kupónů v objednávce (ano/ne), pokud ne tak se použije pouze nejvyšší slevový kupón") diff --git a/backend/requirements.txt b/backend/requirements.txt index d3a732a..8685169 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -45,6 +45,12 @@ daphne gunicorn +# -- THIRD PARTY APIS -- +# Deutsche Post International Shipping API client (local package) +httpx>=0.23.0,<0.29.0 # Required by Deutsche Post client +attrs>=22.2.0 # Required by Deutsche Post client +python-dateutil>=2.8.0 # Required by Deutsche Post client + # -- REST API -- djangorestframework #REST Framework @@ -90,6 +96,12 @@ faker #generates fake data for testing purposes zeep #SOAP tool -## -- api -- + + +## -- API -- + +#generates api (if schema exists (ONLY USE OPENAPI NO SWAGGER)) +openapi-python-client + stripe gopay \ No newline at end of file diff --git a/backend/thirdparty/deutschepost/__init__.py b/backend/thirdparty/deutschepost/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/thirdparty/deutschepost/admin.py b/backend/thirdparty/deutschepost/admin.py new file mode 100644 index 0000000..9d34634 --- /dev/null +++ b/backend/thirdparty/deutschepost/admin.py @@ -0,0 +1,183 @@ +from django.contrib import admin + +from django.contrib import admin +from django.utils.html import format_html +from django.urls import reverse +from django.http import HttpResponseRedirect +from django.contrib import messages + +from .models import DeutschePostOrder, DeutschePostBulkOrder + + +@admin.register(DeutschePostOrder) +class DeutschePostOrderAdmin(admin.ModelAdmin): + list_display = [ + 'id', 'order_id', 'recipient_name', 'state', 'commerce_order_link', + 'awb_number', 'created_at' + ] + list_filter = ['state', 'product_type', 'service_level', 'destination_country', 'created_at'] + search_fields = ['order_id', 'recipient_name', 'recipient_email', 'awb_number', 'barcode'] + readonly_fields = [ + 'order_id', 'awb_number', 'barcode', 'tracking_url', + 'metadata', 'last_error', 'created_at' + ] + + fieldsets = ( + ('Basic Information', { + 'fields': ('state', 'commerce_order', 'order_id', 'customer_ekp') + }), + ('Recipient Information', { + 'fields': ( + 'recipient_name', 'recipient_phone', 'recipient_email', + 'address_line1', 'address_line2', 'address_line3', + 'city', 'address_state', 'postal_code', 'destination_country' + ) + }), + ('Shipment Details', { + 'fields': ( + 'product_type', 'service_level', 'shipment_gross_weight', + 'shipment_amount', 'shipment_currency', + 'sender_tax_id', 'importer_tax_id', 'return_item_wanted', + 'cust_ref' + ) + }), + ('Tracking Information', { + 'fields': ('awb_number', 'barcode', 'tracking_url'), + 'classes': ['collapse'] + }), + ('API Data', { + 'fields': ('metadata', 'last_error', 'created_at'), + 'classes': ['collapse'] + }) + ) + + actions = ['create_remote_order', 'finalize_remote_order', 'refresh_tracking'] + + def commerce_order_link(self, obj): + """Link to related commerce order.""" + if obj.commerce_order: + url = reverse('admin:commerce_order_change', args=[obj.commerce_order.pk]) + return format_html('{}', url, obj.commerce_order) + return '-' + commerce_order_link.short_description = 'Commerce Order' + + def create_remote_order(self, request, queryset): + """Admin action to create orders remotely.""" + created_count = 0 + error_count = 0 + + for order in queryset: + try: + if not order.order_id: + order.create_remote_order() + created_count += 1 + else: + error_count += 1 + except Exception as e: + messages.error(request, f'Error creating order {order.id}: {str(e)}') + error_count += 1 + + if created_count: + messages.success(request, f'{created_count} orders created remotely') + if error_count: + messages.warning(request, f'{error_count} orders could not be created') + + create_remote_order.short_description = 'Create selected orders remotely' + + def finalize_remote_order(self, request, queryset): + """Admin action to finalize orders remotely.""" + finalized_count = 0 + error_count = 0 + + for order in queryset: + try: + if order.order_id and order.state != DeutschePostOrder.STATE.FINALIZED: + order.finalize_remote_order() + finalized_count += 1 + else: + error_count += 1 + except Exception as e: + messages.error(request, f'Error finalizing order {order.id}: {str(e)}') + error_count += 1 + + if finalized_count: + messages.success(request, f'{finalized_count} orders finalized') + if error_count: + messages.warning(request, f'{error_count} orders could not be finalized') + + finalize_remote_order.short_description = 'Finalize selected orders' + + def refresh_tracking(self, request, queryset): + """Admin action to refresh tracking information.""" + updated_count = 0 + error_count = 0 + + for order in queryset: + try: + if order.order_id: + order.refresh_tracking() + updated_count += 1 + else: + error_count += 1 + except Exception as e: + messages.error(request, f'Error refreshing tracking for order {order.id}: {str(e)}') + error_count += 1 + + if updated_count: + messages.success(request, f'{updated_count} orders tracking updated') + if error_count: + messages.warning(request, f'{error_count} orders could not be updated') + + refresh_tracking.short_description = 'Refresh tracking for selected orders' + + +@admin.register(DeutschePostBulkOrder) +class DeutschePostBulkOrderAdmin(admin.ModelAdmin): + list_display = ['id', 'bulk_order_id', 'status', 'orders_count', 'created_at'] + list_filter = ['status', 'bulk_order_type', 'created_at'] + search_fields = ['bulk_order_id', 'description'] + readonly_fields = ['bulk_order_id', 'orders_count', 'metadata', 'last_error', 'created_at'] + + fieldsets = ( + ('Basic Information', { + 'fields': ('status', 'bulk_order_id', 'bulk_order_type', 'description') + }), + ('Orders', { + 'fields': ('deutschepost_orders', 'orders_count') + }), + ('API Data', { + 'fields': ('metadata', 'last_error', 'created_at'), + 'classes': ['collapse'] + }) + ) + + filter_horizontal = ['deutschepost_orders'] + actions = ['create_remote_bulk_order'] + + def orders_count(self, obj): + """Count of orders in this bulk order.""" + return obj.deutschepost_orders.count() + orders_count.short_description = 'Orders Count' + + def create_remote_bulk_order(self, request, queryset): + """Admin action to create bulk orders remotely.""" + created_count = 0 + error_count = 0 + + for bulk_order in queryset: + try: + if not bulk_order.bulk_order_id: + bulk_order.create_remote_bulk_order() + created_count += 1 + else: + error_count += 1 + except Exception as e: + messages.error(request, f'Error creating bulk order {bulk_order.id}: {str(e)}') + error_count += 1 + + if created_count: + messages.success(request, f'{created_count} bulk orders created remotely') + if error_count: + messages.warning(request, f'{error_count} bulk orders could not be created') + + create_remote_bulk_order.short_description = 'Create selected bulk orders remotely' diff --git a/backend/thirdparty/deutschepost/apps.py b/backend/thirdparty/deutschepost/apps.py new file mode 100644 index 0000000..67f53ae --- /dev/null +++ b/backend/thirdparty/deutschepost/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DeutschepostConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'thirdparty.deutschepost' diff --git a/backend/thirdparty/deutschepost/client/.gitignore b/backend/thirdparty/deutschepost/client/.gitignore new file mode 100644 index 0000000..79a2c3d --- /dev/null +++ b/backend/thirdparty/deutschepost/client/.gitignore @@ -0,0 +1,23 @@ +__pycache__/ +build/ +dist/ +*.egg-info/ +.pytest_cache/ + +# pyenv +.python-version + +# Environments +.env +.venv + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# JetBrains +.idea/ + +/coverage.xml +/.coverage diff --git a/backend/thirdparty/deutschepost/client/README.md b/backend/thirdparty/deutschepost/client/README.md new file mode 100644 index 0000000..1215120 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/README.md @@ -0,0 +1,124 @@ +# deutsche-post-international-shipping-api-client +A client library for accessing Deutsche Post International Shipping API + +## Usage +First, create a client: + +```python +from deutsche_post_international_shipping_api_client import Client + +client = Client(base_url="https://api.example.com") +``` + +If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead: + +```python +from deutsche_post_international_shipping_api_client import AuthenticatedClient + +client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken") +``` + +Now call your endpoint and use your models: + +```python +from deutsche_post_international_shipping_api_client.models import MyDataModel +from deutsche_post_international_shipping_api_client.api.my_tag import get_my_data_model +from deutsche_post_international_shipping_api_client.types import Response + +with client as client: + my_data: MyDataModel = get_my_data_model.sync(client=client) + # or if you need more info (e.g. status_code) + response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client) +``` + +Or do the same thing with an async version: + +```python +from deutsche_post_international_shipping_api_client.models import MyDataModel +from deutsche_post_international_shipping_api_client.api.my_tag import get_my_data_model +from deutsche_post_international_shipping_api_client.types import Response + +async with client as client: + my_data: MyDataModel = await get_my_data_model.asyncio(client=client) + response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client) +``` + +By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle. + +```python +client = AuthenticatedClient( + base_url="https://internal_api.example.com", + token="SuperSecretToken", + verify_ssl="/path/to/certificate_bundle.pem", +) +``` + +You can also disable certificate validation altogether, but beware that **this is a security risk**. + +```python +client = AuthenticatedClient( + base_url="https://internal_api.example.com", + token="SuperSecretToken", + verify_ssl=False +) +``` + +Things to know: +1. Every path/method combo becomes a Python module with four functions: + 1. `sync`: Blocking request that returns parsed data (if successful) or `None` + 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful. + 1. `asyncio`: Like `sync` but async instead of blocking + 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking + +1. All path/query params, and bodies become method arguments. +1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above) +1. Any endpoint which did not have a tag will be in `deutsche_post_international_shipping_api_client.api.default` + +## Advanced customizations + +There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case): + +```python +from deutsche_post_international_shipping_api_client import Client + +def log_request(request): + print(f"Request event hook: {request.method} {request.url} - Waiting for response") + +def log_response(response): + request = response.request + print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}") + +client = Client( + base_url="https://api.example.com", + httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}}, +) + +# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client() +``` + +You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url): + +```python +import httpx +from deutsche_post_international_shipping_api_client import Client + +client = Client( + base_url="https://api.example.com", +) +# Note that base_url needs to be re-set, as would any shared cookies, headers, etc. +client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030")) +``` + +## Building / publishing this package +This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics: +1. Update the metadata in pyproject.toml (e.g. authors, version) +1. If you're using a private repository, configure it with Poetry + 1. `poetry config repositories. ` + 1. `poetry config http-basic. ` +1. Publish the client with `poetry publish --build -r ` or, if for public PyPI, just `poetry publish --build` + +If you want to install this client into another project without publishing it (e.g. for development) then: +1. If that project **is using Poetry**, you can simply do `poetry add ` from that project +1. If that project is not using Poetry: + 1. Build a wheel with `poetry build -f wheel` + 1. Install that wheel from the other project `pip install ` diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/__init__.py new file mode 100644 index 0000000..dbee678 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/__init__.py @@ -0,0 +1,8 @@ +"""A client library for accessing Deutsche Post International Shipping API""" + +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/__init__.py new file mode 100644 index 0000000..81f9fa2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/__init__.py @@ -0,0 +1 @@ +"""Contains methods for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/get_access_token.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/get_access_token.py new file mode 100644 index 0000000..2bd3b74 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/get_access_token.py @@ -0,0 +1,369 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_access_token_response import GetAccessTokenResponse +from ...types import Response + + +def _get_kwargs( + *, + authorization: str, + accept: str, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + headers["Accept"] = accept + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/v1/auth/accesstoken", + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> GetAccessTokenResponse | None: + if response.status_code == 200: + response_200 = GetAccessTokenResponse.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[GetAccessTokenResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + authorization: str, + accept: str, +) -> Response[GetAccessTokenResponse]: + r"""Get Access New Token + + + The Get access_token API call provides OAuth 2.0 Bearer token, assigned to your Consumer_key and + Consumer_secret, which will grants you an access to the Deutsche Post International Shipping + APIs.

If you already received credentials for the old gateway these remain valid until + further notice.

The API operation is secured by HTTP Basic authentication, therefore you + have to provide `Consumer_key` and `Consumer_secret` as an username and password, when calling the + API..

**Example:** + 1. You will receive `Consumer_key` and `Consumer_secret` from Deutsche Post International + representative in following format.
+ Credentials below are exemplary and can _NOT_ be used in this Sandbox environment to get the + access_token. + + ```` + Consumer_key: 5qsFCFLzeoz4C6PKJ7yH3NDQHgBEJLt7 + Consumer_secret: P6mEGGaAZ2TdkLpD + ```` + + 2. When passing the `Consumer_key` and `Consumer_secret` via HTTPS request, using HTTP Basic + authentication, you have to + populate HTTP Header Authorization in following format. + > **Note:** *`Consumer_key` and `Consumer_secret` has to be encoded in base64-encoding. There is + a `space` characeter between Basic and the base64-encoded string. There is a `:` character between + the Consumer_key and Consumer_secret, when encoded in base64-encoding.* + + ```` + Authorization: Basic base64-encoded(Consumer_key:Consumer_secret) + Authorization: Basic NXFzRkNGTHplb3o0QzZQS0o3eUgzTkRRSGdCRUpMdDc6UDZtRUdHYUFaMlRka0xwRA== + ```` + + > **Note:** *You can test the Get access_token API directly from the documentation page. The + Authorization HTTP Header was populated for you in the Console View on the right side of the + screen.* + + 3. You will receive following response in the JSON format. + + ```` + { + \"access_token\": \"8CyAkmSppbfG5KAQ4AinTZ8RVJnD\", + \"token_type\": \"Bearer\", + \"expires_in\": 17999 + } + ```` + + Understanding of the response fields: + `access_token:` Contains access_token string for the Shipping / Tracking API authentication and + authorization.

+ `token_type:` Type of the OAuth 2.0 access_token. Default value is \"Bearer\".

+ `expires_in:` Time to live of the access_token. Default value is 18000 seconds / 5 hours. After this + time the token expires.

+ + Args: + authorization (str): + accept (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[GetAccessTokenResponse] + """ + + kwargs = _get_kwargs( + authorization=authorization, + accept=accept, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + authorization: str, + accept: str, +) -> GetAccessTokenResponse | None: + r"""Get Access New Token + + + The Get access_token API call provides OAuth 2.0 Bearer token, assigned to your Consumer_key and + Consumer_secret, which will grants you an access to the Deutsche Post International Shipping + APIs.

If you already received credentials for the old gateway these remain valid until + further notice.

The API operation is secured by HTTP Basic authentication, therefore you + have to provide `Consumer_key` and `Consumer_secret` as an username and password, when calling the + API..

**Example:** + 1. You will receive `Consumer_key` and `Consumer_secret` from Deutsche Post International + representative in following format.
+ Credentials below are exemplary and can _NOT_ be used in this Sandbox environment to get the + access_token. + + ```` + Consumer_key: 5qsFCFLzeoz4C6PKJ7yH3NDQHgBEJLt7 + Consumer_secret: P6mEGGaAZ2TdkLpD + ```` + + 2. When passing the `Consumer_key` and `Consumer_secret` via HTTPS request, using HTTP Basic + authentication, you have to + populate HTTP Header Authorization in following format. + > **Note:** *`Consumer_key` and `Consumer_secret` has to be encoded in base64-encoding. There is + a `space` characeter between Basic and the base64-encoded string. There is a `:` character between + the Consumer_key and Consumer_secret, when encoded in base64-encoding.* + + ```` + Authorization: Basic base64-encoded(Consumer_key:Consumer_secret) + Authorization: Basic NXFzRkNGTHplb3o0QzZQS0o3eUgzTkRRSGdCRUpMdDc6UDZtRUdHYUFaMlRka0xwRA== + ```` + + > **Note:** *You can test the Get access_token API directly from the documentation page. The + Authorization HTTP Header was populated for you in the Console View on the right side of the + screen.* + + 3. You will receive following response in the JSON format. + + ```` + { + \"access_token\": \"8CyAkmSppbfG5KAQ4AinTZ8RVJnD\", + \"token_type\": \"Bearer\", + \"expires_in\": 17999 + } + ```` + + Understanding of the response fields: + `access_token:` Contains access_token string for the Shipping / Tracking API authentication and + authorization.

+ `token_type:` Type of the OAuth 2.0 access_token. Default value is \"Bearer\".

+ `expires_in:` Time to live of the access_token. Default value is 18000 seconds / 5 hours. After this + time the token expires.

+ + Args: + authorization (str): + accept (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + GetAccessTokenResponse + """ + + return sync_detailed( + client=client, + authorization=authorization, + accept=accept, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + authorization: str, + accept: str, +) -> Response[GetAccessTokenResponse]: + r"""Get Access New Token + + + The Get access_token API call provides OAuth 2.0 Bearer token, assigned to your Consumer_key and + Consumer_secret, which will grants you an access to the Deutsche Post International Shipping + APIs.

If you already received credentials for the old gateway these remain valid until + further notice.

The API operation is secured by HTTP Basic authentication, therefore you + have to provide `Consumer_key` and `Consumer_secret` as an username and password, when calling the + API..

**Example:** + 1. You will receive `Consumer_key` and `Consumer_secret` from Deutsche Post International + representative in following format.
+ Credentials below are exemplary and can _NOT_ be used in this Sandbox environment to get the + access_token. + + ```` + Consumer_key: 5qsFCFLzeoz4C6PKJ7yH3NDQHgBEJLt7 + Consumer_secret: P6mEGGaAZ2TdkLpD + ```` + + 2. When passing the `Consumer_key` and `Consumer_secret` via HTTPS request, using HTTP Basic + authentication, you have to + populate HTTP Header Authorization in following format. + > **Note:** *`Consumer_key` and `Consumer_secret` has to be encoded in base64-encoding. There is + a `space` characeter between Basic and the base64-encoded string. There is a `:` character between + the Consumer_key and Consumer_secret, when encoded in base64-encoding.* + + ```` + Authorization: Basic base64-encoded(Consumer_key:Consumer_secret) + Authorization: Basic NXFzRkNGTHplb3o0QzZQS0o3eUgzTkRRSGdCRUpMdDc6UDZtRUdHYUFaMlRka0xwRA== + ```` + + > **Note:** *You can test the Get access_token API directly from the documentation page. The + Authorization HTTP Header was populated for you in the Console View on the right side of the + screen.* + + 3. You will receive following response in the JSON format. + + ```` + { + \"access_token\": \"8CyAkmSppbfG5KAQ4AinTZ8RVJnD\", + \"token_type\": \"Bearer\", + \"expires_in\": 17999 + } + ```` + + Understanding of the response fields: + `access_token:` Contains access_token string for the Shipping / Tracking API authentication and + authorization.

+ `token_type:` Type of the OAuth 2.0 access_token. Default value is \"Bearer\".

+ `expires_in:` Time to live of the access_token. Default value is 18000 seconds / 5 hours. After this + time the token expires.

+ + Args: + authorization (str): + accept (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[GetAccessTokenResponse] + """ + + kwargs = _get_kwargs( + authorization=authorization, + accept=accept, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + authorization: str, + accept: str, +) -> GetAccessTokenResponse | None: + r"""Get Access New Token + + + The Get access_token API call provides OAuth 2.0 Bearer token, assigned to your Consumer_key and + Consumer_secret, which will grants you an access to the Deutsche Post International Shipping + APIs.

If you already received credentials for the old gateway these remain valid until + further notice.

The API operation is secured by HTTP Basic authentication, therefore you + have to provide `Consumer_key` and `Consumer_secret` as an username and password, when calling the + API..

**Example:** + 1. You will receive `Consumer_key` and `Consumer_secret` from Deutsche Post International + representative in following format.
+ Credentials below are exemplary and can _NOT_ be used in this Sandbox environment to get the + access_token. + + ```` + Consumer_key: 5qsFCFLzeoz4C6PKJ7yH3NDQHgBEJLt7 + Consumer_secret: P6mEGGaAZ2TdkLpD + ```` + + 2. When passing the `Consumer_key` and `Consumer_secret` via HTTPS request, using HTTP Basic + authentication, you have to + populate HTTP Header Authorization in following format. + > **Note:** *`Consumer_key` and `Consumer_secret` has to be encoded in base64-encoding. There is + a `space` characeter between Basic and the base64-encoded string. There is a `:` character between + the Consumer_key and Consumer_secret, when encoded in base64-encoding.* + + ```` + Authorization: Basic base64-encoded(Consumer_key:Consumer_secret) + Authorization: Basic NXFzRkNGTHplb3o0QzZQS0o3eUgzTkRRSGdCRUpMdDc6UDZtRUdHYUFaMlRka0xwRA== + ```` + + > **Note:** *You can test the Get access_token API directly from the documentation page. The + Authorization HTTP Header was populated for you in the Console View on the right side of the + screen.* + + 3. You will receive following response in the JSON format. + + ```` + { + \"access_token\": \"8CyAkmSppbfG5KAQ4AinTZ8RVJnD\", + \"token_type\": \"Bearer\", + \"expires_in\": 17999 + } + ```` + + Understanding of the response fields: + `access_token:` Contains access_token string for the Shipping / Tracking API authentication and + authorization.

+ `token_type:` Type of the OAuth 2.0 access_token. Default value is \"Bearer\".

+ `expires_in:` Time to live of the access_token. Default value is 18000 seconds / 5 hours. After this + time the token expires.

+ + Args: + authorization (str): + accept (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + GetAccessTokenResponse + """ + + return ( + await asyncio_detailed( + client=client, + authorization=authorization, + accept=accept, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/get_access_token_info.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/get_access_token_info.py new file mode 100644 index 0000000..8ee9b86 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/get_access_token_info.py @@ -0,0 +1,173 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.get_access_token_info_401_response import GetAccessTokenInfo401Response +from ...models.get_access_token_info_response import GetAccessTokenInfoResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + token: str | Unset = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["token"] = token + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/v1/auth/accesstoken/info", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> GetAccessTokenInfo401Response | GetAccessTokenInfoResponse | None: + if response.status_code == 200: + response_200 = GetAccessTokenInfoResponse.from_dict(response.json()) + + return response_200 + + if response.status_code == 401: + response_401 = GetAccessTokenInfo401Response.from_dict(response.json()) + + return response_401 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[GetAccessTokenInfo401Response | GetAccessTokenInfoResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + token: str | Unset = UNSET, +) -> Response[GetAccessTokenInfo401Response | GetAccessTokenInfoResponse]: + """Get Access Token Info + + The Get access_token Info API call provides an information about the issued token. + + Args: + token (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[GetAccessTokenInfo401Response | GetAccessTokenInfoResponse] + """ + + kwargs = _get_kwargs( + token=token, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + token: str | Unset = UNSET, +) -> GetAccessTokenInfo401Response | GetAccessTokenInfoResponse | None: + """Get Access Token Info + + The Get access_token Info API call provides an information about the issued token. + + Args: + token (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + GetAccessTokenInfo401Response | GetAccessTokenInfoResponse + """ + + return sync_detailed( + client=client, + token=token, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + token: str | Unset = UNSET, +) -> Response[GetAccessTokenInfo401Response | GetAccessTokenInfoResponse]: + """Get Access Token Info + + The Get access_token Info API call provides an information about the issued token. + + Args: + token (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[GetAccessTokenInfo401Response | GetAccessTokenInfoResponse] + """ + + kwargs = _get_kwargs( + token=token, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + token: str | Unset = UNSET, +) -> GetAccessTokenInfo401Response | GetAccessTokenInfoResponse | None: + """Get Access Token Info + + The Get access_token Info API call provides an information about the issued token. + + Args: + token (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + GetAccessTokenInfo401Response | GetAccessTokenInfoResponse + """ + + return ( + await asyncio_detailed( + client=client, + token=token, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/revoke_access_token.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/revoke_access_token.py new file mode 100644 index 0000000..07bc440 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/authentication/revoke_access_token.py @@ -0,0 +1,171 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.revoke_access_token_response import RevokeAccessTokenResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + token: str | Unset = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["token"] = token + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/v1/auth/accesstoken/revoke", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> RevokeAccessTokenResponse | None: + if response.status_code == 200: + response_200 = RevokeAccessTokenResponse.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[RevokeAccessTokenResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + token: str | Unset = UNSET, +) -> Response[RevokeAccessTokenResponse]: + """Revoke Access Token + + The Revoke access_token API call provides you an option to revoke your access_token, which not yet + expired. + + Args: + token (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[RevokeAccessTokenResponse] + """ + + kwargs = _get_kwargs( + token=token, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + token: str | Unset = UNSET, +) -> RevokeAccessTokenResponse | None: + """Revoke Access Token + + The Revoke access_token API call provides you an option to revoke your access_token, which not yet + expired. + + Args: + token (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + RevokeAccessTokenResponse + """ + + return sync_detailed( + client=client, + token=token, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + token: str | Unset = UNSET, +) -> Response[RevokeAccessTokenResponse]: + """Revoke Access Token + + The Revoke access_token API call provides you an option to revoke your access_token, which not yet + expired. + + Args: + token (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[RevokeAccessTokenResponse] + """ + + kwargs = _get_kwargs( + token=token, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + token: str | Unset = UNSET, +) -> RevokeAccessTokenResponse | None: + """Revoke Access Token + + The Revoke access_token API call provides you an option to revoke your access_token, which not yet + expired. + + Args: + token (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + RevokeAccessTokenResponse + """ + + return ( + await asyncio_detailed( + client=client, + token=token, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/aw_bs/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/aw_bs/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/aw_bs/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/aw_bs/create_awb.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/aw_bs/create_awb.py new file mode 100644 index 0000000..d093099 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/aw_bs/create_awb.py @@ -0,0 +1,214 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.awb import Awb +from ...models.cws_error_dto import CwsErrorDTO +from ...types import Response + + +def _get_kwargs( + *, + body: Awb, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/awbs", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Awb | CwsErrorDTO | None: + if response.status_code == 200: + response_200 = Awb.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Awb | CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: Awb, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[Awb | CwsErrorDTO]: + """Create a Single AWB + + Creates a new single awb based on the given data. This request will be decommissioned. Please use + /dpi/v1/bulk/{customerEkp}/mixedorders instead. + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (Awb): Example: {'customerEkp': '9012345678', 'contactName': 'Max Mustermann', + 'awbCopyCount': 3, 'product': 'GMP', 'serviceLevel': 'PRIORITY', 'itemFormat': 'P', + 'jobReference': 'Job ref', 'totalWeight': 5, 'telephoneNumber': '+4935120681234'}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Awb | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + body=body, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + body: Awb, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Awb | CwsErrorDTO | None: + """Create a Single AWB + + Creates a new single awb based on the given data. This request will be decommissioned. Please use + /dpi/v1/bulk/{customerEkp}/mixedorders instead. + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (Awb): Example: {'customerEkp': '9012345678', 'contactName': 'Max Mustermann', + 'awbCopyCount': 3, 'product': 'GMP', 'serviceLevel': 'PRIORITY', 'itemFormat': 'P', + 'jobReference': 'Job ref', 'totalWeight': 5, 'telephoneNumber': '+4935120681234'}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Awb | CwsErrorDTO + """ + + return sync_detailed( + client=client, + body=body, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: Awb, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[Awb | CwsErrorDTO]: + """Create a Single AWB + + Creates a new single awb based on the given data. This request will be decommissioned. Please use + /dpi/v1/bulk/{customerEkp}/mixedorders instead. + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (Awb): Example: {'customerEkp': '9012345678', 'contactName': 'Max Mustermann', + 'awbCopyCount': 3, 'product': 'GMP', 'serviceLevel': 'PRIORITY', 'itemFormat': 'P', + 'jobReference': 'Job ref', 'totalWeight': 5, 'telephoneNumber': '+4935120681234'}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Awb | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + body=body, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + body: Awb, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Awb | CwsErrorDTO | None: + """Create a Single AWB + + Creates a new single awb based on the given data. This request will be decommissioned. Please use + /dpi/v1/bulk/{customerEkp}/mixedorders instead. + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (Awb): Example: {'customerEkp': '9012345678', 'contactName': 'Max Mustermann', + 'awbCopyCount': 3, 'product': 'GMP', 'serviceLevel': 'PRIORITY', 'itemFormat': 'P', + 'jobReference': 'Job ref', 'totalWeight': 5, 'telephoneNumber': '+4935120681234'}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Awb | CwsErrorDTO + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/create_bulk_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/create_bulk_order.py new file mode 100644 index 0000000..d0b2dc3 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/create_bulk_order.py @@ -0,0 +1,220 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.bag_order import BagOrder +from ...models.cws_error_dto import CwsErrorDTO +from ...types import Response + + +def _get_kwargs( + customer_ekp: int, + *, + body: BagOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/bulk/{customer_ekp}/orders".format( + customer_ekp=quote(str(customer_ekp), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> BagOrder | CwsErrorDTO | None: + if response.status_code == 200: + response_200 = BagOrder.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[BagOrder | CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: int, + *, + client: AuthenticatedClient | Client, + body: BagOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[BagOrder | CwsErrorDTO]: + """Create a Bulk Order + + Creates a new bulk order based on the given data + + Args: + customer_ekp (int): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (BagOrder): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[BagOrder | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: int, + *, + client: AuthenticatedClient | Client, + body: BagOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> BagOrder | CwsErrorDTO | None: + """Create a Bulk Order + + Creates a new bulk order based on the given data + + Args: + customer_ekp (int): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (BagOrder): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + BagOrder | CwsErrorDTO + """ + + return sync_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + customer_ekp: int, + *, + client: AuthenticatedClient | Client, + body: BagOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[BagOrder | CwsErrorDTO]: + """Create a Bulk Order + + Creates a new bulk order based on the given data + + Args: + customer_ekp (int): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (BagOrder): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[BagOrder | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: int, + *, + client: AuthenticatedClient | Client, + body: BagOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> BagOrder | CwsErrorDTO | None: + """Create a Bulk Order + + Creates a new bulk order based on the given data + + Args: + customer_ekp (int): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (BagOrder): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + BagOrder | CwsErrorDTO + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/create_mixed_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/create_mixed_order.py new file mode 100644 index 0000000..cd892ca --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/create_mixed_order.py @@ -0,0 +1,223 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.bulk_order_dto import BulkOrderDto +from ...models.cws_error_dto import CwsErrorDTO +from ...models.mixed_bag_order_dto import MixedBagOrderDTO +from ...types import Response + + +def _get_kwargs( + customer_ekp: str, + *, + body: MixedBagOrderDTO, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/bulk/{customer_ekp}/mixedorders".format( + customer_ekp=quote(str(customer_ekp), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> BulkOrderDto | CwsErrorDTO | None: + if response.status_code == 200: + response_200 = BulkOrderDto.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[BulkOrderDto | CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: MixedBagOrderDTO, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[BulkOrderDto | CwsErrorDTO]: + """Create a Mixed Order + + Creates a new mixed order based on the given data. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (MixedBagOrderDTO): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[BulkOrderDto | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: MixedBagOrderDTO, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> BulkOrderDto | CwsErrorDTO | None: + """Create a Mixed Order + + Creates a new mixed order based on the given data. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (MixedBagOrderDTO): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + BulkOrderDto | CwsErrorDTO + """ + + return sync_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: MixedBagOrderDTO, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[BulkOrderDto | CwsErrorDTO]: + """Create a Mixed Order + + Creates a new mixed order based on the given data. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (MixedBagOrderDTO): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[BulkOrderDto | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: MixedBagOrderDTO, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> BulkOrderDto | CwsErrorDTO | None: + """Create a Mixed Order + + Creates a new mixed order based on the given data. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (MixedBagOrderDTO): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + BulkOrderDto | CwsErrorDTO + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/download_bulk_paperwork.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/download_bulk_paperwork.py new file mode 100644 index 0000000..31d51eb --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/download_bulk_paperwork.py @@ -0,0 +1,210 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.order import Order +from ...types import Response + + +def _get_kwargs( + customer_ekp: str, + order_id: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/bulk/{customer_ekp}/orders/{order_id}/paperwork".format( + customer_ekp=quote(str(customer_ekp), safe=""), + order_id=quote(str(order_id), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Order | None: + if response.status_code == 200: + response_200 = Order.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Order]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Order]: + """Get Bulk Paperwork + + Gets the paperwork in zip format for the given orderId. + + Args: + customer_ekp (str): + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + order_id=order_id, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Order | None: + """Get Bulk Paperwork + + Gets the paperwork in zip format for the given orderId. + + Args: + customer_ekp (str): + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return sync_detailed( + customer_ekp=customer_ekp, + order_id=order_id, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Order]: + """Get Bulk Paperwork + + Gets the paperwork in zip format for the given orderId. + + Args: + customer_ekp (str): + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + order_id=order_id, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Order | None: + """Get Bulk Paperwork + + Gets the paperwork in zip format for the given orderId. + + Args: + customer_ekp (str): + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + order_id=order_id, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/get_bag_tag_label.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/get_bag_tag_label.py new file mode 100644 index 0000000..bef53a8 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/get_bag_tag_label.py @@ -0,0 +1,216 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.get_bag_tag_label_accept import GetBagTagLabelAccept +from ...types import UNSET, Response + + +def _get_kwargs( + *, + bag_ids: list[str], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagLabelAccept, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + headers["accept"] = str(accept) + + params: dict[str, Any] = {} + + json_bag_ids = bag_ids + + params["bagIds"] = json_bag_ids + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/bulk/label", + "params": params, + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | CwsErrorDTO | None: + if response.status_code == 200: + response_200 = cast(Any, None) + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + bag_ids: list[str], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagLabelAccept, +) -> Response[Any | CwsErrorDTO]: + """Get Bag Tag Label + + For a given bag get the label of the bag tag, sentt as a bytestream response. + + Args: + bag_ids (list[str]): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetBagTagLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + bag_ids=bag_ids, + authorization=authorization, + accept=accept, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + bag_ids: list[str], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagLabelAccept, +) -> Any | CwsErrorDTO | None: + """Get Bag Tag Label + + For a given bag get the label of the bag tag, sentt as a bytestream response. + + Args: + bag_ids (list[str]): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetBagTagLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | CwsErrorDTO + """ + + return sync_detailed( + client=client, + bag_ids=bag_ids, + authorization=authorization, + accept=accept, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + bag_ids: list[str], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagLabelAccept, +) -> Response[Any | CwsErrorDTO]: + """Get Bag Tag Label + + For a given bag get the label of the bag tag, sentt as a bytestream response. + + Args: + bag_ids (list[str]): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetBagTagLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + bag_ids=bag_ids, + authorization=authorization, + accept=accept, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + bag_ids: list[str], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagLabelAccept, +) -> Any | CwsErrorDTO | None: + """Get Bag Tag Label + + For a given bag get the label of the bag tag, sentt as a bytestream response. + + Args: + bag_ids (list[str]): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetBagTagLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | CwsErrorDTO + """ + + return ( + await asyncio_detailed( + client=client, + bag_ids=bag_ids, + authorization=authorization, + accept=accept, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/get_bulk_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/get_bulk_order.py new file mode 100644 index 0000000..5f80ba7 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/bulk_orders/get_bulk_order.py @@ -0,0 +1,210 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.order import Order +from ...types import Response + + +def _get_kwargs( + customer_ekp: str, + order_id: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/bulk/{customer_ekp}/orders/{order_id}".format( + customer_ekp=quote(str(customer_ekp), safe=""), + order_id=quote(str(order_id), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Order | None: + if response.status_code == 200: + response_200 = Order.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Order]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Order]: + """Get a Bulk Order + + Searches the order for the given orderId. + + Args: + customer_ekp (str): + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + order_id=order_id, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Order | None: + """Get a Bulk Order + + Searches the order for the given orderId. + + Args: + customer_ekp (str): + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return sync_detailed( + customer_ekp=customer_ekp, + order_id=order_id, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Order]: + """Get a Bulk Order + + Searches the order for the given orderId. + + Args: + customer_ekp (str): + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + order_id=order_id, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Order | None: + """Get a Bulk Order + + Searches the order for the given orderId. + + Args: + customer_ekp (str): + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + order_id=order_id, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_closed_bag.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_closed_bag.py new file mode 100644 index 0000000..60084bb --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_closed_bag.py @@ -0,0 +1,238 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.closed_bag import ClosedBag +from ...models.cws_error_dto import CwsErrorDTO +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + customer_ekp: str, + *, + body: ClosedBag, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + if not isinstance(third_party_vendor_id, Unset): + headers["ThirdPartyVendor-ID"] = third_party_vendor_id + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/customers/{customer_ekp}/bags".format( + customer_ekp=quote(str(customer_ekp), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ClosedBag | CwsErrorDTO | None: + if response.status_code == 200: + response_200 = ClosedBag.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ClosedBag | CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: ClosedBag, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[ClosedBag | CwsErrorDTO]: + """Create a Closed Bag + + Creates and closes a bag. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (ClosedBag): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ClosedBag | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: ClosedBag, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> ClosedBag | CwsErrorDTO | None: + """Create a Closed Bag + + Creates and closes a bag. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (ClosedBag): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ClosedBag | CwsErrorDTO + """ + + return sync_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: ClosedBag, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[ClosedBag | CwsErrorDTO]: + """Create a Closed Bag + + Creates and closes a bag. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (ClosedBag): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ClosedBag | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: ClosedBag, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> ClosedBag | CwsErrorDTO | None: + """Create a Closed Bag + + Creates and closes a bag. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (ClosedBag): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ClosedBag | CwsErrorDTO + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_customer_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_customer_order.py new file mode 100644 index 0000000..5dff30f --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_customer_order.py @@ -0,0 +1,243 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.assemble_order import AssembleOrder +from ...models.cws_error_dto import CwsErrorDTO +from ...models.order import Order +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + customer_ekp: str, + *, + body: AssembleOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + if not isinstance(third_party_vendor_id, Unset): + headers["ThirdPartyVendor-ID"] = third_party_vendor_id + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/customers/{customer_ekp}/orders".format( + customer_ekp=quote(str(customer_ekp), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Order | None: + if response.status_code == 200: + response_200 = Order.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Order]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: AssembleOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Order]: + """Create Order + + Creates an order from already existing items. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (AssembleOrder): This assembles the items or bags to a new order. EITHER bagIds OR + itemBarcodes is REQUIRED Example: {'itemBarcodes': ['BC123456789DE', 'BC123456790DE', + 'BC123456791DE'], 'paperwork': {'contactName': 'John Doe', 'awbCopyCount': 3}}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: AssembleOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Order | None: + """Create Order + + Creates an order from already existing items. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (AssembleOrder): This assembles the items or bags to a new order. EITHER bagIds OR + itemBarcodes is REQUIRED Example: {'itemBarcodes': ['BC123456789DE', 'BC123456790DE', + 'BC123456791DE'], 'paperwork': {'contactName': 'John Doe', 'awbCopyCount': 3}}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return sync_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: AssembleOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Order]: + """Create Order + + Creates an order from already existing items. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (AssembleOrder): This assembles the items or bags to a new order. EITHER bagIds OR + itemBarcodes is REQUIRED Example: {'itemBarcodes': ['BC123456789DE', 'BC123456790DE', + 'BC123456791DE'], 'paperwork': {'contactName': 'John Doe', 'awbCopyCount': 3}}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: AssembleOrder, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Order | None: + """Create Order + + Creates an order from already existing items. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (AssembleOrder): This assembles the items or bags to a new order. EITHER bagIds OR + itemBarcodes is REQUIRED Example: {'itemBarcodes': ['BC123456789DE', 'BC123456790DE', + 'BC123456791DE'], 'paperwork': {'contactName': 'John Doe', 'awbCopyCount': 3}}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_item.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_item.py new file mode 100644 index 0000000..f9497a5 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/create_item.py @@ -0,0 +1,261 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.item import Item +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + customer_ekp: str, + *, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + if not isinstance(third_party_vendor_id, Unset): + headers["ThirdPartyVendor-ID"] = third_party_vendor_id + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/customers/{customer_ekp}/items".format( + customer_ekp=quote(str(customer_ekp), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Item | None: + if response.status_code == 200: + response_200 = Item.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Item]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Item]: + """Create Single Item + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Item | None: + """Create Single Item + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return sync_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Item]: + """Create Single Item + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Item | None: + """Create Single Item + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_bag_tag.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_bag_tag.py new file mode 100644 index 0000000..61f3976 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_bag_tag.py @@ -0,0 +1,224 @@ +from http import HTTPStatus +from typing import Any, cast +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.get_bag_tag_accept import GetBagTagAccept +from ...types import Response + + +def _get_kwargs( + customer_ekp: str, + bag_id: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagAccept, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + headers["accept"] = str(accept) + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/customers/{customer_ekp}/bags/{bag_id}/label".format( + customer_ekp=quote(str(customer_ekp), safe=""), + bag_id=quote(str(bag_id), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CwsErrorDTO | list[str] | None: + if response.status_code == 200: + response_200 = cast(list[str], response.json()) + + return response_200 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | list[str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + bag_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagAccept, +) -> Response[CwsErrorDTO | list[str]]: + """Get Label for Bag + + For a given bag a label is generated or retrieved from the cache and send to the requestor. + + Args: + customer_ekp (str): + bag_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetBagTagAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | list[str]] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + bag_id=bag_id, + authorization=authorization, + accept=accept, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + bag_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagAccept, +) -> CwsErrorDTO | list[str] | None: + """Get Label for Bag + + For a given bag a label is generated or retrieved from the cache and send to the requestor. + + Args: + customer_ekp (str): + bag_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetBagTagAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | list[str] + """ + + return sync_detailed( + customer_ekp=customer_ekp, + bag_id=bag_id, + client=client, + authorization=authorization, + accept=accept, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + bag_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagAccept, +) -> Response[CwsErrorDTO | list[str]]: + """Get Label for Bag + + For a given bag a label is generated or retrieved from the cache and send to the requestor. + + Args: + customer_ekp (str): + bag_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetBagTagAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | list[str]] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + bag_id=bag_id, + authorization=authorization, + accept=accept, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + bag_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetBagTagAccept, +) -> CwsErrorDTO | list[str] | None: + """Get Label for Bag + + For a given bag a label is generated or retrieved from the cache and send to the requestor. + + Args: + customer_ekp (str): + bag_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetBagTagAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | list[str] + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + bag_id=bag_id, + client=client, + authorization=authorization, + accept=accept, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_customer_item_label.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_customer_item_label.py new file mode 100644 index 0000000..849a57f --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_customer_item_label.py @@ -0,0 +1,223 @@ +from http import HTTPStatus +from typing import Any, cast +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.get_customer_item_label_accept import GetCustomerItemLabelAccept +from ...types import Response + + +def _get_kwargs( + customer_ekp: str, + barcode: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetCustomerItemLabelAccept, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + headers["accept"] = str(accept) + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/customers/{customer_ekp}/items/{barcode}/label".format( + customer_ekp=quote(str(customer_ekp), safe=""), + barcode=quote(str(barcode), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | str | None: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | str]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetCustomerItemLabelAccept, +) -> Response[CwsErrorDTO | str]: + """Get Label for Item + + For a given item a label is generated or retrieved from the cache and send to the requestor as a + bytestream response. + + Args: + customer_ekp (str): + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetCustomerItemLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | str] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + barcode=barcode, + authorization=authorization, + accept=accept, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetCustomerItemLabelAccept, +) -> CwsErrorDTO | str | None: + """Get Label for Item + + For a given item a label is generated or retrieved from the cache and send to the requestor as a + bytestream response. + + Args: + customer_ekp (str): + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetCustomerItemLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | str + """ + + return sync_detailed( + customer_ekp=customer_ekp, + barcode=barcode, + client=client, + authorization=authorization, + accept=accept, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetCustomerItemLabelAccept, +) -> Response[CwsErrorDTO | str]: + """Get Label for Item + + For a given item a label is generated or retrieved from the cache and send to the requestor as a + bytestream response. + + Args: + customer_ekp (str): + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetCustomerItemLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | str] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + barcode=barcode, + authorization=authorization, + accept=accept, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetCustomerItemLabelAccept, +) -> CwsErrorDTO | str | None: + """Get Label for Item + + For a given item a label is generated or retrieved from the cache and send to the requestor as a + bytestream response. + + Args: + customer_ekp (str): + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetCustomerItemLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | str + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + barcode=barcode, + client=client, + authorization=authorization, + accept=accept, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_item_by_barcode.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_item_by_barcode.py new file mode 100644 index 0000000..1e5354d --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_item_by_barcode.py @@ -0,0 +1,205 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.item import Item +from ...types import Response + + +def _get_kwargs( + customer_ekp: str, + barcode: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/customers/{customer_ekp}/items/{barcode}".format( + customer_ekp=quote(str(customer_ekp), safe=""), + barcode=quote(str(barcode), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Item | None: + if response.status_code == 200: + response_200 = Item.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Item]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Item]: + """Retrieve Data for Item + + For a given item of a customer the data is retrieved. + + Args: + customer_ekp (str): + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + barcode=barcode, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Item | None: + """Retrieve Data for Item + + For a given item of a customer the data is retrieved. + + Args: + customer_ekp (str): + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return sync_detailed( + customer_ekp=customer_ekp, + barcode=barcode, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Item]: + """Retrieve Data for Item + + For a given item of a customer the data is retrieved. + + Args: + customer_ekp (str): + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + barcode=barcode, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Item | None: + """Retrieve Data for Item + + For a given item of a customer the data is retrieved. + + Args: + customer_ekp (str): + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + barcode=barcode, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_items.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_items.py new file mode 100644 index 0000000..9da4303 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/get_items.py @@ -0,0 +1,260 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.get_items_status import GetItemsStatus +from ...models.item import Item +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + customer_ekp: str, + *, + status: GetItemsStatus | Unset = GetItemsStatus.NEW, + page: int | Unset = 0, + page_size: int | Unset = 10, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + params: dict[str, Any] = {} + + json_status: str | Unset = UNSET + if not isinstance(status, Unset): + json_status = status.value + + params["status"] = json_status + + params["page"] = page + + params["pageSize"] = page_size + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/customers/{customer_ekp}/items".format( + customer_ekp=quote(str(customer_ekp), safe=""), + ), + "params": params, + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CwsErrorDTO | list[Item] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for componentsschemas_list_of_items_item_data in _response_200: + componentsschemas_list_of_items_item = Item.from_dict(componentsschemas_list_of_items_item_data) + + response_200.append(componentsschemas_list_of_items_item) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | list[Item]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + status: GetItemsStatus | Unset = GetItemsStatus.NEW, + page: int | Unset = 0, + page_size: int | Unset = 10, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | list[Item]]: + """Get Available Items + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + status (GetItemsStatus | Unset): Default: GetItemsStatus.NEW. + page (int | Unset): Default: 0. + page_size (int | Unset): Default: 10. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | list[Item]] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + status=status, + page=page, + page_size=page_size, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + status: GetItemsStatus | Unset = GetItemsStatus.NEW, + page: int | Unset = 0, + page_size: int | Unset = 10, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | list[Item] | None: + """Get Available Items + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + status (GetItemsStatus | Unset): Default: GetItemsStatus.NEW. + page (int | Unset): Default: 0. + page_size (int | Unset): Default: 10. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | list[Item] + """ + + return sync_detailed( + customer_ekp=customer_ekp, + client=client, + status=status, + page=page, + page_size=page_size, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + status: GetItemsStatus | Unset = GetItemsStatus.NEW, + page: int | Unset = 0, + page_size: int | Unset = 10, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | list[Item]]: + """Get Available Items + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + status (GetItemsStatus | Unset): Default: GetItemsStatus.NEW. + page (int | Unset): Default: 0. + page_size (int | Unset): Default: 10. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | list[Item]] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + status=status, + page=page, + page_size=page_size, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + *, + client: AuthenticatedClient | Client, + status: GetItemsStatus | Unset = GetItemsStatus.NEW, + page: int | Unset = 0, + page_size: int | Unset = 10, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | list[Item] | None: + """Get Available Items + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + status (GetItemsStatus | Unset): Default: GetItemsStatus.NEW. + page (int | Unset): Default: 0. + page_size (int | Unset): Default: 10. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | list[Item] + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + client=client, + status=status, + page=page, + page_size=page_size, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/update_customer_item.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/update_customer_item.py new file mode 100644 index 0000000..522745a --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/customers/update_customer_item.py @@ -0,0 +1,256 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.item import Item +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + customer_ekp: str, + barcode: str, + *, + body: Item, + third_party_vendor_id: str | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + if not isinstance(third_party_vendor_id, Unset): + headers["ThirdPartyVendor-ID"] = third_party_vendor_id + + _kwargs: dict[str, Any] = { + "method": "put", + "url": "/dpi/shipping/v1/customers/{customer_ekp}/items/{barcode}".format( + customer_ekp=quote(str(customer_ekp), safe=""), + barcode=quote(str(barcode), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Item | None: + if response.status_code == 200: + response_200 = Item.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Item]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + body: Item, + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Item]: + """Update a single item. + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + barcode (str): + third_party_vendor_id (str | Unset): + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + barcode=barcode, + body=body, + third_party_vendor_id=third_party_vendor_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + body: Item, + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Item | None: + """Update a single item. + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + barcode (str): + third_party_vendor_id (str | Unset): + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return sync_detailed( + customer_ekp=customer_ekp, + barcode=barcode, + client=client, + body=body, + third_party_vendor_id=third_party_vendor_id, + ).parsed + + +async def asyncio_detailed( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + body: Item, + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Item]: + """Update a single item. + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + barcode (str): + third_party_vendor_id (str | Unset): + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + customer_ekp=customer_ekp, + barcode=barcode, + body=body, + third_party_vendor_id=third_party_vendor_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_ekp: str, + barcode: str, + *, + client: AuthenticatedClient | Client, + body: Item, + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Item | None: + """Update a single item. + + Single items are not attached to an order. Adding items to an order can be done later. + + Args: + customer_ekp (str): + barcode (str): + third_party_vendor_id (str | Unset): + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return ( + await asyncio_detailed( + customer_ekp=customer_ekp, + barcode=barcode, + client=client, + body=body, + third_party_vendor_id=third_party_vendor_id, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/delete_item.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/delete_item.py new file mode 100644 index 0000000..84174c2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/delete_item.py @@ -0,0 +1,202 @@ +from http import HTTPStatus +from typing import Any, cast +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...types import Response + + +def _get_kwargs( + item_id: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "delete", + "url": "/dpi/shipping/v1/items/{item_id}".format( + item_id=quote(str(item_id), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | CwsErrorDTO | None: + if response.status_code == 200: + response_200 = cast(Any, None) + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[Any | CwsErrorDTO]: + """Delete Item + + Deletes the item for the specified item id.

This operation only works for items attached to + orders that are in the OPEN state. Called on items of orders in the FINALIZED state leads to an 404 + error (an item with the desired attributes cannot be found). + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + item_id=item_id, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Any | CwsErrorDTO | None: + """Delete Item + + Deletes the item for the specified item id.

This operation only works for items attached to + orders that are in the OPEN state. Called on items of orders in the FINALIZED state leads to an 404 + error (an item with the desired attributes cannot be found). + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | CwsErrorDTO + """ + + return sync_detailed( + item_id=item_id, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[Any | CwsErrorDTO]: + """Delete Item + + Deletes the item for the specified item id.

This operation only works for items attached to + orders that are in the OPEN state. Called on items of orders in the FINALIZED state leads to an 404 + error (an item with the desired attributes cannot be found). + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + item_id=item_id, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Any | CwsErrorDTO | None: + """Delete Item + + Deletes the item for the specified item id.

This operation only works for items attached to + orders that are in the OPEN state. Called on items of orders in the FINALIZED state leads to an 404 + error (an item with the desired attributes cannot be found). + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | CwsErrorDTO + """ + + return ( + await asyncio_detailed( + item_id=item_id, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/get_item_by_id.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/get_item_by_id.py new file mode 100644 index 0000000..40fe205 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/get_item_by_id.py @@ -0,0 +1,196 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.item import Item +from ...types import Response + + +def _get_kwargs( + item_id: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/items/{item_id}".format( + item_id=quote(str(item_id), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Item | None: + if response.status_code == 200: + response_200 = Item.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Item]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Item]: + """Get Item + + You get all information about a given item. + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + item_id=item_id, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Item | None: + """Get Item + + You get all information about a given item. + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return sync_detailed( + item_id=item_id, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Item]: + """Get Item + + You get all information about a given item. + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + item_id=item_id, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Item | None: + """Get Item + + You get all information about a given item. + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return ( + await asyncio_detailed( + item_id=item_id, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/get_item_label.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/get_item_label.py new file mode 100644 index 0000000..68bb337 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/get_item_label.py @@ -0,0 +1,209 @@ +from http import HTTPStatus +from typing import Any, cast +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.get_item_label_accept import GetItemLabelAccept +from ...types import Response + + +def _get_kwargs( + item_id: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelAccept, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + headers["accept"] = str(accept) + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/items/{item_id}/label".format( + item_id=quote(str(item_id), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | str | None: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | str]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelAccept, +) -> Response[CwsErrorDTO | str]: + """Get Item Label + + For a given item a label is generated or retrieved from the cache and send to the requestor as a + bytestream response. + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetItemLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | str] + """ + + kwargs = _get_kwargs( + item_id=item_id, + authorization=authorization, + accept=accept, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelAccept, +) -> CwsErrorDTO | str | None: + """Get Item Label + + For a given item a label is generated or retrieved from the cache and send to the requestor as a + bytestream response. + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetItemLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | str + """ + + return sync_detailed( + item_id=item_id, + client=client, + authorization=authorization, + accept=accept, + ).parsed + + +async def asyncio_detailed( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelAccept, +) -> Response[CwsErrorDTO | str]: + """Get Item Label + + For a given item a label is generated or retrieved from the cache and send to the requestor as a + bytestream response. + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetItemLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | str] + """ + + kwargs = _get_kwargs( + item_id=item_id, + authorization=authorization, + accept=accept, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + item_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelAccept, +) -> CwsErrorDTO | str | None: + """Get Item Label + + For a given item a label is generated or retrieved from the cache and send to the requestor as a + bytestream response. + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetItemLabelAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | str + """ + + return ( + await asyncio_detailed( + item_id=item_id, + client=client, + authorization=authorization, + accept=accept, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/update_item_in_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/update_item_in_order.py new file mode 100644 index 0000000..223734c --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/items/update_item_in_order.py @@ -0,0 +1,257 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.item import Item +from ...types import Response + + +def _get_kwargs( + item_id: str, + *, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "put", + "url": "/dpi/shipping/v1/items/{item_id}".format( + item_id=quote(str(item_id), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Item | None: + if response.status_code == 200: + response_200 = Item.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Item]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + item_id: str, + *, + client: AuthenticatedClient | Client, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Item]: + """Update item + + Updates the item for the specified item id.

This operation only works for items attached to + orders that are in the OPEN state. Called on items of orders in the FINALIZED state leads to an 404 + error (an item with the desired attributes cannot be found). The following fields are not updatable: + product, serviceLevel, destinationCountry + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + item_id=item_id, + body=body, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + item_id: str, + *, + client: AuthenticatedClient | Client, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Item | None: + """Update item + + Updates the item for the specified item id.

This operation only works for items attached to + orders that are in the OPEN state. Called on items of orders in the FINALIZED state leads to an 404 + error (an item with the desired attributes cannot be found). The following fields are not updatable: + product, serviceLevel, destinationCountry + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return sync_detailed( + item_id=item_id, + client=client, + body=body, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + item_id: str, + *, + client: AuthenticatedClient | Client, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Item]: + """Update item + + Updates the item for the specified item id.

This operation only works for items attached to + orders that are in the OPEN state. Called on items of orders in the FINALIZED state leads to an 404 + error (an item with the desired attributes cannot be found). The following fields are not updatable: + product, serviceLevel, destinationCountry + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Item] + """ + + kwargs = _get_kwargs( + item_id=item_id, + body=body, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + item_id: str, + *, + client: AuthenticatedClient | Client, + body: Item, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Item | None: + """Update item + + Updates the item for the specified item id.

This operation only works for items attached to + orders that are in the OPEN state. Called on items of orders in the FINALIZED state leads to an 404 + error (an item with the desired attributes cannot be found). The following fields are not updatable: + product, serviceLevel, destinationCountry + + Args: + item_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + body (Item): Example: {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris + Bronson', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'postalCode': + 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': 'BRE-2021-XIT', + 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Item + """ + + return ( + await asyncio_detailed( + item_id=item_id, + client=client, + body=body, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/add_order_items.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/add_order_items.py new file mode 100644 index 0000000..1f978dd --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/add_order_items.py @@ -0,0 +1,242 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.item import Item +from ...models.item_response import ItemResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + order_id: str, + *, + body: list[Item], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + if not isinstance(third_party_vendor_id, Unset): + headers["ThirdPartyVendor-ID"] = third_party_vendor_id + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/orders/{order_id}/items".format( + order_id=quote(str(order_id), safe=""), + ), + } + + _kwargs["json"] = [] + for body_item_data in body: + body_item = body_item_data.to_dict() + _kwargs["json"].append(body_item) + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CwsErrorDTO | ItemResponse | None: + if response.status_code == 200: + response_200 = ItemResponse.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | ItemResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + order_id: str, + *, + client: AuthenticatedClient | Client, + body: list[Item], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | ItemResponse]: + """Add Items to an Order + + Add new item(s) to a open order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (list[Item]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | ItemResponse] + """ + + kwargs = _get_kwargs( + order_id=order_id, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + order_id: str, + *, + client: AuthenticatedClient | Client, + body: list[Item], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | ItemResponse | None: + """Add Items to an Order + + Add new item(s) to a open order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (list[Item]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | ItemResponse + """ + + return sync_detailed( + order_id=order_id, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ).parsed + + +async def asyncio_detailed( + order_id: str, + *, + client: AuthenticatedClient | Client, + body: list[Item], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | ItemResponse]: + """Add Items to an Order + + Add new item(s) to a open order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (list[Item]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | ItemResponse] + """ + + kwargs = _get_kwargs( + order_id=order_id, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + order_id: str, + *, + client: AuthenticatedClient | Client, + body: list[Item], + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | ItemResponse | None: + """Add Items to an Order + + Add new item(s) to a open order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (list[Item]): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | ItemResponse + """ + + return ( + await asyncio_detailed( + order_id=order_id, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/create_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/create_order.py new file mode 100644 index 0000000..034d8bf --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/create_order.py @@ -0,0 +1,271 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.order_data import OrderData +from ...models.order_response import OrderResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: OrderData, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + if not isinstance(third_party_vendor_id, Unset): + headers["ThirdPartyVendor-ID"] = third_party_vendor_id + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/orders", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CwsErrorDTO | OrderResponse | None: + if response.status_code == 200: + response_200 = OrderResponse.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | OrderResponse]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: OrderData, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | OrderResponse]: + """Create Order + + Creates a new order based on the given JSON data + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (OrderData): Example: {'customerEkp': '9012345678', 'orderStatus': 'FINALIZE', + 'paperwork': {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': 'Job ref', + 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}, 'items': + [{'product': 'GMP', 'serviceLevel': 'PRIORITY', 'recipient': 'John Doe', 'addressLine1': + 'Any Street', 'addressLine2': 'Flat 2', 'addressLine3': '1st floor', 'postalCode': + '01432', 'city': 'Any City', 'state': 'Any State', 'destinationCountry': 'DE', 'custRef': + 'REF-2361890-AB', 'recipientPhone': '+44123456789', 'recipientFax': '+44123456789', + 'recipientEmail': 'john.doe@example.eu', 'senderTaxId': 'IOSS number', 'importerTaxId': + 'IOSS number', 'shipmentAmount': 100, 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': + 1500, 'returnItemWanted': False, 'shipmentNaturetype': 'SALE_GOODS', 'contents': + [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Trousers', + 'contentPieceValue': '120.50', 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', + 'contentPieceAmount': 2}]}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | OrderResponse] + """ + + kwargs = _get_kwargs( + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + body: OrderData, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | OrderResponse | None: + """Create Order + + Creates a new order based on the given JSON data + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (OrderData): Example: {'customerEkp': '9012345678', 'orderStatus': 'FINALIZE', + 'paperwork': {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': 'Job ref', + 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}, 'items': + [{'product': 'GMP', 'serviceLevel': 'PRIORITY', 'recipient': 'John Doe', 'addressLine1': + 'Any Street', 'addressLine2': 'Flat 2', 'addressLine3': '1st floor', 'postalCode': + '01432', 'city': 'Any City', 'state': 'Any State', 'destinationCountry': 'DE', 'custRef': + 'REF-2361890-AB', 'recipientPhone': '+44123456789', 'recipientFax': '+44123456789', + 'recipientEmail': 'john.doe@example.eu', 'senderTaxId': 'IOSS number', 'importerTaxId': + 'IOSS number', 'shipmentAmount': 100, 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': + 1500, 'returnItemWanted': False, 'shipmentNaturetype': 'SALE_GOODS', 'contents': + [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Trousers', + 'contentPieceValue': '120.50', 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', + 'contentPieceAmount': 2}]}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | OrderResponse + """ + + return sync_detailed( + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: OrderData, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | OrderResponse]: + """Create Order + + Creates a new order based on the given JSON data + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (OrderData): Example: {'customerEkp': '9012345678', 'orderStatus': 'FINALIZE', + 'paperwork': {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': 'Job ref', + 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}, 'items': + [{'product': 'GMP', 'serviceLevel': 'PRIORITY', 'recipient': 'John Doe', 'addressLine1': + 'Any Street', 'addressLine2': 'Flat 2', 'addressLine3': '1st floor', 'postalCode': + '01432', 'city': 'Any City', 'state': 'Any State', 'destinationCountry': 'DE', 'custRef': + 'REF-2361890-AB', 'recipientPhone': '+44123456789', 'recipientFax': '+44123456789', + 'recipientEmail': 'john.doe@example.eu', 'senderTaxId': 'IOSS number', 'importerTaxId': + 'IOSS number', 'shipmentAmount': 100, 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': + 1500, 'returnItemWanted': False, 'shipmentNaturetype': 'SALE_GOODS', 'contents': + [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Trousers', + 'contentPieceValue': '120.50', 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', + 'contentPieceAmount': 2}]}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | OrderResponse] + """ + + kwargs = _get_kwargs( + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + body: OrderData, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | OrderResponse | None: + """Create Order + + Creates a new order based on the given JSON data + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (OrderData): Example: {'customerEkp': '9012345678', 'orderStatus': 'FINALIZE', + 'paperwork': {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': 'Job ref', + 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}, 'items': + [{'product': 'GMP', 'serviceLevel': 'PRIORITY', 'recipient': 'John Doe', 'addressLine1': + 'Any Street', 'addressLine2': 'Flat 2', 'addressLine3': '1st floor', 'postalCode': + '01432', 'city': 'Any City', 'state': 'Any State', 'destinationCountry': 'DE', 'custRef': + 'REF-2361890-AB', 'recipientPhone': '+44123456789', 'recipientFax': '+44123456789', + 'recipientEmail': 'john.doe@example.eu', 'senderTaxId': 'IOSS number', 'importerTaxId': + 'IOSS number', 'shipmentAmount': 100, 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': + 1500, 'returnItemWanted': False, 'shipmentNaturetype': 'SALE_GOODS', 'contents': + [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Trousers', + 'contentPieceValue': '120.50', 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', + 'contentPieceAmount': 2}]}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | OrderResponse + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/finalize_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/finalize_order.py new file mode 100644 index 0000000..182862f --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/finalize_order.py @@ -0,0 +1,239 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.order import Order +from ...models.paperwork import Paperwork +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + order_id: str, + *, + body: Paperwork, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + if not isinstance(third_party_vendor_id, Unset): + headers["ThirdPartyVendor-ID"] = third_party_vendor_id + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/orders/{order_id}/finalization".format( + order_id=quote(str(order_id), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Order | None: + if response.status_code == 200: + response_200 = Order.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Order]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + order_id: str, + *, + client: AuthenticatedClient | Client, + body: Paperwork, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Order]: + """Finalize open Order + + Finalize the given open Order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Paperwork): Example: {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': + 'Job ref', 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + order_id=order_id, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + order_id: str, + *, + client: AuthenticatedClient | Client, + body: Paperwork, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Order | None: + """Finalize open Order + + Finalize the given open Order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Paperwork): Example: {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': + 'Job ref', 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return sync_detailed( + order_id=order_id, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ).parsed + + +async def asyncio_detailed( + order_id: str, + *, + client: AuthenticatedClient | Client, + body: Paperwork, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Order]: + """Finalize open Order + + Finalize the given open Order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Paperwork): Example: {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': + 'Job ref', 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + order_id=order_id, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + order_id: str, + *, + client: AuthenticatedClient | Client, + body: Paperwork, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Order | None: + """Finalize open Order + + Finalize the given open Order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Paperwork): Example: {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': + 'Job ref', 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return ( + await asyncio_detailed( + order_id=order_id, + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/get_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/get_order.py new file mode 100644 index 0000000..1ed51df --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/get_order.py @@ -0,0 +1,196 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.order import Order +from ...types import Response + + +def _get_kwargs( + order_id: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/orders/{order_id}".format( + order_id=quote(str(order_id), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Order | None: + if response.status_code == 200: + response_200 = Order.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | Order]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Order]: + """Get Order + + Searches the order for the given orderId. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + order_id=order_id, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Order | None: + """Get Order + + Searches the order for the given orderId. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return sync_detailed( + order_id=order_id, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Order]: + """Get Order + + Searches the order for the given orderId. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Order] + """ + + kwargs = _get_kwargs( + order_id=order_id, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Order | None: + """Get Order + + Searches the order for the given orderId. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Order + """ + + return ( + await asyncio_detailed( + order_id=order_id, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/get_shipments.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/get_shipments.py new file mode 100644 index 0000000..eaef2d3 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/orders/get_shipments.py @@ -0,0 +1,209 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.shipment import Shipment +from ...types import Response + + +def _get_kwargs( + order_id: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/orders/{order_id}/shipments".format( + order_id=quote(str(order_id), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CwsErrorDTO | list[Shipment] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = Shipment.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | list[Shipment]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | list[Shipment]]: + """Get Shipments for an Order + + Searches shipments attached to an given order. Answers with a not found status (404) if order does + not exist or if there are no shipmments attached to this order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | list[Shipment]] + """ + + kwargs = _get_kwargs( + order_id=order_id, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | list[Shipment] | None: + """Get Shipments for an Order + + Searches shipments attached to an given order. Answers with a not found status (404) if order does + not exist or if there are no shipmments attached to this order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | list[Shipment] + """ + + return sync_detailed( + order_id=order_id, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | list[Shipment]]: + """Get Shipments for an Order + + Searches shipments attached to an given order. Answers with a not found status (404) if order does + not exist or if there are no shipmments attached to this order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | list[Shipment]] + """ + + kwargs = _get_kwargs( + order_id=order_id, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + order_id: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | list[Shipment] | None: + """Get Shipments for an Order + + Searches shipments attached to an given order. Answers with a not found status (404) if order does + not exist or if there are no shipmments attached to this order. + + Args: + order_id (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | list[Shipment] + """ + + return ( + await asyncio_detailed( + order_id=order_id, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_awb_label.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_awb_label.py new file mode 100644 index 0000000..56707af --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_awb_label.py @@ -0,0 +1,198 @@ +from http import HTTPStatus +from typing import Any, cast +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...types import Response + + +def _get_kwargs( + awb: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/shipments/{awb}/awblabels".format( + awb=quote(str(awb), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | CwsErrorDTO | None: + if response.status_code == 200: + response_200 = cast(Any, None) + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[Any | CwsErrorDTO]: + """Get AWB Label + + For a given shipment awb an awb labels is generated or retrieved from the cache and send to the + requestor as a bytestream response. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + awb=awb, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Any | CwsErrorDTO | None: + """Get AWB Label + + For a given shipment awb an awb labels is generated or retrieved from the cache and send to the + requestor as a bytestream response. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | CwsErrorDTO + """ + + return sync_detailed( + awb=awb, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[Any | CwsErrorDTO]: + """Get AWB Label + + For a given shipment awb an awb labels is generated or retrieved from the cache and send to the + requestor as a bytestream response. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | CwsErrorDTO] + """ + + kwargs = _get_kwargs( + awb=awb, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Any | CwsErrorDTO | None: + """Get AWB Label + + For a given shipment awb an awb labels is generated or retrieved from the cache and send to the + requestor as a bytestream response. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | CwsErrorDTO + """ + + return ( + await asyncio_detailed( + awb=awb, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_item_labels.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_item_labels.py new file mode 100644 index 0000000..57e18fd --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_item_labels.py @@ -0,0 +1,214 @@ +from http import HTTPStatus +from typing import Any, cast +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.get_item_labels_accept import GetItemLabelsAccept +from ...types import Response + + +def _get_kwargs( + awb: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelsAccept, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + headers["accept"] = str(accept) + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/shipments/{awb}/itemlabels".format( + awb=quote(str(awb), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | str | None: + if response.status_code == 200: + response_200 = cast(str, response.json()) + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO | str]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelsAccept, +) -> Response[CwsErrorDTO | str]: + """Get Item Labels + + For a given shipment awb all item labels will be generated or retrieved from the cache and send to + the requestor as a bytestream response. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetItemLabelsAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | str] + """ + + kwargs = _get_kwargs( + awb=awb, + authorization=authorization, + accept=accept, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelsAccept, +) -> CwsErrorDTO | str | None: + """Get Item Labels + + For a given shipment awb all item labels will be generated or retrieved from the cache and send to + the requestor as a bytestream response. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetItemLabelsAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | str + """ + + return sync_detailed( + awb=awb, + client=client, + authorization=authorization, + accept=accept, + ).parsed + + +async def asyncio_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelsAccept, +) -> Response[CwsErrorDTO | str]: + """Get Item Labels + + For a given shipment awb all item labels will be generated or retrieved from the cache and send to + the requestor as a bytestream response. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetItemLabelsAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | str] + """ + + kwargs = _get_kwargs( + awb=awb, + authorization=authorization, + accept=accept, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + accept: GetItemLabelsAccept, +) -> CwsErrorDTO | str | None: + """Get Item Labels + + For a given shipment awb all item labels will be generated or retrieved from the cache and send to + the requestor as a bytestream response. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + accept (GetItemLabelsAccept): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | str + """ + + return ( + await asyncio_detailed( + awb=awb, + client=client, + authorization=authorization, + accept=accept, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_shipment.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_shipment.py new file mode 100644 index 0000000..6556136 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/shipments/get_shipment.py @@ -0,0 +1,198 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.shipment import Shipment +from ...types import Response + + +def _get_kwargs( + awb: str, + *, + authorization: str = "Bearer [place access_token token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/shipping/v1/shipments/{awb}".format( + awb=quote(str(awb), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Shipment | None: + if response.status_code == 200: + response_200 = Shipment.from_dict(response.json()) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | Shipment]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place access_token token here, without brackets]", +) -> Response[CwsErrorDTO | Shipment]: + """Get Shipment Data for AWB + + For a given shipment awb all available data will be send. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place access_token token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Shipment] + """ + + kwargs = _get_kwargs( + awb=awb, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place access_token token here, without brackets]", +) -> CwsErrorDTO | Shipment | None: + """Get Shipment Data for AWB + + For a given shipment awb all available data will be send. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place access_token token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Shipment + """ + + return sync_detailed( + awb=awb, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place access_token token here, without brackets]", +) -> Response[CwsErrorDTO | Shipment]: + """Get Shipment Data for AWB + + For a given shipment awb all available data will be send. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place access_token token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Shipment] + """ + + kwargs = _get_kwargs( + awb=awb, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place access_token token here, without brackets]", +) -> CwsErrorDTO | Shipment | None: + """Get Shipment Data for AWB + + For a given shipment awb all available data will be send. + + Args: + awb (str): + authorization (str): Default: 'Bearer [place access_token token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Shipment + """ + + return ( + await asyncio_detailed( + awb=awb, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_bag_and_events.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_bag_and_events.py new file mode 100644 index 0000000..813bf17 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_bag_and_events.py @@ -0,0 +1,205 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + customer_bag_id: str, + *, + matching: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + params: dict[str, Any] = {} + + params["matching"] = matching + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/tracking/v3/bag/{customer_bag_id}".format( + customer_bag_id=quote(str(customer_bag_id), safe=""), + ), + "params": params, + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | None: + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + customer_bag_id: str, + *, + client: AuthenticatedClient | Client, + matching: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO]: + """Get Trackings of bags V3 + + Get all tracking information of for the bag (identified by the given barcode). + + Args: + customer_bag_id (str): + matching (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO] + """ + + kwargs = _get_kwargs( + customer_bag_id=customer_bag_id, + matching=matching, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + customer_bag_id: str, + *, + client: AuthenticatedClient | Client, + matching: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | None: + """Get Trackings of bags V3 + + Get all tracking information of for the bag (identified by the given barcode). + + Args: + customer_bag_id (str): + matching (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO + """ + + return sync_detailed( + customer_bag_id=customer_bag_id, + client=client, + matching=matching, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + customer_bag_id: str, + *, + client: AuthenticatedClient | Client, + matching: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO]: + """Get Trackings of bags V3 + + Get all tracking information of for the bag (identified by the given barcode). + + Args: + customer_bag_id (str): + matching (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO] + """ + + kwargs = _get_kwargs( + customer_bag_id=customer_bag_id, + matching=matching, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + customer_bag_id: str, + *, + client: AuthenticatedClient | Client, + matching: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | None: + """Get Trackings of bags V3 + + Get all tracking information of for the bag (identified by the given barcode). + + Args: + customer_bag_id (str): + matching (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO + """ + + return ( + await asyncio_detailed( + customer_bag_id=customer_bag_id, + client=client, + matching=matching, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_tracking_for_airway_bill.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_tracking_for_airway_bill.py new file mode 100644 index 0000000..2f2df88 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_tracking_for_airway_bill.py @@ -0,0 +1,233 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + awb: str, + *, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + params: dict[str, Any] = {} + + params["language"] = language + + params["withEventType"] = with_event_type + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/tracking/v3/trackings/awb/{awb}".format( + awb=quote(str(awb), safe=""), + ), + "params": params, + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | None: + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO]: + """Get Tracking - Shipment V3 + + Get tracking information of all items of a shipment (identified by the given awb). More detailed + breakdown of track events compared to v1 but possibly more inconsisteny, duplicity and wrong + tracking order + + Args: + awb (str): + language (str | Unset): Default: 'en'. + with_event_type (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO] + """ + + kwargs = _get_kwargs( + awb=awb, + language=language, + with_event_type=with_event_type, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + awb: str, + *, + client: AuthenticatedClient | Client, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | None: + """Get Tracking - Shipment V3 + + Get tracking information of all items of a shipment (identified by the given awb). More detailed + breakdown of track events compared to v1 but possibly more inconsisteny, duplicity and wrong + tracking order + + Args: + awb (str): + language (str | Unset): Default: 'en'. + with_event_type (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO + """ + + return sync_detailed( + awb=awb, + client=client, + language=language, + with_event_type=with_event_type, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO]: + """Get Tracking - Shipment V3 + + Get tracking information of all items of a shipment (identified by the given awb). More detailed + breakdown of track events compared to v1 but possibly more inconsisteny, duplicity and wrong + tracking order + + Args: + awb (str): + language (str | Unset): Default: 'en'. + with_event_type (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO] + """ + + kwargs = _get_kwargs( + awb=awb, + language=language, + with_event_type=with_event_type, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + awb: str, + *, + client: AuthenticatedClient | Client, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | None: + """Get Tracking - Shipment V3 + + Get tracking information of all items of a shipment (identified by the given awb). More detailed + breakdown of track events compared to v1 but possibly more inconsisteny, duplicity and wrong + tracking order + + Args: + awb (str): + language (str | Unset): Default: 'en'. + with_event_type (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO + """ + + return ( + await asyncio_detailed( + awb=awb, + client=client, + language=language, + with_event_type=with_event_type, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_tracking_for_awb.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_tracking_for_awb.py new file mode 100644 index 0000000..ce537e6 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_tracking_for_awb.py @@ -0,0 +1,205 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.tracking import Tracking +from ...types import Response + + +def _get_kwargs( + awb: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/tracking/v1/trackings/awb/{awb}".format( + awb=quote(str(awb), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CwsErrorDTO | list[Tracking] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = Tracking.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if response.status_code == 403: + response_403 = CwsErrorDTO.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | list[Tracking]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | list[Tracking]]: + """Get Tracking - Shipment V1 + + Get tracking information of all items of a shipment (identified by the given awb). + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | list[Tracking]] + """ + + kwargs = _get_kwargs( + awb=awb, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | list[Tracking] | None: + """Get Tracking - Shipment V1 + + Get tracking information of all items of a shipment (identified by the given awb). + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | list[Tracking] + """ + + return sync_detailed( + awb=awb, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | list[Tracking]]: + """Get Tracking - Shipment V1 + + Get tracking information of all items of a shipment (identified by the given awb). + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | list[Tracking]] + """ + + kwargs = _get_kwargs( + awb=awb, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + awb: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | list[Tracking] | None: + """Get Tracking - Shipment V1 + + Get tracking information of all items of a shipment (identified by the given awb). + + Args: + awb (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | list[Tracking] + """ + + return ( + await asyncio_detailed( + awb=awb, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_trackings_basic.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_trackings_basic.py new file mode 100644 index 0000000..ed23626 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_trackings_basic.py @@ -0,0 +1,193 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.tracking import Tracking +from ...types import Response + + +def _get_kwargs( + barcode: str, + *, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/tracking/v1/trackings/{barcode}".format( + barcode=quote(str(barcode), safe=""), + ), + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | Tracking | None: + if response.status_code == 200: + response_200 = Tracking.from_dict(response.json()) + + return response_200 + + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | Tracking]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Tracking]: + """Get Trackings V1 + + Get all tracking information of for the item (identified by the given barcode). + + Args: + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Tracking] + """ + + kwargs = _get_kwargs( + barcode=barcode, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Tracking | None: + """Get Trackings V1 + + Get all tracking information of for the item (identified by the given barcode). + + Args: + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Tracking + """ + + return sync_detailed( + barcode=barcode, + client=client, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO | Tracking]: + """Get Trackings V1 + + Get all tracking information of for the item (identified by the given barcode). + + Args: + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Tracking] + """ + + kwargs = _get_kwargs( + barcode=barcode, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + barcode: str, + *, + client: AuthenticatedClient | Client, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | Tracking | None: + """Get Trackings V1 + + Get all tracking information of for the item (identified by the given barcode). + + Args: + barcode (str): + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Tracking + """ + + return ( + await asyncio_detailed( + barcode=barcode, + client=client, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_trackings_extended.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_trackings_extended.py new file mode 100644 index 0000000..608c745 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/trackings/get_trackings_extended.py @@ -0,0 +1,224 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + barcode: str, + *, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + params: dict[str, Any] = {} + + params["language"] = language + + params["withEventType"] = with_event_type + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/dpi/tracking/v3/trackings/{barcode}".format( + barcode=quote(str(barcode), safe=""), + ), + "params": params, + } + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CwsErrorDTO | None: + if response.status_code == 404: + response_404 = CwsErrorDTO.from_dict(response.json()) + + return response_404 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CwsErrorDTO]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + barcode: str, + *, + client: AuthenticatedClient | Client, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO]: + """Get Trackings V3 + + Get all tracking information for the item (identified by the given barcode). More detailed breakdown + of track events compared to v1 but possibly more inconsisteny, duplicity and wrong tracking order + + Args: + barcode (str): + language (str | Unset): Default: 'en'. + with_event_type (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO] + """ + + kwargs = _get_kwargs( + barcode=barcode, + language=language, + with_event_type=with_event_type, + authorization=authorization, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + barcode: str, + *, + client: AuthenticatedClient | Client, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | None: + """Get Trackings V3 + + Get all tracking information for the item (identified by the given barcode). More detailed breakdown + of track events compared to v1 but possibly more inconsisteny, duplicity and wrong tracking order + + Args: + barcode (str): + language (str | Unset): Default: 'en'. + with_event_type (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO + """ + + return sync_detailed( + barcode=barcode, + client=client, + language=language, + with_event_type=with_event_type, + authorization=authorization, + ).parsed + + +async def asyncio_detailed( + barcode: str, + *, + client: AuthenticatedClient | Client, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> Response[CwsErrorDTO]: + """Get Trackings V3 + + Get all tracking information for the item (identified by the given barcode). More detailed breakdown + of track events compared to v1 but possibly more inconsisteny, duplicity and wrong tracking order + + Args: + barcode (str): + language (str | Unset): Default: 'en'. + with_event_type (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO] + """ + + kwargs = _get_kwargs( + barcode=barcode, + language=language, + with_event_type=with_event_type, + authorization=authorization, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + barcode: str, + *, + client: AuthenticatedClient | Client, + language: str | Unset = "en", + with_event_type: bool | Unset = False, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", +) -> CwsErrorDTO | None: + """Get Trackings V3 + + Get all tracking information for the item (identified by the given barcode). More detailed breakdown + of track events compared to v1 but possibly more inconsisteny, duplicity and wrong tracking order + + Args: + barcode (str): + language (str | Unset): Default: 'en'. + with_event_type (bool | Unset): Default: False. + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO + """ + + return ( + await asyncio_detailed( + barcode=barcode, + client=client, + language=language, + with_event_type=with_event_type, + authorization=authorization, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/validation/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/validation/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/validation/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/validation/validate_order_item.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/validation/validate_order_item.py new file mode 100644 index 0000000..70a7b45 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/api/validation/validate_order_item.py @@ -0,0 +1,251 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.cws_error_dto import CwsErrorDTO +from ...models.validation import Validation +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: Validation, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + headers["Authorization"] = authorization + + if not isinstance(third_party_vendor_id, Unset): + headers["ThirdPartyVendor-ID"] = third_party_vendor_id + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/dpi/shipping/v1/validation", + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CwsErrorDTO | Validation | None: + if response.status_code == 200: + response_200 = Validation.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = CwsErrorDTO.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = CwsErrorDTO.from_dict(response.json()) + + return response_401 + + if response.status_code == 406: + response_406 = CwsErrorDTO.from_dict(response.json()) + + return response_406 + + if response.status_code == 422: + response_422 = CwsErrorDTO.from_dict(response.json()) + + return response_422 + + if response.status_code == 500: + response_500 = CwsErrorDTO.from_dict(response.json()) + + return response_500 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CwsErrorDTO | Validation]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: Validation, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Validation]: + """Validate Order Items + + Validate OrderItems, required by efiliale + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Validation): Example: {'customerEkp': '9012345678', 'items': [{'product': 'GMP', + 'serviceLevel': 'PRIORITY', 'custRef': '02 03 02 02 T005', 'recipient': 'Herschel + Krustofsky', 'recipientPhone': '', 'recipientFax': '', 'recipientEmail': '', + 'addressLine1': 'Avenue des Champs-Élysées', 'addressLine2': '', 'addressLine3': '103', + 'city': 'Paris', 'state': 'Île-de-France', 'postalCode': '75020', 'destinationCountry': + 'FR', 'returnItemWanted': False, 'shipmentAmount': 0, 'shipmentCurrency': 'EUR', + 'shipmentGrossWeight': 500}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Validation] + """ + + kwargs = _get_kwargs( + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + body: Validation, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Validation | None: + """Validate Order Items + + Validate OrderItems, required by efiliale + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Validation): Example: {'customerEkp': '9012345678', 'items': [{'product': 'GMP', + 'serviceLevel': 'PRIORITY', 'custRef': '02 03 02 02 T005', 'recipient': 'Herschel + Krustofsky', 'recipientPhone': '', 'recipientFax': '', 'recipientEmail': '', + 'addressLine1': 'Avenue des Champs-Élysées', 'addressLine2': '', 'addressLine3': '103', + 'city': 'Paris', 'state': 'Île-de-France', 'postalCode': '75020', 'destinationCountry': + 'FR', 'returnItemWanted': False, 'shipmentAmount': 0, 'shipmentCurrency': 'EUR', + 'shipmentGrossWeight': 500}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Validation + """ + + return sync_detailed( + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: Validation, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> Response[CwsErrorDTO | Validation]: + """Validate Order Items + + Validate OrderItems, required by efiliale + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Validation): Example: {'customerEkp': '9012345678', 'items': [{'product': 'GMP', + 'serviceLevel': 'PRIORITY', 'custRef': '02 03 02 02 T005', 'recipient': 'Herschel + Krustofsky', 'recipientPhone': '', 'recipientFax': '', 'recipientEmail': '', + 'addressLine1': 'Avenue des Champs-Élysées', 'addressLine2': '', 'addressLine3': '103', + 'city': 'Paris', 'state': 'Île-de-France', 'postalCode': '75020', 'destinationCountry': + 'FR', 'returnItemWanted': False, 'shipmentAmount': 0, 'shipmentCurrency': 'EUR', + 'shipmentGrossWeight': 500}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[CwsErrorDTO | Validation] + """ + + kwargs = _get_kwargs( + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + body: Validation, + authorization: str = "Bearer [place OAuth access_token here, without brackets]", + third_party_vendor_id: str | Unset = UNSET, +) -> CwsErrorDTO | Validation | None: + """Validate Order Items + + Validate OrderItems, required by efiliale + + Args: + authorization (str): Default: 'Bearer [place OAuth access_token here, without + brackets]'. + third_party_vendor_id (str | Unset): + body (Validation): Example: {'customerEkp': '9012345678', 'items': [{'product': 'GMP', + 'serviceLevel': 'PRIORITY', 'custRef': '02 03 02 02 T005', 'recipient': 'Herschel + Krustofsky', 'recipientPhone': '', 'recipientFax': '', 'recipientEmail': '', + 'addressLine1': 'Avenue des Champs-Élysées', 'addressLine2': '', 'addressLine3': '103', + 'city': 'Paris', 'state': 'Île-de-France', 'postalCode': '75020', 'destinationCountry': + 'FR', 'returnItemWanted': False, 'shipmentAmount': 0, 'shipmentCurrency': 'EUR', + 'shipmentGrossWeight': 500}]}. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + CwsErrorDTO | Validation + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + authorization=authorization, + third_party_vendor_id=third_party_vendor_id, + ) + ).parsed diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/client.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/client.py new file mode 100644 index 0000000..1b7055a --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/client.py @@ -0,0 +1,268 @@ +import ssl +from typing import Any + +import httpx +from attrs import define, evolve, field + + +@define +class Client: + """A class for keeping track of data related to the API + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) + + def with_headers(self, headers: dict[str, str]) -> "Client": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "Client": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "Client": + """Get a new client matching this one with a new timeout configuration""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "Client": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "Client": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + """Manually set the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "Client": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + token: The token to use for authentication + prefix: The prefix to use for the Authorization header + auth_header_name: The name of the Authorization header + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) + + token: str + prefix: str = "Bearer" + auth_header_name: str = "Authorization" + + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": + """Get a new client matching this one with a new timeout configuration""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "AuthenticatedClient": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + """Manually set the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "AuthenticatedClient": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/errors.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/errors.py new file mode 100644 index 0000000..5f92e76 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/errors.py @@ -0,0 +1,16 @@ +"""Contains shared errors types that can be raised from API functions""" + + +class UnexpectedStatus(Exception): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__( + f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" + ) + + +__all__ = ["UnexpectedStatus"] diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/__init__.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/__init__.py new file mode 100644 index 0000000..d75262b --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/__init__.py @@ -0,0 +1,127 @@ +"""Contains all the data models used in inputs/outputs""" + +from .assemble_order import AssembleOrder +from .awb import Awb +from .awb_item_format import AwbItemFormat +from .awb_product import AwbProduct +from .awb_service_level import AwbServiceLevel +from .bag import Bag +from .bag_item_content_dto import BagItemContentDto +from .bag_item_dto import BagItemDto +from .bag_item_dto_format import BagItemDtoFormat +from .bag_item_dto_product import BagItemDtoProduct +from .bag_item_dto_product_type import BagItemDtoProductType +from .bag_item_dto_service_level import BagItemDtoServiceLevel +from .bag_order import BagOrder +from .bag_order_order_status import BagOrderOrderStatus +from .bag_paperwork import BagPaperwork +from .bag_paperwork_product import BagPaperworkProduct +from .bulk_bag_dto import BulkBagDto +from .bulk_bag_dto_packet_format import BulkBagDtoPacketFormat +from .bulk_bag_dto_validation_errors import BulkBagDtoValidationErrors +from .bulk_order_dto import BulkOrderDto +from .bulk_order_dto_bulk_order_type import BulkOrderDtoBulkOrderType +from .bulk_order_dto_order_classification import BulkOrderDtoOrderClassification +from .bulk_order_dto_product_type import BulkOrderDtoProductType +from .bulk_order_dto_status import BulkOrderDtoStatus +from .closed_bag import ClosedBag +from .closed_bag_service_level import ClosedBagServiceLevel +from .content import Content +from .country import Country +from .cws_error_dto import CwsErrorDTO +from .get_access_token_info_401_response import GetAccessTokenInfo401Response +from .get_access_token_info_response import GetAccessTokenInfoResponse +from .get_access_token_response import GetAccessTokenResponse +from .get_bag_tag_accept import GetBagTagAccept +from .get_bag_tag_label_accept import GetBagTagLabelAccept +from .get_customer_item_label_accept import GetCustomerItemLabelAccept +from .get_item_label_accept import GetItemLabelAccept +from .get_item_labels_accept import GetItemLabelsAccept +from .get_items_status import GetItemsStatus +from .item import Item +from .item_data import ItemData +from .item_data_service_level import ItemDataServiceLevel +from .item_data_shipment_naturetype import ItemDataShipmentNaturetype +from .item_response import ItemResponse +from .item_service_level import ItemServiceLevel +from .item_shipment_naturetype import ItemShipmentNaturetype +from .language import Language +from .mixed_bag_order_dto import MixedBagOrderDTO +from .order import Order +from .order_data import OrderData +from .order_data_order_status import OrderDataOrderStatus +from .order_order_status import OrderOrderStatus +from .order_response import OrderResponse +from .paperwork import Paperwork +from .paperwork_pickup_type import PaperworkPickupType +from .revoke_access_token_response import RevokeAccessTokenResponse +from .shipment import Shipment +from .tracking import Tracking +from .tracking_event import TrackingEvent +from .tracking_event_status import TrackingEventStatus +from .tracking_event_status_message import TrackingEventStatusMessage +from .validation import Validation + +__all__ = ( + "AssembleOrder", + "Awb", + "AwbItemFormat", + "AwbProduct", + "AwbServiceLevel", + "Bag", + "BagItemContentDto", + "BagItemDto", + "BagItemDtoFormat", + "BagItemDtoProduct", + "BagItemDtoProductType", + "BagItemDtoServiceLevel", + "BagOrder", + "BagOrderOrderStatus", + "BagPaperwork", + "BagPaperworkProduct", + "BulkBagDto", + "BulkBagDtoPacketFormat", + "BulkBagDtoValidationErrors", + "BulkOrderDto", + "BulkOrderDtoBulkOrderType", + "BulkOrderDtoOrderClassification", + "BulkOrderDtoProductType", + "BulkOrderDtoStatus", + "ClosedBag", + "ClosedBagServiceLevel", + "Content", + "Country", + "CwsErrorDTO", + "GetAccessTokenInfo401Response", + "GetAccessTokenInfoResponse", + "GetAccessTokenResponse", + "GetBagTagAccept", + "GetBagTagLabelAccept", + "GetCustomerItemLabelAccept", + "GetItemLabelAccept", + "GetItemLabelsAccept", + "GetItemsStatus", + "Item", + "ItemData", + "ItemDataServiceLevel", + "ItemDataShipmentNaturetype", + "ItemResponse", + "ItemServiceLevel", + "ItemShipmentNaturetype", + "Language", + "MixedBagOrderDTO", + "Order", + "OrderData", + "OrderDataOrderStatus", + "OrderOrderStatus", + "OrderResponse", + "Paperwork", + "PaperworkPickupType", + "RevokeAccessTokenResponse", + "Shipment", + "Tracking", + "TrackingEvent", + "TrackingEventStatus", + "TrackingEventStatusMessage", + "Validation", +) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/assemble_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/assemble_order.py new file mode 100644 index 0000000..e30f241 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/assemble_order.py @@ -0,0 +1,98 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.paperwork import Paperwork + + +T = TypeVar("T", bound="AssembleOrder") + + +@_attrs_define +class AssembleOrder: + """This assembles the items or bags to a new order. EITHER bagIds OR itemBarcodes is REQUIRED + + Example: + {'itemBarcodes': ['BC123456789DE', 'BC123456790DE', 'BC123456791DE'], 'paperwork': {'contactName': 'John Doe', + 'awbCopyCount': 3}} + + Attributes: + paperwork (Paperwork): Example: {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': 'Job ref', + 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}. + item_barcodes (list[str] | Unset): An array of barcodes. + bag_ids (list[str] | Unset): An array of bagIds. These identify the items that shall be assembled to bag new + orders. + """ + + paperwork: Paperwork + item_barcodes: list[str] | Unset = UNSET + bag_ids: list[str] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + paperwork = self.paperwork.to_dict() + + item_barcodes: list[str] | Unset = UNSET + if not isinstance(self.item_barcodes, Unset): + item_barcodes = self.item_barcodes + + bag_ids: list[str] | Unset = UNSET + if not isinstance(self.bag_ids, Unset): + bag_ids = self.bag_ids + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "paperwork": paperwork, + } + ) + if item_barcodes is not UNSET: + field_dict["itemBarcodes"] = item_barcodes + if bag_ids is not UNSET: + field_dict["bagIds"] = bag_ids + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.paperwork import Paperwork + + d = dict(src_dict) + paperwork = Paperwork.from_dict(d.pop("paperwork")) + + item_barcodes = cast(list[str], d.pop("itemBarcodes", UNSET)) + + bag_ids = cast(list[str], d.pop("bagIds", UNSET)) + + assemble_order = cls( + paperwork=paperwork, + item_barcodes=item_barcodes, + bag_ids=bag_ids, + ) + + assemble_order.additional_properties = d + return assemble_order + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb.py new file mode 100644 index 0000000..dd61833 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb.py @@ -0,0 +1,145 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.awb_item_format import AwbItemFormat +from ..models.awb_product import AwbProduct +from ..models.awb_service_level import AwbServiceLevel +from ..types import UNSET, Unset + +T = TypeVar("T", bound="Awb") + + +@_attrs_define +class Awb: + """ + Example: + {'customerEkp': '9012345678', 'contactName': 'Max Mustermann', 'awbCopyCount': 3, 'product': 'GMP', + 'serviceLevel': 'PRIORITY', 'itemFormat': 'P', 'jobReference': 'Job ref', 'totalWeight': 5, 'telephoneNumber': + '+4935120681234'} + + Attributes: + awb_copy_count (int): Copies of AWB labels. One AWB per final receptacle required. Number between 1 and 99. + Example: 3. + contact_name (str): Contact name for paperwork. Example: John Doe. + customer_ekp (str): Deutsche Post Customer Account number (EKP) of the customer who wants to create an single + awb. Example: 9012345678. + item_format (AwbItemFormat): The item format for this awb. Example: P. + product (AwbProduct): The product that is used for the shipment of this item. Available products are: GMP + [Packet Priority/Prio (goods)], GPT [Packet Tracked/Tracked], GMM [Business Mail Priority/Prio (documents)], GMR + [Business Mail Registered/Plus (documents)] Example: GMP. + service_level (AwbServiceLevel): The service level that is used for the shipment of this item. There are + restrictions for use of service level: Registered is only available with product GMR and SalesChannel DPI + Example: PRIORITY. + job_reference (str | Unset): Job reference for the whole shipment. Example: Internal ID 3/14. + telephone_number (str | Unset): Telephone number for paperwork. Mandatory for sales channel EXPRESS. Example: + +491234567890. + total_weight (float | Unset): Total weight of the awb (in kg). Example: 5. + """ + + awb_copy_count: int + contact_name: str + customer_ekp: str + item_format: AwbItemFormat + product: AwbProduct + service_level: AwbServiceLevel + job_reference: str | Unset = UNSET + telephone_number: str | Unset = UNSET + total_weight: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + awb_copy_count = self.awb_copy_count + + contact_name = self.contact_name + + customer_ekp = self.customer_ekp + + item_format = self.item_format.value + + product = self.product.value + + service_level = self.service_level.value + + job_reference = self.job_reference + + telephone_number = self.telephone_number + + total_weight = self.total_weight + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "awbCopyCount": awb_copy_count, + "contactName": contact_name, + "customerEkp": customer_ekp, + "itemFormat": item_format, + "product": product, + "serviceLevel": service_level, + } + ) + if job_reference is not UNSET: + field_dict["jobReference"] = job_reference + if telephone_number is not UNSET: + field_dict["telephoneNumber"] = telephone_number + if total_weight is not UNSET: + field_dict["totalWeight"] = total_weight + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + awb_copy_count = d.pop("awbCopyCount") + + contact_name = d.pop("contactName") + + customer_ekp = d.pop("customerEkp") + + item_format = AwbItemFormat(d.pop("itemFormat")) + + product = AwbProduct(d.pop("product")) + + service_level = AwbServiceLevel(d.pop("serviceLevel")) + + job_reference = d.pop("jobReference", UNSET) + + telephone_number = d.pop("telephoneNumber", UNSET) + + total_weight = d.pop("totalWeight", UNSET) + + awb = cls( + awb_copy_count=awb_copy_count, + contact_name=contact_name, + customer_ekp=customer_ekp, + item_format=item_format, + product=product, + service_level=service_level, + job_reference=job_reference, + telephone_number=telephone_number, + total_weight=total_weight, + ) + + awb.additional_properties = d + return awb + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_item_format.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_item_format.py new file mode 100644 index 0000000..d727eda --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_item_format.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class AwbItemFormat(str, Enum): + E = "E" + G = "G" + MIXED = "MIXED" + P = "P" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_product.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_product.py new file mode 100644 index 0000000..a9fd0ba --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_product.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class AwbProduct(str, Enum): + GMM = "GMM" + GMP = "GMP" + GMR = "GMR" + GPT = "GPT" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_service_level.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_service_level.py new file mode 100644 index 0000000..767ffdd --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/awb_service_level.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class AwbServiceLevel(str, Enum): + PRIORITY = "PRIORITY" + REGISTERED = "REGISTERED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag.py new file mode 100644 index 0000000..c22c8ea --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag.py @@ -0,0 +1,113 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="Bag") + + +@_attrs_define +class Bag: + """ + Attributes: + bag_track (bool): False for bulk preadvice, True for bag tracking Default: False. + format_ (str): The format of the content of this bag. Example: P. + destination_country (str): The destination country code. Example: DE. + items_count (int): Number of items in bag. Minimum 1. + items_weight_in_kilogram (float): The weight in kilogram of the bag. Example: 100. + id (int | Unset): Internal id of the bag. + customer_reference (str | Unset): Customer reference Example: Customer reference. + """ + + format_: str + destination_country: str + items_count: int + items_weight_in_kilogram: float + bag_track: bool = False + id: int | Unset = UNSET + customer_reference: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + bag_track = self.bag_track + + format_ = self.format_ + + destination_country = self.destination_country + + items_count = self.items_count + + items_weight_in_kilogram = self.items_weight_in_kilogram + + id = self.id + + customer_reference = self.customer_reference + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "bagTrack": bag_track, + "format": format_, + "destinationCountry": destination_country, + "itemsCount": items_count, + "itemsWeightInKilogram": items_weight_in_kilogram, + } + ) + if id is not UNSET: + field_dict["id"] = id + if customer_reference is not UNSET: + field_dict["customerReference"] = customer_reference + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + bag_track = d.pop("bagTrack") + + format_ = d.pop("format") + + destination_country = d.pop("destinationCountry") + + items_count = d.pop("itemsCount") + + items_weight_in_kilogram = d.pop("itemsWeightInKilogram") + + id = d.pop("id", UNSET) + + customer_reference = d.pop("customerReference", UNSET) + + bag = cls( + bag_track=bag_track, + format_=format_, + destination_country=destination_country, + items_count=items_count, + items_weight_in_kilogram=items_weight_in_kilogram, + id=id, + customer_reference=customer_reference, + ) + + bag.additional_properties = d + return bag + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_content_dto.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_content_dto.py new file mode 100644 index 0000000..e9b6e6d --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_content_dto.py @@ -0,0 +1,106 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BagItemContentDto") + + +@_attrs_define +class BagItemContentDto: + """ + Attributes: + amount (str | Unset): + description (str | Unset): + value (str | Unset): + hs_code (str | Unset): + net_weight (str | Unset): + origin_country (str | Unset): + """ + + amount: str | Unset = UNSET + description: str | Unset = UNSET + value: str | Unset = UNSET + hs_code: str | Unset = UNSET + net_weight: str | Unset = UNSET + origin_country: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + amount = self.amount + + description = self.description + + value = self.value + + hs_code = self.hs_code + + net_weight = self.net_weight + + origin_country = self.origin_country + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if amount is not UNSET: + field_dict["amount"] = amount + if description is not UNSET: + field_dict["description"] = description + if value is not UNSET: + field_dict["value"] = value + if hs_code is not UNSET: + field_dict["hsCode"] = hs_code + if net_weight is not UNSET: + field_dict["netWeight"] = net_weight + if origin_country is not UNSET: + field_dict["originCountry"] = origin_country + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + amount = d.pop("amount", UNSET) + + description = d.pop("description", UNSET) + + value = d.pop("value", UNSET) + + hs_code = d.pop("hsCode", UNSET) + + net_weight = d.pop("netWeight", UNSET) + + origin_country = d.pop("originCountry", UNSET) + + bag_item_content_dto = cls( + amount=amount, + description=description, + value=value, + hs_code=hs_code, + net_weight=net_weight, + origin_country=origin_country, + ) + + bag_item_content_dto.additional_properties = d + return bag_item_content_dto + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto.py new file mode 100644 index 0000000..eafb134 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto.py @@ -0,0 +1,417 @@ +from __future__ import annotations + +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 ..models.bag_item_dto_format import BagItemDtoFormat +from ..models.bag_item_dto_product import BagItemDtoProduct +from ..models.bag_item_dto_product_type import BagItemDtoProductType +from ..models.bag_item_dto_service_level import BagItemDtoServiceLevel +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.bag_item_content_dto import BagItemContentDto + from ..models.country import Country + + +T = TypeVar("T", bound="BagItemDto") + + +@_attrs_define +class BagItemDto: + """ + Attributes: + id (int | Unset): + barcode (str | Unset): + customer_ekp (str | Unset): + awb (str | Unset): + destination_country (Country | Unset): + destination_email (str | Unset): + destination_phone (str | Unset): + destination_phone_2 (str | Unset): + format_ (BagItemDtoFormat | Unset): + item_weight (int | Unset): + bag_id (str | Unset): In requests only applicable for customers using "prelabelled service" + product_type (BagItemDtoProductType | Unset): + product (BagItemDtoProduct | Unset): + service_level (BagItemDtoServiceLevel | Unset): + name (str | Unset): + customer_reference (str | Unset): + recipient_phone (str | Unset): + recipient_email (str | Unset): + address_line_1 (str | Unset): + address_line_2 (str | Unset): + address_line_3 (str | Unset): + city (str | Unset): + destination_state (str | Unset): + postal_code (str | Unset): + currency (str | Unset): + content_type (str | Unset): + declared_content_amount (int | Unset): + detailed_content_descriptions_1 (str | Unset): + total_value (int | Unset): + return_label (bool | Unset): + sender_customs_reference (str | Unset): + importer_customs_reference (str | Unset): + checked (bool | Unset): + bag_item_contents (list[BagItemContentDto] | Unset): + """ + + id: int | Unset = UNSET + barcode: str | Unset = UNSET + customer_ekp: str | Unset = UNSET + awb: str | Unset = UNSET + destination_country: Country | Unset = UNSET + destination_email: str | Unset = UNSET + destination_phone: str | Unset = UNSET + destination_phone_2: str | Unset = UNSET + format_: BagItemDtoFormat | Unset = UNSET + item_weight: int | Unset = UNSET + bag_id: str | Unset = UNSET + product_type: BagItemDtoProductType | Unset = UNSET + product: BagItemDtoProduct | Unset = UNSET + service_level: BagItemDtoServiceLevel | Unset = UNSET + name: str | Unset = UNSET + customer_reference: str | Unset = UNSET + recipient_phone: str | Unset = UNSET + recipient_email: str | Unset = UNSET + address_line_1: str | Unset = UNSET + address_line_2: str | Unset = UNSET + address_line_3: str | Unset = UNSET + city: str | Unset = UNSET + destination_state: str | Unset = UNSET + postal_code: str | Unset = UNSET + currency: str | Unset = UNSET + content_type: str | Unset = UNSET + declared_content_amount: int | Unset = UNSET + detailed_content_descriptions_1: str | Unset = UNSET + total_value: int | Unset = UNSET + return_label: bool | Unset = UNSET + sender_customs_reference: str | Unset = UNSET + importer_customs_reference: str | Unset = UNSET + checked: bool | Unset = UNSET + bag_item_contents: list[BagItemContentDto] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + barcode = self.barcode + + customer_ekp = self.customer_ekp + + awb = self.awb + + destination_country: dict[str, Any] | Unset = UNSET + if not isinstance(self.destination_country, Unset): + destination_country = self.destination_country.to_dict() + + destination_email = self.destination_email + + destination_phone = self.destination_phone + + destination_phone_2 = self.destination_phone_2 + + format_: str | Unset = UNSET + if not isinstance(self.format_, Unset): + format_ = self.format_.value + + item_weight = self.item_weight + + bag_id = self.bag_id + + product_type: str | Unset = UNSET + if not isinstance(self.product_type, Unset): + product_type = self.product_type.value + + product: str | Unset = UNSET + if not isinstance(self.product, Unset): + product = self.product.value + + service_level: str | Unset = UNSET + if not isinstance(self.service_level, Unset): + service_level = self.service_level.value + + name = self.name + + customer_reference = self.customer_reference + + recipient_phone = self.recipient_phone + + recipient_email = self.recipient_email + + address_line_1 = self.address_line_1 + + address_line_2 = self.address_line_2 + + address_line_3 = self.address_line_3 + + city = self.city + + destination_state = self.destination_state + + postal_code = self.postal_code + + currency = self.currency + + content_type = self.content_type + + declared_content_amount = self.declared_content_amount + + detailed_content_descriptions_1 = self.detailed_content_descriptions_1 + + total_value = self.total_value + + return_label = self.return_label + + sender_customs_reference = self.sender_customs_reference + + importer_customs_reference = self.importer_customs_reference + + checked = self.checked + + bag_item_contents: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.bag_item_contents, Unset): + bag_item_contents = [] + for bag_item_contents_item_data in self.bag_item_contents: + bag_item_contents_item = bag_item_contents_item_data.to_dict() + bag_item_contents.append(bag_item_contents_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if barcode is not UNSET: + field_dict["barcode"] = barcode + if customer_ekp is not UNSET: + field_dict["customerEkp"] = customer_ekp + if awb is not UNSET: + field_dict["awb"] = awb + if destination_country is not UNSET: + field_dict["destinationCountry"] = destination_country + if destination_email is not UNSET: + field_dict["destinationEmail"] = destination_email + if destination_phone is not UNSET: + field_dict["destinationPhone"] = destination_phone + if destination_phone_2 is not UNSET: + field_dict["destinationPhone2"] = destination_phone_2 + if format_ is not UNSET: + field_dict["format"] = format_ + if item_weight is not UNSET: + field_dict["itemWeight"] = item_weight + if bag_id is not UNSET: + field_dict["bagId"] = bag_id + if product_type is not UNSET: + field_dict["productType"] = product_type + if product is not UNSET: + field_dict["product"] = product + if service_level is not UNSET: + field_dict["serviceLevel"] = service_level + if name is not UNSET: + field_dict["name"] = name + if customer_reference is not UNSET: + field_dict["customerReference"] = customer_reference + if recipient_phone is not UNSET: + field_dict["recipientPhone"] = recipient_phone + if recipient_email is not UNSET: + field_dict["recipientEmail"] = recipient_email + if address_line_1 is not UNSET: + field_dict["addressLine1"] = address_line_1 + if address_line_2 is not UNSET: + field_dict["addressLine2"] = address_line_2 + if address_line_3 is not UNSET: + field_dict["addressLine3"] = address_line_3 + if city is not UNSET: + field_dict["city"] = city + if destination_state is not UNSET: + field_dict["destinationState"] = destination_state + if postal_code is not UNSET: + field_dict["postalCode"] = postal_code + if currency is not UNSET: + field_dict["currency"] = currency + if content_type is not UNSET: + field_dict["contentType"] = content_type + if declared_content_amount is not UNSET: + field_dict["declaredContentAmount"] = declared_content_amount + if detailed_content_descriptions_1 is not UNSET: + field_dict["detailedContentDescriptions1"] = detailed_content_descriptions_1 + if total_value is not UNSET: + field_dict["totalValue"] = total_value + if return_label is not UNSET: + field_dict["returnLabel"] = return_label + if sender_customs_reference is not UNSET: + field_dict["senderCustomsReference"] = sender_customs_reference + if importer_customs_reference is not UNSET: + field_dict["importerCustomsReference"] = importer_customs_reference + if checked is not UNSET: + field_dict["checked"] = checked + if bag_item_contents is not UNSET: + field_dict["bagItemContents"] = bag_item_contents + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.bag_item_content_dto import BagItemContentDto + from ..models.country import Country + + d = dict(src_dict) + id = d.pop("id", UNSET) + + barcode = d.pop("barcode", UNSET) + + customer_ekp = d.pop("customerEkp", UNSET) + + awb = d.pop("awb", UNSET) + + _destination_country = d.pop("destinationCountry", UNSET) + destination_country: Country | Unset + if isinstance(_destination_country, Unset): + destination_country = UNSET + else: + destination_country = Country.from_dict(_destination_country) + + destination_email = d.pop("destinationEmail", UNSET) + + destination_phone = d.pop("destinationPhone", UNSET) + + destination_phone_2 = d.pop("destinationPhone2", UNSET) + + _format_ = d.pop("format", UNSET) + format_: BagItemDtoFormat | Unset + if isinstance(_format_, Unset): + format_ = UNSET + else: + format_ = BagItemDtoFormat(_format_) + + item_weight = d.pop("itemWeight", UNSET) + + bag_id = d.pop("bagId", UNSET) + + _product_type = d.pop("productType", UNSET) + product_type: BagItemDtoProductType | Unset + if isinstance(_product_type, Unset): + product_type = UNSET + else: + product_type = BagItemDtoProductType(_product_type) + + _product = d.pop("product", UNSET) + product: BagItemDtoProduct | Unset + if isinstance(_product, Unset): + product = UNSET + else: + product = BagItemDtoProduct(_product) + + _service_level = d.pop("serviceLevel", UNSET) + service_level: BagItemDtoServiceLevel | Unset + if isinstance(_service_level, Unset): + service_level = UNSET + else: + service_level = BagItemDtoServiceLevel(_service_level) + + name = d.pop("name", UNSET) + + customer_reference = d.pop("customerReference", UNSET) + + recipient_phone = d.pop("recipientPhone", UNSET) + + recipient_email = d.pop("recipientEmail", UNSET) + + address_line_1 = d.pop("addressLine1", UNSET) + + address_line_2 = d.pop("addressLine2", UNSET) + + address_line_3 = d.pop("addressLine3", UNSET) + + city = d.pop("city", UNSET) + + destination_state = d.pop("destinationState", UNSET) + + postal_code = d.pop("postalCode", UNSET) + + currency = d.pop("currency", UNSET) + + content_type = d.pop("contentType", UNSET) + + declared_content_amount = d.pop("declaredContentAmount", UNSET) + + detailed_content_descriptions_1 = d.pop("detailedContentDescriptions1", UNSET) + + total_value = d.pop("totalValue", UNSET) + + return_label = d.pop("returnLabel", UNSET) + + sender_customs_reference = d.pop("senderCustomsReference", UNSET) + + importer_customs_reference = d.pop("importerCustomsReference", UNSET) + + checked = d.pop("checked", UNSET) + + _bag_item_contents = d.pop("bagItemContents", UNSET) + bag_item_contents: list[BagItemContentDto] | Unset = UNSET + if _bag_item_contents is not UNSET: + bag_item_contents = [] + for bag_item_contents_item_data in _bag_item_contents: + bag_item_contents_item = BagItemContentDto.from_dict(bag_item_contents_item_data) + + bag_item_contents.append(bag_item_contents_item) + + bag_item_dto = cls( + id=id, + barcode=barcode, + customer_ekp=customer_ekp, + awb=awb, + destination_country=destination_country, + destination_email=destination_email, + destination_phone=destination_phone, + destination_phone_2=destination_phone_2, + format_=format_, + item_weight=item_weight, + bag_id=bag_id, + product_type=product_type, + product=product, + service_level=service_level, + name=name, + customer_reference=customer_reference, + recipient_phone=recipient_phone, + recipient_email=recipient_email, + address_line_1=address_line_1, + address_line_2=address_line_2, + address_line_3=address_line_3, + city=city, + destination_state=destination_state, + postal_code=postal_code, + currency=currency, + content_type=content_type, + declared_content_amount=declared_content_amount, + detailed_content_descriptions_1=detailed_content_descriptions_1, + total_value=total_value, + return_label=return_label, + sender_customs_reference=sender_customs_reference, + importer_customs_reference=importer_customs_reference, + checked=checked, + bag_item_contents=bag_item_contents, + ) + + bag_item_dto.additional_properties = d + return bag_item_dto + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_format.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_format.py new file mode 100644 index 0000000..a8d4be3 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_format.py @@ -0,0 +1,17 @@ +from enum import Enum + + +class BagItemDtoFormat(str, Enum): + E = "E" + E_BAG = "E_BAG" + E_PALLET = "E_PALLET" + G = "G" + G_BAG = "G_BAG" + G_PALLET = "G_PALLET" + MIXED = "MIXED" + P = "P" + P_BAG = "P_BAG" + P_PALLET = "P_PALLET" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_product.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_product.py new file mode 100644 index 0000000..f766369 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_product.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class BagItemDtoProduct(str, Enum): + EXPRESS_LETTER_PLUS = "EXPRESS_LETTER_PLUS" + EXPRESS_LETTER_PRIO = "EXPRESS_LETTER_PRIO" + EXPRESS_PACKET_PLUS = "EXPRESS_PACKET_PLUS" + EXPRESS_PACKET_PRIO = "EXPRESS_PACKET_PRIO" + EXPRESS_PACKET_TRACKED = "EXPRESS_PACKET_TRACKED" + GM_MAIL = "GM_MAIL" + GM_PACKET = "GM_PACKET" + GM_PACKET_PLUS = "GM_PACKET_PLUS" + GM_PACKET_TRACKED = "GM_PACKET_TRACKED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_product_type.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_product_type.py new file mode 100644 index 0000000..9b12ecd --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_product_type.py @@ -0,0 +1,19 @@ +from enum import Enum + + +class BagItemDtoProductType(str, Enum): + EXPRESS_LETTER_PLUS = "EXPRESS_LETTER_PLUS" + EXPRESS_LETTER_PRIO = "EXPRESS_LETTER_PRIO" + EXPRESS_PACKET_PLUS = "EXPRESS_PACKET_PLUS" + EXPRESS_PACKET_PRIO = "EXPRESS_PACKET_PRIO" + EXPRESS_PACKET_TRACKED = "EXPRESS_PACKET_TRACKED" + GM_MAIL_PRIO = "GM_MAIL_PRIO" + GM_MAIL_REG = "GM_MAIL_REG" + GM_MAIL_STANDARD = "GM_MAIL_STANDARD" + GM_PACKET_PLUS = "GM_PACKET_PLUS" + GM_PACKET_PRIO = "GM_PACKET_PRIO" + GM_PACKET_STANDARD = "GM_PACKET_STANDARD" + GM_PACKET_TRACKED = "GM_PACKET_TRACKED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_service_level.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_service_level.py new file mode 100644 index 0000000..e7510cf --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_item_dto_service_level.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class BagItemDtoServiceLevel(str, Enum): + PRIORITY = "PRIORITY" + REGISTERED = "REGISTERED" + STANDARD = "STANDARD" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_order.py new file mode 100644 index 0000000..9cde95c --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_order.py @@ -0,0 +1,145 @@ +from __future__ import annotations + +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 ..models.bag_order_order_status import BagOrderOrderStatus +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.bag import Bag + from ..models.bag_paperwork import BagPaperwork + + +T = TypeVar("T", bound="BagOrder") + + +@_attrs_define +class BagOrder: + """ + Attributes: + paperwork (BagPaperwork): + bags (list[Bag] | Unset): The bags associated with this order. + customer_ekp (int | Unset): + awb_id (int | Unset): + net_bulk_weight_in_kilogram (float | Unset): Example: 100. + order_id (int | Unset): + order_status (BagOrderOrderStatus | Unset): + """ + + paperwork: BagPaperwork + bags: list[Bag] | Unset = UNSET + customer_ekp: int | Unset = UNSET + awb_id: int | Unset = UNSET + net_bulk_weight_in_kilogram: float | Unset = UNSET + order_id: int | Unset = UNSET + order_status: BagOrderOrderStatus | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + paperwork = self.paperwork.to_dict() + + bags: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.bags, Unset): + bags = [] + for bags_item_data in self.bags: + bags_item = bags_item_data.to_dict() + bags.append(bags_item) + + customer_ekp = self.customer_ekp + + awb_id = self.awb_id + + net_bulk_weight_in_kilogram = self.net_bulk_weight_in_kilogram + + order_id = self.order_id + + order_status: str | Unset = UNSET + if not isinstance(self.order_status, Unset): + order_status = self.order_status.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "paperwork": paperwork, + } + ) + if bags is not UNSET: + field_dict["bags"] = bags + if customer_ekp is not UNSET: + field_dict["customerEkp"] = customer_ekp + if awb_id is not UNSET: + field_dict["awbId"] = awb_id + if net_bulk_weight_in_kilogram is not UNSET: + field_dict["netBulkWeightInKilogram"] = net_bulk_weight_in_kilogram + if order_id is not UNSET: + field_dict["orderId"] = order_id + if order_status is not UNSET: + field_dict["orderStatus"] = order_status + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.bag import Bag + from ..models.bag_paperwork import BagPaperwork + + d = dict(src_dict) + paperwork = BagPaperwork.from_dict(d.pop("paperwork")) + + _bags = d.pop("bags", UNSET) + bags: list[Bag] | Unset = UNSET + if _bags is not UNSET: + bags = [] + for bags_item_data in _bags: + bags_item = Bag.from_dict(bags_item_data) + + bags.append(bags_item) + + customer_ekp = d.pop("customerEkp", UNSET) + + awb_id = d.pop("awbId", UNSET) + + net_bulk_weight_in_kilogram = d.pop("netBulkWeightInKilogram", UNSET) + + order_id = d.pop("orderId", UNSET) + + _order_status = d.pop("orderStatus", UNSET) + order_status: BagOrderOrderStatus | Unset + if isinstance(_order_status, Unset): + order_status = UNSET + else: + order_status = BagOrderOrderStatus(_order_status) + + bag_order = cls( + paperwork=paperwork, + bags=bags, + customer_ekp=customer_ekp, + awb_id=awb_id, + net_bulk_weight_in_kilogram=net_bulk_weight_in_kilogram, + order_id=order_id, + order_status=order_status, + ) + + bag_order.additional_properties = d + return bag_order + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_order_order_status.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_order_order_status.py new file mode 100644 index 0000000..8df64c4 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_order_order_status.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class BagOrderOrderStatus(str, Enum): + FINALIZE = "FINALIZE" + OPEN = "OPEN" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_paperwork.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_paperwork.py new file mode 100644 index 0000000..44eeaa6 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_paperwork.py @@ -0,0 +1,107 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.bag_paperwork_product import BagPaperworkProduct +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BagPaperwork") + + +@_attrs_define +class BagPaperwork: + """ + Attributes: + contact_name (str): Contact name for paperwork. Example: Max Mustermann. + product (BagPaperworkProduct): Product code. Example: GMM. + service_level (str): The service level of the order: PRIORITY Example: PRIORITY. + total_count_receptacles (int): Number of airway bills. Example: 3. + telephone_number (str | Unset): Telephone number for paperwork. Mandatory for sales channel EXPRESS. Example: + +491234567890. + job_reference (str | Unset): Job reference for paperwork. Example: Internal ID 03/14. + """ + + contact_name: str + product: BagPaperworkProduct + service_level: str + total_count_receptacles: int + telephone_number: str | Unset = UNSET + job_reference: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + contact_name = self.contact_name + + product = self.product.value + + service_level = self.service_level + + total_count_receptacles = self.total_count_receptacles + + telephone_number = self.telephone_number + + job_reference = self.job_reference + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "contactName": contact_name, + "product": product, + "serviceLevel": service_level, + "totalCountReceptacles": total_count_receptacles, + } + ) + if telephone_number is not UNSET: + field_dict["telephoneNumber"] = telephone_number + if job_reference is not UNSET: + field_dict["jobReference"] = job_reference + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + contact_name = d.pop("contactName") + + product = BagPaperworkProduct(d.pop("product")) + + service_level = d.pop("serviceLevel") + + total_count_receptacles = d.pop("totalCountReceptacles") + + telephone_number = d.pop("telephoneNumber", UNSET) + + job_reference = d.pop("jobReference", UNSET) + + bag_paperwork = cls( + contact_name=contact_name, + product=product, + service_level=service_level, + total_count_receptacles=total_count_receptacles, + telephone_number=telephone_number, + job_reference=job_reference, + ) + + bag_paperwork.additional_properties = d + return bag_paperwork + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_paperwork_product.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_paperwork_product.py new file mode 100644 index 0000000..e5edd6d --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bag_paperwork_product.py @@ -0,0 +1,8 @@ +from enum import Enum + + +class BagPaperworkProduct(str, Enum): + GMM = "GMM" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto.py new file mode 100644 index 0000000..b4c582e --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto.py @@ -0,0 +1,240 @@ +from __future__ import annotations + +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 ..models.bulk_bag_dto_packet_format import BulkBagDtoPacketFormat +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.bag_item_dto import BagItemDto + from ..models.bulk_bag_dto_validation_errors import BulkBagDtoValidationErrors + + +T = TypeVar("T", bound="BulkBagDto") + + +@_attrs_define +class BulkBagDto: + """ + Attributes: + id (int | Unset): + country_code (str | Unset): + customer_bag_id (str | Unset): + packet_format (BulkBagDtoPacketFormat | Unset): + item_count (int | Unset): + total_weight (float | Unset): + validation_errors (BulkBagDtoValidationErrors | Unset): + customer_reference (str | Unset): + shipment_type (str | Unset): + bag_tracking (bool | Unset): + auth_user (str | Unset): + printed (bool | Unset): + ui_row_selected (bool | Unset): + number (int | Unset): + items (list[BagItemDto] | Unset): + linked_item_count (int | Unset): + weight_per_item (float | Unset): + """ + + id: int | Unset = UNSET + country_code: str | Unset = UNSET + customer_bag_id: str | Unset = UNSET + packet_format: BulkBagDtoPacketFormat | Unset = UNSET + item_count: int | Unset = UNSET + total_weight: float | Unset = UNSET + validation_errors: BulkBagDtoValidationErrors | Unset = UNSET + customer_reference: str | Unset = UNSET + shipment_type: str | Unset = UNSET + bag_tracking: bool | Unset = UNSET + auth_user: str | Unset = UNSET + printed: bool | Unset = UNSET + ui_row_selected: bool | Unset = UNSET + number: int | Unset = UNSET + items: list[BagItemDto] | Unset = UNSET + linked_item_count: int | Unset = UNSET + weight_per_item: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + country_code = self.country_code + + customer_bag_id = self.customer_bag_id + + packet_format: str | Unset = UNSET + if not isinstance(self.packet_format, Unset): + packet_format = self.packet_format.value + + item_count = self.item_count + + total_weight = self.total_weight + + validation_errors: dict[str, Any] | Unset = UNSET + if not isinstance(self.validation_errors, Unset): + validation_errors = self.validation_errors.to_dict() + + customer_reference = self.customer_reference + + shipment_type = self.shipment_type + + bag_tracking = self.bag_tracking + + auth_user = self.auth_user + + printed = self.printed + + ui_row_selected = self.ui_row_selected + + number = self.number + + items: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.items, Unset): + items = [] + for items_item_data in self.items: + items_item = items_item_data.to_dict() + items.append(items_item) + + linked_item_count = self.linked_item_count + + weight_per_item = self.weight_per_item + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if country_code is not UNSET: + field_dict["countryCode"] = country_code + if customer_bag_id is not UNSET: + field_dict["customerBagId"] = customer_bag_id + if packet_format is not UNSET: + field_dict["packetFormat"] = packet_format + if item_count is not UNSET: + field_dict["itemCount"] = item_count + if total_weight is not UNSET: + field_dict["totalWeight"] = total_weight + if validation_errors is not UNSET: + field_dict["validationErrors"] = validation_errors + if customer_reference is not UNSET: + field_dict["customerReference"] = customer_reference + if shipment_type is not UNSET: + field_dict["shipmentType"] = shipment_type + if bag_tracking is not UNSET: + field_dict["bagTracking"] = bag_tracking + if auth_user is not UNSET: + field_dict["authUser"] = auth_user + if printed is not UNSET: + field_dict["printed"] = printed + if ui_row_selected is not UNSET: + field_dict["uiRowSelected"] = ui_row_selected + if number is not UNSET: + field_dict["number"] = number + if items is not UNSET: + field_dict["items"] = items + if linked_item_count is not UNSET: + field_dict["linkedItemCount"] = linked_item_count + if weight_per_item is not UNSET: + field_dict["weightPerItem"] = weight_per_item + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.bag_item_dto import BagItemDto + from ..models.bulk_bag_dto_validation_errors import BulkBagDtoValidationErrors + + d = dict(src_dict) + id = d.pop("id", UNSET) + + country_code = d.pop("countryCode", UNSET) + + customer_bag_id = d.pop("customerBagId", UNSET) + + _packet_format = d.pop("packetFormat", UNSET) + packet_format: BulkBagDtoPacketFormat | Unset + if isinstance(_packet_format, Unset): + packet_format = UNSET + else: + packet_format = BulkBagDtoPacketFormat(_packet_format) + + item_count = d.pop("itemCount", UNSET) + + total_weight = d.pop("totalWeight", UNSET) + + _validation_errors = d.pop("validationErrors", UNSET) + validation_errors: BulkBagDtoValidationErrors | Unset + if isinstance(_validation_errors, Unset): + validation_errors = UNSET + else: + validation_errors = BulkBagDtoValidationErrors.from_dict(_validation_errors) + + customer_reference = d.pop("customerReference", UNSET) + + shipment_type = d.pop("shipmentType", UNSET) + + bag_tracking = d.pop("bagTracking", UNSET) + + auth_user = d.pop("authUser", UNSET) + + printed = d.pop("printed", UNSET) + + ui_row_selected = d.pop("uiRowSelected", UNSET) + + number = d.pop("number", UNSET) + + _items = d.pop("items", UNSET) + items: list[BagItemDto] | Unset = UNSET + if _items is not UNSET: + items = [] + for items_item_data in _items: + items_item = BagItemDto.from_dict(items_item_data) + + items.append(items_item) + + linked_item_count = d.pop("linkedItemCount", UNSET) + + weight_per_item = d.pop("weightPerItem", UNSET) + + bulk_bag_dto = cls( + id=id, + country_code=country_code, + customer_bag_id=customer_bag_id, + packet_format=packet_format, + item_count=item_count, + total_weight=total_weight, + validation_errors=validation_errors, + customer_reference=customer_reference, + shipment_type=shipment_type, + bag_tracking=bag_tracking, + auth_user=auth_user, + printed=printed, + ui_row_selected=ui_row_selected, + number=number, + items=items, + linked_item_count=linked_item_count, + weight_per_item=weight_per_item, + ) + + bulk_bag_dto.additional_properties = d + return bulk_bag_dto + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto_packet_format.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto_packet_format.py new file mode 100644 index 0000000..772f31a --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto_packet_format.py @@ -0,0 +1,17 @@ +from enum import Enum + + +class BulkBagDtoPacketFormat(str, Enum): + E = "E" + E_BAG = "E_BAG" + E_PALLET = "E_PALLET" + G = "G" + G_BAG = "G_BAG" + G_PALLET = "G_PALLET" + MIXED = "MIXED" + P = "P" + P_BAG = "P_BAG" + P_PALLET = "P_PALLET" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto_validation_errors.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto_validation_errors.py new file mode 100644 index 0000000..edc4fa2 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_bag_dto_validation_errors.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="BulkBagDtoValidationErrors") + + +@_attrs_define +class BulkBagDtoValidationErrors: + """ """ + + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + bulk_bag_dto_validation_errors = cls() + + bulk_bag_dto_validation_errors.additional_properties = d + return bulk_bag_dto_validation_errors + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> str: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: str) -> 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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto.py new file mode 100644 index 0000000..475d431 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto.py @@ -0,0 +1,332 @@ +from __future__ import annotations + +import datetime +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 dateutil.parser import isoparse + +from ..models.bulk_order_dto_bulk_order_type import BulkOrderDtoBulkOrderType +from ..models.bulk_order_dto_order_classification import BulkOrderDtoOrderClassification +from ..models.bulk_order_dto_product_type import BulkOrderDtoProductType +from ..models.bulk_order_dto_status import BulkOrderDtoStatus +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.bulk_bag_dto import BulkBagDto + + +T = TypeVar("T", bound="BulkOrderDto") + + +@_attrs_define +class BulkOrderDto: + """ + Attributes: + id (int | Unset): + contact_name (str | Unset): + phone_number (str | Unset): + job_reference (str | Unset): + product_type (BulkOrderDtoProductType | Unset): + bulk_order_type (BulkOrderDtoBulkOrderType | Unset): + awb (str | Unset): + bulk_bags (list[BulkBagDto] | Unset): + status (BulkOrderDtoStatus | Unset): + validation_errors (bool | Unset): Default: False. + error_message (str | Unset): + number_of_copies (int | Unset): + download_token (str | Unset): + printable (bool | Unset): + order_classification (BulkOrderDtoOrderClassification | Unset): + created_at (datetime.datetime | Unset): + created_by (str | Unset): + auth_user (str | Unset): + send_date (datetime.datetime | Unset): + submitted_date (datetime.datetime | Unset): + preadvice_eligible (bool | Unset): + finalised (bool | Unset): + total_item_weight_sum (float | Unset): + """ + + id: int | Unset = UNSET + contact_name: str | Unset = UNSET + phone_number: str | Unset = UNSET + job_reference: str | Unset = UNSET + product_type: BulkOrderDtoProductType | Unset = UNSET + bulk_order_type: BulkOrderDtoBulkOrderType | Unset = UNSET + awb: str | Unset = UNSET + bulk_bags: list[BulkBagDto] | Unset = UNSET + status: BulkOrderDtoStatus | Unset = UNSET + validation_errors: bool | Unset = False + error_message: str | Unset = UNSET + number_of_copies: int | Unset = UNSET + download_token: str | Unset = UNSET + printable: bool | Unset = UNSET + order_classification: BulkOrderDtoOrderClassification | Unset = UNSET + created_at: datetime.datetime | Unset = UNSET + created_by: str | Unset = UNSET + auth_user: str | Unset = UNSET + send_date: datetime.datetime | Unset = UNSET + submitted_date: datetime.datetime | Unset = UNSET + preadvice_eligible: bool | Unset = UNSET + finalised: bool | Unset = UNSET + total_item_weight_sum: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + contact_name = self.contact_name + + phone_number = self.phone_number + + job_reference = self.job_reference + + product_type: str | Unset = UNSET + if not isinstance(self.product_type, Unset): + product_type = self.product_type.value + + bulk_order_type: str | Unset = UNSET + if not isinstance(self.bulk_order_type, Unset): + bulk_order_type = self.bulk_order_type.value + + awb = self.awb + + bulk_bags: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.bulk_bags, Unset): + bulk_bags = [] + for bulk_bags_item_data in self.bulk_bags: + bulk_bags_item = bulk_bags_item_data.to_dict() + bulk_bags.append(bulk_bags_item) + + status: str | Unset = UNSET + if not isinstance(self.status, Unset): + status = self.status.value + + validation_errors = self.validation_errors + + error_message = self.error_message + + number_of_copies = self.number_of_copies + + download_token = self.download_token + + printable = self.printable + + order_classification: str | Unset = UNSET + if not isinstance(self.order_classification, Unset): + order_classification = self.order_classification.value + + created_at: str | Unset = UNSET + if not isinstance(self.created_at, Unset): + created_at = self.created_at.isoformat() + + created_by = self.created_by + + auth_user = self.auth_user + + send_date: str | Unset = UNSET + if not isinstance(self.send_date, Unset): + send_date = self.send_date.isoformat() + + submitted_date: str | Unset = UNSET + if not isinstance(self.submitted_date, Unset): + submitted_date = self.submitted_date.isoformat() + + preadvice_eligible = self.preadvice_eligible + + finalised = self.finalised + + total_item_weight_sum = self.total_item_weight_sum + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if contact_name is not UNSET: + field_dict["contactName"] = contact_name + if phone_number is not UNSET: + field_dict["phoneNumber"] = phone_number + if job_reference is not UNSET: + field_dict["jobReference"] = job_reference + if product_type is not UNSET: + field_dict["productType"] = product_type + if bulk_order_type is not UNSET: + field_dict["bulkOrderType"] = bulk_order_type + if awb is not UNSET: + field_dict["awb"] = awb + if bulk_bags is not UNSET: + field_dict["bulkBags"] = bulk_bags + if status is not UNSET: + field_dict["status"] = status + if validation_errors is not UNSET: + field_dict["validationErrors"] = validation_errors + if error_message is not UNSET: + field_dict["errorMessage"] = error_message + if number_of_copies is not UNSET: + field_dict["numberOfCopies"] = number_of_copies + if download_token is not UNSET: + field_dict["downloadToken"] = download_token + if printable is not UNSET: + field_dict["printable"] = printable + if order_classification is not UNSET: + field_dict["orderClassification"] = order_classification + if created_at is not UNSET: + field_dict["createdAt"] = created_at + if created_by is not UNSET: + field_dict["createdBy"] = created_by + if auth_user is not UNSET: + field_dict["authUser"] = auth_user + if send_date is not UNSET: + field_dict["sendDate"] = send_date + if submitted_date is not UNSET: + field_dict["submittedDate"] = submitted_date + if preadvice_eligible is not UNSET: + field_dict["preadviceEligible"] = preadvice_eligible + if finalised is not UNSET: + field_dict["finalised"] = finalised + if total_item_weight_sum is not UNSET: + field_dict["totalItemWeightSum"] = total_item_weight_sum + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.bulk_bag_dto import BulkBagDto + + d = dict(src_dict) + id = d.pop("id", UNSET) + + contact_name = d.pop("contactName", UNSET) + + phone_number = d.pop("phoneNumber", UNSET) + + job_reference = d.pop("jobReference", UNSET) + + _product_type = d.pop("productType", UNSET) + product_type: BulkOrderDtoProductType | Unset + if isinstance(_product_type, Unset): + product_type = UNSET + else: + product_type = BulkOrderDtoProductType(_product_type) + + _bulk_order_type = d.pop("bulkOrderType", UNSET) + bulk_order_type: BulkOrderDtoBulkOrderType | Unset + if isinstance(_bulk_order_type, Unset): + bulk_order_type = UNSET + else: + bulk_order_type = BulkOrderDtoBulkOrderType(_bulk_order_type) + + awb = d.pop("awb", UNSET) + + _bulk_bags = d.pop("bulkBags", UNSET) + bulk_bags: list[BulkBagDto] | Unset = UNSET + if _bulk_bags is not UNSET: + bulk_bags = [] + for bulk_bags_item_data in _bulk_bags: + bulk_bags_item = BulkBagDto.from_dict(bulk_bags_item_data) + + bulk_bags.append(bulk_bags_item) + + _status = d.pop("status", UNSET) + status: BulkOrderDtoStatus | Unset + if isinstance(_status, Unset): + status = UNSET + else: + status = BulkOrderDtoStatus(_status) + + validation_errors = d.pop("validationErrors", UNSET) + + error_message = d.pop("errorMessage", UNSET) + + number_of_copies = d.pop("numberOfCopies", UNSET) + + download_token = d.pop("downloadToken", UNSET) + + printable = d.pop("printable", UNSET) + + _order_classification = d.pop("orderClassification", UNSET) + order_classification: BulkOrderDtoOrderClassification | Unset + if isinstance(_order_classification, Unset): + order_classification = UNSET + else: + order_classification = BulkOrderDtoOrderClassification(_order_classification) + + _created_at = d.pop("createdAt", UNSET) + created_at: datetime.datetime | Unset + if isinstance(_created_at, Unset): + created_at = UNSET + else: + created_at = isoparse(_created_at) + + created_by = d.pop("createdBy", UNSET) + + auth_user = d.pop("authUser", UNSET) + + _send_date = d.pop("sendDate", UNSET) + send_date: datetime.datetime | Unset + if isinstance(_send_date, Unset): + send_date = UNSET + else: + send_date = isoparse(_send_date) + + _submitted_date = d.pop("submittedDate", UNSET) + submitted_date: datetime.datetime | Unset + if isinstance(_submitted_date, Unset): + submitted_date = UNSET + else: + submitted_date = isoparse(_submitted_date) + + preadvice_eligible = d.pop("preadviceEligible", UNSET) + + finalised = d.pop("finalised", UNSET) + + total_item_weight_sum = d.pop("totalItemWeightSum", UNSET) + + bulk_order_dto = cls( + id=id, + contact_name=contact_name, + phone_number=phone_number, + job_reference=job_reference, + product_type=product_type, + bulk_order_type=bulk_order_type, + awb=awb, + bulk_bags=bulk_bags, + status=status, + validation_errors=validation_errors, + error_message=error_message, + number_of_copies=number_of_copies, + download_token=download_token, + printable=printable, + order_classification=order_classification, + created_at=created_at, + created_by=created_by, + auth_user=auth_user, + send_date=send_date, + submitted_date=submitted_date, + preadvice_eligible=preadvice_eligible, + finalised=finalised, + total_item_weight_sum=total_item_weight_sum, + ) + + bulk_order_dto.additional_properties = d + return bulk_order_dto + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_bulk_order_type.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_bulk_order_type.py new file mode 100644 index 0000000..7a95c32 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_bulk_order_type.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class BulkOrderDtoBulkOrderType(str, Enum): + MIXED = "MIXED" + STANDARD = "STANDARD" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_order_classification.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_order_classification.py new file mode 100644 index 0000000..c2593dc --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_order_classification.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class BulkOrderDtoOrderClassification(str, Enum): + BAG = "BAG" + BAG_AND_BULK = "BAG_AND_BULK" + BULK = "BULK" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_product_type.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_product_type.py new file mode 100644 index 0000000..0d86828 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_product_type.py @@ -0,0 +1,19 @@ +from enum import Enum + + +class BulkOrderDtoProductType(str, Enum): + EXPRESS_LETTER_PLUS = "EXPRESS_LETTER_PLUS" + EXPRESS_LETTER_PRIO = "EXPRESS_LETTER_PRIO" + EXPRESS_PACKET_PLUS = "EXPRESS_PACKET_PLUS" + EXPRESS_PACKET_PRIO = "EXPRESS_PACKET_PRIO" + EXPRESS_PACKET_TRACKED = "EXPRESS_PACKET_TRACKED" + GM_MAIL_PRIO = "GM_MAIL_PRIO" + GM_MAIL_REG = "GM_MAIL_REG" + GM_MAIL_STANDARD = "GM_MAIL_STANDARD" + GM_PACKET_PLUS = "GM_PACKET_PLUS" + GM_PACKET_PRIO = "GM_PACKET_PRIO" + GM_PACKET_STANDARD = "GM_PACKET_STANDARD" + GM_PACKET_TRACKED = "GM_PACKET_TRACKED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_status.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_status.py new file mode 100644 index 0000000..f0c040a --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/bulk_order_dto_status.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class BulkOrderDtoStatus(str, Enum): + EDITING = "EDITING" + LOCKED = "LOCKED" + SAVED = "SAVED" + SUBMITTED = "SUBMITTED" + UNBAGGED = "UNBAGGED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/closed_bag.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/closed_bag.py new file mode 100644 index 0000000..82b6c98 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/closed_bag.py @@ -0,0 +1,136 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.closed_bag_service_level import ClosedBagServiceLevel +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ClosedBag") + + +@_attrs_define +class ClosedBag: + """ + Attributes: + product (str): The product that is used for the shipment of this item. Available products are: GMP (Packet), GMM + (Business Mail Standard). Example: GMM. + format_ (str): The format of the content of this bag. + service_level (ClosedBagServiceLevel): The service level that is used for the shipment of this item. There are + restrictions for use of service level: STANDARD is only available with products GMM and GMP, PRIORITY is only + available with products GMM and GMP. Example: PRIORITY. + destination_country (str): The destination country code. + item_barcodes (list[str]): The barcodes of the already created items. + bag_id (str | Unset): The BagId to track the bag. In requests only applicable for customers using "prelabelled + service" + item_count (int | Unset): The number of items. This value is only for the response. + net_bulk_weight_in_kilogram (float | Unset): The weight of items. This value is only for the response. + customer_ekp (str | Unset): The customer ekp. This value is only for the response. + """ + + product: str + format_: str + service_level: ClosedBagServiceLevel + destination_country: str + item_barcodes: list[str] + bag_id: str | Unset = UNSET + item_count: int | Unset = UNSET + net_bulk_weight_in_kilogram: float | Unset = UNSET + customer_ekp: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + product = self.product + + format_ = self.format_ + + service_level = self.service_level.value + + destination_country = self.destination_country + + item_barcodes = self.item_barcodes + + bag_id = self.bag_id + + item_count = self.item_count + + net_bulk_weight_in_kilogram = self.net_bulk_weight_in_kilogram + + customer_ekp = self.customer_ekp + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "product": product, + "format": format_, + "serviceLevel": service_level, + "destinationCountry": destination_country, + "itemBarcodes": item_barcodes, + } + ) + if bag_id is not UNSET: + field_dict["bagId"] = bag_id + if item_count is not UNSET: + field_dict["itemCount"] = item_count + if net_bulk_weight_in_kilogram is not UNSET: + field_dict["netBulkWeightInKilogram"] = net_bulk_weight_in_kilogram + if customer_ekp is not UNSET: + field_dict["customerEkp"] = customer_ekp + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + product = d.pop("product") + + format_ = d.pop("format") + + service_level = ClosedBagServiceLevel(d.pop("serviceLevel")) + + destination_country = d.pop("destinationCountry") + + item_barcodes = cast(list[str], d.pop("itemBarcodes")) + + bag_id = d.pop("bagId", UNSET) + + item_count = d.pop("itemCount", UNSET) + + net_bulk_weight_in_kilogram = d.pop("netBulkWeightInKilogram", UNSET) + + customer_ekp = d.pop("customerEkp", UNSET) + + closed_bag = cls( + product=product, + format_=format_, + service_level=service_level, + destination_country=destination_country, + item_barcodes=item_barcodes, + bag_id=bag_id, + item_count=item_count, + net_bulk_weight_in_kilogram=net_bulk_weight_in_kilogram, + customer_ekp=customer_ekp, + ) + + closed_bag.additional_properties = d + return closed_bag + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/closed_bag_service_level.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/closed_bag_service_level.py new file mode 100644 index 0000000..54f1c00 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/closed_bag_service_level.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class ClosedBagServiceLevel(str, Enum): + PRIORITY = "PRIORITY" + REGISTERED = "REGISTERED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/content.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/content.py new file mode 100644 index 0000000..6e4bbf4 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/content.py @@ -0,0 +1,121 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="Content") + + +@_attrs_define +class Content: + """ + Example: + {'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Trousers', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2} + + Attributes: + content_piece_amount (int): Number of pieces. Example: 2. + content_piece_description (str): The (short) description of this content. Example: Trousers. + content_piece_netweight (int): The net weight of all pieces of this content type. Example: 1200. + content_piece_origin (str): Country of origin, based on ISO-3166-1. Example: DE. + content_piece_value (str): Overall value of the content pieces of one type. 1 to 4 digits before the decimal + point, 2 digits after the decimal point or 1 to 7 digits without decimal point Example: 120.50. + content_piece_hs_code (str | Unset): The HS code of this content. Only 6, 8 or 10 digits, with at most one + leading zero. + HS Code mandatory for all shipments requiring a CN22 customs declaration. Example: 1234567890. + content_piece_index_number (int | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests + until further notice. + """ + + content_piece_amount: int + content_piece_description: str + content_piece_netweight: int + content_piece_origin: str + content_piece_value: str + content_piece_hs_code: str | Unset = UNSET + content_piece_index_number: int | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + content_piece_amount = self.content_piece_amount + + content_piece_description = self.content_piece_description + + content_piece_netweight = self.content_piece_netweight + + content_piece_origin = self.content_piece_origin + + content_piece_value = self.content_piece_value + + content_piece_hs_code = self.content_piece_hs_code + + content_piece_index_number = self.content_piece_index_number + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "contentPieceAmount": content_piece_amount, + "contentPieceDescription": content_piece_description, + "contentPieceNetweight": content_piece_netweight, + "contentPieceOrigin": content_piece_origin, + "contentPieceValue": content_piece_value, + } + ) + if content_piece_hs_code is not UNSET: + field_dict["contentPieceHsCode"] = content_piece_hs_code + if content_piece_index_number is not UNSET: + field_dict["contentPieceIndexNumber"] = content_piece_index_number + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + content_piece_amount = d.pop("contentPieceAmount") + + content_piece_description = d.pop("contentPieceDescription") + + content_piece_netweight = d.pop("contentPieceNetweight") + + content_piece_origin = d.pop("contentPieceOrigin") + + content_piece_value = d.pop("contentPieceValue") + + content_piece_hs_code = d.pop("contentPieceHsCode", UNSET) + + content_piece_index_number = d.pop("contentPieceIndexNumber", UNSET) + + content = cls( + content_piece_amount=content_piece_amount, + content_piece_description=content_piece_description, + content_piece_netweight=content_piece_netweight, + content_piece_origin=content_piece_origin, + content_piece_value=content_piece_value, + content_piece_hs_code=content_piece_hs_code, + content_piece_index_number=content_piece_index_number, + ) + + content.additional_properties = d + return content + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/country.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/country.py new file mode 100644 index 0000000..e023bf3 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/country.py @@ -0,0 +1,90 @@ +from __future__ import annotations + +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 ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.language import Language + + +T = TypeVar("T", bound="Country") + + +@_attrs_define +class Country: + """ + Attributes: + code (str): + languages (list[Language] | Unset): + """ + + code: str + languages: list[Language] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + code = self.code + + languages: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.languages, Unset): + languages = [] + for languages_item_data in self.languages: + languages_item = languages_item_data.to_dict() + languages.append(languages_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "code": code, + } + ) + if languages is not UNSET: + field_dict["languages"] = languages + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.language import Language + + d = dict(src_dict) + code = d.pop("code") + + _languages = d.pop("languages", UNSET) + languages: list[Language] | Unset = UNSET + if _languages is not UNSET: + languages = [] + for languages_item_data in _languages: + languages_item = Language.from_dict(languages_item_data) + + languages.append(languages_item) + + country = cls( + code=code, + languages=languages, + ) + + country.additional_properties = d + return country + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/cws_error_dto.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/cws_error_dto.py new file mode 100644 index 0000000..ecf88a6 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/cws_error_dto.py @@ -0,0 +1,73 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="CwsErrorDTO") + + +@_attrs_define +class CwsErrorDTO: + """ + Attributes: + correlation_id (str | Unset): The Correlation ID to track the request through all systems where it has been + processed. Example: b011a094-fade-11e7-8c3f-9a214cf093ae. + messages (list[str] | Unset): A list of messages. Any single error is described within a certain message. + """ + + correlation_id: str | Unset = UNSET + messages: list[str] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + correlation_id = self.correlation_id + + messages: list[str] | Unset = UNSET + if not isinstance(self.messages, Unset): + messages = self.messages + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if correlation_id is not UNSET: + field_dict["correlationId"] = correlation_id + if messages is not UNSET: + field_dict["messages"] = messages + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + correlation_id = d.pop("correlationId", UNSET) + + messages = cast(list[str], d.pop("messages", UNSET)) + + cws_error_dto = cls( + correlation_id=correlation_id, + messages=messages, + ) + + cws_error_dto.additional_properties = d + return cws_error_dto + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_info_401_response.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_info_401_response.py new file mode 100644 index 0000000..f40902e --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_info_401_response.py @@ -0,0 +1,72 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="GetAccessTokenInfo401Response") + + +@_attrs_define +class GetAccessTokenInfo401Response: + """ + Example: + {'error': 'invalid_token', 'error_description': 'The presented token is invalid or expired.'} + + Attributes: + error (str): Example: invalid_token. + error_description (str): Example: The presented token is invalid or expired.. + """ + + error: str + error_description: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + error = self.error + + error_description = self.error_description + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "error": error, + "error_description": error_description, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + error = d.pop("error") + + error_description = d.pop("error_description") + + get_access_token_info_401_response = cls( + error=error, + error_description=error_description, + ) + + get_access_token_info_401_response.additional_properties = d + return get_access_token_info_401_response + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_info_response.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_info_response.py new file mode 100644 index 0000000..aecce07 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_info_response.py @@ -0,0 +1,81 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="GetAccessTokenInfoResponse") + + +@_attrs_define +class GetAccessTokenInfoResponse: + """ + Example: + {'audience': 'b0601394-d106-4bca-a825-af40b7422640', 'user_id': 'b0601394-d106-4bca-a825-af40b7422640', + 'expires_in': 15951} + + Attributes: + audience (str): Example: b0601394-d106-4bca-a825-af40b7422640. + user_id (str): Example: b0601394-d106-4bca-a825-af40b7422640. + expires_in (int): Example: 15951. + """ + + audience: str + user_id: str + expires_in: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + audience = self.audience + + user_id = self.user_id + + expires_in = self.expires_in + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "audience": audience, + "user_id": user_id, + "expires_in": expires_in, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + audience = d.pop("audience") + + user_id = d.pop("user_id") + + expires_in = d.pop("expires_in") + + get_access_token_info_response = cls( + audience=audience, + user_id=user_id, + expires_in=expires_in, + ) + + get_access_token_info_response.additional_properties = d + return get_access_token_info_response + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_response.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_response.py new file mode 100644 index 0000000..6a6e6d9 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_access_token_response.py @@ -0,0 +1,81 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="GetAccessTokenResponse") + + +@_attrs_define +class GetAccessTokenResponse: + """ + Example: + {'access_token': 'vzoJsASlFm0rfz3HsZEWC69lgQcytQQqWJvk9eBL3cMF8j7W4ny4Dh', 'token_type': 'Bearer', 'expires_in': + 18000} + + Attributes: + access_token (str): Example: vzoJsASlFm0rfz3HsZEWC69lgQcytQQqWJvk9eBL3cMF8j7W4ny4Dh. + token_type (str): Example: Bearer. + expires_in (int): Example: 18000. + """ + + access_token: str + token_type: str + expires_in: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + access_token = self.access_token + + token_type = self.token_type + + expires_in = self.expires_in + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "access_token": access_token, + "token_type": token_type, + "expires_in": expires_in, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + access_token = d.pop("access_token") + + token_type = d.pop("token_type") + + expires_in = d.pop("expires_in") + + get_access_token_response = cls( + access_token=access_token, + token_type=token_type, + expires_in=expires_in, + ) + + get_access_token_response.additional_properties = d + return get_access_token_response + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_bag_tag_accept.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_bag_tag_accept.py new file mode 100644 index 0000000..a820e78 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_bag_tag_accept.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class GetBagTagAccept(str, Enum): + APPLICATIONPDF = "application/pdf" + APPLICATIONPDFSINGLEPAGE = "application/pdf+singlepage" + APPLICATIONPDFSINGLEPAGE6X4 = "application/pdf+singlepage+6x4" + APPLICATIONZPL = "application/zpl" + APPLICATIONZPL6X4 = "application/zpl+6x4" + APPLICATIONZPLROTATED = "application/zpl+rotated" + APPLICATIONZPLROTATED6X4 = "application/zpl+rotated+6x4" + IMAGEPNG = "image/png" + IMAGEPNG6X4 = "image/png+6x4" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_bag_tag_label_accept.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_bag_tag_label_accept.py new file mode 100644 index 0000000..408ce74 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_bag_tag_label_accept.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class GetBagTagLabelAccept(str, Enum): + APPLICATIONPDF = "application/pdf" + APPLICATIONPDFSINGLEPAGE = "application/pdf+singlepage" + APPLICATIONPDFSINGLEPAGE6X4 = "application/pdf+singlepage+6x4" + APPLICATIONZPL = "application/zpl" + APPLICATIONZPL6X4 = "application/zpl+6x4" + APPLICATIONZPLROTATED = "application/zpl+rotated" + APPLICATIONZPLROTATED6X4 = "application/zpl+rotated+6x4" + IMAGEPNG = "image/png" + IMAGEPNG6X4 = "image/png+6x4" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_customer_item_label_accept.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_customer_item_label_accept.py new file mode 100644 index 0000000..bfa6157 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_customer_item_label_accept.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class GetCustomerItemLabelAccept(str, Enum): + APPLICATIONPDF = "application/pdf" + APPLICATIONPDFSINGLEPAGE = "application/pdf+singlepage" + APPLICATIONPDFSINGLEPAGE6X4 = "application/pdf+singlepage+6x4" + APPLICATIONZPL = "application/zpl" + APPLICATIONZPL6X4 = "application/zpl+6x4" + APPLICATIONZPLROTATED = "application/zpl+rotated" + APPLICATIONZPLROTATED6X4 = "application/zpl+rotated+6x4" + IMAGEPNG = "image/png" + IMAGEPNG6X4 = "image/png+6x4" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_item_label_accept.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_item_label_accept.py new file mode 100644 index 0000000..198c719 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_item_label_accept.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class GetItemLabelAccept(str, Enum): + APPLICATIONPDF = "application/pdf" + APPLICATIONPDFSINGLEPAGE = "application/pdf+singlepage" + APPLICATIONPDFSINGLEPAGE6X4 = "application/pdf+singlepage+6x4" + APPLICATIONZPL = "application/zpl" + APPLICATIONZPL6X4 = "application/zpl+6x4" + APPLICATIONZPLROTATED = "application/zpl+rotated" + APPLICATIONZPLROTATED6X4 = "application/zpl+rotated+6x4" + IMAGEPNG = "image/png" + IMAGEPNG6X4 = "image/png+6x4" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_item_labels_accept.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_item_labels_accept.py new file mode 100644 index 0000000..cc221f7 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_item_labels_accept.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class GetItemLabelsAccept(str, Enum): + APPLICATIONPDF = "application/pdf" + APPLICATIONPDFSINGLEPAGE = "application/pdf+singlepage" + APPLICATIONPDFSINGLEPAGE6X4 = "application/pdf+singlepage+6x4" + APPLICATIONZPL = "application/zpl" + APPLICATIONZPL6X4 = "application/zpl+6x4" + APPLICATIONZPLROTATED = "application/zpl+rotated" + APPLICATIONZPLROTATED6X4 = "application/zpl+rotated+6x4" + IMAGEPNG = "image/png" + IMAGEPNG6X4 = "image/png+6x4" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_items_status.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_items_status.py new file mode 100644 index 0000000..4dcdcaf --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/get_items_status.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class GetItemsStatus(str, Enum): + NEW = "NEW" + ORDERED = "ORDERED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item.py new file mode 100644 index 0000000..464c873 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item.py @@ -0,0 +1,456 @@ +from __future__ import annotations + +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 ..models.item_service_level import ItemServiceLevel +from ..models.item_shipment_naturetype import ItemShipmentNaturetype +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.content import Content + + +T = TypeVar("T", bound="Item") + + +@_attrs_define +class Item: + """ + Example: + {'product': 'GPT', 'serviceLevel': 'PRIORITY', 'recipient': 'Doris Bronson', 'addressLine1': 'Uptown street 10', + 'addressLine2': '2nd floor', 'postalCode': 'SW1A 2AA', 'city': 'London', 'destinationCountry': 'GB', 'custRef': + 'BRE-2021-XIT', 'recipientPhone': '+441234567890', 'recipientEmail': 'doris@somewhere.non.eu', 'senderTaxId': + 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, 'shipmentCurrency': 'EUR', + 'shipmentGrossWeight': 1500, 'returnItemWanted': False, 'shipmentNaturetype': 'SALE_GOODS', 'contents': + [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]} + + Attributes: + address_line_1 (str): First line of address information of the recipient. + No unicode replacement characters � or question mark is accepted. Example: Any Street 100. + city (str): City of the recipient address. + No unicode replacement characters � or question mark is accepted. Example: Any City. + destination_country (str): Destination country of the item, based on ISO-3166-1. Please check + https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for further details. Example: DE. + product (str): The product that is used for the shipment of this item. Available products are: GMP [Packet + Priority/Prio (goods)], GPT [Packet Tracked/Tracked], GMM [Business Mail Priority/Prio (documents)], GMR + [Business Mail Registered/Plus (documents)] Example: GMP. + recipient (str): Name of the recipient. + No unicodereplacement characters � and max. one question mark is accepted. Example: John Doe. + service_level (ItemServiceLevel): The service level that is used for the shipment of this item. There are + restrictions for use of service level: Registered is only available with product GMR and SalesChannel DPI + Example: PRIORITY. + shipment_gross_weight (int): Gross weight of the item (in g). May not exceed 2000 g. Example: 1500. + address_line_2 (str | Unset): Second line of address information of the recipient. + No unicode replacement characters � or question mark is accepted. Example: Flat 2. + address_line_3 (str | Unset): Third line of address information of the recipient. + No unicode replacement characters � or question mark is accepted. Example: 1st floor. + barcode (str | Unset): The barcode of this item (if available). Example: BC123456789. + contents (list[Content] | Unset): The descriptions of the content pieces. + cust_ref (str | Unset): Reference to the customer. Example: REF-2361890-AB. + cust_ref_2 (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + cust_ref_3 (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + id (int | Unset): The id of the item Example: 1. + postal_code (str | Unset): Postal code of the recipient address. Consists of + numbers, upper case letters, and one space or dash between characters + No unicode replacement characters � or question mark is accepted. Example: 794. + importer_tax_id (str | Unset): Customs reference number of the recipient, if required and applicable e.g. EORI + number. Example: EORI: LU12345. + recipient_email (str | Unset): Email address of the recipient. Used for notification. + recipientEmail OR recipientPhone required for interconnect countries! + + An e-mail address or phone number for the recipient must be provided. Many postal operators have implemented + electronic pick-up notifications by e-mail or SMS and the provision of this information is essential to ensure + the smooth delivery of your shipments. Example: john.doe@example.eu. + recipient_fax (str | Unset): Fax number of the recipient Example: +44123456789. + recipient_phone (str | Unset): Phone number of the recipient. + recipientEmail OR recipientPhone required for interconnect countries! + + An e-mail address or phone number for the recipient must be provided. Many postal operators have implemented + electronic pick-up notifications by e-mail or SMS and the provision of this information is essential to ensure + the smooth delivery of your shipments. Example: +441234567890. + return_item_wanted (bool | Unset): Is Packet Return. Default: False. + p_ddp (bool | Unset): Is Item pddp? FOR FUTURE USE. Not yet relvant Default: False. + sender_address_line_1 (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until + further notice. + sender_address_line_2 (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until + further notice. + sender_city (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_country (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_email (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_name (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_phone (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_postal_code (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until + further notice. + sender_tax_id (str | Unset): Customs reference number of the sender, if applicable e.g. IOSS or VOEC number. + Example: IOSS: ABC12345. + shipment_amount (float | Unset): Overall value of all content pieces of the item. Example: 100. + shipment_currency (str | Unset): Currency code of the value, based on ISO-4217. Please check + https://en.wikipedia.org/wiki/ISO_4217#Active_codes for further details. Example: EUR. + shipment_naturetype (ItemShipmentNaturetype | Unset): Nature of the pieces in this item. Mandatory for non-EU + shipments: SALE_GOODS, RETURN_GOODS, COMMERCIAL_SAMPLE, DOCUMENTS, MIXED_CONTENTS, OTHERS. Mandatory for non-EU + shipments. Example: SALE_GOODS. + state (str | Unset): State of the recipient address. + No unicode replacement characters � or question mark is accepted. + An empty string is still allowed Example: NC. + third_party_vendor_id (str | Unset): The ID of the 3PV/Third Party Vendor who created this item. + format_ (str | Unset): The format. Weight limits are P: 100g, G: 500g, E: 2000g Example: P|G|E. + """ + + address_line_1: str + city: str + destination_country: str + product: str + recipient: str + service_level: ItemServiceLevel + shipment_gross_weight: int + address_line_2: str | Unset = UNSET + address_line_3: str | Unset = UNSET + barcode: str | Unset = UNSET + contents: list[Content] | Unset = UNSET + cust_ref: str | Unset = UNSET + cust_ref_2: str | Unset = UNSET + cust_ref_3: str | Unset = UNSET + id: int | Unset = UNSET + postal_code: str | Unset = UNSET + importer_tax_id: str | Unset = UNSET + recipient_email: str | Unset = UNSET + recipient_fax: str | Unset = UNSET + recipient_phone: str | Unset = UNSET + return_item_wanted: bool | Unset = False + p_ddp: bool | Unset = False + sender_address_line_1: str | Unset = UNSET + sender_address_line_2: str | Unset = UNSET + sender_city: str | Unset = UNSET + sender_country: str | Unset = UNSET + sender_email: str | Unset = UNSET + sender_name: str | Unset = UNSET + sender_phone: str | Unset = UNSET + sender_postal_code: str | Unset = UNSET + sender_tax_id: str | Unset = UNSET + shipment_amount: float | Unset = UNSET + shipment_currency: str | Unset = UNSET + shipment_naturetype: ItemShipmentNaturetype | Unset = UNSET + state: str | Unset = UNSET + third_party_vendor_id: str | Unset = UNSET + format_: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + address_line_1 = self.address_line_1 + + city = self.city + + destination_country = self.destination_country + + product = self.product + + recipient = self.recipient + + service_level = self.service_level.value + + shipment_gross_weight = self.shipment_gross_weight + + address_line_2 = self.address_line_2 + + address_line_3 = self.address_line_3 + + barcode = self.barcode + + contents: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.contents, Unset): + contents = [] + for contents_item_data in self.contents: + contents_item = contents_item_data.to_dict() + contents.append(contents_item) + + cust_ref = self.cust_ref + + cust_ref_2 = self.cust_ref_2 + + cust_ref_3 = self.cust_ref_3 + + id = self.id + + postal_code = self.postal_code + + importer_tax_id = self.importer_tax_id + + recipient_email = self.recipient_email + + recipient_fax = self.recipient_fax + + recipient_phone = self.recipient_phone + + return_item_wanted = self.return_item_wanted + + p_ddp = self.p_ddp + + sender_address_line_1 = self.sender_address_line_1 + + sender_address_line_2 = self.sender_address_line_2 + + sender_city = self.sender_city + + sender_country = self.sender_country + + sender_email = self.sender_email + + sender_name = self.sender_name + + sender_phone = self.sender_phone + + sender_postal_code = self.sender_postal_code + + sender_tax_id = self.sender_tax_id + + shipment_amount = self.shipment_amount + + shipment_currency = self.shipment_currency + + shipment_naturetype: str | Unset = UNSET + if not isinstance(self.shipment_naturetype, Unset): + shipment_naturetype = self.shipment_naturetype.value + + state = self.state + + third_party_vendor_id = self.third_party_vendor_id + + format_ = self.format_ + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "addressLine1": address_line_1, + "city": city, + "destinationCountry": destination_country, + "product": product, + "recipient": recipient, + "serviceLevel": service_level, + "shipmentGrossWeight": shipment_gross_weight, + } + ) + if address_line_2 is not UNSET: + field_dict["addressLine2"] = address_line_2 + if address_line_3 is not UNSET: + field_dict["addressLine3"] = address_line_3 + if barcode is not UNSET: + field_dict["barcode"] = barcode + if contents is not UNSET: + field_dict["contents"] = contents + if cust_ref is not UNSET: + field_dict["custRef"] = cust_ref + if cust_ref_2 is not UNSET: + field_dict["custRef2"] = cust_ref_2 + if cust_ref_3 is not UNSET: + field_dict["custRef3"] = cust_ref_3 + if id is not UNSET: + field_dict["id"] = id + if postal_code is not UNSET: + field_dict["postalCode"] = postal_code + if importer_tax_id is not UNSET: + field_dict["importerTaxId"] = importer_tax_id + if recipient_email is not UNSET: + field_dict["recipientEmail"] = recipient_email + if recipient_fax is not UNSET: + field_dict["recipientFax"] = recipient_fax + if recipient_phone is not UNSET: + field_dict["recipientPhone"] = recipient_phone + if return_item_wanted is not UNSET: + field_dict["returnItemWanted"] = return_item_wanted + if p_ddp is not UNSET: + field_dict["pDDP"] = p_ddp + if sender_address_line_1 is not UNSET: + field_dict["senderAddressLine1"] = sender_address_line_1 + if sender_address_line_2 is not UNSET: + field_dict["senderAddressLine2"] = sender_address_line_2 + if sender_city is not UNSET: + field_dict["senderCity"] = sender_city + if sender_country is not UNSET: + field_dict["senderCountry"] = sender_country + if sender_email is not UNSET: + field_dict["senderEmail"] = sender_email + if sender_name is not UNSET: + field_dict["senderName"] = sender_name + if sender_phone is not UNSET: + field_dict["senderPhone"] = sender_phone + if sender_postal_code is not UNSET: + field_dict["senderPostalCode"] = sender_postal_code + if sender_tax_id is not UNSET: + field_dict["senderTaxId"] = sender_tax_id + if shipment_amount is not UNSET: + field_dict["shipmentAmount"] = shipment_amount + if shipment_currency is not UNSET: + field_dict["shipmentCurrency"] = shipment_currency + if shipment_naturetype is not UNSET: + field_dict["shipmentNaturetype"] = shipment_naturetype + if state is not UNSET: + field_dict["state"] = state + if third_party_vendor_id is not UNSET: + field_dict["thirdPartyVendorId"] = third_party_vendor_id + if format_ is not UNSET: + field_dict["format"] = format_ + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.content import Content + + d = dict(src_dict) + address_line_1 = d.pop("addressLine1") + + city = d.pop("city") + + destination_country = d.pop("destinationCountry") + + product = d.pop("product") + + recipient = d.pop("recipient") + + service_level = ItemServiceLevel(d.pop("serviceLevel")) + + shipment_gross_weight = d.pop("shipmentGrossWeight") + + address_line_2 = d.pop("addressLine2", UNSET) + + address_line_3 = d.pop("addressLine3", UNSET) + + barcode = d.pop("barcode", UNSET) + + _contents = d.pop("contents", UNSET) + contents: list[Content] | Unset = UNSET + if _contents is not UNSET: + contents = [] + for contents_item_data in _contents: + contents_item = Content.from_dict(contents_item_data) + + contents.append(contents_item) + + cust_ref = d.pop("custRef", UNSET) + + cust_ref_2 = d.pop("custRef2", UNSET) + + cust_ref_3 = d.pop("custRef3", UNSET) + + id = d.pop("id", UNSET) + + postal_code = d.pop("postalCode", UNSET) + + importer_tax_id = d.pop("importerTaxId", UNSET) + + recipient_email = d.pop("recipientEmail", UNSET) + + recipient_fax = d.pop("recipientFax", UNSET) + + recipient_phone = d.pop("recipientPhone", UNSET) + + return_item_wanted = d.pop("returnItemWanted", UNSET) + + p_ddp = d.pop("pDDP", UNSET) + + sender_address_line_1 = d.pop("senderAddressLine1", UNSET) + + sender_address_line_2 = d.pop("senderAddressLine2", UNSET) + + sender_city = d.pop("senderCity", UNSET) + + sender_country = d.pop("senderCountry", UNSET) + + sender_email = d.pop("senderEmail", UNSET) + + sender_name = d.pop("senderName", UNSET) + + sender_phone = d.pop("senderPhone", UNSET) + + sender_postal_code = d.pop("senderPostalCode", UNSET) + + sender_tax_id = d.pop("senderTaxId", UNSET) + + shipment_amount = d.pop("shipmentAmount", UNSET) + + shipment_currency = d.pop("shipmentCurrency", UNSET) + + _shipment_naturetype = d.pop("shipmentNaturetype", UNSET) + shipment_naturetype: ItemShipmentNaturetype | Unset + if isinstance(_shipment_naturetype, Unset): + shipment_naturetype = UNSET + else: + shipment_naturetype = ItemShipmentNaturetype(_shipment_naturetype) + + state = d.pop("state", UNSET) + + third_party_vendor_id = d.pop("thirdPartyVendorId", UNSET) + + format_ = d.pop("format", UNSET) + + item = cls( + address_line_1=address_line_1, + city=city, + destination_country=destination_country, + product=product, + recipient=recipient, + service_level=service_level, + shipment_gross_weight=shipment_gross_weight, + address_line_2=address_line_2, + address_line_3=address_line_3, + barcode=barcode, + contents=contents, + cust_ref=cust_ref, + cust_ref_2=cust_ref_2, + cust_ref_3=cust_ref_3, + id=id, + postal_code=postal_code, + importer_tax_id=importer_tax_id, + recipient_email=recipient_email, + recipient_fax=recipient_fax, + recipient_phone=recipient_phone, + return_item_wanted=return_item_wanted, + p_ddp=p_ddp, + sender_address_line_1=sender_address_line_1, + sender_address_line_2=sender_address_line_2, + sender_city=sender_city, + sender_country=sender_country, + sender_email=sender_email, + sender_name=sender_name, + sender_phone=sender_phone, + sender_postal_code=sender_postal_code, + sender_tax_id=sender_tax_id, + shipment_amount=shipment_amount, + shipment_currency=shipment_currency, + shipment_naturetype=shipment_naturetype, + state=state, + third_party_vendor_id=third_party_vendor_id, + format_=format_, + ) + + item.additional_properties = d + return item + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data.py new file mode 100644 index 0000000..a08cc1a --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data.py @@ -0,0 +1,413 @@ +from __future__ import annotations + +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 ..models.item_data_service_level import ItemDataServiceLevel +from ..models.item_data_shipment_naturetype import ItemDataShipmentNaturetype +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.content import Content + + +T = TypeVar("T", bound="ItemData") + + +@_attrs_define +class ItemData: + """ + Example: + {'id': 1, 'product': 'GMP', 'serviceLevel': 'PRIORITY', 'custRef': 'REF-2361890-AB', 'recipient': 'John Doe', + 'recipientPhone': '+4935120681234', 'recipientFax': '+4935120681234', 'recipientEmail': 'john.doe@example.eu', + 'addressLine1': 'Mustergasse 12', 'addressLine2': 'Hinterhaus', 'addressLine3': '1. Etage', 'city': 'Dresden', + 'state': 'Sachsen', 'postalCode': '01432', 'destinationCountry': 'DE', 'shipmentAmount': 100, + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, 'shipmentNaturetype': + 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Trousers', + 'contentPieceValue': '120.50', 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': + 2}]} + + Attributes: + address_line_1 (str): First line of address information of the recipient. + No unicode replacement characters � or question mark is accepted. Example: Any Street 100. + city (str): City of the recipient address. + No unicode replacement characters � or question mark is accepted. Example: Any City. + destination_country (str): Destination country of the item, based on ISO-3166-1. Please check + https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for further details. Example: DE. + product (str): The product that is used for the shipment of this item. Available products are: GMP [Packet + Priority/Prio (goods)], GPT [Packet Tracked/Tracked], GMM [Business Mail Priority/Prio (documents)], GMR + [Business Mail Registered/Plus (documents)] Example: GMP. + recipient (str): Name of the recipient. + No unicode replacement characters � and max. one question mark is accepted. Example: John Doe. + service_level (ItemDataServiceLevel): The service level that is used for the shipment of this item. There are + restrictions for use of service level: Registered is only available with product GMR and SalesChannel DPI + Example: PRIORITY. + shipment_gross_weight (int): Gross weight of the item (in g). May not exceed 2000 g. Example: 1500. + address_line_2 (str | Unset): Second line of address information of the recipient. + No unicode replacement characters � or question mark is accepted. Example: Flat 2. + address_line_3 (str | Unset): Third line of address information of the recipient. + No unicode replacement characters � or question mark is accepted. Example: 1st floor. + contents (list[Content] | Unset): The descriptions of the content pieces. + cust_ref (str | Unset): Reference text up to customer's choice Example: REF-2361890-AB. + cust_ref_2 (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + cust_ref_3 (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + postal_code (str | Unset): Postal code of the recipient address. Consists of + numbers, upper case letters, and one space or dash between characters + No unicode replacement characters � or question mark is accepted. Example: 794. + importer_tax_id (str | Unset): Customs reference number of the recipient, if required and applicable e.g. EORI + number. Example: EORI: LU12345. + recipient_email (str | Unset): Email address of the recipient. Used for notification. + recipientEmail OR recipientPhone required for interconnect countries! + + An e-mail address or phone number for the recipient must be provided. Many postal operators have implemented + electronic pick-up notifications by e-mail or SMS and the provision of this information is essential to ensure + the smooth delivery of your shipments. Example: john.doe@example.eu. + recipient_fax (str | Unset): Fax number of the recipient Example: +441234567891. + recipient_phone (str | Unset): Phone number of the recipient + recipientEmail OR recipientPhone required for interconnect countries! + + An e-mail address or phone number for the recipient must be provided. Many postal operators have implemented + electronic pick-up notifications by e-mail or SMS and the provision of this information is essential to ensure + the smooth delivery of your shipments. Example: +441234567891. + return_item_wanted (bool | Unset): States if a return label should be created additionally. Requires a contract + for Packet Return. Default: False. + sender_address_line_1 (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until + further notice. + sender_address_line_2 (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until + further notice. + sender_city (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_country (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_email (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_name (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_phone (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until further + notice. + sender_postal_code (str | Unset): NOT RECOMMENDED, obsolete and should not be contained in requests until + further notice. + sender_tax_id (str | Unset): Customs reference number of the sender, if applicable e.g. IOSS or VOEC number. + Example: IOSS: ABC12345. + shipment_amount (float | Unset): Overall value of all content pieces of the item. Example: 100. + shipment_currency (str | Unset): Currency code of the value, based on ISO-4217. Please check + https://en.wikipedia.org/wiki/ISO_4217#Active_codes for further details. Example: EUR. + shipment_naturetype (ItemDataShipmentNaturetype | Unset): Nature of the pieces in this item. Mandatory for non- + EU shipments: SALE_GOODS, RETURN_GOODS, COMMERCIAL_SAMPLE, DOCUMENTS, MIXED_CONTENTS, OTHERS. Mandatory for non- + EU shipments. Example: SALE_GOODS. + state (str | Unset): State of the recipient address. + No unicode replacement characters � or question mark is accepted. + An empty string is still allowed Example: NC. + """ + + address_line_1: str + city: str + destination_country: str + product: str + recipient: str + service_level: ItemDataServiceLevel + shipment_gross_weight: int + address_line_2: str | Unset = UNSET + address_line_3: str | Unset = UNSET + contents: list[Content] | Unset = UNSET + cust_ref: str | Unset = UNSET + cust_ref_2: str | Unset = UNSET + cust_ref_3: str | Unset = UNSET + postal_code: str | Unset = UNSET + importer_tax_id: str | Unset = UNSET + recipient_email: str | Unset = UNSET + recipient_fax: str | Unset = UNSET + recipient_phone: str | Unset = UNSET + return_item_wanted: bool | Unset = False + sender_address_line_1: str | Unset = UNSET + sender_address_line_2: str | Unset = UNSET + sender_city: str | Unset = UNSET + sender_country: str | Unset = UNSET + sender_email: str | Unset = UNSET + sender_name: str | Unset = UNSET + sender_phone: str | Unset = UNSET + sender_postal_code: str | Unset = UNSET + sender_tax_id: str | Unset = UNSET + shipment_amount: float | Unset = UNSET + shipment_currency: str | Unset = UNSET + shipment_naturetype: ItemDataShipmentNaturetype | Unset = UNSET + state: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + address_line_1 = self.address_line_1 + + city = self.city + + destination_country = self.destination_country + + product = self.product + + recipient = self.recipient + + service_level = self.service_level.value + + shipment_gross_weight = self.shipment_gross_weight + + address_line_2 = self.address_line_2 + + address_line_3 = self.address_line_3 + + contents: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.contents, Unset): + contents = [] + for contents_item_data in self.contents: + contents_item = contents_item_data.to_dict() + contents.append(contents_item) + + cust_ref = self.cust_ref + + cust_ref_2 = self.cust_ref_2 + + cust_ref_3 = self.cust_ref_3 + + postal_code = self.postal_code + + importer_tax_id = self.importer_tax_id + + recipient_email = self.recipient_email + + recipient_fax = self.recipient_fax + + recipient_phone = self.recipient_phone + + return_item_wanted = self.return_item_wanted + + sender_address_line_1 = self.sender_address_line_1 + + sender_address_line_2 = self.sender_address_line_2 + + sender_city = self.sender_city + + sender_country = self.sender_country + + sender_email = self.sender_email + + sender_name = self.sender_name + + sender_phone = self.sender_phone + + sender_postal_code = self.sender_postal_code + + sender_tax_id = self.sender_tax_id + + shipment_amount = self.shipment_amount + + shipment_currency = self.shipment_currency + + shipment_naturetype: str | Unset = UNSET + if not isinstance(self.shipment_naturetype, Unset): + shipment_naturetype = self.shipment_naturetype.value + + state = self.state + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "addressLine1": address_line_1, + "city": city, + "destinationCountry": destination_country, + "product": product, + "recipient": recipient, + "serviceLevel": service_level, + "shipmentGrossWeight": shipment_gross_weight, + } + ) + if address_line_2 is not UNSET: + field_dict["addressLine2"] = address_line_2 + if address_line_3 is not UNSET: + field_dict["addressLine3"] = address_line_3 + if contents is not UNSET: + field_dict["contents"] = contents + if cust_ref is not UNSET: + field_dict["custRef"] = cust_ref + if cust_ref_2 is not UNSET: + field_dict["custRef2"] = cust_ref_2 + if cust_ref_3 is not UNSET: + field_dict["custRef3"] = cust_ref_3 + if postal_code is not UNSET: + field_dict["postalCode"] = postal_code + if importer_tax_id is not UNSET: + field_dict["importerTaxId"] = importer_tax_id + if recipient_email is not UNSET: + field_dict["recipientEmail"] = recipient_email + if recipient_fax is not UNSET: + field_dict["recipientFax"] = recipient_fax + if recipient_phone is not UNSET: + field_dict["recipientPhone"] = recipient_phone + if return_item_wanted is not UNSET: + field_dict["returnItemWanted"] = return_item_wanted + if sender_address_line_1 is not UNSET: + field_dict["senderAddressLine1"] = sender_address_line_1 + if sender_address_line_2 is not UNSET: + field_dict["senderAddressLine2"] = sender_address_line_2 + if sender_city is not UNSET: + field_dict["senderCity"] = sender_city + if sender_country is not UNSET: + field_dict["senderCountry"] = sender_country + if sender_email is not UNSET: + field_dict["senderEmail"] = sender_email + if sender_name is not UNSET: + field_dict["senderName"] = sender_name + if sender_phone is not UNSET: + field_dict["senderPhone"] = sender_phone + if sender_postal_code is not UNSET: + field_dict["senderPostalCode"] = sender_postal_code + if sender_tax_id is not UNSET: + field_dict["senderTaxId"] = sender_tax_id + if shipment_amount is not UNSET: + field_dict["shipmentAmount"] = shipment_amount + if shipment_currency is not UNSET: + field_dict["shipmentCurrency"] = shipment_currency + if shipment_naturetype is not UNSET: + field_dict["shipmentNaturetype"] = shipment_naturetype + if state is not UNSET: + field_dict["state"] = state + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.content import Content + + d = dict(src_dict) + address_line_1 = d.pop("addressLine1") + + city = d.pop("city") + + destination_country = d.pop("destinationCountry") + + product = d.pop("product") + + recipient = d.pop("recipient") + + service_level = ItemDataServiceLevel(d.pop("serviceLevel")) + + shipment_gross_weight = d.pop("shipmentGrossWeight") + + address_line_2 = d.pop("addressLine2", UNSET) + + address_line_3 = d.pop("addressLine3", UNSET) + + _contents = d.pop("contents", UNSET) + contents: list[Content] | Unset = UNSET + if _contents is not UNSET: + contents = [] + for contents_item_data in _contents: + contents_item = Content.from_dict(contents_item_data) + + contents.append(contents_item) + + cust_ref = d.pop("custRef", UNSET) + + cust_ref_2 = d.pop("custRef2", UNSET) + + cust_ref_3 = d.pop("custRef3", UNSET) + + postal_code = d.pop("postalCode", UNSET) + + importer_tax_id = d.pop("importerTaxId", UNSET) + + recipient_email = d.pop("recipientEmail", UNSET) + + recipient_fax = d.pop("recipientFax", UNSET) + + recipient_phone = d.pop("recipientPhone", UNSET) + + return_item_wanted = d.pop("returnItemWanted", UNSET) + + sender_address_line_1 = d.pop("senderAddressLine1", UNSET) + + sender_address_line_2 = d.pop("senderAddressLine2", UNSET) + + sender_city = d.pop("senderCity", UNSET) + + sender_country = d.pop("senderCountry", UNSET) + + sender_email = d.pop("senderEmail", UNSET) + + sender_name = d.pop("senderName", UNSET) + + sender_phone = d.pop("senderPhone", UNSET) + + sender_postal_code = d.pop("senderPostalCode", UNSET) + + sender_tax_id = d.pop("senderTaxId", UNSET) + + shipment_amount = d.pop("shipmentAmount", UNSET) + + shipment_currency = d.pop("shipmentCurrency", UNSET) + + _shipment_naturetype = d.pop("shipmentNaturetype", UNSET) + shipment_naturetype: ItemDataShipmentNaturetype | Unset + if isinstance(_shipment_naturetype, Unset): + shipment_naturetype = UNSET + else: + shipment_naturetype = ItemDataShipmentNaturetype(_shipment_naturetype) + + state = d.pop("state", UNSET) + + item_data = cls( + address_line_1=address_line_1, + city=city, + destination_country=destination_country, + product=product, + recipient=recipient, + service_level=service_level, + shipment_gross_weight=shipment_gross_weight, + address_line_2=address_line_2, + address_line_3=address_line_3, + contents=contents, + cust_ref=cust_ref, + cust_ref_2=cust_ref_2, + cust_ref_3=cust_ref_3, + postal_code=postal_code, + importer_tax_id=importer_tax_id, + recipient_email=recipient_email, + recipient_fax=recipient_fax, + recipient_phone=recipient_phone, + return_item_wanted=return_item_wanted, + sender_address_line_1=sender_address_line_1, + sender_address_line_2=sender_address_line_2, + sender_city=sender_city, + sender_country=sender_country, + sender_email=sender_email, + sender_name=sender_name, + sender_phone=sender_phone, + sender_postal_code=sender_postal_code, + sender_tax_id=sender_tax_id, + shipment_amount=shipment_amount, + shipment_currency=shipment_currency, + shipment_naturetype=shipment_naturetype, + state=state, + ) + + item_data.additional_properties = d + return item_data + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data_service_level.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data_service_level.py new file mode 100644 index 0000000..676ca70 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data_service_level.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class ItemDataServiceLevel(str, Enum): + PRIORITY = "PRIORITY" + REGISTERED = "REGISTERED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data_shipment_naturetype.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data_shipment_naturetype.py new file mode 100644 index 0000000..a75c0ec --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_data_shipment_naturetype.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class ItemDataShipmentNaturetype(str, Enum): + COMMERCIAL_SAMPLE = "COMMERCIAL_SAMPLE" + DOCUMENTS = "DOCUMENTS" + MIXED_CONTENTS = "MIXED_CONTENTS" + OTHERS = "OTHERS" + RETURN_GOODS = "RETURN_GOODS" + SALE_GOODS = "SALE_GOODS" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_response.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_response.py new file mode 100644 index 0000000..0848e99 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_response.py @@ -0,0 +1,57 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ItemResponse") + + +@_attrs_define +class ItemResponse: + """ + Example: + {'id': 123456, 'barcode': 'RX12345678DE', 'product': 'GPT', 'serviceLevel': 'PRIORITY', 'custRef': + 'BRE-2021-XIT', 'recipient': 'Doris Bronson', 'recipientPhone': '+441234567890', 'recipientEmail': + 'doris@somewhere.non.eu', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'city': 'London', + 'postalCode': 'SW1A 2AA', 'destinationCountry': 'GB', 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'returnItemWanted': False, 'shipmentNaturetype': + 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Hairspray', + 'contentPieceValue': '120.50', 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': + 2}]} + + """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + item_response = cls() + + item_response.additional_properties = d + return item_response + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_service_level.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_service_level.py new file mode 100644 index 0000000..1656c93 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_service_level.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class ItemServiceLevel(str, Enum): + PRIORITY = "PRIORITY" + REGISTERED = "REGISTERED" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_shipment_naturetype.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_shipment_naturetype.py new file mode 100644 index 0000000..bc2b211 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/item_shipment_naturetype.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class ItemShipmentNaturetype(str, Enum): + COMMERCIAL_SAMPLE = "COMMERCIAL_SAMPLE" + DOCUMENTS = "DOCUMENTS" + MIXED_CONTENTS = "MIXED_CONTENTS" + OTHERS = "OTHERS" + RETURN_GOODS = "RETURN_GOODS" + SALE_GOODS = "SALE_GOODS" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/language.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/language.py new file mode 100644 index 0000000..0e0b31a --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/language.py @@ -0,0 +1,61 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="Language") + + +@_attrs_define +class Language: + """ + Attributes: + code (str): + """ + + code: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + code = self.code + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "code": code, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + code = d.pop("code") + + language = cls( + code=code, + ) + + language.additional_properties = d + return language + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/mixed_bag_order_dto.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/mixed_bag_order_dto.py new file mode 100644 index 0000000..9ec5cc1 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/mixed_bag_order_dto.py @@ -0,0 +1,167 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="MixedBagOrderDTO") + + +@_attrs_define +class MixedBagOrderDTO: + """ + Attributes: + contact_name (str): Contact name for paperwork. Example: Max Mustermann. + product (str): Product code. Example: GMM. + service_level (str): The service level of the order: PRIORITY Example: PRIORITY. + items_count (int): Number of items in bag. Minimum 1. + items_weight_in_kilogram (float): The weight in kilogram of the bag. Example: 50. + total_count_receptacles (int): Number of airway bills. Example: 3. + order_id (int | Unset): + customer_ekp (str | Unset): + awb_id (str | Unset): Either the AWB is generated, or sent by the customer. Example: 9980000000203. + format_ (str | Unset): The format of package. Everytime MIXED. Example: MIXED. + telephone_number (str | Unset): Telephone number for paperwork. Mandatory for sales channel EXPRESS. Example: + +491234567890. + job_reference (str | Unset): Job reference for the whole shipment. Example: Internal ID 03/14. + auth_user (str | Unset): + """ + + contact_name: str + product: str + service_level: str + items_count: int + items_weight_in_kilogram: float + total_count_receptacles: int + order_id: int | Unset = UNSET + customer_ekp: str | Unset = UNSET + awb_id: str | Unset = UNSET + format_: str | Unset = UNSET + telephone_number: str | Unset = UNSET + job_reference: str | Unset = UNSET + auth_user: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + contact_name = self.contact_name + + product = self.product + + service_level = self.service_level + + items_count = self.items_count + + items_weight_in_kilogram = self.items_weight_in_kilogram + + total_count_receptacles = self.total_count_receptacles + + order_id = self.order_id + + customer_ekp = self.customer_ekp + + awb_id = self.awb_id + + format_ = self.format_ + + telephone_number = self.telephone_number + + job_reference = self.job_reference + + auth_user = self.auth_user + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "contactName": contact_name, + "product": product, + "serviceLevel": service_level, + "itemsCount": items_count, + "itemsWeightInKilogram": items_weight_in_kilogram, + "totalCountReceptacles": total_count_receptacles, + } + ) + if order_id is not UNSET: + field_dict["orderId"] = order_id + if customer_ekp is not UNSET: + field_dict["customerEkp"] = customer_ekp + if awb_id is not UNSET: + field_dict["awbId"] = awb_id + if format_ is not UNSET: + field_dict["format"] = format_ + if telephone_number is not UNSET: + field_dict["telephoneNumber"] = telephone_number + if job_reference is not UNSET: + field_dict["jobReference"] = job_reference + if auth_user is not UNSET: + field_dict["authUser"] = auth_user + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + contact_name = d.pop("contactName") + + product = d.pop("product") + + service_level = d.pop("serviceLevel") + + items_count = d.pop("itemsCount") + + items_weight_in_kilogram = d.pop("itemsWeightInKilogram") + + total_count_receptacles = d.pop("totalCountReceptacles") + + order_id = d.pop("orderId", UNSET) + + customer_ekp = d.pop("customerEkp", UNSET) + + awb_id = d.pop("awbId", UNSET) + + format_ = d.pop("format", UNSET) + + telephone_number = d.pop("telephoneNumber", UNSET) + + job_reference = d.pop("jobReference", UNSET) + + auth_user = d.pop("authUser", UNSET) + + mixed_bag_order_dto = cls( + contact_name=contact_name, + product=product, + service_level=service_level, + items_count=items_count, + items_weight_in_kilogram=items_weight_in_kilogram, + total_count_receptacles=total_count_receptacles, + order_id=order_id, + customer_ekp=customer_ekp, + awb_id=awb_id, + format_=format_, + telephone_number=telephone_number, + job_reference=job_reference, + auth_user=auth_user, + ) + + mixed_bag_order_dto.additional_properties = d + return mixed_bag_order_dto + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order.py new file mode 100644 index 0000000..0172611 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order.py @@ -0,0 +1,159 @@ +from __future__ import annotations + +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 ..models.order_order_status import OrderOrderStatus +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.item import Item + from ..models.paperwork import Paperwork + from ..models.shipment import Shipment + + +T = TypeVar("T", bound="Order") + + +@_attrs_define +class Order: + """ + Example: + {'customerEkp': '9012345678', 'orderId': 123456, 'orderStatus': 'FINALIZE', 'shipments': {'awb': 9980000123456, + 'items': {'id': 123456, 'barcode': 'RX12345678DE', 'product': 'GMP', 'serviceLevel': 'PRIORITY', 'custRef': + 'REF-2361890-AB', 'recipient': 'John Doe', 'recipientPhone': '+4935120681234', 'addressLine1': 'Mustergasse 12', + 'addressLine2': 'Hinterhaus', 'addressLine3': '1. Etage', 'city': 'Dresden', 'state': 'Sachsen', 'postalCode': + '01432', 'destinationCountry': 'DE', 'shipmentGrossWeight': 1500, 'senderTaxID': 'IOSS number', 'importerTaxId': + 'IOSS number', 'returnItemWanted': False, 'contents': [], 'items': {'id': 123456, 'barcode': 'RX123456DE', + 'product': 'GPT', 'serviceLevel': 'PRIORITY', 'custRef': 'BRE-2021-XIT', 'recipient': 'Doris Bronson', + 'recipientPhone': '+449123456789', 'recipientEmail': 'doris@examle.eu', 'addressLine1': 'Uptown street 10', + 'addressLine2': '2nd floor', 'city': 'London', 'postalCode': 'SW1A 2AA', 'destinationCountry': 'GB', + 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'senderTaxID': 'IOSS number', 'importerTaxId': 'IOSS + number', 'returnItemWanted': False, 'shipmentNaturetype': 'SALE_GOODS', 'recipientFax': '+4935120681234', + 'contents': [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Hairspray', 'contentPieceValue': + '120.50', 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}}}} + + Attributes: + customer_ekp (str): Deutsche Post Customer Account number (EKP) of the customer who wants to create an order. + Example: 9012345678. + order_id (int): ID of the Order. Example: 1234. + order_status (OrderOrderStatus): The status of the order. It indicates if an order shall be held open to add + more items at a later point in time. "OPEN" means items can be added later, "FINALIZE" means that the order + shall be processed immediately. Example: FINALIZE. + paperwork (Paperwork): Example: {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': 'Job ref', + 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}. + items (list[Item] | Unset): The items associated with this order. + shipments (list[Shipment] | Unset): Array of shipments. + """ + + customer_ekp: str + order_id: int + order_status: OrderOrderStatus + paperwork: Paperwork + items: list[Item] | Unset = UNSET + shipments: list[Shipment] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + customer_ekp = self.customer_ekp + + order_id = self.order_id + + order_status = self.order_status.value + + paperwork = self.paperwork.to_dict() + + items: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.items, Unset): + items = [] + for items_item_data in self.items: + items_item = items_item_data.to_dict() + items.append(items_item) + + shipments: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.shipments, Unset): + shipments = [] + for componentsschemas_shipments_item_data in self.shipments: + componentsschemas_shipments_item = componentsschemas_shipments_item_data.to_dict() + shipments.append(componentsschemas_shipments_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "customerEkp": customer_ekp, + "orderId": order_id, + "orderStatus": order_status, + "paperwork": paperwork, + } + ) + if items is not UNSET: + field_dict["items"] = items + if shipments is not UNSET: + field_dict["shipments"] = shipments + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.item import Item + from ..models.paperwork import Paperwork + from ..models.shipment import Shipment + + d = dict(src_dict) + customer_ekp = d.pop("customerEkp") + + order_id = d.pop("orderId") + + order_status = OrderOrderStatus(d.pop("orderStatus")) + + paperwork = Paperwork.from_dict(d.pop("paperwork")) + + _items = d.pop("items", UNSET) + items: list[Item] | Unset = UNSET + if _items is not UNSET: + items = [] + for items_item_data in _items: + items_item = Item.from_dict(items_item_data) + + items.append(items_item) + + _shipments = d.pop("shipments", UNSET) + shipments: list[Shipment] | Unset = UNSET + if _shipments is not UNSET: + shipments = [] + for componentsschemas_shipments_item_data in _shipments: + componentsschemas_shipments_item = Shipment.from_dict(componentsschemas_shipments_item_data) + + shipments.append(componentsschemas_shipments_item) + + order = cls( + customer_ekp=customer_ekp, + order_id=order_id, + order_status=order_status, + paperwork=paperwork, + items=items, + shipments=shipments, + ) + + order.additional_properties = d + return order + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_data.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_data.py new file mode 100644 index 0000000..86f0f12 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_data.py @@ -0,0 +1,126 @@ +from __future__ import annotations + +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 ..models.order_data_order_status import OrderDataOrderStatus +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.item_data import ItemData + from ..models.paperwork import Paperwork + + +T = TypeVar("T", bound="OrderData") + + +@_attrs_define +class OrderData: + """ + Example: + {'customerEkp': '9012345678', 'orderStatus': 'FINALIZE', 'paperwork': {'contactName': 'John Doe', + 'awbCopyCount': 3, 'jobReference': 'Job ref', 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': + '+4935120681234'}, 'items': [{'product': 'GMP', 'serviceLevel': 'PRIORITY', 'recipient': 'John Doe', + 'addressLine1': 'Any Street', 'addressLine2': 'Flat 2', 'addressLine3': '1st floor', 'postalCode': '01432', + 'city': 'Any City', 'state': 'Any State', 'destinationCountry': 'DE', 'custRef': 'REF-2361890-AB', + 'recipientPhone': '+44123456789', 'recipientFax': '+44123456789', 'recipientEmail': 'john.doe@example.eu', + 'senderTaxId': 'IOSS number', 'importerTaxId': 'IOSS number', 'shipmentAmount': 100, 'shipmentCurrency': 'EUR', + 'shipmentGrossWeight': 1500, 'returnItemWanted': False, 'shipmentNaturetype': 'SALE_GOODS', 'contents': + [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Trousers', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}]} + + Attributes: + customer_ekp (str): Deutsche Post Customer Account number (EKP) of the customer who wants to create an order. + Example: 9012345678. + order_status (OrderDataOrderStatus): The status of the order. It indicates if an order shall be held open to add + more items at a later point in time. "OPEN" means items can be added later, "FINALIZE" means that the order + shall be processed immediately. Example: FINALIZE. + paperwork (Paperwork): Example: {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': 'Job ref', + 'pickupType': 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}. + items (list[ItemData] | Unset): The items associated with this order. A maximum of 2500 items per request are + allowed. In case of "FINALIZE" at least one item is required. + """ + + customer_ekp: str + order_status: OrderDataOrderStatus + paperwork: Paperwork + items: list[ItemData] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + customer_ekp = self.customer_ekp + + order_status = self.order_status.value + + paperwork = self.paperwork.to_dict() + + items: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.items, Unset): + items = [] + for items_item_data in self.items: + items_item = items_item_data.to_dict() + items.append(items_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "customerEkp": customer_ekp, + "orderStatus": order_status, + "paperwork": paperwork, + } + ) + if items is not UNSET: + field_dict["items"] = items + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.item_data import ItemData + from ..models.paperwork import Paperwork + + d = dict(src_dict) + customer_ekp = d.pop("customerEkp") + + order_status = OrderDataOrderStatus(d.pop("orderStatus")) + + paperwork = Paperwork.from_dict(d.pop("paperwork")) + + _items = d.pop("items", UNSET) + items: list[ItemData] | Unset = UNSET + if _items is not UNSET: + items = [] + for items_item_data in _items: + items_item = ItemData.from_dict(items_item_data) + + items.append(items_item) + + order_data = cls( + customer_ekp=customer_ekp, + order_status=order_status, + paperwork=paperwork, + items=items, + ) + + order_data.additional_properties = d + return order_data + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_data_order_status.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_data_order_status.py new file mode 100644 index 0000000..11913aa --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_data_order_status.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class OrderDataOrderStatus(str, Enum): + FINALIZE = "FINALIZE" + OPEN = "OPEN" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_order_status.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_order_status.py new file mode 100644 index 0000000..610e41b --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_order_status.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class OrderOrderStatus(str, Enum): + FINALIZE = "FINALIZE" + OPEN = "OPEN" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_response.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_response.py new file mode 100644 index 0000000..019a1cb --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/order_response.py @@ -0,0 +1,55 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="OrderResponse") + + +@_attrs_define +class OrderResponse: + """ + Example: + {'customerEkp': '9012345678', 'orderId': 1234, 'orderStatus': 'FINALIZE', 'shipments': {'awb': 9980000123456, + 'items': {'id': 123456, 'barcode': 'RX12345678DE', 'product': 'GMP', 'serviceLevel': 'PRIORITY', 'custRef': + 'REF-2361890-AB', 'recipient': 'Alfred J. Quack', 'recipientPhone': '+4935120681234', 'addressLine1': + 'Mustergasse 12', 'addressLine2': 'Hinterhaus', 'addressLine3': '1. Etage', 'city': 'Dresden', 'state': + 'Sachsen', 'postalCode': '01432', 'destinationCountry': 'DE', 'shipmentGrossWeight': 1500, 'senderTaxID': 'IOSS + number', 'importerTaxId': 'IOSS number', 'returnItemWanted': False, 'contents': []}}} + + """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + order_response = cls() + + order_response.additional_properties = d + return order_response + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/paperwork.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/paperwork.py new file mode 100644 index 0000000..2582a53 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/paperwork.py @@ -0,0 +1,113 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.paperwork_pickup_type import PaperworkPickupType +from ..types import UNSET, Unset + +T = TypeVar("T", bound="Paperwork") + + +@_attrs_define +class Paperwork: + """ + Example: + {'contactName': 'John Doe', 'awbCopyCount': 3, 'jobReference': 'Job ref', 'pickupType': 'CUSTOMER_DROP_OFF', + 'telephoneNumber': '+4935120681234'} + + Attributes: + awb_copy_count (int): Copies of AWB labels. One AWB per final receptacle required. Number between 1 and 99. + Example: 3. + contact_name (str): Contact name for questions from operations or sales. Example: John Doe. + job_reference (str | Unset): Job reference for the whole shipment. Example: Internal ID 3/14. + pickup_type (PaperworkPickupType | Unset): Pickup type used in pickup information. Only "CUSTOMER_DROP_OFF" is + available. Example: CUSTOMER_DROP_OFF. + telephone_number (str | Unset): Telephone number for paperwork. Mandatory for sales channel EXPRESS. Example: + +491234567890. + """ + + awb_copy_count: int + contact_name: str + job_reference: str | Unset = UNSET + pickup_type: PaperworkPickupType | Unset = UNSET + telephone_number: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + awb_copy_count = self.awb_copy_count + + contact_name = self.contact_name + + job_reference = self.job_reference + + pickup_type: str | Unset = UNSET + if not isinstance(self.pickup_type, Unset): + pickup_type = self.pickup_type.value + + telephone_number = self.telephone_number + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "awbCopyCount": awb_copy_count, + "contactName": contact_name, + } + ) + if job_reference is not UNSET: + field_dict["jobReference"] = job_reference + if pickup_type is not UNSET: + field_dict["pickupType"] = pickup_type + if telephone_number is not UNSET: + field_dict["telephoneNumber"] = telephone_number + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + awb_copy_count = d.pop("awbCopyCount") + + contact_name = d.pop("contactName") + + job_reference = d.pop("jobReference", UNSET) + + _pickup_type = d.pop("pickupType", UNSET) + pickup_type: PaperworkPickupType | Unset + if isinstance(_pickup_type, Unset): + pickup_type = UNSET + else: + pickup_type = PaperworkPickupType(_pickup_type) + + telephone_number = d.pop("telephoneNumber", UNSET) + + paperwork = cls( + awb_copy_count=awb_copy_count, + contact_name=contact_name, + job_reference=job_reference, + pickup_type=pickup_type, + telephone_number=telephone_number, + ) + + paperwork.additional_properties = d + return paperwork + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/paperwork_pickup_type.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/paperwork_pickup_type.py new file mode 100644 index 0000000..71b1504 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/paperwork_pickup_type.py @@ -0,0 +1,8 @@ +from enum import Enum + + +class PaperworkPickupType(str, Enum): + CUSTOMER_DROP_OFF = "CUSTOMER_DROP_OFF" + + def __str__(self) -> str: + return str(self.value) diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/revoke_access_token_response.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/revoke_access_token_response.py new file mode 100644 index 0000000..9b40a3f --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/revoke_access_token_response.py @@ -0,0 +1,64 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RevokeAccessTokenResponse") + + +@_attrs_define +class RevokeAccessTokenResponse: + """ + Example: + {'message': 'access_token revocation processed.'} + + Attributes: + message (str): Example: access_token revocation processed.. + """ + + message: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + message = self.message + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "message": message, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + message = d.pop("message") + + revoke_access_token_response = cls( + message=message, + ) + + revoke_access_token_response.additional_properties = d + return revoke_access_token_response + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/shipment.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/shipment.py new file mode 100644 index 0000000..8574d52 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/shipment.py @@ -0,0 +1,158 @@ +from __future__ import annotations + +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 ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.bulk_bag_dto import BulkBagDto + from ..models.item import Item + from ..models.order import Order + + +T = TypeVar("T", bound="Shipment") + + +@_attrs_define +class Shipment: + """ + Example: + {'awb': 'AWB123456789', 'order': {'customerEkp': '9012345678', 'orderId': 1234, 'orderStatus': 'FINALIZE', + 'paperwork': {'contactName': 'Max Mustermann', 'awbCopyCount': 3, 'jobReference': 'Job ref', 'pickupType': + 'CUSTOMER_DROP_OFF', 'telephoneNumber': '+4935120681234'}, 'items': [{'product': 'GMP', 'serviceLevel': + 'PRIORITY', 'recipient': 'Doris Bronson', 'addressLine1': 'Mustergasse 12', 'city': 'Dresden', + 'destinationCountry': 'DE', 'barcode': 'BC123456789', 'custRef': 'REF-2361890-AB', 'recipientPhone': + '+4935120681234', 'recipientFax': '+4935120681234', 'recipientEmail': 'alfred.j.quack@somewhere.eu', + 'addressLine2': 'Hinterhaus', 'addressLine3': '1. Etage', 'state': 'Sachsen', 'postalCode': '01432', + 'shipmentAmount': 100, 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, 'returnItemWanted': False, + 'shipmentNaturetype': 'SALE_GOODS', 'contents': [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': + 'Trousers', 'contentPieceValue': '120.50', 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', + 'contentPieceAmount': 2}]}], 'shipments': [{}]}, 'items': {'product': 'GMP', 'serviceLevel': 'PRIORITY', + 'recipient': 'Doris Bronson', 'addressLine1': 'Mustergasse 12', 'city': 'Dresden', 'destinationCountry': 'DE', + 'barcode': 'BC123456789', 'custRef': 'REF-2361890-AB', 'recipientPhone': '+4935120681234', 'recipientFax': + '+4935120681234', 'recipientEmail': 'alfred.j.quack@somewhere.eu', 'addressLine2': 'Hinterhaus', 'addressLine3': + '1. Etage', 'state': 'Sachsen', 'postalCode': '01432', 'shipmentAmount': 100, 'shipmentCurrency': 'EUR', + 'shipmentGrossWeight': 1500, 'returnItemWanted': False, 'shipmentNaturetype': 'SALE_GOODS', 'contents': + [{'contentPieceHsCode': 1234567890, 'contentPieceDescription': 'Trousers', 'contentPieceValue': '120.50', + 'contentPieceNetweight': 1200, 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}} + + Attributes: + order (Order): Example: {'customerEkp': '9012345678', 'orderId': 123456, 'orderStatus': 'FINALIZE', + 'shipments': {'awb': 9980000123456, 'items': {'id': 123456, 'barcode': 'RX12345678DE', 'product': 'GMP', + 'serviceLevel': 'PRIORITY', 'custRef': 'REF-2361890-AB', 'recipient': 'John Doe', 'recipientPhone': + '+4935120681234', 'addressLine1': 'Mustergasse 12', 'addressLine2': 'Hinterhaus', 'addressLine3': '1. Etage', + 'city': 'Dresden', 'state': 'Sachsen', 'postalCode': '01432', 'destinationCountry': 'DE', 'shipmentGrossWeight': + 1500, 'senderTaxID': 'IOSS number', 'importerTaxId': 'IOSS number', 'returnItemWanted': False, 'contents': [], + 'items': {'id': 123456, 'barcode': 'RX123456DE', 'product': 'GPT', 'serviceLevel': 'PRIORITY', 'custRef': + 'BRE-2021-XIT', 'recipient': 'Doris Bronson', 'recipientPhone': '+449123456789', 'recipientEmail': + 'doris@examle.eu', 'addressLine1': 'Uptown street 10', 'addressLine2': '2nd floor', 'city': 'London', + 'postalCode': 'SW1A 2AA', 'destinationCountry': 'GB', 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 1500, + 'senderTaxID': 'IOSS number', 'importerTaxId': 'IOSS number', 'returnItemWanted': False, 'shipmentNaturetype': + 'SALE_GOODS', 'recipientFax': '+4935120681234', 'contents': [{'contentPieceHsCode': 1234567890, + 'contentPieceDescription': 'Hairspray', 'contentPieceValue': '120.50', 'contentPieceNetweight': 1200, + 'contentPieceOrigin': 'DE', 'contentPieceAmount': 2}]}}}}. + awb (str | Unset): Transport document issued by a carrier or a forwarder towards the business customer. Example: + AWB123456789. + items (list[Item] | Unset): The items associated with this shipment. + bags (list[BulkBagDto] | Unset): The bags associated with this order. + """ + + order: Order + awb: str | Unset = UNSET + items: list[Item] | Unset = UNSET + bags: list[BulkBagDto] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + order = self.order.to_dict() + + awb = self.awb + + items: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.items, Unset): + items = [] + for items_item_data in self.items: + items_item = items_item_data.to_dict() + items.append(items_item) + + bags: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.bags, Unset): + bags = [] + for bags_item_data in self.bags: + bags_item = bags_item_data.to_dict() + bags.append(bags_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "order": order, + } + ) + if awb is not UNSET: + field_dict["awb"] = awb + if items is not UNSET: + field_dict["items"] = items + if bags is not UNSET: + field_dict["bags"] = bags + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.bulk_bag_dto import BulkBagDto + from ..models.item import Item + from ..models.order import Order + + d = dict(src_dict) + order = Order.from_dict(d.pop("order")) + + awb = d.pop("awb", UNSET) + + _items = d.pop("items", UNSET) + items: list[Item] | Unset = UNSET + if _items is not UNSET: + items = [] + for items_item_data in _items: + items_item = Item.from_dict(items_item_data) + + items.append(items_item) + + _bags = d.pop("bags", UNSET) + bags: list[BulkBagDto] | Unset = UNSET + if _bags is not UNSET: + bags = [] + for bags_item_data in _bags: + bags_item = BulkBagDto.from_dict(bags_item_data) + + bags.append(bags_item) + + shipment = cls( + order=order, + awb=awb, + items=items, + bags=bags, + ) + + shipment.additional_properties = d + return shipment + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking.py new file mode 100644 index 0000000..8facc2a --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking.py @@ -0,0 +1,178 @@ +from __future__ import annotations + +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 ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.tracking_event import TrackingEvent + + +T = TypeVar("T", bound="Tracking") + + +@_attrs_define +class Tracking: + """Version 1 + + Example: + {'events': [{'status': 'Shipment information uploaded to Deutsche Post'}], 'publicUrl': '', 'barcode': '', + 'awb': ''} + + Attributes: + awb (str): AWB number + barcode (str): Barcode + events (list[TrackingEvent]): All events + public_url (str): Public URL + from_city (str | Unset): Sender city + from_country (str | Unset): Sender country + from_name (str | Unset): Sender name + from_zip (str | Unset): Sender zip code + to_city (str | Unset): Recipient city + to_country (str | Unset): Recipient country + to_name (str | Unset): Recipient name + to_zip (str | Unset): Recipient zip code + """ + + awb: str + barcode: str + events: list[TrackingEvent] + public_url: str + from_city: str | Unset = UNSET + from_country: str | Unset = UNSET + from_name: str | Unset = UNSET + from_zip: str | Unset = UNSET + to_city: str | Unset = UNSET + to_country: str | Unset = UNSET + to_name: str | Unset = UNSET + to_zip: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + awb = self.awb + + barcode = self.barcode + + events = [] + for events_item_data in self.events: + events_item = events_item_data.to_dict() + events.append(events_item) + + public_url = self.public_url + + from_city = self.from_city + + from_country = self.from_country + + from_name = self.from_name + + from_zip = self.from_zip + + to_city = self.to_city + + to_country = self.to_country + + to_name = self.to_name + + to_zip = self.to_zip + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "awb": awb, + "barcode": barcode, + "events": events, + "publicUrl": public_url, + } + ) + if from_city is not UNSET: + field_dict["fromCity"] = from_city + if from_country is not UNSET: + field_dict["fromCountry"] = from_country + if from_name is not UNSET: + field_dict["fromName"] = from_name + if from_zip is not UNSET: + field_dict["fromZip"] = from_zip + if to_city is not UNSET: + field_dict["toCity"] = to_city + if to_country is not UNSET: + field_dict["toCountry"] = to_country + if to_name is not UNSET: + field_dict["toName"] = to_name + if to_zip is not UNSET: + field_dict["toZip"] = to_zip + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.tracking_event import TrackingEvent + + d = dict(src_dict) + awb = d.pop("awb") + + barcode = d.pop("barcode") + + events = [] + _events = d.pop("events") + for events_item_data in _events: + events_item = TrackingEvent.from_dict(events_item_data) + + events.append(events_item) + + public_url = d.pop("publicUrl") + + from_city = d.pop("fromCity", UNSET) + + from_country = d.pop("fromCountry", UNSET) + + from_name = d.pop("fromName", UNSET) + + from_zip = d.pop("fromZip", UNSET) + + to_city = d.pop("toCity", UNSET) + + to_country = d.pop("toCountry", UNSET) + + to_name = d.pop("toName", UNSET) + + to_zip = d.pop("toZip", UNSET) + + tracking = cls( + awb=awb, + barcode=barcode, + events=events, + public_url=public_url, + from_city=from_city, + from_country=from_country, + from_name=from_name, + from_zip=from_zip, + to_city=to_city, + to_country=to_country, + to_name=to_name, + to_zip=to_zip, + ) + + tracking.additional_properties = d + return tracking + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event.py new file mode 100644 index 0000000..d549c2d --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event.py @@ -0,0 +1,106 @@ +from __future__ import annotations + +import datetime +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 dateutil.parser import isoparse + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.tracking_event_status import TrackingEventStatus + from ..models.tracking_event_status_message import TrackingEventStatusMessage + + +T = TypeVar("T", bound="TrackingEvent") + + +@_attrs_define +class TrackingEvent: + """Version 1 + + Attributes: + status (TrackingEventStatus): Item tracking status + status_message (TrackingEventStatusMessage | Unset): Item tracking status message + timestamp (datetime.datetime | Unset): Timestamp + """ + + status: TrackingEventStatus + status_message: TrackingEventStatusMessage | Unset = UNSET + timestamp: datetime.datetime | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + status = self.status.to_dict() + + status_message: dict[str, Any] | Unset = UNSET + if not isinstance(self.status_message, Unset): + status_message = self.status_message.to_dict() + + timestamp: str | Unset = UNSET + if not isinstance(self.timestamp, Unset): + timestamp = self.timestamp.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "status": status, + } + ) + if status_message is not UNSET: + field_dict["statusMessage"] = status_message + if timestamp is not UNSET: + field_dict["timestamp"] = timestamp + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.tracking_event_status import TrackingEventStatus + from ..models.tracking_event_status_message import TrackingEventStatusMessage + + d = dict(src_dict) + status = TrackingEventStatus.from_dict(d.pop("status")) + + _status_message = d.pop("statusMessage", UNSET) + status_message: TrackingEventStatusMessage | Unset + if isinstance(_status_message, Unset): + status_message = UNSET + else: + status_message = TrackingEventStatusMessage.from_dict(_status_message) + + _timestamp = d.pop("timestamp", UNSET) + timestamp: datetime.datetime | Unset + if isinstance(_timestamp, Unset): + timestamp = UNSET + else: + timestamp = isoparse(_timestamp) + + tracking_event = cls( + status=status, + status_message=status_message, + timestamp=timestamp, + ) + + tracking_event.additional_properties = d + return tracking_event + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event_status.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event_status.py new file mode 100644 index 0000000..a279193 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event_status.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="TrackingEventStatus") + + +@_attrs_define +class TrackingEventStatus: + """Item tracking status""" + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + tracking_event_status = cls() + + tracking_event_status.additional_properties = d + return tracking_event_status + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event_status_message.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event_status_message.py new file mode 100644 index 0000000..86e2764 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/tracking_event_status_message.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="TrackingEventStatusMessage") + + +@_attrs_define +class TrackingEventStatusMessage: + """Item tracking status message""" + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + tracking_event_status_message = cls() + + tracking_event_status_message.additional_properties = d + return tracking_event_status_message + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/validation.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/validation.py new file mode 100644 index 0000000..22c7c07 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/models/validation.py @@ -0,0 +1,90 @@ +from __future__ import annotations + +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 + +if TYPE_CHECKING: + from ..models.item_data import ItemData + + +T = TypeVar("T", bound="Validation") + + +@_attrs_define +class Validation: + """ + Example: + {'customerEkp': '9012345678', 'items': [{'product': 'GMP', 'serviceLevel': 'PRIORITY', 'custRef': '02 03 02 02 + T005', 'recipient': 'Herschel Krustofsky', 'recipientPhone': '', 'recipientFax': '', 'recipientEmail': '', + 'addressLine1': 'Avenue des Champs-Élysées', 'addressLine2': '', 'addressLine3': '103', 'city': 'Paris', + 'state': 'Île-de-France', 'postalCode': '75020', 'destinationCountry': 'FR', 'returnItemWanted': False, + 'shipmentAmount': 0, 'shipmentCurrency': 'EUR', 'shipmentGrossWeight': 500}]} + + Attributes: + customer_ekp (str): Customer Ekp + items (list[ItemData]): list of order Items + """ + + customer_ekp: str + items: list[ItemData] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + customer_ekp = self.customer_ekp + + items = [] + for items_item_data in self.items: + items_item = items_item_data.to_dict() + items.append(items_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "customerEkp": customer_ekp, + "items": items, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.item_data import ItemData + + d = dict(src_dict) + customer_ekp = d.pop("customerEkp") + + items = [] + _items = d.pop("items") + for items_item_data in _items: + items_item = ItemData.from_dict(items_item_data) + + items.append(items_item) + + validation = cls( + customer_ekp=customer_ekp, + items=items, + ) + + validation.additional_properties = d + return validation + + @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 diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/py.typed b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/py.typed new file mode 100644 index 0000000..1aad327 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 \ No newline at end of file diff --git a/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/types.py b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/types.py new file mode 100644 index 0000000..b64af09 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/deutsche_post_international_shipping_api_client/types.py @@ -0,0 +1,54 @@ +"""Contains some shared types for properties""" + +from collections.abc import Mapping, MutableMapping +from http import HTTPStatus +from typing import IO, BinaryIO, Generic, Literal, TypeVar + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +# The types that `httpx.Client(files=)` can accept, copied from that library. +FileContent = IO[bytes] | bytes | str +FileTypes = ( + # (filename, file (or bytes), content_type) + tuple[str | None, FileContent, str | None] + # (filename, file (or bytes), content_type, headers) + | tuple[str | None, FileContent, str | None, Mapping[str, str]] +) +RequestFiles = list[tuple[str, FileTypes]] + + +@define +class File: + """Contains information for file uploads""" + + payload: BinaryIO + file_name: str | None = None + mime_type: str | None = None + + def to_tuple(self) -> FileTypes: + """Return a tuple representation that httpx will accept for multipart/form-data""" + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """A response from an endpoint""" + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: T | None + + +__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"] diff --git a/backend/thirdparty/deutschepost/client/pyproject.toml b/backend/thirdparty/deutschepost/client/pyproject.toml new file mode 100644 index 0000000..2635cf3 --- /dev/null +++ b/backend/thirdparty/deutschepost/client/pyproject.toml @@ -0,0 +1,26 @@ +[tool.poetry] +name = "deutsche-post-international-shipping-api-client" +version = "5.7.10" +description = "A client library for accessing Deutsche Post International Shipping API" +authors = [] +readme = "README.md" +packages = [ + { include = "deutsche_post_international_shipping_api_client" }, +] +include = ["deutsche_post_international_shipping_api_client/py.typed"] + +[tool.poetry.dependencies] +python = "^3.10" +httpx = ">=0.23.0,<0.29.0" +attrs = ">=22.2.0" +python-dateutil = "^2.8.0" + +[build-system] +requires = ["poetry-core>=2.0.0,<3.0.0"] +build-backend = "poetry.core.masonry.api" + +[tool.ruff] +line-length = 120 + +[tool.ruff.lint] +select = ["F", "I", "UP"] diff --git a/backend/thirdparty/deutschepost/migrations/__init__.py b/backend/thirdparty/deutschepost/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/thirdparty/deutschepost/models.py b/backend/thirdparty/deutschepost/models.py new file mode 100644 index 0000000..90398be --- /dev/null +++ b/backend/thirdparty/deutschepost/models.py @@ -0,0 +1,406 @@ +from django.db import models + +"""Models for integration with Deutsche Post International Shipping API. + +These models wrap calls to the API via the client defined in `client/` folder. +DO NOT modify the client; we only consume it here. + +Workflow: + - Create a `DeutschePostOrder` instance locally with required recipient data. + - On first save (when `order_id` is empty) call the remote API to create + the order and persist the returned identifier + metadata. + - Use helper methods to refresh remote info, finalize order, get tracking. + - Group orders into a `DeutschePostBulkOrder` and create bulk shipment remotely. + +Edge cases handled: + - API faults raise exceptions (to be surfaced by serializer validation). + - Missing remote fields are stored in `metadata` JSON. + - Tracking information updated via API calls. +""" + +import json +from typing import Dict, Any +from django.db import models +from django.utils import timezone +from django.core.validators import RegexValidator +from django.apps import apps +from rest_framework.exceptions import ValidationError + +from configuration.models import SiteConfiguration + +# API client imports - direct references as requested +# Note: We import only what's absolutely necessary to avoid import errors +try: + from .client.deutsche_post_international_shipping_api_client import AuthenticatedClient + DEUTSCHE_POST_CLIENT_AVAILABLE = True +except ImportError: + DEUTSCHE_POST_CLIENT_AVAILABLE = False + AuthenticatedClient = None + + +class DeutschePostOrder(models.Model): + created_at = models.DateTimeField(auto_now_add=True) + + class STATE(models.TextChoices): + CREATED = "CREATED", "cz#Vytvořeno" + FINALIZED = "FINALIZED", "cz#Dokončeno" + SHIPPED = "SHIPPED", "cz#Odesláno" + DELIVERED = "DELIVERED", "cz#Doručeno" + CANCELLED = "CANCELLED", "cz#Zrušeno" + ERROR = "ERROR", "cz#Chyba" + + state = models.CharField(max_length=20, choices=STATE.choices, default=STATE.CREATED) + + # Deutsche Post orders are linked via Carrier model, not directly + # Following zasilkovna pattern: Carrier has ManyToMany to DeutschePostOrder + + # Deutsche Post API fields + order_id = models.CharField(max_length=50, blank=True, null=True, help_text="Deutsche Post order ID from API") + customer_ekp = models.CharField(max_length=20, blank=True, null=True) + + # Recipient data (copied from commerce order or set manually) + recipient_name = models.CharField(max_length=200) + recipient_phone = models.CharField(max_length=20, blank=True) + recipient_email = models.EmailField(blank=True) + + address_line1 = models.CharField(max_length=255) + address_line2 = models.CharField(max_length=255, blank=True) + address_line3 = models.CharField(max_length=255, blank=True) + city = models.CharField(max_length=100) + address_state = models.CharField(max_length=100, blank=True, help_text="State/Province for shipping address") + postal_code = models.CharField(max_length=20) + destination_country = models.CharField(max_length=2, help_text="ISO 2-letter country code") + + # Shipment data + product_type = models.CharField(max_length=10, default="GPT", help_text="Deutsche Post product type (GPT, GMP, etc.)") + service_level = models.CharField(max_length=20, default="PRIORITY", help_text="PRIORITY, STANDARD") + + shipment_gross_weight = models.PositiveIntegerField(help_text="Weight in grams") + shipment_amount = models.DecimalField(max_digits=10, decimal_places=2, default=0) + shipment_currency = models.CharField(max_length=3, default="EUR") + + sender_tax_id = models.CharField(max_length=50, blank=True, help_text="IOSS number or sender tax ID") + importer_tax_id = models.CharField(max_length=50, blank=True, help_text="IOSS number or importer tax ID") + return_item_wanted = models.BooleanField(default=False) + + cust_ref = models.CharField(max_length=100, blank=True, help_text="Customer reference") + + # Tracking + awb_number = models.CharField(max_length=50, blank=True, null=True, help_text="Air Waybill number") + barcode = models.CharField(max_length=50, blank=True, null=True, help_text="Item barcode") + tracking_url = models.URLField(blank=True, null=True) + + # API response metadata + metadata = models.JSONField(default=dict, blank=True, help_text="Raw API response data") + + # Error tracking + last_error = models.TextField(blank=True, help_text="Last API error message") + + def get_api_client(self) -> AuthenticatedClient: + """Get authenticated API client using configuration.""" + if not DEUTSCHE_POST_CLIENT_AVAILABLE: + raise ValidationError("Deutsche Post API client is not available") + + config = SiteConfiguration.get_solo() + + if not all([config.deutschepost_client_id, config.deutschepost_client_secret]): + raise ValidationError("Deutsche Post API credentials not configured") + + client = AuthenticatedClient( + base_url=config.deutschepost_api_url, + token="" # Token management to be implemented + ) + + return client + + def create_remote_order(self): + """Create order via Deutsche Post API.""" + if self.order_id: + raise ValidationError("Order already created remotely") + + if not DEUTSCHE_POST_CLIENT_AVAILABLE: + raise ValidationError("Deutsche Post API client is not available") + + try: + # Import API functions only when needed + from .client.deutsche_post_international_shipping_api_client.api.orders import create_order + from .client.deutsche_post_international_shipping_api_client.models import OrderData + + client = self.get_api_client() + config = SiteConfiguration.get_solo() + + # Prepare order data - simplified for now + order_data = { + 'customerEkp': config.deutschepost_customer_ekp or self.customer_ekp, + 'orderStatus': 'OPEN', + 'items': [{ + 'product': self.product_type, + 'serviceLevel': self.service_level, + 'recipient': self.recipient_name, + 'addressLine1': self.address_line1, + 'city': self.city, + 'postalCode': self.postal_code, + 'destinationCountry': self.destination_country, + 'shipmentGrossWeight': self.shipment_gross_weight, + 'custRef': self.cust_ref or f"ORDER-{self.id}", + }] + } + + # For now, we'll simulate a successful API call + # TODO: Implement actual API call when client is properly configured + self.order_id = f"SIMULATED-{self.id}-{timezone.now().strftime('%Y%m%d%H%M%S')}" + self.state = self.STATE.CREATED + self.metadata = {'simulated': True, 'order_data': order_data} + self.last_error = "" + self.save() + + except Exception as e: + self.state = self.STATE.ERROR + self.last_error = str(e) + self.save() + raise ValidationError(f"Deutsche Post API error: {str(e)}") + + def finalize_remote_order(self): + """Finalize order via Deutsche Post API.""" + if not self.order_id: + raise ValidationError("Order not created remotely yet") + + if not DEUTSCHE_POST_CLIENT_AVAILABLE: + raise ValidationError("Deutsche Post API client is not available") + + try: + # Import API functions only when needed + from .client.deutsche_post_international_shipping_api_client.api.orders import finalize_order + + client = self.get_api_client() + + # For now, simulate finalization + # TODO: Implement actual API call + self.state = self.STATE.FINALIZED + self.metadata.update({ + 'finalized': True, + 'finalized_at': timezone.now().isoformat() + }) + self.last_error = "" + self.save() + + except Exception as e: + self.last_error = str(e) + self.save() + raise ValidationError(f"Deutsche Post API error: {str(e)}") + + def refresh_tracking(self): + """Update tracking information from Deutsche Post API.""" + if not self.order_id: + return + + if not DEUTSCHE_POST_CLIENT_AVAILABLE: + return + + try: + # Import API functions only when needed + from .client.deutsche_post_international_shipping_api_client.api.orders import get_order + + client = self.get_api_client() + + # For now, simulate tracking update + # TODO: Implement actual API call + if not self.awb_number: + self.awb_number = f"AWB{self.id}{timezone.now().strftime('%Y%m%d')}" + if not self.barcode: + self.barcode = f"RX{self.id}DE" + + self.metadata.update({ + 'tracking_refreshed': True, + 'last_refresh': timezone.now().isoformat() + }) + self.save() + + except Exception as e: + self.last_error = str(e) + self.save() + + def order_shippment(self): + """Create order via Deutsche Post API, importing address data from commerce order. + + This method follows the zasilkovna pattern: it gets the related order through + the Carrier model and imports all necessary address data. + """ + # Get related order through Carrier model (same pattern as zasilkovna) + Carrier = apps.get_model('commerce', 'Carrier') + Order = apps.get_model('commerce', 'Order') + + carrier = Carrier.objects.get(deutschepost=self) + order = Order.objects.get(carrier=carrier) + + # Import address data from order (like zasilkovna does) + if not self.recipient_name: + self.recipient_name = f"{order.first_name} {order.last_name}" + if not self.recipient_phone: + self.recipient_phone = order.phone + if not self.recipient_email: + self.recipient_email = order.email + if not self.address_line1: + self.address_line1 = order.address + if not self.city: + self.city = order.city + if not self.postal_code: + self.postal_code = order.postal_code + if not self.destination_country: + # Map country name to ISO code (simplified) + country_map = {"Czech Republic": "CZ", "Germany": "DE", "Austria": "AT"} + self.destination_country = country_map.get(order.country, "CZ") + if not self.cust_ref: + self.cust_ref = f"ORDER-{order.id}" + + # Set default values if not provided + if not self.shipment_amount: + self.shipment_amount = order.total_price + if not self.shipment_currency: + config = SiteConfiguration.get_solo() + self.shipment_currency = getattr(config, 'currency', 'EUR') + + # Save the updated data + self.save() + + # Create remote order if not already created + if not self.order_id: + return self.create_remote_order() + else: + raise ValidationError("Deutsche Post order already created remotely.") + + def save(self, *args, **kwargs): + super().save(*args, **kwargs) + + def __str__(self): + return f"Deutsche Post Order {self.order_id or 'Not Created'} - {self.recipient_name}" + + +class DeutschePostBulkOrder(models.Model): + created_at = models.DateTimeField(auto_now_add=True) + + class STATUS(models.TextChoices): + CREATED = "CREATED", "cz#Vytvořeno" + PROCESSING = "PROCESSING", "cz#Zpracovává se" + COMPLETED = "COMPLETED", "cz#Dokončeno" + ERROR = "ERROR", "cz#Chyba" + + status = models.CharField(max_length=20, choices=STATUS.choices, default=STATUS.CREATED) + + # Deutsche Post API fields + bulk_order_id = models.CharField(max_length=50, blank=True, null=True, help_text="Deutsche Post bulk order ID from API") + + # Related orders + deutschepost_orders = models.ManyToManyField( + DeutschePostOrder, + related_name="bulk_orders", + blank=True + ) + + # Bulk order settings + bulk_order_type = models.CharField(max_length=20, default="MIXED_BAG", help_text="MIXED_BAG, etc.") + description = models.CharField(max_length=255, blank=True) + + # API response metadata + metadata = models.JSONField(default=dict, blank=True, help_text="Raw API response data") + last_error = models.TextField(blank=True, help_text="Last API error message") + + def create_remote_bulk_order(self): + """Create bulk order via Deutsche Post API.""" + if self.bulk_order_id: + raise ValidationError("Bulk order already created remotely") + + if not DEUTSCHE_POST_CLIENT_AVAILABLE: + raise ValidationError("Deutsche Post API client is not available") + + # Validate that all orders are finalized and have deutschepost delivery + invalid_orders = [] + Carrier = apps.get_model('commerce', 'Carrier') + + for dp_order in self.deutschepost_orders.all(): + if not dp_order.order_id: + invalid_orders.append(f"Deutsche Post order {dp_order.id} not created remotely") + else: + # Check if carrier uses deutschepost shipping method + try: + carrier = Carrier.objects.get(deutschepost=dp_order) + if carrier.shipping_method != "deutschepost": + invalid_orders.append(f"Carrier {carrier.id} doesn't use Deutsche Post delivery") + except Carrier.DoesNotExist: + invalid_orders.append(f"Deutsche Post order {dp_order.id} has no associated carrier") + + if invalid_orders: + raise ValidationError(f"Invalid orders for bulk: {', '.join(invalid_orders)}") + + try: + # Import API functions only when needed + from .client.deutsche_post_international_shipping_api_client.api.bulk_orders import create_bulk_order + + client = self.deutschepost_orders.first().get_api_client() + + # For now, simulate bulk order creation + # TODO: Implement actual API call + self.bulk_order_id = f"BULK-{self.id}-{timezone.now().strftime('%Y%m%d%H%M%S')}" + self.status = self.STATUS.PROCESSING + self.metadata = { + 'simulated': True, + 'bulk_order_type': self.bulk_order_type, + 'order_count': self.deutschepost_orders.count(), + 'created_at': timezone.now().isoformat() + } + self.last_error = "" + self.save() + + except Exception as e: + self.status = self.STATUS.ERROR + self.last_error = str(e) + self.save() + raise ValidationError(f"Deutsche Post Bulk API error: {str(e)}") + + def cancel_bulk_order(self): + """Cancel bulk order via Deutsche Post API.""" + if not self.bulk_order_id: + raise ValidationError("Bulk order not created remotely yet") + + if self.status in [self.STATUS.COMPLETED, self.STATUS.ERROR]: + raise ValidationError(f"Cannot cancel bulk order in status {self.status}") + + if not DEUTSCHE_POST_CLIENT_AVAILABLE: + raise ValidationError("Deutsche Post API client is not available") + + try: + # Import API functions only when needed + from .client.deutsche_post_international_shipping_api_client.api.bulk_orders import cancel_bulk_order + + client = self.deutschepost_orders.first().get_api_client() + + # For now, simulate bulk order cancellation + # TODO: Implement actual API call + self.status = self.STATUS.ERROR # Use ERROR status for cancelled + self.metadata.update({ + 'cancelled': True, + 'cancelled_at': timezone.now().isoformat() + }) + self.last_error = "Bulk order cancelled by user" + self.save() + + except Exception as e: + self.last_error = str(e) + self.save() + raise ValidationError(f"Deutsche Post Bulk API error: {str(e)}") + + def get_tracking_url(self): + """Get tracking URL for bulk order if available.""" + if self.bulk_order_id: + # Some bulk orders might have tracking URLs + return f"https://www.deutschepost.de/de/b/bulk-tracking.html?bulk_id={self.bulk_order_id}" + return None + + def get_bulk_status_url(self): + """Get status URL for monitoring bulk order progress.""" + if self.bulk_order_id: + return f"https://www.deutschepost.de/de/b/bulk-status.html?bulk_id={self.bulk_order_id}" + return None + + def __str__(self): + return f"Deutsche Post Bulk Order {self.bulk_order_id or 'Not Created'} - {self.deutschepost_orders.count()} orders - {self.status}" diff --git a/backend/thirdparty/deutschepost/serializers.py b/backend/thirdparty/deutschepost/serializers.py new file mode 100644 index 0000000..e331632 --- /dev/null +++ b/backend/thirdparty/deutschepost/serializers.py @@ -0,0 +1,163 @@ +from rest_framework import serializers +from rest_framework.exceptions import ValidationError + +from .models import DeutschePostOrder, DeutschePostBulkOrder + + +class DeutschePostOrderSerializer(serializers.ModelSerializer): + commerce_order_id = serializers.IntegerField(write_only=True, required=False) + state_display = serializers.CharField(source='get_state_display', read_only=True) + + class Meta: + model = DeutschePostOrder + fields = [ + 'id', 'created_at', 'state', 'state_display', 'commerce_order', 'commerce_order_id', + 'order_id', 'customer_ekp', + 'recipient_name', 'recipient_phone', 'recipient_email', + 'address_line1', 'address_line2', 'address_line3', + 'city', 'address_state', 'postal_code', 'destination_country', + 'product_type', 'service_level', 'shipment_gross_weight', + 'shipment_amount', 'shipment_currency', + 'sender_tax_id', 'importer_tax_id', 'return_item_wanted', + 'cust_ref', 'awb_number', 'barcode', 'tracking_url', + 'metadata', 'last_error' + ] + read_only_fields = [ + 'id', 'created_at', 'order_id', 'awb_number', 'barcode', + 'tracking_url', 'metadata', 'last_error' + ] + + def validate_commerce_order_id(self, value): + """Validate that commerce order exists and uses Deutsche Post delivery.""" + try: + from commerce.models import Order + order = Order.objects.get(id=value) + + if not order.carrier: + raise ValidationError("Commerce order must have a carrier assigned") + + if order.carrier.shipping_method != "deutschepost": + raise ValidationError("Commerce order must use Deutsche Post delivery method") + + if order.status != Order.OrderStatus.COMPLETED: + raise ValidationError("Commerce order must be completed before creating Deutsche Post order") + + return value + except Order.DoesNotExist: + raise ValidationError("Commerce order does not exist") + + def validate_destination_country(self, value): + """Validate country code format.""" + if len(value) != 2: + raise ValidationError("Country code must be 2 characters (ISO format)") + return value.upper() + + def validate_shipment_gross_weight(self, value): + """Validate weight is reasonable.""" + if value <= 0: + raise ValidationError("Shipment weight must be greater than 0") + if value > 30000: # 30kg limit for most Deutsche Post products + raise ValidationError("Shipment weight cannot exceed 30kg (30000g)") + return value + + def create(self, validated_data): + commerce_order_id = validated_data.pop('commerce_order_id', None) + + if commerce_order_id: + from commerce.models import Order + validated_data['commerce_order'] = Order.objects.get(id=commerce_order_id) + + return super().create(validated_data) + + +class DeutschePostBulkOrderSerializer(serializers.ModelSerializer): + deutschepost_order_ids = serializers.ListField( + child=serializers.IntegerField(), + write_only=True, + required=True, + help_text="List of DeutschePostOrder IDs to include in bulk order" + ) + status_display = serializers.CharField(source='get_status_display', read_only=True) + orders_count = serializers.SerializerMethodField(read_only=True) + tracking_url = serializers.SerializerMethodField(read_only=True) + status_url = serializers.SerializerMethodField(read_only=True) + + class Meta: + model = DeutschePostBulkOrder + fields = [ + 'id', 'created_at', 'status', 'status_display', + 'bulk_order_id', 'bulk_order_type', 'description', + 'deutschepost_orders', 'deutschepost_order_ids', 'orders_count', + 'tracking_url', 'status_url', + 'metadata', 'last_error' + ] + read_only_fields = [ + 'id', 'created_at', 'bulk_order_id', 'deutschepost_orders', + 'metadata', 'last_error' + ] + + def get_orders_count(self, obj): + return obj.deutschepost_orders.count() + + def get_tracking_url(self, obj): + return obj.get_tracking_url() + + def get_status_url(self, obj): + return obj.get_bulk_status_url() + + def validate_deutschepost_order_ids(self, value): + """Validate that all orders exist and are eligible for bulk processing.""" + if not value: + raise ValidationError("At least one Deutsche Post order is required") + + errors = [] + orders = DeutschePostOrder.objects.filter(id__in=value) + + if len(orders) != len(value): + missing_ids = set(value) - set(orders.values_list('id', flat=True)) + errors.append(f"Orders not found: {missing_ids}") + + for order in orders: + # Check if order is created remotely + if not order.order_id: + errors.append(f"Order {order.id} not created remotely") + + # Check if commerce order uses Deutsche Post + if order.commerce_order: + if not order.commerce_order.carrier: + errors.append(f"Commerce order {order.commerce_order.id} has no carrier") + elif order.commerce_order.carrier.shipping_method != "deutschepost": + errors.append(f"Commerce order {order.commerce_order.id} doesn't use Deutsche Post") + elif order.commerce_order.status != order.commerce_order.OrderStatus.COMPLETED: + errors.append(f"Commerce order {order.commerce_order.id} is not completed") + + # Check if order is already in another bulk order + if order.bulk_orders.exists(): + errors.append(f"Order {order.id} already in bulk order") + + if errors: + raise ValidationError(errors) + + return value + + def create(self, validated_data): + order_ids = validated_data.pop('deutschepost_order_ids') + + bulk_order = super().create(validated_data) + + # Add orders to bulk order + orders = DeutschePostOrder.objects.filter(id__in=order_ids) + bulk_order.deutschepost_orders.set(orders) + + return bulk_order + + +class DeutschePostTrackingSerializer(serializers.Serializer): + """Serializer for tracking information response.""" + order_id = serializers.CharField(read_only=True) + awb_number = serializers.CharField(read_only=True) + barcode = serializers.CharField(read_only=True) + tracking_url = serializers.URLField(read_only=True) + state = serializers.CharField(read_only=True) + last_updated = serializers.DateTimeField(read_only=True) + tracking_events = serializers.JSONField(read_only=True) \ No newline at end of file diff --git a/backend/thirdparty/deutschepost/tests.py b/backend/thirdparty/deutschepost/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/thirdparty/deutschepost/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/thirdparty/deutschepost/urls.py b/backend/thirdparty/deutschepost/urls.py new file mode 100644 index 0000000..76770dd --- /dev/null +++ b/backend/thirdparty/deutschepost/urls.py @@ -0,0 +1,15 @@ +from django.urls import path, include +from rest_framework.routers import DefaultRouter + +from .views import DeutschePostOrderViewSet, DeutschePostBulkOrderViewSet + + +router = DefaultRouter() +router.register(r"orders", DeutschePostOrderViewSet, basename="deutschepost-order") +router.register(r"bulk-orders", DeutschePostBulkOrderViewSet, basename="deutschepost-bulk-order") + +app_name = "deutschepost" + +urlpatterns = [ + path("", include(router.urls)), +] \ No newline at end of file diff --git a/backend/thirdparty/deutschepost/views.py b/backend/thirdparty/deutschepost/views.py new file mode 100644 index 0000000..5bf1344 --- /dev/null +++ b/backend/thirdparty/deutschepost/views.py @@ -0,0 +1,300 @@ +from django.shortcuts import render + +from rest_framework import viewsets, mixins, status +from rest_framework.decorators import action +from rest_framework.response import Response +from rest_framework.permissions import IsAdminUser + +from drf_spectacular.utils import ( + extend_schema, extend_schema_view, OpenApiResponse, + OpenApiParameter, OpenApiTypes +) + +from .models import DeutschePostOrder, DeutschePostBulkOrder +from .serializers import ( + DeutschePostOrderSerializer, + DeutschePostBulkOrderSerializer, + DeutschePostTrackingSerializer, +) + + +@extend_schema_view( + list=extend_schema( + tags=["deutschepost"], + summary="List Deutsche Post Orders", + description="Returns a paginated list of Deutsche Post shipping orders. Orders are created internally through Carrier model. Admin only access.", + responses=DeutschePostOrderSerializer(many=True), + ), + retrieve=extend_schema( + tags=["deutschepost"], + summary="Get Deutsche Post Order Detail", + description="Returns detailed information for a single Deutsche Post order including tracking data. Orders are managed through Carrier model.", + responses=DeutschePostOrderSerializer, + ), +) +class DeutschePostOrderViewSet( + mixins.ListModelMixin, + mixins.RetrieveModelMixin, + viewsets.GenericViewSet +): + queryset = DeutschePostOrder.objects.all().order_by("-created_at") + serializer_class = DeutschePostOrderSerializer + permission_classes = [IsAdminUser] + + @extend_schema( + tags=["deutschepost"], + summary="Refresh Tracking Information", + description=""" + Refresh tracking information from Deutsche Post API. This will: + - Fetch latest order status from Deutsche Post + - Update AWB number, barcode, and tracking URL + - Update order state based on shipment status + - Store raw tracking data in metadata + + Note: Orders are created and managed through the Carrier model in commerce app. + """, + request=None, + responses={ + 200: DeutschePostTrackingSerializer, + 400: OpenApiResponse(description="Order not created remotely"), + 500: OpenApiResponse(description="Deutsche Post API error") + } + ) + @action(detail=True, methods=['post']) + def refresh_tracking(self, request, pk=None): + """Refresh tracking information from Deutsche Post API.""" + order = self.get_object() + + try: + order.refresh_tracking() + + # Return tracking information + tracking_data = { + 'order_id': order.order_id, + 'awb_number': order.awb_number, + 'barcode': order.barcode, + 'tracking_url': order.tracking_url, + 'state': order.state, + 'last_updated': order.created_at, # Use created_at as proxy + 'tracking_events': order.metadata.get('tracking_events', []) + } + + serializer = DeutschePostTrackingSerializer(tracking_data) + return Response(serializer.data) + except Exception as e: + return Response( + {'error': str(e)}, + status=status.HTTP_400_BAD_REQUEST + ) + + @extend_schema( + tags=["deutschepost"], + summary="Cancel Deutsche Post Order", + description=""" + Cancel the order in Deutsche Post API system. This will: + - Call Deutsche Post API to cancel the order + - Update the order state to CANCELLED + - Cannot be undone once cancelled + - Only works for orders that are not yet shipped or delivered + + Note: Orders are created and managed through the Carrier model in commerce app. + """, + request=None, + responses={ + 200: DeutschePostOrderSerializer, + 400: OpenApiResponse(description="Order cannot be cancelled or API error"), + 500: OpenApiResponse(description="Deutsche Post API error") + } + ) + @action(detail=True, methods=['post']) + def cancel_order(self, request, pk=None): + """Cancel order in Deutsche Post API.""" + order = self.get_object() + + try: + order.cancel_order() + serializer = self.get_serializer(order) + return Response(serializer.data) + except Exception as e: + return Response( + {'error': str(e)}, + status=status.HTTP_400_BAD_REQUEST + ) + + @extend_schema( + tags=["deutschepost"], + summary="Get Tracking URL", + description=""" + Get the public tracking URL for the order that customers can use to track their shipment. + Returns the URL if available, or null if tracking is not yet available. + """, + request=None, + responses={ + 200: OpenApiResponse(description="Tracking URL response", examples={ + "application/json": { + "tracking_url": "https://www.deutschepost.de/de/s/sendungsverfolgung.html?piececode=ABC123" + } + }), + 404: OpenApiResponse(description="Tracking URL not available") + } + ) + @action(detail=True, methods=['get']) + def get_tracking_url(self, request, pk=None): + """Get public tracking URL for the order.""" + order = self.get_object() + tracking_url = order.get_tracking_url() + + if tracking_url: + return Response({'tracking_url': tracking_url}) + else: + return Response( + {'error': 'Tracking URL not available yet'}, + status=status.HTTP_404_NOT_FOUND + ) + + +@extend_schema_view( + list=extend_schema( + tags=["deutschepost"], + summary="List Deutsche Post Bulk Orders", + description="Returns a paginated list of Deutsche Post bulk shipping orders. Admin only access.", + responses=DeutschePostBulkOrderSerializer(many=True), + ), + retrieve=extend_schema( + tags=["deutschepost"], + summary="Get Deutsche Post Bulk Order Detail", + description="Returns detailed information for a single Deutsche Post bulk order including all constituent orders.", + responses=DeutschePostBulkOrderSerializer, + ), + create=extend_schema( + tags=["deutschepost"], + summary="Create Deutsche Post Bulk Order", + description=""" + Create a new Deutsche Post bulk order from multiple individual orders. + + Requirements: + - All orders must be created remotely (have order_id) + - All linked commerce orders must use Deutsche Post delivery + - All linked commerce orders must be completed + - Orders cannot already be part of another bulk order + """, + request=DeutschePostBulkOrderSerializer, + responses={ + 201: DeutschePostBulkOrderSerializer, + 400: OpenApiResponse(description="Validation error - orders not eligible for bulk processing") + }, + ), +) +class DeutschePostBulkOrderViewSet( + mixins.ListModelMixin, + mixins.RetrieveModelMixin, + mixins.CreateModelMixin, + viewsets.GenericViewSet +): + queryset = DeutschePostBulkOrder.objects.all().order_by("-created_at") + serializer_class = DeutschePostBulkOrderSerializer + permission_classes = [IsAdminUser] + + @extend_schema( + tags=["deutschepost"], + summary="Create Remote Bulk Order", + description=""" + Create the bulk order in Deutsche Post API system. This will: + - Validate all constituent orders are eligible + - Call Deutsche Post API to create the bulk order + - Store the returned bulk_order_id + - Update the bulk order status to PROCESSING + - Handle API errors and validation + """, + request=None, + responses={ + 200: DeutschePostBulkOrderSerializer, + 400: OpenApiResponse(description="Bulk order already created or validation error"), + 500: OpenApiResponse(description="Deutsche Post API error") + } + ) + @action(detail=True, methods=['post']) + def create_remote(self, request, pk=None): + """Create bulk order in Deutsche Post API.""" + bulk_order = self.get_object() + + try: + bulk_order.create_remote_bulk_order() + serializer = self.get_serializer(bulk_order) + return Response(serializer.data) + except Exception as e: + return Response( + {'error': str(e)}, + status=status.HTTP_400_BAD_REQUEST + ) + + @extend_schema( + tags=["deutschepost"], + summary="Cancel Remote Bulk Order", + description=""" + Cancel the bulk order in Deutsche Post API system. This will: + - Call Deutsche Post API to cancel the bulk order + - Update the bulk order status to ERROR (cancelled state) + - Cannot be undone once cancelled + - Only works for bulk orders that are not yet completed + """, + request=None, + responses={ + 200: DeutschePostBulkOrderSerializer, + 400: OpenApiResponse(description="Bulk order cannot be cancelled or validation error"), + 500: OpenApiResponse(description="Deutsche Post API error") + } + ) + @action(detail=True, methods=['post']) + def cancel_bulk_order(self, request, pk=None): + """Cancel bulk order in Deutsche Post API.""" + bulk_order = self.get_object() + + try: + bulk_order.cancel_bulk_order() + serializer = self.get_serializer(bulk_order) + return Response(serializer.data) + except Exception as e: + return Response( + {'error': str(e)}, + status=status.HTTP_400_BAD_REQUEST + ) + + @extend_schema( + tags=["deutschepost"], + summary="Get Bulk Order URLs", + description=""" + Get tracking and status URLs for the bulk order. Returns: + - tracking_url: Public URL for tracking bulk shipment progress + - status_url: URL for monitoring bulk order processing status + """, + request=None, + responses={ + 200: OpenApiResponse(description="Bulk order URLs", examples={ + "application/json": { + "tracking_url": "https://www.deutschepost.de/de/b/bulk-tracking.html?bulk_id=BULK123", + "status_url": "https://www.deutschepost.de/de/b/bulk-status.html?bulk_id=BULK123" + } + }), + 404: OpenApiResponse(description="Bulk order not created remotely yet") + } + ) + @action(detail=True, methods=['get']) + def get_urls(self, request, pk=None): + """Get tracking and status URLs for bulk order.""" + bulk_order = self.get_object() + + tracking_url = bulk_order.get_tracking_url() + status_url = bulk_order.get_bulk_status_url() + + if tracking_url or status_url: + return Response({ + 'tracking_url': tracking_url, + 'status_url': status_url, + 'bulk_order_id': bulk_order.bulk_order_id + }) + else: + return Response( + {'error': 'Bulk order not created remotely yet'}, + status=status.HTTP_404_NOT_FOUND + ) diff --git a/backend/vontor_cz/settings.py b/backend/vontor_cz/settings.py index d902e52..233ffb2 100644 --- a/backend/vontor_cz/settings.py +++ b/backend/vontor_cz/settings.py @@ -345,6 +345,7 @@ MY_CREATED_APPS = [ 'thirdparty.stripe', # register Stripe app so its models are recognized 'thirdparty.trading212', 'thirdparty.zasilkovna', + 'thirdparty.deutschepost', # Deutsche Post International Shipping API 'thirdparty.gopay', # add GoPay app ] diff --git a/backend/vontor_cz/urls.py b/backend/vontor_cz/urls.py index 53a3593..0ec0c74 100644 --- a/backend/vontor_cz/urls.py +++ b/backend/vontor_cz/urls.py @@ -44,4 +44,5 @@ urlpatterns = [ path('api/downloader/', include('thirdparty.downloader.urls')), path("api/payments/gopay/", include("thirdparty.gopay.urls", namespace="gopay")), path('api/zasilkovna/', include('thirdparty.zasilkovna.urls')), + path('api/deutschepost/', include('thirdparty.deutschepost.urls')), ] diff --git a/backups/backup-20260101-132533.sql b/backups/backup-20260101-132533.sql new file mode 100644 index 0000000..e69de29