# coding: utf-8

"""
    Gigs Core API

    API to manage voice & data plans for smartphones, wearables and IoT in 200+ countries.  # noqa: E501

    The version of the OpenAPI document: 0.0.1
    Contact: support@gigs.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import Any, Optional
from pydantic import BaseModel, Field, validator

class DeviceModel(BaseModel):
    """
    DeviceModel
    """
    object: Optional[Any] = Field(..., description="Type of object is always `deviceModel`.")
    id: Optional[Any] = Field(..., description="Unique identifier for the deviceModel.")
    brand: Optional[Any] = Field(..., description="The brand of the device model.")
    name: Optional[Any] = Field(..., description="The device model's name.")
    sim_types: Optional[Any] = Field(..., alias="simTypes", description="List of SIM types supported by this device model.")
    type: Optional[Any] = Field(..., description="The type of the device model.")
    __properties = ["object", "id", "brand", "name", "simTypes", "type"]

    @validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in ('car', 'iot', 'laptop', 'router', 'smartphone', 'feature-phone', 'smartwatch', 'tablet', 'wearable', 'other'):
            raise ValueError("must be one of enum values ('car', 'iot', 'laptop', 'router', 'smartphone', 'feature-phone', 'smartwatch', 'tablet', 'wearable', 'other')")
        return value

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> DeviceModel:
        """Create an instance of DeviceModel from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # set to None if object (nullable) is None
        # and __fields_set__ contains the field
        if self.object is None and "object" in self.__fields_set__:
            _dict['object'] = None

        # set to None if id (nullable) is None
        # and __fields_set__ contains the field
        if self.id is None and "id" in self.__fields_set__:
            _dict['id'] = None

        # set to None if brand (nullable) is None
        # and __fields_set__ contains the field
        if self.brand is None and "brand" in self.__fields_set__:
            _dict['brand'] = None

        # set to None if name (nullable) is None
        # and __fields_set__ contains the field
        if self.name is None and "name" in self.__fields_set__:
            _dict['name'] = None

        # set to None if sim_types (nullable) is None
        # and __fields_set__ contains the field
        if self.sim_types is None and "sim_types" in self.__fields_set__:
            _dict['simTypes'] = None

        # set to None if type (nullable) is None
        # and __fields_set__ contains the field
        if self.type is None and "type" in self.__fields_set__:
            _dict['type'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> DeviceModel:
        """Create an instance of DeviceModel from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return DeviceModel.parse_obj(obj)

        _obj = DeviceModel.parse_obj({
            "object": obj.get("object"),
            "id": obj.get("id"),
            "brand": obj.get("brand"),
            "name": obj.get("name"),
            "sim_types": obj.get("simTypes"),
            "type": obj.get("type")
        })
        return _obj

