You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SOP/sop-sdk/sdk-c++/common/OpenClient.h

67 lines
1.5 KiB

#ifndef SDK_CXX_OPENCLIENT_H
#define SDK_CXX_OPENCLIENT_H
#include <string>
#include "httplib.h"
#include "../request/BaseRequest.h"
#include "../thirdparty/CJsonObject/CJsonObject.hpp"
using namespace std;
struct HostInfo {
string host;
int port;
char *path;
};
/**
*
*/
class OpenClient {
private:
/** 应用id */
string appId;
/** 私钥文件路径 */
string privateKeyFilePath;
public:
/**
*
* @param appId ID
* @param privateKeyFilePath
* @param url URL
*/
OpenClient(const string &appId, const string &privateKeyFilePath, const string &url);
/**
*
* @param request BaseRequest的子类
* @param token token
* @return
*/
neb::CJsonObject execute(BaseRequest *request, const string& token);
/**
*
* @param request BaseRequest的子类
* @return
*/
neb::CJsonObject execute(BaseRequest *request);
private:
HostInfo hostInfo;
map<string, string> buildParams(BaseRequest *request, const string& token);
static httplib::MultipartFormDataItems
getMultipartFormDataItems(map<string, string> allParams, vector<FileInfo> fileInfoList);
static httplib::Params getParams(map<string, string> params);
static neb::CJsonObject parseResponse(const string& responseBody,BaseRequest *request);
};
#endif //SDK_CXX_OPENCLIENT_H