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

"""
uexcorpapi

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from uexcorpapi.api_helper import APIHelper
from uexcorpapi.models.commodity import Commodity
from uexcorpapi.models.item import Item
from uexcorpapi.models.mglobal import Global
from uexcorpapi.models.vehicle_buy import VehicleBuy
from uexcorpapi.models.vehicle_rent import VehicleRent


class Data4(object):

    """Implementation of the 'Data4' model.

    Attributes:
        commodity (Commodity): The model property of type Commodity.
        mglobal (Global): The model property of type Global.
        item (Item): The model property of type Item.
        vehicle_buy (VehicleBuy): The model property of type VehicleBuy.
        vehicle_rent (VehicleRent): The model property of type VehicleRent.
        additional_properties (Dict[str, Any]): The additional properties for
            the model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "commodity": 'commodity',
        "mglobal": 'global',
        "item": 'item',
        "vehicle_buy": 'vehicle_buy',
        "vehicle_rent": 'vehicle_rent'
    }

    def __init__(self,
                 commodity=None,
                 mglobal=None,
                 item=None,
                 vehicle_buy=None,
                 vehicle_rent=None,
                 additional_properties=None):
        """Constructor for the Data4 class"""

        # Initialize members of the class
        self.commodity = commodity 
        self.mglobal = mglobal 
        self.item = item 
        self.vehicle_buy = vehicle_buy 
        self.vehicle_rent = vehicle_rent 

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @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
        commodity = Commodity.from_dictionary(dictionary.get('commodity')) if dictionary.get('commodity') else None
        mglobal = Global.from_dictionary(dictionary.get('global')) if dictionary.get('global') else None
        item = Item.from_dictionary(dictionary.get('item')) if dictionary.get('item') else None
        vehicle_buy = VehicleBuy.from_dictionary(dictionary.get('vehicle_buy')) if dictionary.get('vehicle_buy') else None
        vehicle_rent = VehicleRent.from_dictionary(dictionary.get('vehicle_rent')) if dictionary.get('vehicle_rent') else None
        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items() if k not in cls._names.values()},
            unboxing_function=lambda value: value)
        # Return an object of this model
        return cls(commodity,
                   mglobal,
                   item,
                   vehicle_buy,
                   vehicle_rent,
                   additional_properties)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'commodity={self.commodity!r}, '
                f'mglobal={self.mglobal!r}, '
                f'item={self.item!r}, '
                f'vehicle_buy={self.vehicle_buy!r}, '
                f'vehicle_rent={self.vehicle_rent!r}, '
                f'additional_properties={self.additional_properties!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'commodity={self.commodity!s}, '
                f'mglobal={self.mglobal!s}, '
                f'item={self.item!s}, '
                f'vehicle_buy={self.vehicle_buy!s}, '
                f'vehicle_rent={self.vehicle_rent!s}, '
                f'additional_properties={self.additional_properties!s})')
