# 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

class SubscriptionsCreateRequest(BaseModel):
    """
    SubscriptionsCreateRequest
    """
    device: Optional[Any] = Field(None, description="The unique identifier for the existing [Device](https://developers.gigs.com/docs/api/49514fddd1f44-retrieve-a-device) to be linked with the passed SIM. Some network providers require this field for activation. Trying to link a pSIM to a second device will cause an error.")
    plan: Optional[Any] = Field(..., description="The unique identifier for the existing [plan](https://developers.gigs.com/docs/api/b3A6MzMwODcxMzA-retrieve-a-plan) to be used for the subscription.")
    sim: Optional[Any] = Field(None, description="The unique identifier for the existing [SIM](https://developers.gigs.com/docs/api/b3A6MzMwODcxMzQ-retrieve-a-sim) to be used for the subscription. In combination with an eSIM plan, it can be passed as `auto` to request a new eSIM.")
    user_address: Optional[Any] = Field(None, alias="userAddress", description="The unique identifier for the existing [user address](https://developers.gigs.com/docs/api/b3A6MzMwODcxNDk-retrieve-a-user-address) to be used for the subscription. Only needed if the plan requires an address.")
    user: Optional[Any] = Field(..., description="The unique identifier for the existing [user](https://developers.gigs.com/docs/api/b3A6MzMwODcxNDM-retrieve-a-user) to which the subscription will be assigned.")
    porting: Optional[Any] = Field(None, description="The unique identifier for the existing draft [porting](https://developers.gigs.com/docs/api/bea041f643438-retrieve-a-porting) to be used for the subscription.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts. ")
    __properties = ["device", "plan", "sim", "userAddress", "user", "porting"]

    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) -> SubscriptionsCreateRequest:
        """Create an instance of SubscriptionsCreateRequest 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 device (nullable) is None
        # and __fields_set__ contains the field
        if self.device is None and "device" in self.__fields_set__:
            _dict['device'] = None

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

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

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

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

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

        return _dict

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

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

        _obj = SubscriptionsCreateRequest.parse_obj({
            "device": obj.get("device"),
            "plan": obj.get("plan"),
            "sim": obj.get("sim"),
            "user_address": obj.get("userAddress"),
            "user": obj.get("user"),
            "porting": obj.get("porting")
        })
        return _obj

