public inbox for [email protected]
 help / color / mirror / Atom feed
From: Alviro Iskandar Setiawan <[email protected]>
To: Ammar Faizi <[email protected]>,
	Michael William Jonathan <[email protected]>
Cc: Alviro Iskandar Setiawan <[email protected]>,
	Ravel Kevin Ethan <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [RFC PATCH 2/9] gwarnt: Create initial P2P ad data structure
Date: Tue, 10 Sep 2024 23:44:07 +0200	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Create an abstraction to make P2P ad uniform across multiple
crypto currency exchanges.

Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
---
 Makefile              |  3 ++-
 src/gwarnt/p2p_ad.cpp | 31 +++++++++++++++++++++++++++++++
 src/gwarnt/p2p_ad.hpp | 31 +++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 src/gwarnt/p2p_ad.cpp
 create mode 100644 src/gwarnt/p2p_ad.hpp

diff --git a/Makefile b/Makefile
index ba50192..7dbfb71 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,8 @@ C_SOURCES	:=
 CXX_SOURCES	:= \
 	src/gwarnt/entry.cpp \
 	src/gwarnt/helpers.cpp \
-	src/gwarnt/net.cpp
+	src/gwarnt/net.cpp \
+	src/gwarnt/p2p_ad.cpp
 
 C_OBJECTS	:= $(C_SOURCES:.c=.o)
 CXX_OBJECTS	:= $(CXX_SOURCES:.cpp=.o)
diff --git a/src/gwarnt/p2p_ad.cpp b/src/gwarnt/p2p_ad.cpp
new file mode 100644
index 0000000..7e8e0e5
--- /dev/null
+++ b/src/gwarnt/p2p_ad.cpp
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <gwarnt/p2p_ad.hpp>
+#include <cstddef>
+
+namespace gwarnt {
+
+std::string p2p_ad::dump(void) const
+{
+	std::string ret = "";
+	size_t i = 0;
+
+	ret += "ad_id: " + ad_id_ + "\n";
+	ret += "merchant_name: " + merchant_name_ + "\n";
+	ret += "fiat: " + fiat_ + "\n";
+	ret += "crypto: " + crypto_ + "\n";
+	ret += "trade_type: " + trade_type_ + "\n";
+	ret += "exchange: " + exchange_ + "\n";
+	ret += "price: " + std::to_string(price_) + "\n";
+	ret += "min_amount: " + std::to_string(min_amount_) + "\n";
+	ret += "max_amount: " + std::to_string(max_amount_) + "\n";
+	ret += "tradable_amount: " + std::to_string(tradable_amount_) + "\n";
+
+	ret += "methods: ";
+	for (const auto &m : methods_)
+		ret += (i++ > 0 ? ", " : "") + m;
+
+	return ret;
+}
+
+} /* namespace gwarnt */
diff --git a/src/gwarnt/p2p_ad.hpp b/src/gwarnt/p2p_ad.hpp
new file mode 100644
index 0000000..85799b2
--- /dev/null
+++ b/src/gwarnt/p2p_ad.hpp
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#ifndef GWARNT__P2PDS_HPP
+#define GWARNT__P2PDS_HPP
+
+#include <vector>
+#include <string>
+
+namespace gwarnt {
+
+struct p2p_ad {
+	std::string	ad_id_;
+	std::string	merchant_name_;
+	std::string	fiat_;
+	std::string	crypto_;
+	std::string	trade_type_;
+	std::string	exchange_;
+
+	double	price_;
+	double	min_amount_;
+	double	max_amount_;
+	double	tradable_amount_;
+
+	std::vector<std::string>	methods_;
+
+	std::string dump(void) const;
+};
+
+} /* namespace gwarnt */
+
+#endif /* #ifndef GWARNT__P2PDS_HPP */
-- 
Alviro Iskandar Setiawan


  reply	other threads:[~2024-09-10 21:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10 21:44 [RFC PATCH 0/9] Introducing GNU/Weeb Arbitrage Opportunity Notification Bot Alviro Iskandar Setiawan
2024-09-10 21:44 ` Alviro Iskandar Setiawan [this message]
2024-09-10 21:44 ` [RFC PATCH 3/9] gwarnt: p2p: Add P2P Binance Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 4/9] gwarnt: p2p: Add P2P OKX Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 5/9] gwarnt: Create function to find arbitrage opportunities Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 6/9] gwarnt: p2p/binance: Fix invalid page Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 7/9] gwarnt: Create the initial example Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 8/9] gwarnt: Add README file Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 9/9] gwarnt: Add Telegram bot Alviro Iskandar Setiawan
2024-09-10 22:21 ` [RFC PATCH 0/9] Introducing GNU/Weeb Arbitrage Opportunity Notification Bot Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240910214414.3401712-3-alviro.iskandar@gnuweeb.org \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox