added command "list" (so far without -status)
This commit is contained in:
+29
@@ -66,7 +66,36 @@ ticket_t Dao::fetch_ticket_create(std::string title, std::string description) {
|
||||
|
||||
|
||||
vector<ticket_t> Dao::fetch_ticket_get_all() {
|
||||
string response;
|
||||
string url = this->base_url + "/tickets";
|
||||
|
||||
CURL *handle = curl_easy_init();
|
||||
|
||||
struct curl_slist* headers = nullptr;
|
||||
headers = curl_slist_append(headers, "Content-Type: application/json");
|
||||
headers = curl_slist_append(headers, ("Authorization: Bearer " + this->api_key).c_str());
|
||||
|
||||
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
|
||||
|
||||
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &response);
|
||||
|
||||
CURLcode rc = curl_easy_perform(handle);
|
||||
|
||||
curl_slist_free_all(headers);
|
||||
curl_easy_cleanup(handle);
|
||||
|
||||
if (rc != CURLE_OK) {
|
||||
throw std::runtime_error(std::string("curl_easy_perform failed: ") + curl_easy_strerror(rc));
|
||||
}
|
||||
|
||||
nlohmann::json j = nlohmann::json::parse(response);
|
||||
|
||||
vector<ticket_t> t = j.get<vector<ticket_t>>();
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
vector<ticket_t> Dao::fetch_ticket_get_by_status(string status) {
|
||||
|
||||
Reference in New Issue
Block a user