# -*- 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.error_status import ErrorStatus
from shelldatareportingapis.models.update_odometer_reference import UpdateOdometerReference


class UpdateOdometerResponse(object):

    """Implementation of the 'UpdateOdometerResponse' model.

    TODO: type model description here.

    Attributes:
        service_reference (int): Main reference number for tracking.
        update_odometer_references (List[UpdateOdometerReference]): TODO: type
            description here.
        error (ErrorStatus): TODO: type description here.
        request_id (str): API Request Id

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "service_reference": 'ServiceReference',
        "update_odometer_references": 'UpdateOdometerReferences',
        "error": 'Error',
        "request_id": 'RequestId'
    }

    _optionals = [
        'service_reference',
        'update_odometer_references',
        'error',
        'request_id',
    ]

    def __init__(self,
                 service_reference=APIHelper.SKIP,
                 update_odometer_references=APIHelper.SKIP,
                 error=APIHelper.SKIP,
                 request_id=APIHelper.SKIP):
        """Constructor for the UpdateOdometerResponse class"""

        # Initialize members of the class
        if service_reference is not APIHelper.SKIP:
            self.service_reference = service_reference 
        if update_odometer_references is not APIHelper.SKIP:
            self.update_odometer_references = update_odometer_references 
        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
        service_reference = dictionary.get("ServiceReference") if dictionary.get("ServiceReference") else APIHelper.SKIP
        update_odometer_references = None
        if dictionary.get('UpdateOdometerReferences') is not None:
            update_odometer_references = [UpdateOdometerReference.from_dictionary(x) for x in dictionary.get('UpdateOdometerReferences')]
        else:
            update_odometer_references = 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(service_reference,
                   update_odometer_references,
                   error,
                   request_id)
