"""visaacceptancemergedspec.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.models.service import (
    Service,
)


class AncillaryInformation(object):
    """Implementation of the 'AncillaryInformation' model.

    Attributes:
        ticket_number (str): Ticket number, which consists of the carrier code, form,
            and serial number, without the check digit. **Important** This field is
            required in the U.S. in order for you to qualify for either the custom
            payment service (CPS) or the electronic interchange reimbursement fee
            (EIRF) program. Format: English characters only. Optional field for
            ancillary services.
        passenger_name (str): Name of the passenger. If the passenger’s name is not
            available, this value is the cardholder’s name. If neither the
            passenger’s name nor the cardholder’s name is available, this value is a
            description of the ancillary purchase. **Important** This field is
            required in the U.S. in order for you to qualify for either the custom
            payment service (CPS) or the electronic interchange reimbursement fee
            (EIRF) program. Format: English characters only. Optional field for
            ancillary service.
        connected_ticket_number (str): Number for the airline ticket to which the
            ancillary purchase is connected.  If this purchase has a connection or
            relationship to another purchase such as a baggage fee for a passenger
            transport ticket, this field must contain the ticket number for the other
            purchase.  For a stand-alone purchase, the value for this field must be
            the same as the value for the
            `travelInformation.transit.airline.ancillaryInformation.ticketNumber`
            field. **Important** This field is required in the U.S. in order for you
            to qualify for either the custom payment service (CPS) or the electronic
            interchange reimbursement fee (EIRF) program. Format: English characters
            only. Optional request field for ancillary services.
        credit_reason_indicator (str): Reason for the credit. Possible values: - `A`:
            Cancellation of the ancillary passenger transport purchase. - `B`:
            Cancellation of the airline ticket and the passenger transport ancillary
            purchase. - `C`: Cancellation of the airline ticket. - `O`: Other. - `P`:
            Partial refund of the airline ticket. Format: English characters only.
            Optional field for ancillary services.
        service (List[Service]): The model property of type List[Service].
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "ticket_number": "ticketNumber",
        "passenger_name": "passengerName",
        "connected_ticket_number": "connectedTicketNumber",
        "credit_reason_indicator": "creditReasonIndicator",
        "service": "service",
    }

    _optionals = [
        "ticket_number",
        "passenger_name",
        "connected_ticket_number",
        "credit_reason_indicator",
        "service",
    ]

    def __init__(
        self,
        ticket_number=APIHelper.SKIP,
        passenger_name=APIHelper.SKIP,
        connected_ticket_number=APIHelper.SKIP,
        credit_reason_indicator=APIHelper.SKIP,
        service=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a AncillaryInformation instance."""
        # Initialize members of the class
        if ticket_number is not APIHelper.SKIP:
            self.ticket_number = ticket_number
        if passenger_name is not APIHelper.SKIP:
            self.passenger_name = passenger_name
        if connected_ticket_number is not APIHelper.SKIP:
            self.connected_ticket_number = connected_ticket_number
        if credit_reason_indicator is not APIHelper.SKIP:
            self.credit_reason_indicator = credit_reason_indicator
        if service is not APIHelper.SKIP:
            self.service = service

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        ticket_number =\
            dictionary.get("ticketNumber")\
            if dictionary.get("ticketNumber")\
                else APIHelper.SKIP
        passenger_name =\
            dictionary.get("passengerName")\
            if dictionary.get("passengerName")\
                else APIHelper.SKIP
        connected_ticket_number =\
            dictionary.get("connectedTicketNumber")\
            if dictionary.get("connectedTicketNumber")\
                else APIHelper.SKIP
        credit_reason_indicator =\
            dictionary.get("creditReasonIndicator")\
            if dictionary.get("creditReasonIndicator")\
                else APIHelper.SKIP
        service = None
        if dictionary.get("service") is not None:
            service = [
                Service.from_dictionary(x)
                    for x in dictionary.get("service")
            ]
        else:
            service = APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(ticket_number,
                   passenger_name,
                   connected_ticket_number,
                   credit_reason_indicator,
                   service,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _ticket_number=(
            self.ticket_number
            if hasattr(self, "ticket_number")
            else None
        )
        _passenger_name=(
            self.passenger_name
            if hasattr(self, "passenger_name")
            else None
        )
        _connected_ticket_number=(
            self.connected_ticket_number
            if hasattr(self, "connected_ticket_number")
            else None
        )
        _credit_reason_indicator=(
            self.credit_reason_indicator
            if hasattr(self, "credit_reason_indicator")
            else None
        )
        _service=(
            self.service
            if hasattr(self, "service")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"ticket_number={_ticket_number!r}, "
            f"passenger_name={_passenger_name!r}, "
            f"connected_ticket_number={_connected_ticket_number!r}, "
            f"credit_reason_indicator={_credit_reason_indicator!r}, "
            f"service={_service!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _ticket_number=(
            self.ticket_number
            if hasattr(self, "ticket_number")
            else None
        )
        _passenger_name=(
            self.passenger_name
            if hasattr(self, "passenger_name")
            else None
        )
        _connected_ticket_number=(
            self.connected_ticket_number
            if hasattr(self, "connected_ticket_number")
            else None
        )
        _credit_reason_indicator=(
            self.credit_reason_indicator
            if hasattr(self, "credit_reason_indicator")
            else None
        )
        _service=(
            self.service
            if hasattr(self, "service")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"ticket_number={_ticket_number!s}, "
            f"passenger_name={_passenger_name!s}, "
            f"connected_ticket_number={_connected_ticket_number!s}, "
            f"credit_reason_indicator={_credit_reason_indicator!s}, "
            f"service={_service!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
