All files / src/models realtime-data-message.model.ts

100% Statements 27/27
100% Branches 2/2
100% Functions 1/1
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 668x 8x 8x 8x         8x 8x 8x 8x 8x         8x     8x       8x         8x   8x     8x     8x         8x     8x           8x               8x       8x    
import {enumProperty, model, property} from "@waytrade/microservice-core";
import {AccountSummary} from "./account-summary.model";
import {MarketData} from "./market-data.model";
import {Position} from "./position.model";
 
/**
 * Type of a real-time data message.
 */
export enum RealtimeDataMessageType {
  Subscribe = "subscribe",
  Unsubscribe = "unsubscribe",
  Publish = "publish",
  Unpublish = "unpublish",
}
 
/** Payload of a real-time data error message. */
@model("Payload of a real-time data error message.")
export class RealtimeDataError {
  /** The error code. */
  @property("The error code.")
  code?: number;
 
  /** The error description. */
  @property("The error description")
  desc?: string;
}
 
/** Payload of a real-time data message. */
@model("Payload of a message on the live-data stream.")
export class RealtimeDataMessagePayload {
  @property("Update on the account summary.")
  accountSummary?: AccountSummary;
 
  @property("Updated position.")
  position?: Position;
 
  @property("Updated market data.")
  marketdata?: MarketData;
}
 
/** A message on the real-time data stream. */
@model("A message on the real-time data stream.")
export class RealtimeDataMessage {
  /** The message topic. */
  @property("The message topic.")
  topic!: string;
 
  @property(
    "If valid, this a error mesaage and this attribute provides details " +
      "about the error",
  )
  error?: RealtimeDataError;
 
  /** The message type. 'publish' if not specified. */
  @enumProperty(
    "RealtimeDataMessageType",
    RealtimeDataMessageType,
    "The message type.  'publish' if not specified.",
  )
  type?: RealtimeDataMessageType;
 
  /** The message data payload. */
  @property("The message data payload.")
  data?: RealtimeDataMessagePayload;
}