# 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, Union
from pydantic import BaseModel, Field, StrictFloat, StrictInt, StrictStr
from marqeta_client.models.funding import Funding
from marqeta_client.models.jit_funding_api import JitFundingApi
from marqeta_client.models.response import Response

class GpaReturns(BaseModel):
    """
    GpaReturns
    """
    token: StrictStr = ...
    amount: Union[StrictFloat, StrictInt] = ...
    tags: Optional[StrictStr] = None
    memo: Optional[StrictStr] = None
    created_time: datetime = Field(..., description="yyyy-MM-ddTHH:mm:ssZ")
    last_modified_time: datetime = Field(..., description="yyyy-MM-ddTHH:mm:ssZ")
    transaction_token: StrictStr = ...
    state: StrictStr = ...
    response: Response = ...
    funding: Funding = ...
    funding_source_token: StrictStr = ...
    funding_source_address_token: Optional[StrictStr] = None
    jit_funding: Optional[JitFundingApi] = None
    original_order_token: Optional[StrictStr] = None
    __properties = ["token", "amount", "tags", "memo", "created_time", "last_modified_time", "transaction_token", "state", "response", "funding", "funding_source_token", "funding_source_address_token", "jit_funding", "original_order_token"]

    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) -> GpaReturns:
        """Create an instance of GpaReturns 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 response
        if self.response:
            _dict['response'] = self.response.to_dict()
        # override the default output from pydantic by calling `to_dict()` of funding
        if self.funding:
            _dict['funding'] = self.funding.to_dict()
        # override the default output from pydantic by calling `to_dict()` of jit_funding
        if self.jit_funding:
            _dict['jit_funding'] = self.jit_funding.to_dict()
        return _dict

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

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

        _obj = GpaReturns.parse_obj({
            "token": obj.get("token"),
            "amount": obj.get("amount"),
            "tags": obj.get("tags"),
            "memo": obj.get("memo"),
            "created_time": obj.get("created_time"),
            "last_modified_time": obj.get("last_modified_time"),
            "transaction_token": obj.get("transaction_token"),
            "state": obj.get("state"),
            "response": Response.from_dict(obj.get("response")) if obj.get("response") is not None else None,
            "funding": Funding.from_dict(obj.get("funding")) if obj.get("funding") is not None else None,
            "funding_source_token": obj.get("funding_source_token"),
            "funding_source_address_token": obj.get("funding_source_address_token"),
            "jit_funding": JitFundingApi.from_dict(obj.get("jit_funding")) if obj.get("jit_funding") is not None else None,
            "original_order_token": obj.get("original_order_token")
        })
        return _obj

