# coding: utf-8

"""
    Conekta API

    Conekta sdk  # noqa: E501

    The version of the OpenAPI document: 2.1.0
    Contact: engineering@conekta.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 Optional
from pydantic import BaseModel, Field, StrictStr, validator
from conekta.models.company_fiscal_info_address_response import CompanyFiscalInfoAddressResponse

class CompanyFiscalInfoResponse(BaseModel):
    """
    Company fiscal info model
    """
    object: Optional[StrictStr] = Field(None, description="The resource's type")
    tax_id: Optional[StrictStr] = Field(None, description="Tax ID of the company")
    legal_entity_name: Optional[StrictStr] = Field(None, description="Legal name of the company")
    business_type: Optional[StrictStr] = Field(None, description="Business type of the company")
    phone: Optional[StrictStr] = Field(None, description="Phone number of the company")
    physical_person_business_type: Optional[StrictStr] = Field(None, description="Business type if 'persona_fisica'")
    address: Optional[CompanyFiscalInfoAddressResponse] = None
    __properties = ["object", "tax_id", "legal_entity_name", "business_type", "phone", "physical_person_business_type", "address"]

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

        if value not in ('fiscal_info'):
            raise ValueError("must be one of enum values ('fiscal_info')")
        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) -> CompanyFiscalInfoResponse:
        """Create an instance of CompanyFiscalInfoResponse 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)
        # override the default output from pydantic by calling `to_dict()` of address
        if self.address:
            _dict['address'] = self.address.to_dict()
        return _dict

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

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

        _obj = CompanyFiscalInfoResponse.parse_obj({
            "object": obj.get("object"),
            "tax_id": obj.get("tax_id"),
            "legal_entity_name": obj.get("legal_entity_name"),
            "business_type": obj.get("business_type"),
            "phone": obj.get("phone"),
            "physical_person_business_type": obj.get("physical_person_business_type"),
            "address": CompanyFiscalInfoAddressResponse.from_dict(obj.get("address")) if obj.get("address") is not None else None
        })
        return _obj

