FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.
C++ ai-agentsalgorithmic-tradingbloomberg-terminalcppfinancefinancial-marketsfintechgood-first-issueinvestmentinvestment-researchmachine-learningopensourcepythonqtquantitative-financestock-markettrading
#pragma once
#include "core/result/Result.h"
#include <QByteArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QMap>
#include <QObject>
#include <QString>
#include <functional>
namespace fincept::services {
/// Thin testing client for the Data Mapping screen's "Test API" button.
///
/// This is a deliberate exception to the no-direct-HTTP rule for screens: the
/// Data Mapping screen lets the *user* type an arbitrary URL/method/body and
/// poke it to see the response shape. Wrapping that flow in a service keeps the
/// network call off the screen, preserves the screen-as-context lifetime model,
/// and centralises method dispatch.
///
/// Not a `Producer` — there is no topic, no cache, no schedule. One shot per
/// user click.
class DataMappingTestClient : public QObject {
Q_OBJECT
public:
using Callback = std::function<void(Result<QJsonDocument>)>;
enum class Method { Get, Post, Put, Delete };
static DataMappingTestClient& instance();
/// Issue a single test request. `context` scopes the callback's lifetime
/// (Qt-style — when context is destroyed, the callback is dropped).
/// `headers` are applied to this request only (see
/// DataNormalizationService::build_request_headers) — they may carry
/// credentials, so never log them.
void test_api(Method method, const QString& url, const QJsonObject& body, const QObject* context,
Callback callback, const QMap<QByteArray, QByteArray>& headers = {});
private:
DataMappingTestClient() = default;
Q_DISABLE_COPY(DataMappingTestClient)
};
} // namespace fincept::services