From 0bef191acd5a77544852e6a3daae2df05bd34a31 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Wed, 19 Jan 2022 11:20:45 +0000
Subject: [PATCH] Reformat and change send to x-www-form-urlencoded

---
 json.hpp |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/json.hpp b/json.hpp
index adcb147..e896869 100644
--- a/json.hpp
+++ b/json.hpp
@@ -25,10 +25,11 @@
 	BROKER_REQUEST,
 	BROKER_ACK,
 	BROKER_CONFIRM,
+	ERROR,
 	NONE
 };
 
-enum TradeTypeEnum { BUY_AGGRESSOR, SELL_AGGRESSOR };
+enum TradeTypeEnum { BUY_AGGRESSOR, SELL_AGGRESSOR, BROKER_TRADE };
 
 struct Message {
 	MessageTypes type;
@@ -36,6 +37,12 @@
 	Message(MessageTypes type, std::string product);
 	Message();
 	virtual ~Message() = default;
+};
+
+struct ErrorMessage : public Message {
+	std::string message;
+	ErrorMessage(std::string message);
+	std::string as_string();
 };
 
 struct FromExchange : public Message {
@@ -75,6 +82,7 @@
 	                std::chrono::nanoseconds expiry, double aggFee,
 	                double pasFee, double broFee, uint64_t sequence,
 	                double timestamp);
+	std::string as_string();
 };
 
 struct SettleMessage : public FromExchange {
@@ -84,6 +92,7 @@
 	SettleMessage(MessageTypes type, std::string product,
 	              std::string stationName, std::chrono::nanoseconds expiry,
 	              double price, uint64_t sequence, double timestamp);
+	std::string as_string();
 };
 
 struct AddMessage : public ToExchange {
@@ -101,9 +110,12 @@
 	double price;
 	uint64_t filled;
 	uint64_t resting;
+	std::string owner;
 	AddedMessage(MessageTypes type, std::string product, std::string id,
 	             book::OrderSideEnum side, double price, uint64_t filled,
-	             uint64_t resting, uint64_t sequence, double timestamp);
+	             uint64_t resting, std::string owner, uint64_t sequence,
+	             double timestamp);
+	std::string as_string();
 };
 
 struct DeleteMessage : public ToExchange {
@@ -118,12 +130,14 @@
 	DeletedMessage(MessageTypes type, std::string product, std::string id,
 	               book::OrderSideEnum side, uint64_t sequence,
 	               double timestamp);
+	std::string as_string();
 };
 
 struct RejectMessage : public FromExchange {
 	std::string error;
 	RejectMessage(MessageTypes type, std::string product, std::string error,
 	              uint64_t sequence, double timestamp);
+	std::string as_string();
 };
 
 struct TradeMessage : public FromExchange {
@@ -139,12 +153,14 @@
 	             TradeTypeEnum tradeType, std::string passiveOrder,
 	             uint64_t passiveOrderRemaining, uint64_t sequence,
 	             double timestamp);
+	std::string as_string();
 };
 
 struct BrokerRequest : public Broker {
 	BrokerRequest(MessageTypes type, std::string product, double price,
 	              book::OrderSideEnum side, uint64_t volume,
 	              std::string counterparty);
+	std::string as_string();
 };
 
 struct BrokerAck : public Broker {
@@ -155,6 +171,7 @@
 	          book::OrderSideEnum side, uint64_t volume,
 	          std::string counterparty, std::string id,
 	          std::string brokerTradeStatus, std::string owner);
+	std::string as_string();
 };
 
 struct BrokerConfirm : public Broker {
@@ -162,6 +179,7 @@
 	BrokerConfirm(MessageTypes type, std::string product, double price,
 	              book::OrderSideEnum side, uint64_t volume,
 	              std::string counterparty, std::string id);
+	std::string as_string();
 };
 
 std::queue<Message*> parse(std::string& str);

--
Gitblit v1.9.3