"""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.pagination_response import (
    PaginationResponse,
)
from mindbodypublicapi.models.product import (
    Product,
)


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

    Represents the response object for retrieving products.

    Attributes:
        pagination_response (PaginationResponse): Contains information about the
            pagination to use.
        products (List[Product]): Contains information about the products.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "pagination_response": "PaginationResponse",
        "products": "Products",
    }

    _optionals = [
        "pagination_response",
        "products",
    ]

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

    @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
        pagination_response =\
            PaginationResponse.from_dictionary(
                dictionary.get("PaginationResponse"))\
                if "PaginationResponse" in dictionary.keys()\
                else APIHelper.SKIP
        products = None
        if dictionary.get("Products") is not None:
            products = [
                Product.from_dictionary(x)
                    for x in dictionary.get("Products")
            ]
        else:
            products = APIHelper.SKIP

        # Return an object of this model
        return cls(pagination_response,
                   products)

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

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