# coding: utf-8

"""
    Marqeta Core API

    Simplified management of your payment programs  # noqa: E501

    The version of the OpenAPI document: 3.0.0
    Contact: dev@swadesh.co
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


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

from datetime import datetime
from typing import Dict, List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist, constr
from marqeta_client.models.address_request_model import AddressRequestModel
from marqeta_client.models.beneficial_owner_request import BeneficialOwnerRequest
from marqeta_client.models.business_incorporation import BusinessIncorporation
from marqeta_client.models.business_proprietor import BusinessProprietor
from marqeta_client.models.identification_request_model import IdentificationRequestModel
from marqeta_client.models.primary_contact_info_model import PrimaryContactInfoModel

class BusinessCardholder(BaseModel):
    """
    BusinessCardholder
    """
    token: Optional[constr(strict=True, max_length=36, min_length=1)] = None
    active: Optional[StrictBool] = True
    notes: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    ip_address: Optional[constr(strict=True, max_length=39, min_length=0)] = None
    password: Optional[constr(strict=True, max_length=255, min_length=1)] = Field(None, description="Strong password required")
    phone: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    metadata: Optional[Dict[str, StrictStr]] = None
    account_holder_group_token: Optional[constr(strict=True, max_length=36, min_length=0)] = None
    identifications: Optional[conlist(IdentificationRequestModel)] = None
    business_name_legal: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    business_name_dba: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    office_location: Optional[AddressRequestModel] = None
    in_current_location_since: Optional[datetime] = None
    website: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    date_established: Optional[datetime] = None
    general_business_description: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    history: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    business_type: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    international_office_locations: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    taxpayer_id: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    duns_number: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    primary_contact: Optional[PrimaryContactInfoModel] = None
    incorporation: Optional[BusinessIncorporation] = None
    proprietor_or_officer: Optional[BusinessProprietor] = None
    beneficial_owner1: Optional[BeneficialOwnerRequest] = None
    beneficial_owner2: Optional[BeneficialOwnerRequest] = None
    beneficial_owner3: Optional[BeneficialOwnerRequest] = None
    beneficial_owner4: Optional[BeneficialOwnerRequest] = None
    attester_name: Optional[constr(strict=True, max_length=64, min_length=0)] = None
    attestation_consent: Optional[StrictBool] = False
    attester_title: Optional[constr(strict=True, max_length=64, min_length=0)] = None
    attestation_date: Optional[datetime] = Field(None, description="YYYY-MM-DDThh:mm:ssZ")
    proprietor_is_beneficial_owner: Optional[StrictBool] = False
    __properties = ["token", "active", "notes", "ip_address", "password", "phone", "metadata", "account_holder_group_token", "identifications", "business_name_legal", "business_name_dba", "office_location", "in_current_location_since", "website", "date_established", "general_business_description", "history", "business_type", "international_office_locations", "taxpayer_id", "duns_number", "primary_contact", "incorporation", "proprietor_or_officer", "beneficial_owner1", "beneficial_owner2", "beneficial_owner3", "beneficial_owner4", "attester_name", "attestation_consent", "attester_title", "attestation_date", "proprietor_is_beneficial_owner"]

    class Config:
        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) -> BusinessCardholder:
        """Create an instance of BusinessCardholder 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 each item in identifications (list)
        _items = []
        if self.identifications:
            for _item in self.identifications:
                if _item:
                    _items.append(_item.to_dict())
            _dict['identifications'] = _items
        # override the default output from pydantic by calling `to_dict()` of office_location
        if self.office_location:
            _dict['office_location'] = self.office_location.to_dict()
        # override the default output from pydantic by calling `to_dict()` of primary_contact
        if self.primary_contact:
            _dict['primary_contact'] = self.primary_contact.to_dict()
        # override the default output from pydantic by calling `to_dict()` of incorporation
        if self.incorporation:
            _dict['incorporation'] = self.incorporation.to_dict()
        # override the default output from pydantic by calling `to_dict()` of proprietor_or_officer
        if self.proprietor_or_officer:
            _dict['proprietor_or_officer'] = self.proprietor_or_officer.to_dict()
        # override the default output from pydantic by calling `to_dict()` of beneficial_owner1
        if self.beneficial_owner1:
            _dict['beneficial_owner1'] = self.beneficial_owner1.to_dict()
        # override the default output from pydantic by calling `to_dict()` of beneficial_owner2
        if self.beneficial_owner2:
            _dict['beneficial_owner2'] = self.beneficial_owner2.to_dict()
        # override the default output from pydantic by calling `to_dict()` of beneficial_owner3
        if self.beneficial_owner3:
            _dict['beneficial_owner3'] = self.beneficial_owner3.to_dict()
        # override the default output from pydantic by calling `to_dict()` of beneficial_owner4
        if self.beneficial_owner4:
            _dict['beneficial_owner4'] = self.beneficial_owner4.to_dict()
        return _dict

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

        if type(obj) is not dict:
            return BusinessCardholder.parse_obj(obj)

        _obj = BusinessCardholder.parse_obj({
            "token": obj.get("token"),
            "active": obj.get("active") if obj.get("active") is not None else True,
            "notes": obj.get("notes"),
            "ip_address": obj.get("ip_address"),
            "password": obj.get("password"),
            "phone": obj.get("phone"),
            "metadata": obj.get("metadata"),
            "account_holder_group_token": obj.get("account_holder_group_token"),
            "identifications": [IdentificationRequestModel.from_dict(_item) for _item in obj.get("identifications")] if obj.get("identifications") is not None else None,
            "business_name_legal": obj.get("business_name_legal"),
            "business_name_dba": obj.get("business_name_dba"),
            "office_location": AddressRequestModel.from_dict(obj.get("office_location")) if obj.get("office_location") is not None else None,
            "in_current_location_since": obj.get("in_current_location_since"),
            "website": obj.get("website"),
            "date_established": obj.get("date_established"),
            "general_business_description": obj.get("general_business_description"),
            "history": obj.get("history"),
            "business_type": obj.get("business_type"),
            "international_office_locations": obj.get("international_office_locations"),
            "taxpayer_id": obj.get("taxpayer_id"),
            "duns_number": obj.get("duns_number"),
            "primary_contact": PrimaryContactInfoModel.from_dict(obj.get("primary_contact")) if obj.get("primary_contact") is not None else None,
            "incorporation": BusinessIncorporation.from_dict(obj.get("incorporation")) if obj.get("incorporation") is not None else None,
            "proprietor_or_officer": BusinessProprietor.from_dict(obj.get("proprietor_or_officer")) if obj.get("proprietor_or_officer") is not None else None,
            "beneficial_owner1": BeneficialOwnerRequest.from_dict(obj.get("beneficial_owner1")) if obj.get("beneficial_owner1") is not None else None,
            "beneficial_owner2": BeneficialOwnerRequest.from_dict(obj.get("beneficial_owner2")) if obj.get("beneficial_owner2") is not None else None,
            "beneficial_owner3": BeneficialOwnerRequest.from_dict(obj.get("beneficial_owner3")) if obj.get("beneficial_owner3") is not None else None,
            "beneficial_owner4": BeneficialOwnerRequest.from_dict(obj.get("beneficial_owner4")) if obj.get("beneficial_owner4") is not None else None,
            "attester_name": obj.get("attester_name"),
            "attestation_consent": obj.get("attestation_consent") if obj.get("attestation_consent") is not None else False,
            "attester_title": obj.get("attester_title"),
            "attestation_date": obj.get("attestation_date"),
            "proprietor_is_beneficial_owner": obj.get("proprietor_is_beneficial_owner") if obj.get("proprietor_is_beneficial_owner") is not None else False
        })
        return _obj

