# coding: utf-8

"""
    Wink Payment API

    A programmatic way to create bookings, receive payment and disburse funds globally.  ## APIs Not every integrator needs every APIs. For that reason, we have separated APIs into context.  - [Affiliate](/affiliate): All APIs related to selling travel inventory as an affiliate. - [Analytics](/analytics): All APIs related to tracking metrics across a wide variety of data source segments including, more entertaining, leaderboard metrics. - [Booking](/booking): All APIs related to creating platform bookings. - [Channel Manager](/channel-manager): All APIs related to channel managers who want to integrate with our platform. - [Extranet](/extranet): All APIs related to managing travel inventory and suppliers. - [Inventory](/inventory): All APIs related to retrieve known travel inventory as it was found using the Lookup API.. - [Lookup](/lookup): All APIs related to locating inventory by region, locale and property flags. - [Reference](/reference): All APIs related to retrieving platform-supported taxonomies. - [TripPay](/payment): All APIs related to TripPay account management, booking, mapping and integration features.  ## SDKs We are actively working on supporting the most used languages out there. If you don't see your language here, reach out to us with a request to officially add your language. In the meantime, if you want to roll your own SDK, you can do so by downloading the OpenAPI spec and using one of the many available OpenAPI generators available: [https://openapi-generator.tech/docs/generators](https://openapi-generator.tech/docs/generators).  - Java SDK [https://github.com/wink-travel/trip-pay-sdk-java](https://github.com/wink-travel/trip-pay-sdk-java)  # Usage These features are made available to you via a [REST API](https://en.wikipedia.org/wiki/Representational_state_transfer). This API is language agnostic. We will link to SDKs for the most popular programming languages on this page as they become available.  ## Versioning We chose to version our endpoints in a way that we hope affects your integration with us the least. You request the version of our API you wish to work with via the `Wink-Version` header. When it's time for you to upgrade, you only have to change the version number to get access to our updated endpoints.  ## Release history - Follow updates on Github: https://github.com/wink-travel/wink-sdk-java/blob/master/CHANGELOG.md 

    The version of the OpenAPI document: 30.18.0
    Contact: bjorn@wink.travel
    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 datetime import date, datetime
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from trip_pay_payment.models.address import Address
from trip_pay_payment.models.bank_account import BankAccount
from trip_pay_payment.models.contact import Contact
from typing import Optional, Set
from typing_extensions import Self

class Account(BaseModel):
    """
    Account holds KYC, bank account and contact information of an affiliate, supplier, user or any type of entity that is to be a beneficiary of funds through the payment.
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="Document UUID")
    created_date: Optional[datetime] = Field(default=None, description="Datetime this record was first created", alias="createdDate")
    last_update: Optional[datetime] = Field(default=None, description="Datetime this record was last updated", alias="lastUpdate")
    version: Optional[StrictInt] = Field(default=None, description="Version property that shows how many times this document has been persisted. Document will not persist if the version property is less than current version property in the system. Result in an optimistic locking exception.")
    type: StrictStr = Field(description="Type of account tells us what the account is capable of.")
    owner_type: StrictStr = Field(description="Type of account owner tells us whether ths account is managed by a company or an individual.", alias="ownerType")
    account_owner_identifier: Annotated[str, Field(min_length=1, strict=True)] = Field(description="The entity that created this account.", alias="accountOwnerIdentifier")
    name: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Name of company / full name of person")
    legal_name: Optional[StrictStr] = Field(default=None, description="Legal name of entity if other than name", alias="legalName")
    user_identifier: Annotated[str, Field(min_length=1, strict=True)] = Field(description="The authenticated user that owns this account.", alias="userIdentifier")
    owner: Contact = Field(description="The owning user entity.")
    account_email: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Account email is where we will send KYC documents and other account specific mailings", alias="accountEmail")
    account_phone_number: Optional[StrictStr] = Field(default=None, description="Account phone number is mostly used for KYC purchases", alias="accountPhoneNumber")
    description: StrictStr = Field(description="Short company / person description.")
    url: StrictStr = Field(description="AffiliateAccount website. If private person with no personal website, link to main social network account.")
    status: StrictStr = Field(description="Account status shows if it's approved")
    currency_code: Annotated[str, Field(min_length=3, strict=True, max_length=3)] = Field(description="Account's main currency.", alias="currencyCode")
    address: Address = Field(description="Account address. Usually the business address")
    acquirers: Optional[List[Any]] = None
    bank_accounts: Optional[List[BankAccount]] = Field(default=None, alias="bankAccounts")
    owner_type_identifier: Optional[StrictStr] = Field(default=None, description="This is the tax identification number (TIN) for individuals and entity identification number (EIN) for companies.", alias="ownerTypeIdentifier")
    dob: Optional[date] = Field(default=None, description="This is the individual's date of birth.")
    tasks: Optional[List[Any]] = None
    preferred_disbursement_type: Optional[StrictStr] = Field(default='BANK_TRANSFER', description="The preferred method which the account holder wishes to be paid. This will play a role if we choose to automate the payout flow.", alias="preferredDisbursementType")
    vat_id: Optional[StrictStr] = Field(default=None, description="An optional VAT ID", alias="vatID")
    __properties: ClassVar[List[str]] = ["id", "createdDate", "lastUpdate", "version", "type", "ownerType", "accountOwnerIdentifier", "name", "legalName", "userIdentifier", "owner", "accountEmail", "accountPhoneNumber", "description", "url", "status", "currencyCode", "address", "acquirers", "bankAccounts", "ownerTypeIdentifier", "dob", "tasks", "preferredDisbursementType", "vatID"]

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['MERCHANT', 'AFFILIATE', 'AGENT', 'FACILITATOR', 'RATE_PROVIDER', 'TRIP_PAY']):
            raise ValueError("must be one of enum values ('MERCHANT', 'AFFILIATE', 'AGENT', 'FACILITATOR', 'RATE_PROVIDER', 'TRIP_PAY')")
        return value

    @field_validator('owner_type')
    def owner_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['COMPANY', 'INDIVIDUAL']):
            raise ValueError("must be one of enum values ('COMPANY', 'INDIVIDUAL')")
        return value

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['REGISTERED', 'REVIEW', 'APPROVED', 'DEACTIVATED', 'REJECTED']):
            raise ValueError("must be one of enum values ('REGISTERED', 'REVIEW', 'APPROVED', 'DEACTIVATED', 'REJECTED')")
        return value

    @field_validator('preferred_disbursement_type')
    def preferred_disbursement_type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['VIRTUAL_CREDIT_CARD', 'BANK_TRANSFER']):
            raise ValueError("must be one of enum values ('VIRTUAL_CREDIT_CARD', 'BANK_TRANSFER')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of Account from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of owner
        if self.owner:
            _dict['owner'] = self.owner.to_dict()
        # override the default output from pydantic by calling `to_dict()` of address
        if self.address:
            _dict['address'] = self.address.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in bank_accounts (list)
        _items = []
        if self.bank_accounts:
            for _item_bank_accounts in self.bank_accounts:
                if _item_bank_accounts:
                    _items.append(_item_bank_accounts.to_dict())
            _dict['bankAccounts'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Account from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "createdDate": obj.get("createdDate"),
            "lastUpdate": obj.get("lastUpdate"),
            "version": obj.get("version"),
            "type": obj.get("type"),
            "ownerType": obj.get("ownerType"),
            "accountOwnerIdentifier": obj.get("accountOwnerIdentifier"),
            "name": obj.get("name"),
            "legalName": obj.get("legalName"),
            "userIdentifier": obj.get("userIdentifier"),
            "owner": Contact.from_dict(obj["owner"]) if obj.get("owner") is not None else None,
            "accountEmail": obj.get("accountEmail"),
            "accountPhoneNumber": obj.get("accountPhoneNumber"),
            "description": obj.get("description"),
            "url": obj.get("url"),
            "status": obj.get("status") if obj.get("status") is not None else 'REGISTERED',
            "currencyCode": obj.get("currencyCode"),
            "address": Address.from_dict(obj["address"]) if obj.get("address") is not None else None,
            "acquirers": obj.get("acquirers"),
            "bankAccounts": [BankAccount.from_dict(_item) for _item in obj["bankAccounts"]] if obj.get("bankAccounts") is not None else None,
            "ownerTypeIdentifier": obj.get("ownerTypeIdentifier"),
            "dob": obj.get("dob"),
            "tasks": obj.get("tasks"),
            "preferredDisbursementType": obj.get("preferredDisbursementType") if obj.get("preferredDisbursementType") is not None else 'BANK_TRANSFER',
            "vatID": obj.get("vatID")
        })
        return _obj


