# 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, StrictBool, StrictFloat, StrictInt, StrictStr
from marqeta_client.models.funding import Funding
from marqeta_client.models.msa_aggregated_balances import MsaAggregatedBalances
from marqeta_client.models.msa_balances import MsaBalances

class MsaOrderResponse(BaseModel):
    """
    MsaOrderResponse
    """
    token: Optional[StrictStr] = None
    user_token: Optional[StrictStr] = None
    business_token: Optional[StrictStr] = None
    order_balances: MsaBalances = ...
    purchase_amount: Union[StrictFloat, StrictInt] = ...
    last_transaction_date: datetime = Field(..., description="yyyy-MM-ddThh:mm:ssZ")
    start_date: Optional[datetime] = Field(None, description="yyyy-MM-ddThh:mm:ssZ")
    end_date: Optional[datetime] = Field(None, description="yyyy-MM-ddThh:mm:ssZ")
    currency_code: StrictStr = ...
    active: StrictBool = ...
    reward_amount: Union[StrictFloat, StrictInt] = ...
    reward_trigger_amount: Union[StrictFloat, StrictInt] = ...
    unloaded_amount: Optional[Union[StrictFloat, StrictInt]] = None
    campaign_token: StrictStr = ...
    funding: Funding = ...
    created_time: datetime = Field(..., description="yyyy-MM-ddTHH:mm:ssZ")
    last_modified_time: datetime = Field(..., description="yyyy-MM-ddTHH:mm:ssZ")
    aggregated_balances: MsaAggregatedBalances = ...
    transaction_token: StrictStr = ...
    __properties = ["token", "user_token", "business_token", "order_balances", "purchase_amount", "last_transaction_date", "start_date", "end_date", "currency_code", "active", "reward_amount", "reward_trigger_amount", "unloaded_amount", "campaign_token", "funding", "created_time", "last_modified_time", "aggregated_balances", "transaction_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) -> MsaOrderResponse:
        """Create an instance of MsaOrderResponse 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 order_balances
        if self.order_balances:
            _dict['order_balances'] = self.order_balances.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 aggregated_balances
        if self.aggregated_balances:
            _dict['aggregated_balances'] = self.aggregated_balances.to_dict()
        return _dict

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

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

        _obj = MsaOrderResponse.parse_obj({
            "token": obj.get("token"),
            "user_token": obj.get("user_token"),
            "business_token": obj.get("business_token"),
            "order_balances": MsaBalances.from_dict(obj.get("order_balances")) if obj.get("order_balances") is not None else None,
            "purchase_amount": obj.get("purchase_amount"),
            "last_transaction_date": obj.get("last_transaction_date"),
            "start_date": obj.get("start_date"),
            "end_date": obj.get("end_date"),
            "currency_code": obj.get("currency_code"),
            "active": obj.get("active") if obj.get("active") is not None else False,
            "reward_amount": obj.get("reward_amount"),
            "reward_trigger_amount": obj.get("reward_trigger_amount"),
            "unloaded_amount": obj.get("unloaded_amount"),
            "campaign_token": obj.get("campaign_token"),
            "funding": Funding.from_dict(obj.get("funding")) if obj.get("funding") is not None else None,
            "created_time": obj.get("created_time"),
            "last_modified_time": obj.get("last_modified_time"),
            "aggregated_balances": MsaAggregatedBalances.from_dict(obj.get("aggregated_balances")) if obj.get("aggregated_balances") is not None else None,
            "transaction_token": obj.get("transaction_token")
        })
        return _obj

