# 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, validator
from marqeta_client.models.internal_funding_source import InternalFundingSource

class InternalGPAOrder(BaseModel):
    """
    InternalGPAOrder
    """
    tags: Optional[StrictStr] = None
    memo: Optional[StrictStr] = None
    token: StrictStr = ...
    amount: Union[StrictFloat, StrictInt] = ...
    currency: Optional[StrictStr] = None
    funding_source: Optional[InternalFundingSource] = Field(None, alias="fundingSource")
    original_order_id: Optional[StrictStr] = Field(None, alias="originalOrderId")
    order_type: Optional[StrictStr] = Field(None, alias="orderType")
    order_state: Optional[StrictStr] = Field(None, alias="orderState")
    response_code: Optional[StrictStr] = Field(None, alias="responseCode")
    response_memo: Optional[StrictStr] = Field(None, alias="responseMemo")
    created_time: Optional[datetime] = None
    last_modified_time: Optional[datetime] = None
    __properties = ["tags", "memo", "token", "amount", "currency", "fundingSource", "originalOrderId", "orderType", "orderState", "responseCode", "responseMemo", "created_time", "last_modified_time"]

    @validator('order_state')
    def order_state_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('PENDING', 'REVERSED', 'CLEARED', 'COMPLETION', 'DECLINED', 'ERROR'):
            raise ValueError("must be one of enum values ('PENDING', 'REVERSED', 'CLEARED', 'COMPLETION', 'DECLINED', 'ERROR')")
        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) -> InternalGPAOrder:
        """Create an instance of InternalGPAOrder 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 funding_source
        if self.funding_source:
            _dict['fundingSource'] = self.funding_source.to_dict()
        return _dict

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

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

        _obj = InternalGPAOrder.parse_obj({
            "tags": obj.get("tags"),
            "memo": obj.get("memo"),
            "token": obj.get("token"),
            "amount": obj.get("amount"),
            "currency": obj.get("currency"),
            "funding_source": InternalFundingSource.from_dict(obj.get("fundingSource")) if obj.get("fundingSource") is not None else None,
            "original_order_id": obj.get("originalOrderId"),
            "order_type": obj.get("orderType"),
            "order_state": obj.get("orderState"),
            "response_code": obj.get("responseCode"),
            "response_memo": obj.get("responseMemo"),
            "created_time": obj.get("created_time"),
            "last_modified_time": obj.get("last_modified_time")
        })
        return _obj

