# -*- coding: utf-8 -*-

"""
shelldatareportingapis

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from shelldatareportingapis.api_helper import APIHelper
from shelldatareportingapis.models.card_group_response_card_groups_items import CardGroupResponseCardGroupsItems
from shelldatareportingapis.models.error_status import ErrorStatus


class CardGroupResponse(object):

    """Implementation of the 'CardGroupResponse' model.

    TODO: type model description here.

    Attributes:
        card_groups (List[CardGroupResponseCardGroupsItems]): TODO: type
            description here.
        current_page (int): current page
        row_count (int): number of records in current response
        total_pages (int): Total pages available
        error (ErrorStatus): TODO: type description here.
        request_id (str): API Request id

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "card_groups": 'CardGroups',
        "current_page": 'CurrentPage',
        "row_count": 'RowCount',
        "total_pages": 'TotalPages',
        "error": 'Error',
        "request_id": 'RequestId'
    }

    _optionals = [
        'card_groups',
        'current_page',
        'row_count',
        'total_pages',
        'error',
        'request_id',
    ]

    def __init__(self,
                 card_groups=APIHelper.SKIP,
                 current_page=APIHelper.SKIP,
                 row_count=APIHelper.SKIP,
                 total_pages=APIHelper.SKIP,
                 error=APIHelper.SKIP,
                 request_id=APIHelper.SKIP):
        """Constructor for the CardGroupResponse class"""

        # Initialize members of the class
        if card_groups is not APIHelper.SKIP:
            self.card_groups = card_groups 
        if current_page is not APIHelper.SKIP:
            self.current_page = current_page 
        if row_count is not APIHelper.SKIP:
            self.row_count = row_count 
        if total_pages is not APIHelper.SKIP:
            self.total_pages = total_pages 
        if error is not APIHelper.SKIP:
            self.error = error 
        if request_id is not APIHelper.SKIP:
            self.request_id = request_id 

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Creates 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
        card_groups = None
        if dictionary.get('CardGroups') is not None:
            card_groups = [CardGroupResponseCardGroupsItems.from_dictionary(x) for x in dictionary.get('CardGroups')]
        else:
            card_groups = APIHelper.SKIP
        current_page = dictionary.get("CurrentPage") if dictionary.get("CurrentPage") else APIHelper.SKIP
        row_count = dictionary.get("RowCount") if dictionary.get("RowCount") else APIHelper.SKIP
        total_pages = dictionary.get("TotalPages") if dictionary.get("TotalPages") else APIHelper.SKIP
        error = ErrorStatus.from_dictionary(dictionary.get('Error')) if 'Error' in dictionary.keys() else APIHelper.SKIP
        request_id = dictionary.get("RequestId") if dictionary.get("RequestId") else APIHelper.SKIP
        # Return an object of this model
        return cls(card_groups,
                   current_page,
                   row_count,
                   total_pages,
                   error,
                   request_id)
