curl_stocks
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1
9#ifndef API_H
10#define API_H
11
12#include <stddef.h> // for size_t
13#include <string> // for string
14
15#include "curl.h" // for CURL, CURLcode
16
33size_t
34callback(void *contents,
35 size_t size,
36 size_t nmemb,
37 std::string *s); // Member function pointer is different than
38 // ordinary function pointer
39
43class Api
44{
45private:
46 CURL *api_handle;
47 CURLcode curl_result;
49 std::string apikey;
50 std::string base_url;
52public:
56 Api();
63 Api(std::string apikey, std::string cert_path);
64
72 void fetch(std::string const &function,
73 std::string const &symbol,
74 std::string &stock_data);
75
79 ~Api();
80};
81
82#endif /* ifndef API_H */
83/* @}*/
Wraps alphavantage API. Fetches stock data using curl.
Definition api.h:44
size_t callback(void *contents, size_t size, size_t nmemb, std::string *s)
A call back function to be used with curl.
Definition api.cpp:7
Api()
Default constructor.
Definition api.cpp:14
~Api()
Destructor cleans up curl objects.
Definition api.cpp:65
void fetch(std::string const &function, std::string const &symbol, std::string &stock_data)
Fetch stock data.
Definition api.cpp:30