# coding: utf-8

"""
Binance Derivatives Trading Portfolio Margin WebSocket Market Streams

OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin WebSocket Market Streams
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Set
from typing_extensions import Self


class Executionreport(BaseModel):
    """
    Executionreport
    """  # noqa: E501

    E: Optional[StrictInt] = Field(default=None, alias="E")
    s: Optional[StrictStr] = None
    c: Optional[StrictStr] = None
    S: Optional[StrictStr] = Field(default=None, alias="S")
    o: Optional[StrictStr] = None
    f: Optional[StrictStr] = None
    q: Optional[StrictStr] = None
    p: Optional[StrictStr] = None
    P: Optional[StrictStr] = Field(default=None, alias="P")
    d: Optional[StrictInt] = None
    F: Optional[StrictStr] = Field(default=None, alias="F")
    g: Optional[StrictInt] = None
    C: Optional[StrictStr] = Field(default=None, alias="C")
    x: Optional[StrictStr] = None
    X: Optional[StrictStr] = Field(default=None, alias="X")
    r: Optional[StrictStr] = None
    i: Optional[StrictInt] = None
    l: Optional[StrictStr] = None
    z: Optional[StrictStr] = None
    L: Optional[StrictStr] = Field(default=None, alias="L")
    n: Optional[StrictStr] = None
    N: Optional[StrictStr] = Field(default=None, alias="N")
    T: Optional[StrictInt] = Field(default=None, alias="T")
    t: Optional[StrictInt] = None
    v: Optional[StrictInt] = None
    I: Optional[StrictInt] = Field(default=None, alias="I")
    w: Optional[StrictBool] = None
    m: Optional[StrictBool] = None
    O: Optional[StrictInt] = Field(default=None, alias="O")
    Z: Optional[StrictStr] = Field(default=None, alias="Z")
    Y: Optional[StrictStr] = Field(default=None, alias="Y")
    Q: Optional[StrictStr] = Field(default=None, alias="Q")
    D: Optional[StrictInt] = Field(default=None, alias="D")
    j: Optional[StrictInt] = None
    J: Optional[StrictInt] = Field(default=None, alias="J")
    W: Optional[StrictInt] = Field(default=None, alias="W")
    V: Optional[StrictStr] = Field(default=None, alias="V")
    u: Optional[StrictInt] = None
    U: Optional[StrictInt] = Field(default=None, alias="U")
    A: Optional[StrictStr] = Field(default=None, alias="A")
    B: Optional[StrictStr] = Field(default=None, alias="B")
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = [
        "E",
        "s",
        "c",
        "S",
        "o",
        "f",
        "q",
        "p",
        "P",
        "d",
        "F",
        "g",
        "C",
        "x",
        "X",
        "r",
        "i",
        "l",
        "z",
        "L",
        "n",
        "N",
        "T",
        "t",
        "v",
        "I",
        "w",
        "m",
        "O",
        "Z",
        "Y",
        "Q",
        "D",
        "j",
        "J",
        "W",
        "V",
        "u",
        "U",
        "A",
        "B",
    ]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of Executionreport from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        excluded_fields: Set[str] = set(
            [
                "additional_properties",
            ]
        )

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Executionreport from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate(
            {
                "E": obj.get("E"),
                "s": obj.get("s"),
                "c": obj.get("c"),
                "S": obj.get("S"),
                "o": obj.get("o"),
                "f": obj.get("f"),
                "q": obj.get("q"),
                "p": obj.get("p"),
                "P": obj.get("P"),
                "d": obj.get("d"),
                "F": obj.get("F"),
                "g": obj.get("g"),
                "C": obj.get("C"),
                "x": obj.get("x"),
                "X": obj.get("X"),
                "r": obj.get("r"),
                "i": obj.get("i"),
                "l": obj.get("l"),
                "z": obj.get("z"),
                "L": obj.get("L"),
                "n": obj.get("n"),
                "N": obj.get("N"),
                "T": obj.get("T"),
                "t": obj.get("t"),
                "v": obj.get("v"),
                "I": obj.get("I"),
                "w": obj.get("w"),
                "m": obj.get("m"),
                "O": obj.get("O"),
                "Z": obj.get("Z"),
                "Y": obj.get("Y"),
                "Q": obj.get("Q"),
                "D": obj.get("D"),
                "j": obj.get("j"),
                "J": obj.get("J"),
                "W": obj.get("W"),
                "V": obj.get("V"),
                "u": obj.get("u"),
                "U": obj.get("U"),
                "A": obj.get("A"),
                "B": obj.get("B"),
            }
        )
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj
