Longbridge OpenAPI C++ SDK
http_client.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <optional>
5 #include <string>
6 
7 #include "async_result.hpp"
8 #include "oauth.hpp"
9 #include "status.hpp"
10 
11 typedef struct lb_http_client_t lb_http_client_t;
12 
13 namespace longbridge {
14 
15 struct HttpResult
16 {
17  const char* response_body;
18 
21  {
22  }
23 };
24 
26 {
27 private:
28  lb_http_client_t* http_client_;
29 
30 public:
32  HttpClient(HttpClient&) = delete;
33  HttpClient(HttpClient&&) noexcept;
35 
44  static HttpClient from_apikey(const std::string& app_key,
45  const std::string& app_secret,
46  const std::string& access_token,
47  const std::optional<std::string>& http_url = std::nullopt);
48 
55 
62  static HttpClient from_oauth(const OAuth& oauth,
63  const std::optional<std::string>& http_url = std::nullopt);
64 
68  void request(const std::string& method,
69  const std::string& path,
70  const std::optional<std::map<std::string, std::string>>& headers,
71  const std::optional<std::string>& body,
72  AsyncCallback<void*, HttpResult> callback);
73 };
74 
75 }
Definition: http_client.hpp:26
static HttpClient from_apikey(const std::string &app_key, const std::string &app_secret, const std::string &access_token, const std::optional< std::string > &http_url=std::nullopt)
void request(const std::string &method, const std::string &path, const std::optional< std::map< std::string, std::string >> &headers, const std::optional< std::string > &body, AsyncCallback< void *, HttpResult > callback)
HttpClient(HttpClient &&) noexcept
HttpClient(HttpClient &)=delete
static HttpClient from_apikey_env(Status &status)
static HttpClient from_oauth(const OAuth &oauth, const std::optional< std::string > &http_url=std::nullopt)
Definition: oauth.hpp:19
Definition: status.hpp:19
struct lb_http_client_t lb_http_client_t
Definition: http_client.hpp:11
Definition: async_result.hpp:8
std::function< void(AsyncResult< Ctx, T >)> AsyncCallback
Definition: async_result.hpp:48
Definition: http_client.hpp:16
HttpResult(const char *response_body)
Definition: http_client.hpp:19
const char * response_body
Definition: http_client.hpp:17