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
