# 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
from marqeta_client.models.internal_funding_source import InternalFundingSource
from marqeta_client.models.internal_gateway_merchant import InternalGatewayMerchant
from marqeta_client.models.internal_user import InternalUser
from marqeta_client.models.network_metadata import NetworkMetadata

class InternalGatewayLog(BaseModel):
    """
    InternalGatewayLog
    """
    gateway_merchant: Optional[InternalGatewayMerchant] = Field(None, alias="gatewayMerchant")
    order_id: Optional[StrictStr] = Field(None, alias="orderId")
    request_method: Optional[StrictStr] = Field(None, alias="requestMethod")
    gateway_request_method: Optional[StrictStr] = Field(None, alias="gatewayRequestMethod")
    response_code: Optional[StrictStr] = Field(None, alias="responseCode")
    response_sub_code: Optional[StrictStr] = Field(None, alias="responseSubCode")
    response_reason_code: Optional[StrictStr] = Field(None, alias="responseReasonCode")
    response_message: Optional[StrictStr] = Field(None, alias="responseMessage")
    gateway_response_message: Optional[StrictStr] = Field(None, alias="gatewayResponseMessage")
    response_status: Optional[StrictStr] = Field(None, alias="responseStatus")
    gateway_transaction_id: Optional[StrictStr] = Field(None, alias="gatewayTransactionId")
    amount: Optional[Union[StrictFloat, StrictInt]] = None
    api_duration: Optional[StrictInt] = Field(None, alias="apiDuration")
    gateway_duration: Optional[StrictInt] = Field(None, alias="gatewayDuration")
    memo: Optional[StrictStr] = None
    gateway_version: Optional[StrictStr] = Field(None, alias="gatewayVersion")
    funding_source: InternalFundingSource = ...
    internal_user: Optional[InternalUser] = Field(None, alias="internalUser")
    network_metadata: Optional[NetworkMetadata] = None
    __properties = ["gatewayMerchant", "orderId", "requestMethod", "gatewayRequestMethod", "responseCode", "responseSubCode", "responseReasonCode", "responseMessage", "gatewayResponseMessage", "responseStatus", "gatewayTransactionId", "amount", "apiDuration", "gatewayDuration", "memo", "gatewayVersion", "funding_source", "internalUser", "network_metadata"]

    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) -> InternalGatewayLog:
        """Create an instance of InternalGatewayLog 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_merchant
        if self.gateway_merchant:
            _dict['gatewayMerchant'] = self.gateway_merchant.to_dict()
        # override the default output from pydantic by calling `to_dict()` of funding_source
        if self.funding_source:
            _dict['funding_source'] = self.funding_source.to_dict()
        # override the default output from pydantic by calling `to_dict()` of internal_user
        if self.internal_user:
            _dict['internalUser'] = self.internal_user.to_dict()
        # override the default output from pydantic by calling `to_dict()` of network_metadata
        if self.network_metadata:
            _dict['network_metadata'] = self.network_metadata.to_dict()
        return _dict

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

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

        _obj = InternalGatewayLog.parse_obj({
            "gateway_merchant": InternalGatewayMerchant.from_dict(obj.get("gatewayMerchant")) if obj.get("gatewayMerchant") is not None else None,
            "order_id": obj.get("orderId"),
            "request_method": obj.get("requestMethod"),
            "gateway_request_method": obj.get("gatewayRequestMethod"),
            "response_code": obj.get("responseCode"),
            "response_sub_code": obj.get("responseSubCode"),
            "response_reason_code": obj.get("responseReasonCode"),
            "response_message": obj.get("responseMessage"),
            "gateway_response_message": obj.get("gatewayResponseMessage"),
            "response_status": obj.get("responseStatus"),
            "gateway_transaction_id": obj.get("gatewayTransactionId"),
            "amount": obj.get("amount"),
            "api_duration": obj.get("apiDuration"),
            "gateway_duration": obj.get("gatewayDuration"),
            "memo": obj.get("memo"),
            "gateway_version": obj.get("gatewayVersion"),
            "funding_source": InternalFundingSource.from_dict(obj.get("funding_source")) if obj.get("funding_source") is not None else None,
            "internal_user": InternalUser.from_dict(obj.get("internalUser")) if obj.get("internalUser") is not None else None,
            "network_metadata": NetworkMetadata.from_dict(obj.get("network_metadata")) if obj.get("network_metadata") is not None else None
        })
        return _obj

