LongPort OpenAPI C++ SDK
config.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <optional>
4 #include <string>
5 #include <utility>
6 
7 #include "async_result.hpp"
8 #include "status.hpp"
9 #include "types.hpp"
10 
11 typedef struct lb_config_t lb_config_t;
12 
13 namespace longport {
14 
15 class Config
16 {
17 private:
18  lb_config_t* config_;
19 
20 public:
21  Config();
22  Config(lb_config_t* config);
23  Config(const Config&) = delete;
24  Config(Config&& other);
25 
41  Config(const std::string& app_key,
42  const std::string& app_secret,
43  const std::string& access_token,
44  const std::optional<std::string>& http_url,
45  const std::optional<std::string>& quote_ws_url,
46  const std::optional<std::string>& trade_ws_url,
47  const std::optional<Language>& language,
48  bool enable_overnight,
49  const std::optional<PushCandlestickMode>& push_candlestick_mode);
50 
57  Config(const std::string& app_key,
58  const std::string& app_secret,
59  const std::string& access_token)
60  : Config(app_key,
61  app_secret,
62  access_token,
63  std::nullopt,
64  std::nullopt,
65  std::nullopt,
66  std::nullopt,
67  false,
68  std::nullopt)
69  {
70  }
71 
73 
74  operator const lb_config_t*() const;
75 
96  static Status from_env(Config& config);
97 
99  void refresh_access_token(int64_t expired_at,
101 };
102 
103 } // namespace longport
Definition: config.hpp:16
Config(const std::string &app_key, const std::string &app_secret, const std::string &access_token, const std::optional< std::string > &http_url, const std::optional< std::string > &quote_ws_url, const std::optional< std::string > &trade_ws_url, const std::optional< Language > &language, bool enable_overnight, const std::optional< PushCandlestickMode > &push_candlestick_mode)
Config(const Config &)=delete
Config(const std::string &app_key, const std::string &app_secret, const std::string &access_token)
Definition: config.hpp:57
static Status from_env(Config &config)
Config(lb_config_t *config)
void refresh_access_token(int64_t expired_at, AsyncCallback< void *, std::string > callback)
Gets a new access_token
Config(Config &&other)
Definition: status.hpp:9
struct lb_config_t lb_config_t
Definition: config.hpp:11
Definition: async_result.hpp:7
std::function< void(AsyncResult< Ctx, T >)> AsyncCallback
Definition: async_result.hpp:39