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

"""
swaggerpetstoreopenapi30

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from swaggerpetstoreopenapi30.api_helper import APIHelper


class Order(object):

    """Implementation of the 'Order' model.

    Attributes:
        id (int): The model property of type int.
        pet_id (int): The model property of type int.
        quantity (int): The model property of type int.
        ship_date (datetime): The model property of type datetime.
        order_status (OrderStatusEnum): Order Status
        complete (bool): The model property of type bool.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": 'id',
        "pet_id": 'petId',
        "quantity": 'quantity',
        "ship_date": 'shipDate',
        "order_status": 'orderStatus',
        "complete": 'complete'
    }

    _optionals = [
        'id',
        'pet_id',
        'quantity',
        'ship_date',
        'order_status',
        'complete',
    ]

    def __init__(self,
                 id=APIHelper.SKIP,
                 pet_id=APIHelper.SKIP,
                 quantity=APIHelper.SKIP,
                 ship_date=APIHelper.SKIP,
                 order_status='approved',
                 complete=APIHelper.SKIP):
        """Constructor for the Order class"""

        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id 
        if pet_id is not APIHelper.SKIP:
            self.pet_id = pet_id 
        if quantity is not APIHelper.SKIP:
            self.quantity = quantity 
        if ship_date is not APIHelper.SKIP:
            self.ship_date = APIHelper.apply_datetime_converter(ship_date, APIHelper.RFC3339DateTime) if ship_date else None 
        self.order_status = order_status 
        if complete is not APIHelper.SKIP:
            self.complete = complete 

    @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
        id = dictionary.get("id") if dictionary.get("id") else APIHelper.SKIP
        pet_id = dictionary.get("petId") if dictionary.get("petId") else APIHelper.SKIP
        quantity = dictionary.get("quantity") if dictionary.get("quantity") else APIHelper.SKIP
        ship_date = APIHelper.RFC3339DateTime.from_value(dictionary.get("shipDate")).datetime if dictionary.get("shipDate") else APIHelper.SKIP
        order_status = dictionary.get("orderStatus") if dictionary.get("orderStatus") else 'approved'
        complete = dictionary.get("complete") if "complete" in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(id,
                   pet_id,
                   quantity,
                   ship_date,
                   order_status,
                   complete)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'id={(self.id if hasattr(self, "id") else None)!r}, '
                f'pet_id={(self.pet_id if hasattr(self, "pet_id") else None)!r}, '
                f'quantity={(self.quantity if hasattr(self, "quantity") else None)!r}, '
                f'ship_date={(self.ship_date if hasattr(self, "ship_date") else None)!r}, '
                f'order_status={(self.order_status if hasattr(self, "order_status") else None)!r}, '
                f'complete={(self.complete if hasattr(self, "complete") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'id={(self.id if hasattr(self, "id") else None)!s}, '
                f'pet_id={(self.pet_id if hasattr(self, "pet_id") else None)!s}, '
                f'quantity={(self.quantity if hasattr(self, "quantity") else None)!s}, '
                f'ship_date={(self.ship_date if hasattr(self, "ship_date") else None)!s}, '
                f'order_status={(self.order_status if hasattr(self, "order_status") else None)!s}, '
                f'complete={(self.complete if hasattr(self, "complete") else None)!s})')
