# coding: utf-8

"""
    Bluefin API

    Bluefin API

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


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
from bluefin_pro_api_client.models.order_side import OrderSide
from typing import Optional, Set
from typing_extensions import Self

class CreateOrderRequestSignOrderFields(BaseModel):
    """
    CreateOrderRequestSignOrderFields
    """ # noqa: E501
    market_address: StrictStr = Field(description="The market address", alias="marketAddress")
    account_address: StrictStr = Field(description="The account address of the order. May be an account user is authorized for.", alias="accountAddress")
    price_e9: StrictStr = Field(description="The price in base e9 of the asset to be traded. Should always be a number", alias="priceE9")
    quantity_e9: StrictStr = Field(description="The quantity in base e9 of the asset to be traded. Should always be a number", alias="quantityE9")
    side: OrderSide
    leverage_e9: StrictStr = Field(description="The leverage in base e9 of the order to be traded. Should always be a number", alias="leverageE9")
    is_isolated: StrictBool = Field(description="Is this order isolated or cross margin. Note market must be set to the same mode.", alias="isIsolated")
    salt: StrictStr = Field(description="The random generated SALT. Should always be a number")
    expires_at_utc_millis: StrictInt = Field(description="timestamp in millis at which order will expire. Defaults to 1 month for LIMIT orders if not provided", alias="expiresAtUtcMillis")
    signed_at_utc_millis: StrictInt = Field(description="The timestamp in millis at which the request was signed", alias="signedAtUtcMillis")
    __properties: ClassVar[List[str]] = ["marketAddress", "accountAddress", "priceE9", "quantityE9", "side", "leverageE9", "isIsolated", "salt", "expiresAtUtcMillis", "signedAtUtcMillis"]

    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 CreateOrderRequestSignOrderFields 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.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "marketAddress": obj.get("marketAddress"),
            "accountAddress": obj.get("accountAddress"),
            "priceE9": obj.get("priceE9"),
            "quantityE9": obj.get("quantityE9"),
            "side": obj.get("side"),
            "leverageE9": obj.get("leverageE9"),
            "isIsolated": obj.get("isIsolated") if obj.get("isIsolated") is not None else False,
            "salt": obj.get("salt"),
            "expiresAtUtcMillis": obj.get("expiresAtUtcMillis"),
            "signedAtUtcMillis": obj.get("signedAtUtcMillis")
        })
        return _obj


