2026-10-13 07:37:43 -05:00 | | | //+------------------------------------------------------------------+
|
2026-05-07 16:15:15 -05:00 | | | //| Customers.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
|
| | |
|
| | | #ifndef TBPWRRAPER_SRC_MQL5_CUSTOMERS_MQH
|
| | | #define TBPWRRAPER_SRC_MQL5_CUSTOMERS_MQH
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | #include "Base.mqh"
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-06-03 12:24:19 -05:00 | | | namespace TSN
|
| | | {
|
2026-05-07 16:15:15 -05:00 | | | class CAddtionalDataTbpAccountLoggin : public ITbpAdditionalData
|
| | | {
|
| | | public:
|
| | | CAddtionalDataTbpAccountLoggin(void) {}
|
| | | ~CAddtionalDataTbpAccountLoggin(void) {}
|
| | | string Get() override final { return string(AccountInfoInteger(ACCOUNT_LOGIN)); }
|
| | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | class CTbpCustomers : public CTbpBase
|
| | | {
|
| | | private:
|
| | | bool m_delete_aditional_data;
|
| | | ITbpAdditionalData* m_aditional_data;
|
| | | string m_software_id;
|
| | |
|
| | | public:
|
| | | CTbpCustomers(void) : m_software_id(NULL), m_aditional_data(NULL), m_delete_aditional_data(true) {}
|
| | | ~CTbpCustomers(void) { if(m_delete_aditional_data && CheckPointer(m_aditional_data) == POINTER_DYNAMIC) delete m_aditional_data; }
|
| | |
|
| | | //--- Getters \ Setters
|
| | | // Dato adicional
|
| | | ITbpAdditionalData* AdditionalData() { return m_aditional_data; }
|
| | | void AdditionalData(ITbpAdditionalData* ptr, bool delete_on_destructor);
|
| | |
|
| | | // Software id
|
| | | string SoftwareId() const { return m_software_id; }
|
| | | void SoftwareId(const string& software_id) { m_software_id = software_id; }
|
| | |
|
| | | //---
|
| | | // Nota importante
|
| | | // Las funciones reontanr un bool de exito o falso en la llamda \ parse json como tal no el valor
|
| | | // Para eso consulten el json o hay funciones que ya trean un &out
|
2026-10-13 07:37:43 -05:00 | | | // En caso de fallo consultar LastErr() y LastHttp()
|
2026-05-07 16:15:15 -05:00 | | |
|
| | | // Get customers of a software
|
| | | // Lista clientes de un software concreto.
|
| | | bool GetCustomersSotfware(); // Para el resultado consultar el json
|
| | |
|
| | | //---
|
| | | // User has software
|
| | | // Verifica licencia incluyendo datos adicionales.
|
| | | bool UserHasSoftware(const string& userd_id, bool &out); // Resultado en out
|
| | |
|
| | | //---
|
| | | // User has software (no additional data)
|
| | | // Comprueba si un usuario posee una licencia sin la necesidad de enviar un dato adicional.
|
| | | // ATENCIÓN: este endpoint no valida datos adicionales asociados a la licencia, por lo que puede si un
|
| | | // tercero posee el userId podrá usar tu bot. Este endpoint está pensado para la reventa de bots.
|
| | | bool UserHastSoftwareNoaAdditionalData(const string& userd_id, bool &out); // Resultado en out
|
| | |
|
| | |
|
| | | //---
|
| | | // User has software (Telegram)
|
| | | // Comprueba licencia usando identificador de Telegram.
|
| | | bool UserHastSoftwareTelegram(const string& telegram_user, bool& out); // Resultado en out
|
| | |
|
| | | //---
|
| | | // First demo download
|
| | | // Comprueba si es la primera descarga de demo de un software.
|
| | | bool FirstDemoDowlandSoftware(const string& user_id, datetime& out); // Resultado en out
|
| | |
|
| | |
|
| | | //---
|
| | | // Check job delivery access
|
| | | // Verifica si un usuario puede acceder a la entrega de un trabajo.
|
| | | // bool CheckJobDeliveryAccess();
|
| | |
|
| | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | void CTbpCustomers::AdditionalData(ITbpAdditionalData *ptr, bool delete_on_destructor)
|
| | | {
|
| | | m_aditional_data = ptr;
|
| | | m_delete_aditional_data = delete_on_destructor;
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | bool CTbpCustomers::GetCustomersSotfware(void)
|
| | | {
|
2026-10-13 07:37:43 -05:00 | | | const string url = THE_BOT_PLACE_API_CUSTOMERS + m_software_id;
|
| | | return SendAndParse(url);
|
2026-05-07 16:15:15 -05:00 | | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | bool CTbpCustomers::UserHasSoftware(const string& userd_id, bool &out)
|
| | | {
|
| | | // URL: https://europe-west2-thebotplace.cloudfunctions.net/api/v1/api/customers/user-has-product?userId=<userId>&softwareId=<softwareId>&additional=<additional>
|
| | | const string url = StringFormat("%scustomers/user-has-product?userId=%s&softwareId=%s&additional=%s",
|
| | | THE_BOT_PLACE_BASE_URL, userd_id, m_software_id, m_aditional_data.Get());
|
| | |
|
| | | //---
|
2026-10-13 07:37:43 -05:00 | | | if(!Send(url))
|
2026-05-07 16:15:15 -05:00 | | | return false;
|
2026-06-03 12:24:19 -05:00 | | |
|
2026-10-13 07:37:43 -05:00 | | | //--- No hace falta parsear, trabajamos directo sobre el raw
|
2026-07-21 07:45:54 -05:00 | | | out = (CharArrayToString(m_json.m_raw) == "true");
|
2026-05-07 16:15:15 -05:00 | | | return true;
|
| | | }
|
| | | //+------------------------------------------------------------------+
|
| | | bool CTbpCustomers::UserHastSoftwareNoaAdditionalData(const string &userd_id, bool &out)
|
| | | {
|
| | | // URL: https://europe-west2-thebotplace.cloudfunctions.net/api/v1/api/customers/user-has-product-no-additional?userId=<userId>&softwareId=<softwareId>
|
| | | const string url = StringFormat("%scustomers/user-has-product-no-additional?userId=%s&softwareId=%s",
|
| | | THE_BOT_PLACE_BASE_URL, userd_id, m_software_id);
|
| | |
|
| | | //---
|
2026-10-13 07:37:43 -05:00 | | | if(!Send(url))
|
2026-05-07 16:15:15 -05:00 | | | return false;
|
2026-06-03 12:24:19 -05:00 | | |
|
| | | //---
|
2026-07-21 07:45:54 -05:00 | | | out = (CharArrayToString(m_json.m_raw) == "true");
|
2026-05-07 16:15:15 -05:00 | | | return true;
|
| | | }
|
| | | //+------------------------------------------------------------------+
|
| | | bool CTbpCustomers::UserHastSoftwareTelegram(const string &telegram_user, bool &out)
|
| | | {
|
| | | // URL: https://europe-west2-thebotplace.cloudfunctions.net/api/v1/api/customers/user-has-product-by-telegram?telegram=<telegram>&softwareId=<softwareId>&additional=<additional>
|
| | | // quite lo de adicional al parecer es obligatorio: https://documenter.getpostman.com/view/19130707/2s9XxztsWt
|
2026-10-13 07:37:43 -05:00 | | | const string url = StringFormat("%scustomers/user-has-product-by-telegram?telegram=%s&softwareId=%s&additional=%s",
|
| | | THE_BOT_PLACE_BASE_URL, telegram_user, m_software_id, m_aditional_data.Get());
|
2026-05-07 16:15:15 -05:00 | | |
|
| | | //---
|
2026-10-13 07:37:43 -05:00 | | | if(!Send(url))
|
2026-05-07 16:15:15 -05:00 | | | return false;
|
2026-06-03 12:24:19 -05:00 | | |
|
| | | //---
|
2026-07-21 07:45:54 -05:00 | | | out = (CharArrayToString(m_json.m_raw) == "true");
|
2026-05-07 16:15:15 -05:00 | | | return true;
|
| | | }
|
| | | //+------------------------------------------------------------------+
|
| | | bool CTbpCustomers::FirstDemoDowlandSoftware(const string &user_id, datetime &out)
|
| | | {
|
| | | // URL: https://europe-west2-thebotplace.cloudfunctions.net/api/v1/api/software/first-demo-download?userId=<userId>&softwareId=<softwareId>
|
| | | const string url = StringFormat("%ssoftware/first-demo-download?userId=%s&softwareId=%s",
|
| | | THE_BOT_PLACE_BASE_URL, user_id, m_software_id);
|
| | |
|
| | | //---
|
2026-10-13 07:37:43 -05:00 | | | if(!Send(url))
|
2026-05-07 16:15:15 -05:00 | | | return false;
|
2026-06-03 12:24:19 -05:00 | | |
|
| | | //---
|
2026-07-21 07:45:54 -05:00 | | | out = datetime(long(CharArrayToString(m_json.m_raw))); // Viene en unix
|
2026-05-07 16:15:15 -05:00 | | | return true;
|
| | | }
|
2026-06-03 12:24:19 -05:00 | | | }
|
2026-05-07 16:15:15 -05:00 | | | //+------------------------------------------------------------------+
|
| | | #endif // TBPWRRAPER_SRC_MQL5_CUSTOMERS_MQH
|