# coding: utf-8

"""
    Mentortools Marketplace Server

    Mentortools service for ingesting payment-provider webhooks into normalized order events

    The version of the OpenAPI document: 0.1.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


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


from typing import Any, Dict, Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt
from marketplace_server_connector.models.flow import Flow
from marketplace_server_connector.models.provider import Provider

class AccountIn(BaseModel):
    """
    AccountIn
    """
    portal_id: Optional[StrictInt] = None
    provider: Optional[Provider] = Field(...)
    flow: Optional[Flow] = None
    credentials: Optional[Dict[str, Any]] = None
    is_active: Optional[StrictBool] = True
    __properties = ["portal_id", "provider", "flow", "credentials", "is_active"]

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

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

        return _dict

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

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

        _obj = AccountIn.parse_obj({
            "portal_id": obj.get("portal_id"),
            "provider": obj.get("provider"),
            "flow": obj.get("flow"),
            "credentials": obj.get("credentials"),
            "is_active": obj.get("is_active") if obj.get("is_active") is not None else True
        })
        return _obj


