TbpWrraper/Src/Base.mqh

82 lignes
2,7 Kio
MQL5
Brut Lien permanent Vue normale Historique

2026-03-08 17:37:22 -05:00
//+------------------------------------------------------------------+
//| Main.mqh |
//| Copyright 2025, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, Niquel Mendoza."
#property link "https://www.mql5.com/es/users/nique_372"
#property strict
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "Defines.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CTbpBase : public CLoggerBase
{
protected:
//--- Variables miembro
string m_api_key;
CJson m_json;
int m_timeout;
public:
CTbpBase(void) : m_api_key(NULL), m_timeout(5000) {}
~CTbpBase(void) {}
//--- Getters \ Setters
//- Apy key
__forceinline string ApyKey() const { return m_api_key; }
void ApyKey(const string& apykey) { m_api_key = apykey; }
//- json
CJson* GetLastJson() { return &m_json; }
//- Timeout
__forceinline int Timeout() const { return m_timeout; }
void Timeout(const int timeout) { m_timeout = timeout; }
//---
bool GetAllClients();
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CTbpBase::GetAllClients()
{
//---
string res_headers;
char data[], result[];
string req_headers = "api-key: " + m_api_key + "\r\n";
const static string url = THE_BOT_PLACE_BASE_URL + "customers/";
//---
const int request = WebRequest(
"GET",
url,
req_headers,
m_timeout,
data,
result,
res_headers
);
//---
const string msg = CharArrayToString(result);
//---
if(request != 200)
{
LogError(StringFormat("Fallo al mandar request, codigo de requeset = %d, result:\n%s", request, msg), FUNCION_ACTUAL);
return false;
}
//---
return m_json.Parse(msg);
}
//+------------------------------------------------------------------+