# 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 Optional
from pydantic import BaseModel, StrictStr
from marqeta_client.models.address_verification import AddressVerification
from marqeta_client.models.device import Device
from marqeta_client.models.digital_wallet_token_metadata import DigitalWalletTokenMetadata
from marqeta_client.models.token_service_provider import TokenServiceProvider
from marqeta_client.models.user_card_holder_response import UserCardHolderResponse
from marqeta_client.models.wallet_provider_profile import WalletProviderProfile

class DigitalWalletToken(BaseModel):
    """
    DigitalWalletToken
    """
    token: Optional[StrictStr] = None
    card_token: Optional[StrictStr] = None
    state: Optional[StrictStr] = None
    state_reason: Optional[StrictStr] = None
    fulfillment_status: Optional[StrictStr] = None
    issuer_eligibility_decision: Optional[StrictStr] = None
    created_time: Optional[datetime] = None
    last_modified_time: Optional[datetime] = None
    token_service_provider: Optional[TokenServiceProvider] = None
    device: Optional[Device] = None
    wallet_provider_profile: Optional[WalletProviderProfile] = None
    address_verification: Optional[AddressVerification] = None
    user: Optional[UserCardHolderResponse] = None
    metadata: Optional[DigitalWalletTokenMetadata] = None
    __properties = ["token", "card_token", "state", "state_reason", "fulfillment_status", "issuer_eligibility_decision", "created_time", "last_modified_time", "token_service_provider", "device", "wallet_provider_profile", "address_verification", "user", "metadata"]

    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) -> DigitalWalletToken:
        """Create an instance of DigitalWalletToken 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 token_service_provider
        if self.token_service_provider:
            _dict['token_service_provider'] = self.token_service_provider.to_dict()
        # override the default output from pydantic by calling `to_dict()` of device
        if self.device:
            _dict['device'] = self.device.to_dict()
        # override the default output from pydantic by calling `to_dict()` of wallet_provider_profile
        if self.wallet_provider_profile:
            _dict['wallet_provider_profile'] = self.wallet_provider_profile.to_dict()
        # override the default output from pydantic by calling `to_dict()` of address_verification
        if self.address_verification:
            _dict['address_verification'] = self.address_verification.to_dict()
        # override the default output from pydantic by calling `to_dict()` of user
        if self.user:
            _dict['user'] = self.user.to_dict()
        # override the default output from pydantic by calling `to_dict()` of metadata
        if self.metadata:
            _dict['metadata'] = self.metadata.to_dict()
        return _dict

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

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

        _obj = DigitalWalletToken.parse_obj({
            "token": obj.get("token"),
            "card_token": obj.get("card_token"),
            "state": obj.get("state"),
            "state_reason": obj.get("state_reason"),
            "fulfillment_status": obj.get("fulfillment_status"),
            "issuer_eligibility_decision": obj.get("issuer_eligibility_decision"),
            "created_time": obj.get("created_time"),
            "last_modified_time": obj.get("last_modified_time"),
            "token_service_provider": TokenServiceProvider.from_dict(obj.get("token_service_provider")) if obj.get("token_service_provider") is not None else None,
            "device": Device.from_dict(obj.get("device")) if obj.get("device") is not None else None,
            "wallet_provider_profile": WalletProviderProfile.from_dict(obj.get("wallet_provider_profile")) if obj.get("wallet_provider_profile") is not None else None,
            "address_verification": AddressVerification.from_dict(obj.get("address_verification")) if obj.get("address_verification") is not None else None,
            "user": UserCardHolderResponse.from_dict(obj.get("user")) if obj.get("user") is not None else None,
            "metadata": DigitalWalletTokenMetadata.from_dict(obj.get("metadata")) if obj.get("metadata") is not None else None
        })
        return _obj

