This commit is contained in:
parent
74dc204f22
commit
b005631d20
41
src/komens.cpp
Normal file
41
src/komens.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include "const.h"
|
||||||
|
#include "helper_funcs.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "net.h"
|
||||||
|
#include <bits/chrono.h>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
#include <curses.h>
|
||||||
|
#include <cwchar>
|
||||||
|
#include <ncurses.h>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <panel.h>
|
||||||
|
#include <string>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using nlohmann::json;
|
||||||
|
|
||||||
|
std::vector<allocation> komens_allocated;
|
||||||
|
|
||||||
|
void komens_page() {
|
||||||
|
current_allocated = &komens_allocated;
|
||||||
|
json resp_from_api;
|
||||||
|
{
|
||||||
|
std::string endpoint = "api/3/komens";
|
||||||
|
resp_from_api = bakaapi::get_data_from_endpoint(endpoint, GET);
|
||||||
|
}
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
/* Initialize curses */
|
||||||
|
initscr();
|
||||||
|
start_color();
|
||||||
|
cbreak();
|
||||||
|
noecho();
|
||||||
|
keypad(stdscr, TRUE);
|
||||||
|
|
||||||
|
/* Initialize all the colors */
|
||||||
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
|
init_pair(i, i, COLOR_BLACK);
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,7 @@ void marks_page() {
|
|||||||
json resp_from_api;
|
json resp_from_api;
|
||||||
{
|
{
|
||||||
std::string endpoint = "api/3/marks";
|
std::string endpoint = "api/3/marks";
|
||||||
resp_from_api = bakaapi::get_data_from_endpoint(endpoint);
|
resp_from_api = bakaapi::get_data_from_endpoint(endpoint, GET);
|
||||||
}
|
}
|
||||||
size_t size_my_wins = resp_from_api["Subjects"].size();
|
size_t size_my_wins = resp_from_api["Subjects"].size();
|
||||||
WINDOW **my_wins = new (std::nothrow) WINDOW *[size_my_wins];
|
WINDOW **my_wins = new (std::nothrow) WINDOW *[size_my_wins];
|
||||||
|
@ -20,12 +20,6 @@
|
|||||||
|
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
// metods
|
|
||||||
enum metod {
|
|
||||||
GET,
|
|
||||||
POST,
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string access_token;
|
std::string access_token;
|
||||||
|
|
||||||
CURL *curl = curl_easy_init();
|
CURL *curl = curl_easy_init();
|
||||||
@ -159,7 +153,7 @@ void is_access_token_empty() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// supports all endpoints that only require access_token
|
// supports all endpoints that only require access_token
|
||||||
json get_data_from_endpoint(std::string &endpoint,
|
json get_data_from_endpoint(std::string &endpoint, metod metod,
|
||||||
std::string additional_data) {
|
std::string additional_data) {
|
||||||
is_access_token_empty();
|
is_access_token_empty();
|
||||||
access_token_refreshed:
|
access_token_refreshed:
|
||||||
|
@ -5,12 +5,19 @@
|
|||||||
#ifndef _ba_ne_hg_
|
#ifndef _ba_ne_hg_
|
||||||
#define _ba_ne_hg_
|
#define _ba_ne_hg_
|
||||||
|
|
||||||
|
// metods
|
||||||
|
enum metod {
|
||||||
|
GET,
|
||||||
|
POST,
|
||||||
|
};
|
||||||
|
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
extern CURL *curl;
|
extern CURL *curl;
|
||||||
namespace bakaapi {
|
namespace bakaapi {
|
||||||
void login(std::string username, std::string password);
|
void login(std::string username, std::string password);
|
||||||
void refresh_access_token();
|
void refresh_access_token();
|
||||||
json get_data_from_endpoint(std::string &endpoint, std::string data = "");
|
json get_data_from_endpoint(std::string &endpoint, metod metod,
|
||||||
|
std::string additional_data = "");
|
||||||
} // namespace bakaapi
|
} // namespace bakaapi
|
||||||
#endif
|
#endif
|
@ -100,7 +100,8 @@ reload_for_new_week:
|
|||||||
std::string date_string = "date=" + date_stringstream.str();
|
std::string date_string = "date=" + date_stringstream.str();
|
||||||
std::string endpoint = "api/3/timetable/actual";
|
std::string endpoint = "api/3/timetable/actual";
|
||||||
|
|
||||||
json resp_from_api = bakaapi::get_data_from_endpoint(endpoint, date_string);
|
json resp_from_api =
|
||||||
|
bakaapi::get_data_from_endpoint(endpoint, GET, date_string);
|
||||||
|
|
||||||
// this may be unnecessary but i dont have enaugh data to test it
|
// this may be unnecessary but i dont have enaugh data to test it
|
||||||
// it sorts the hours by start time
|
// it sorts the hours by start time
|
||||||
|
Loading…
x
Reference in New Issue
Block a user