mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
- 新增ISV用户平台
- 新增门户网站(portal) - 新增`C++`,`Rust`语言SDK
This commit is contained in:
66
sop-sdk/sdk-c++/common/OpenClient.h
Normal file
66
sop-sdk/sdk-c++/common/OpenClient.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#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
|
Reference in New Issue
Block a user