# 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.gateway_response import GatewayResponse

class Gatewaylog(BaseModel):
    """
    Gatewaylog
    """
    id: Optional[StrictInt] = None
    trace_number: Optional[StrictInt] = Field(None, alias="traceNumber")
    payment_type_code: Optional[StrictStr] = Field(None, alias="paymentTypeCode")
    ach_transaction_type: Optional[StrictStr] = Field(None, alias="achTransactionType")
    memo: Optional[StrictStr] = None
    gateway_version: Optional[StrictStr] = Field(None, alias="gatewayVersion")
    gateway_response: Optional[GatewayResponse] = Field(None, alias="gatewayResponse")
    timed_out: Optional[StrictBool] = Field(None, alias="timedOut")
    deal_id: Optional[StrictInt] = Field(None, alias="deal_Id")
    order_id: Optional[StrictStr] = Field(None, alias="order_Id")
    request_method: Optional[StrictStr] = None
    response_code: Optional[StrictStr] = None
    response_subcode: Optional[StrictStr] = None
    response_reasoncode: Optional[StrictStr] = None
    response_message: Optional[StrictStr] = None
    status: Optional[StrictStr] = None
    fraud_avs: Optional[StrictStr] = None
    fraud_auth: Optional[StrictStr] = None
    fraud_cvv: Optional[StrictStr] = None
    gateway_transaction_id: Optional[StrictStr] = Field(None, alias="gateway_transactionId")
    original_gateway: Optional[Gatewaylog] = None
    amount: Optional[Union[StrictFloat, StrictInt]] = None
    duplicate: Optional[StrictStr] = None
    post_date: Optional[datetime] = None
    response_time: Optional[datetime] = None
    api_duration: Optional[StrictInt] = None
    gateway_duration: Optional[StrictInt] = None
    ach_status: Optional[StrictStr] = None
    created: Optional[datetime] = None
    modified: Optional[datetime] = None
    __properties = ["id", "traceNumber", "paymentTypeCode", "achTransactionType", "memo", "gatewayVersion", "gatewayResponse", "timedOut", "deal_Id", "order_Id", "request_method", "response_code", "response_subcode", "response_reasoncode", "response_message", "status", "fraud_avs", "fraud_auth", "fraud_cvv", "gateway_transactionId", "original_gateway", "amount", "duplicate", "post_date", "response_time", "api_duration", "gateway_duration", "ach_status", "created", "modified"]

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

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

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

        _obj = Gatewaylog.parse_obj({
            "id": obj.get("id"),
            "trace_number": obj.get("traceNumber"),
            "payment_type_code": obj.get("paymentTypeCode"),
            "ach_transaction_type": obj.get("achTransactionType"),
            "memo": obj.get("memo"),
            "gateway_version": obj.get("gatewayVersion"),
            "gateway_response": GatewayResponse.from_dict(obj.get("gatewayResponse")) if obj.get("gatewayResponse") is not None else None,
            "timed_out": obj.get("timedOut"),
            "deal_id": obj.get("deal_Id"),
            "order_id": obj.get("order_Id"),
            "request_method": obj.get("request_method"),
            "response_code": obj.get("response_code"),
            "response_subcode": obj.get("response_subcode"),
            "response_reasoncode": obj.get("response_reasoncode"),
            "response_message": obj.get("response_message"),
            "status": obj.get("status"),
            "fraud_avs": obj.get("fraud_avs"),
            "fraud_auth": obj.get("fraud_auth"),
            "fraud_cvv": obj.get("fraud_cvv"),
            "gateway_transaction_id": obj.get("gateway_transactionId"),
            "original_gateway": Gatewaylog.from_dict(obj.get("original_gateway")) if obj.get("original_gateway") is not None else None,
            "amount": obj.get("amount"),
            "duplicate": obj.get("duplicate"),
            "post_date": obj.get("post_date"),
            "response_time": obj.get("response_time"),
            "api_duration": obj.get("api_duration"),
            "gateway_duration": obj.get("gateway_duration"),
            "ach_status": obj.get("ach_status"),
            "created": obj.get("created"),
            "modified": obj.get("modified")
        })
        return _obj

