# generated by datamodel-codegen:
#   filename:  Oms/Cancel.json

from __future__ import annotations

from typing import Annotated, Optional

from msgspec import Meta, Struct

from .. import definitions


class Cancel(Struct, omit_defaults=True):
    id: definitions.OrderId
    o: definitions.CancelStatus
    tn: Annotated[int, Meta(ge=0)]
    ts: int
    xid: str
    r: Optional[str] = None

    # Constructor that takes all field titles as arguments for convenience
    @classmethod
    def new(
        cls,
        id: definitions.OrderId,
        o: definitions.CancelStatus,
        tn: int,
        ts: int,
        xid: str,
        r: Optional[str] = None,
    ):
        return cls(
            id,
            o,
            tn,
            ts,
            xid,
            r,
        )

    def __str__(self) -> str:
        return f"Cancel(id={self.id},o={self.o},tn={self.tn},ts={self.ts},xid={self.xid},r={self.r})"
