Skip to content

Commit

Permalink
Add first approximation to dlman add/remove goal
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Jul 24, 2018
1 parent 708a543 commit 16026d8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,30 @@ void DownloadManager::RemoveFavorite(string chartkey)
curl_easy_setopt(r->handle, CURLOPT_CUSTOMREQUEST, "DELETE");
}

void DownloadManager::RemoveGoal(string chartkey, float wife, float rate)
{
string req = "user/" + DLMAN->sessionUser + "/goals/" + chartkey+"/"+to_string(wife)+"/"+to_string(rate);
auto done = [](HTTPRequest& req, CURLMsg *) {

};
auto r = SendRequest(req, {}, done);
if (r)
curl_easy_setopt(r->handle, CURLOPT_CUSTOMREQUEST, "DELETE");
}

void DownloadManager::AddGoal(string chartkey, float wife, float rate, DateTime timeAssigned)
{
string req = "user/" + DLMAN->sessionUser + "/goals";
auto done = [](HTTPRequest& req, CURLMsg *) {

};
vector<pair<string, string>> postParams = { make_pair("chartkey", chartkey),
make_pair("rate", to_string(rate)),
make_pair("wife", to_string(wife)),
make_pair("timeAssigned", timeAssigned.GetString()) };
SendRequest(req, postParams, done, true, true);
}

void DownloadManager::RefreshFavourites()
{
string req = "user/" + DLMAN->sessionUser + "/favorites";
Expand Down
3 changes: 3 additions & 0 deletions src/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ class DownloadManager
void RefreshFavourites();
vector<string> favorites;

void AddGoal(string chartkey, float wife, float rate, DateTime timeAssigned);
void RemoveGoal(string chartkey, float wife, float rate);

void EndSessionIfExists(); //Calls EndSession if logged in
void EndSession(); //Sends session destroy request
void StartSession(string user, string pass, function<void(bool loggedIn)> done); //Sends login request if not already logging in
Expand Down

0 comments on commit 16026d8

Please sign in to comment.