# 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 typing import Dict, List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist, constr, validator
from marqeta_client.models.identification_request_model import IdentificationRequestModel

class CardHolderModel(BaseModel):
    """
    CardHolderModel
    """
    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=0)] = None
    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
    honorific: Optional[constr(strict=True, max_length=10, min_length=0)] = None
    gender: Optional[constr(strict=True, max_length=1, min_length=0)] = None
    first_name: Optional[constr(strict=True, max_length=40, min_length=0)] = None
    middle_name: Optional[constr(strict=True, max_length=40, min_length=0)] = None
    last_name: Optional[constr(strict=True, max_length=40, min_length=0)] = None
    email: Optional[constr(strict=True, max_length=255, min_length=1)] = None
    address1: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    address2: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    city: Optional[constr(strict=True, max_length=40, min_length=0)] = None
    state: Optional[constr(strict=True, max_length=32, min_length=0)] = None
    country: Optional[constr(strict=True, max_length=40, min_length=0)] = None
    birth_date: Optional[StrictStr] = None
    corporate_card_holder: Optional[StrictBool] = False
    ssn: Optional[StrictStr] = None
    passport_number: Optional[constr(strict=True, max_length=40, min_length=0)] = None
    passport_expiration_date: Optional[StrictStr] = None
    id_card_number: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    id_card_expiration_date: Optional[StrictStr] = None
    nationality: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    company: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    parent_token: Optional[constr(strict=True, max_length=36, min_length=1)] = None
    uses_parent_account: Optional[StrictBool] = Field(False, description="Default is false")
    postal_code: Optional[constr(strict=True, max_length=10, min_length=0)] = None
    __properties = ["token", "active", "notes", "ip_address", "password", "phone", "metadata", "account_holder_group_token", "identifications", "honorific", "gender", "first_name", "middle_name", "last_name", "email", "address1", "address2", "city", "state", "country", "birth_date", "corporate_card_holder", "ssn", "passport_number", "passport_expiration_date", "id_card_number", "id_card_expiration_date", "nationality", "company", "parent_token", "uses_parent_account", "postal_code"]

    @validator('gender')
    def gender_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('F', 'M'):
            raise ValueError("must be one of enum values ('F', 'M')")
        return v

    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) -> CardHolderModel:
        """Create an instance of CardHolderModel 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
        return _dict

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

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

        _obj = CardHolderModel.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,
            "honorific": obj.get("honorific"),
            "gender": obj.get("gender"),
            "first_name": obj.get("first_name"),
            "middle_name": obj.get("middle_name"),
            "last_name": obj.get("last_name"),
            "email": obj.get("email"),
            "address1": obj.get("address1"),
            "address2": obj.get("address2"),
            "city": obj.get("city"),
            "state": obj.get("state"),
            "country": obj.get("country"),
            "birth_date": obj.get("birth_date"),
            "corporate_card_holder": obj.get("corporate_card_holder") if obj.get("corporate_card_holder") is not None else False,
            "ssn": obj.get("ssn"),
            "passport_number": obj.get("passport_number"),
            "passport_expiration_date": obj.get("passport_expiration_date"),
            "id_card_number": obj.get("id_card_number"),
            "id_card_expiration_date": obj.get("id_card_expiration_date"),
            "nationality": obj.get("nationality"),
            "company": obj.get("company"),
            "parent_token": obj.get("parent_token"),
            "uses_parent_account": obj.get("uses_parent_account") if obj.get("uses_parent_account") is not None else False,
            "postal_code": obj.get("postal_code")
        })
        return _obj

