"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper
from cellpointapi.models.person_name import (
    PersonName,
)


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

    Search vouchers request.

    Attributes:
        order_id (str): Identifier for an order.
        owners (List[PersonName]): List of owners with issued vouchers
        issuer (str): Issuer of the voucher
        voucher_type (VoucherType): Type of voucher
        merchant_order_reference (str): Reference for identifying an order.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "owners": "owners",
        "issuer": "issuer",
        "voucher_type": "voucherType",
        "merchant_order_reference": "merchantOrderReference",
        "order_id": "orderId",
    }

    _optionals = [
        "order_id",
    ]

    def __init__(
        self,
        owners=None,
        voucher_type=None,
        merchant_order_reference=None,
        order_id=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a SearchVouchersRequest instance."""
        # Initialize members of the class
        if order_id is not APIHelper.SKIP:
            self.order_id = order_id
        self.owners = owners
        self.issuer = "SWAV_PAYMENT_GATEWAY"
        self.voucher_type = voucher_type
        self.merchant_order_reference = merchant_order_reference

        # 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
        owners = None
        if dictionary.get("owners") is not None:
            owners = [
                PersonName.from_dictionary(x)
                    for x in dictionary.get("owners")
            ]
        voucher_type =\
            dictionary.get("voucherType")\
            if dictionary.get("voucherType")\
                else None
        merchant_order_reference =\
            dictionary.get("merchantOrderReference")\
            if dictionary.get("merchantOrderReference")\
                else None
        order_id =\
            dictionary.get("orderId")\
            if dictionary.get("orderId")\
                else 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(owners,
                   voucher_type,
                   merchant_order_reference,
                   order_id,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _order_id=(
            self.order_id
            if hasattr(self, "order_id")
            else None
        )
        _owners=self.owners
        _issuer=self.issuer
        _voucher_type=self.voucher_type
        _merchant_order_reference=self.merchant_order_reference
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"order_id={_order_id!r}, "
            f"owners={_owners!r}, "
            f"issuer={_issuer!r}, "
            f"voucher_type={_voucher_type!r}, "
            f"merchant_order_reference={_merchant_order_reference!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _order_id=(
            self.order_id
            if hasattr(self, "order_id")
            else None
        )
        _owners=self.owners
        _issuer=self.issuer
        _voucher_type=self.voucher_type
        _merchant_order_reference=self.merchant_order_reference
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"order_id={_order_id!s}, "
            f"owners={_owners!s}, "
            f"issuer={_issuer!s}, "
            f"voucher_type={_voucher_type!s}, "
            f"merchant_order_reference={_merchant_order_reference!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
