# 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 typing import Optional, Union
from pydantic import BaseModel, Field, StrictFloat, StrictInt, StrictStr, constr, validator
from marqeta_client.models.card_acceptor_model import CardAcceptorModel
from marqeta_client.models.original_credit_sender_data import OriginalCreditSenderData
from marqeta_client.models.webhook import Webhook

class OrignalcreditRequestModel(BaseModel):
    """
    OrignalcreditRequestModel
    """
    transaction_purpose: Optional[StrictStr] = Field(None, alias="transactionPurpose")
    amount: Union[StrictFloat, StrictInt] = ...
    card_token: constr(strict=True, max_length=36, min_length=1) = ...
    mid: constr(strict=True, max_length=50, min_length=1) = ...
    screening_score: Optional[StrictStr] = None
    card_acceptor: Optional[CardAcceptorModel] = None
    type: StrictStr = ...
    sender_data: Optional[OriginalCreditSenderData] = None
    webhook: Optional[Webhook] = None
    __properties = ["transactionPurpose", "amount", "card_token", "mid", "screening_score", "card_acceptor", "type", "sender_data", "webhook"]

    @validator('type')
    def type_validate_enum(cls, v):
        if v not in ('account_to_account', 'person_to_person', 'prepaid', 'wallet_transfer', 'money_transfer_by_bank', 'business_to_business', 'disbursement', 'government_disbursement', 'gambling_payout', 'loyalty', 'merchant_disbursement', 'online_gambling_payout', 'pension_disbursement', 'prepaid_loads', 'card_bill_payment', 'bill_payment', 'cash_claim', 'cash_in', 'cash_out', 'mobile_air_time_payment', 'money_transfer_by_merchant', 'face_to_face_merchant_payment', 'government_payment', 'payments_goods_services'):
            raise ValueError("must be one of enum values ('account_to_account', 'person_to_person', 'prepaid', 'wallet_transfer', 'money_transfer_by_bank', 'business_to_business', 'disbursement', 'government_disbursement', 'gambling_payout', 'loyalty', 'merchant_disbursement', 'online_gambling_payout', 'pension_disbursement', 'prepaid_loads', 'card_bill_payment', 'bill_payment', 'cash_claim', 'cash_in', 'cash_out', 'mobile_air_time_payment', 'money_transfer_by_merchant', 'face_to_face_merchant_payment', 'government_payment', 'payments_goods_services')")
        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) -> OrignalcreditRequestModel:
        """Create an instance of OrignalcreditRequestModel 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 card_acceptor
        if self.card_acceptor:
            _dict['card_acceptor'] = self.card_acceptor.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sender_data
        if self.sender_data:
            _dict['sender_data'] = self.sender_data.to_dict()
        # override the default output from pydantic by calling `to_dict()` of webhook
        if self.webhook:
            _dict['webhook'] = self.webhook.to_dict()
        return _dict

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

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

        _obj = OrignalcreditRequestModel.parse_obj({
            "transaction_purpose": obj.get("transactionPurpose"),
            "amount": obj.get("amount"),
            "card_token": obj.get("card_token"),
            "mid": obj.get("mid"),
            "screening_score": obj.get("screening_score"),
            "card_acceptor": CardAcceptorModel.from_dict(obj.get("card_acceptor")) if obj.get("card_acceptor") is not None else None,
            "type": obj.get("type"),
            "sender_data": OriginalCreditSenderData.from_dict(obj.get("sender_data")) if obj.get("sender_data") is not None else None,
            "webhook": Webhook.from_dict(obj.get("webhook")) if obj.get("webhook") is not None else None
        })
        return _obj

