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

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.link_description import LinkDescription
from paypalserversdk.models.transaction_details import TransactionDetails


class SearchResponse(object):

    """Implementation of the 'Search Response' model.

    The search response information.

    Attributes:
        transaction_details (List[TransactionDetails]): An array of
            transaction detail objects.
        account_number (str): The merchant account number.
        start_date (str): The date and time, in [Internet date and time
            format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds
            are required while fractional seconds are optional. Note: The
            regular expression provides guidance but does not reject all
            invalid dates.
        end_date (str): The date and time, in [Internet date and time
            format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds
            are required while fractional seconds are optional. Note: The
            regular expression provides guidance but does not reject all
            invalid dates.
        last_refreshed_datetime (str): The date and time, in [Internet date
            and time format](https://tools.ietf.org/html/rfc3339#section-5.6).
            Seconds are required while fractional seconds are optional. Note:
            The regular expression provides guidance but does not reject all
            invalid dates.
        page (int): A zero-relative index of transactions.
        total_items (int): The total number of transactions as an integer
            beginning with the specified `page` in the full result and not
            just in this response.
        total_pages (int): The total number of pages, as an `integer`, when
            the `total_items` is divided into pages of the specified
            `page_size`.
        links (List[LinkDescription]): An array of request-related [HATEOAS
            links](/api/rest/responses/#hateoas-links).

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "transaction_details": 'transaction_details',
        "account_number": 'account_number',
        "start_date": 'start_date',
        "end_date": 'end_date',
        "last_refreshed_datetime": 'last_refreshed_datetime',
        "page": 'page',
        "total_items": 'total_items',
        "total_pages": 'total_pages',
        "links": 'links'
    }

    _optionals = [
        'transaction_details',
        'account_number',
        'start_date',
        'end_date',
        'last_refreshed_datetime',
        'page',
        'total_items',
        'total_pages',
        'links',
    ]

    def __init__(self,
                 transaction_details=APIHelper.SKIP,
                 account_number=APIHelper.SKIP,
                 start_date=APIHelper.SKIP,
                 end_date=APIHelper.SKIP,
                 last_refreshed_datetime=APIHelper.SKIP,
                 page=APIHelper.SKIP,
                 total_items=APIHelper.SKIP,
                 total_pages=APIHelper.SKIP,
                 links=APIHelper.SKIP):
        """Constructor for the SearchResponse class"""

        # Initialize members of the class
        if transaction_details is not APIHelper.SKIP:
            self.transaction_details = transaction_details 
        if account_number is not APIHelper.SKIP:
            self.account_number = account_number 
        if start_date is not APIHelper.SKIP:
            self.start_date = start_date 
        if end_date is not APIHelper.SKIP:
            self.end_date = end_date 
        if last_refreshed_datetime is not APIHelper.SKIP:
            self.last_refreshed_datetime = last_refreshed_datetime 
        if page is not APIHelper.SKIP:
            self.page = page 
        if total_items is not APIHelper.SKIP:
            self.total_items = total_items 
        if total_pages is not APIHelper.SKIP:
            self.total_pages = total_pages 
        if links is not APIHelper.SKIP:
            self.links = links 

    @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
        transaction_details = None
        if dictionary.get('transaction_details') is not None:
            transaction_details = [TransactionDetails.from_dictionary(x) for x in dictionary.get('transaction_details')]
        else:
            transaction_details = APIHelper.SKIP
        account_number = dictionary.get("account_number") if dictionary.get("account_number") else APIHelper.SKIP
        start_date = dictionary.get("start_date") if dictionary.get("start_date") else APIHelper.SKIP
        end_date = dictionary.get("end_date") if dictionary.get("end_date") else APIHelper.SKIP
        last_refreshed_datetime = dictionary.get("last_refreshed_datetime") if dictionary.get("last_refreshed_datetime") else APIHelper.SKIP
        page = dictionary.get("page") if dictionary.get("page") else APIHelper.SKIP
        total_items = dictionary.get("total_items") if dictionary.get("total_items") else APIHelper.SKIP
        total_pages = dictionary.get("total_pages") if dictionary.get("total_pages") else APIHelper.SKIP
        links = None
        if dictionary.get('links') is not None:
            links = [LinkDescription.from_dictionary(x) for x in dictionary.get('links')]
        else:
            links = APIHelper.SKIP
        # Return an object of this model
        return cls(transaction_details,
                   account_number,
                   start_date,
                   end_date,
                   last_refreshed_datetime,
                   page,
                   total_items,
                   total_pages,
                   links)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'transaction_details={(self.transaction_details if hasattr(self, "transaction_details") else None)!r}, '
                f'account_number={(self.account_number if hasattr(self, "account_number") else None)!r}, '
                f'start_date={(self.start_date if hasattr(self, "start_date") else None)!r}, '
                f'end_date={(self.end_date if hasattr(self, "end_date") else None)!r}, '
                f'last_refreshed_datetime={(self.last_refreshed_datetime if hasattr(self, "last_refreshed_datetime") else None)!r}, '
                f'page={(self.page if hasattr(self, "page") else None)!r}, '
                f'total_items={(self.total_items if hasattr(self, "total_items") else None)!r}, '
                f'total_pages={(self.total_pages if hasattr(self, "total_pages") else None)!r}, '
                f'links={(self.links if hasattr(self, "links") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'transaction_details={(self.transaction_details if hasattr(self, "transaction_details") else None)!s}, '
                f'account_number={(self.account_number if hasattr(self, "account_number") else None)!s}, '
                f'start_date={(self.start_date if hasattr(self, "start_date") else None)!s}, '
                f'end_date={(self.end_date if hasattr(self, "end_date") else None)!s}, '
                f'last_refreshed_datetime={(self.last_refreshed_datetime if hasattr(self, "last_refreshed_datetime") else None)!s}, '
                f'page={(self.page if hasattr(self, "page") else None)!s}, '
                f'total_items={(self.total_items if hasattr(self, "total_items") else None)!s}, '
                f'total_pages={(self.total_pages if hasattr(self, "total_pages") else None)!s}, '
                f'links={(self.links if hasattr(self, "links") else None)!s})')
