"""mindbodypublicapi.

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

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper
from mindbodypublicapi.models.promo_code import (
    PromoCode,
)


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

    Attributes:
        promo_code (PromoCode): The model property of type PromoCode.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "promo_code": "PromoCode",
    }

    _optionals = [
        "promo_code",
    ]

    def __init__(
        self,
        promo_code=APIHelper.SKIP):
        """Initialize a AddPromoCodeResponse instance."""
        # Initialize members of the class
        if promo_code is not APIHelper.SKIP:
            self.promo_code = promo_code

    @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
        promo_code =\
            PromoCode.from_dictionary(
                dictionary.get("PromoCode"))\
                if "PromoCode" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(promo_code)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _promo_code=(
            self.promo_code
            if hasattr(self, "promo_code")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"promo_code={_promo_code!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _promo_code=(
            self.promo_code
            if hasattr(self, "promo_code")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"promo_code={_promo_code!s}, "
            f")"
        )
