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
