This commit is contained in:
tanghc
2021-02-25 18:11:01 +08:00
parent 419f041786
commit d223659376
13 changed files with 3459 additions and 6697 deletions

View File

@@ -2,18 +2,12 @@
#define SDK_CXX_OPENCLIENT_H
#include <string>
#include <json/json.h>
#include "httplib.h"
#include "../request/BaseRequest.h"
#include "../thirdparty/CJsonObject/CJsonObject.hpp"
using namespace std;
struct HostInfo {
string host;
int port;
char *path;
};
/**
* 请求客户端
*/
@@ -21,6 +15,7 @@ class OpenClient {
private:
/** 应用id */
string appId;
string url;
/** 私钥文件路径 */
string privateKeyFilePath;
@@ -39,19 +34,17 @@ public:
* @param token token
* @return 返回响应结果
*/
neb::CJsonObject execute(BaseRequest *request, const string& token);
Json::Value execute(BaseRequest *request, const string& token);
/**
* 发送请求
* @param request 请求对象BaseRequest的子类
* @return 返回响应结果
*/
neb::CJsonObject execute(BaseRequest *request);
Json::Value execute(BaseRequest *request);
private:
HostInfo hostInfo;
map<string, string> buildParams(BaseRequest *request, const string& token);
static httplib::MultipartFormDataItems
@@ -59,7 +52,9 @@ private:
static httplib::Params getParams(map<string, string> params);
static neb::CJsonObject parseResponse(const string& responseBody,BaseRequest *request);
static string getQuery(map<string, string> params);
static Json::Value parseResponse(const string& responseBody,BaseRequest *request);
};