#ifndef COINBASE_SUBSCRIPTION_H #define COINBASE_SUBSCRIPTION_H #include #include #include #include #include #include #include #include #include //------------------------------------------------------------------------------ namespace coinbase { static Json::Value GetSubscribeMsg() { Json::Value root; /* Subscribe { "type": "subscribe", "product_ids": ["ETH-USD", "ETH-EUR"], "channel": "level2", "jwt": "abcd..", } */ std::string channel_name = "level2"; std::vector crypto_ids = {"BTC-USD"}; root["type"] = Json::Value("subscribe"); Json::Value product_ids(Json::ValueType::arrayValue); size_t index = 0; for (auto i: crypto_ids) { product_ids.insert(index++, i); } root["product_ids"] = product_ids; root["channel"] = "level2"; std::system("bash -c \"/home/wds/dev/coinbase/gen_jwt.py > /home/wds/dev/coinbase/jwt.txt\""); std::string jwt; std::ifstream ifstrm("/home/wds/dev/coinbase/jwt.txt"); ifstrm >> jwt; root["jwt"] = jwt; return root; } } #endif