Fixed search command not working properly

This commit is contained in:
David Allen 2023-07-02 17:28:18 -06:00
parent 8a7ada342a
commit fb7efdd7a4
10 changed files with 143 additions and 120 deletions

View file

@ -39,28 +39,36 @@ namespace gdpm::rest_api{
enum type_e: int { any = 0, addon, project };
enum support_e: int { all = 0, official, community, testing };
enum sort_e: int { none = 0, rating, cost, name, updated };
/* TODO: Include all information with categories and not just type*/
struct category{
int id;
int type;
string name;
};
using categories = std::vector<category>;
struct request_params{
int type ;
int type;
int category;
int support;
string user;
string godot_version;
int max_results;
string user = "";
string cost = "";
string godot_version = "4.0";
int max_results = 500;
int page;
int offset;
int sort;
bool reverse;
int verbose;
};
request_params make_from_config(const config::context& config);
request_params make_request_params(type_e type = GDPM_DEFAULT_ASSET_TYPE, int category = GDPM_DEFAULT_ASSET_CATEGORY, support_e support = GDPM_DEFAULT_ASSET_SUPPORT, const string& user = GDPM_DEFAULT_ASSET_USER, const string& godot_version = GDPM_DEFAULT_ASSET_GODOT_VERSION, int max_results = GDPM_DEFAULT_ASSET_MAX_RESULTS, int page = GDPM_DEFAULT_ASSET_PAGE, sort_e sort = GDPM_DEFAULT_ASSET_SORT, bool reverse = GDPM_DEFAULT_ASSET_REVERSE, int verbose = GDPM_DEFAULT_ASSET_VERBOSE);
string to_json(const rapidjson::Document& doc);
string to_string(type_e type);
string to_string(support_e support);
string to_string(sort_e sort);
void _print_params(const request_params& params, const string& filter);
error print_params(const request_params& params, const string& filter = "");
error print_asset(const request_params& params, const string& filter = "", const print::style& style = print::style::list);
rapidjson::Document _parse_json(const string& r, int verbose = 0);
string _prepare_request(const string& url, const request_params& context, const string& filter);
@ -69,7 +77,6 @@ namespace gdpm::rest_api{
bool logout();
rapidjson::Document configure(const string& url = constants::HostUrl, type_e type = any, int verbose = 0);
rapidjson::Document get_assets_list(const string& url = constants::HostUrl, type_e type = GDPM_DEFAULT_ASSET_TYPE, int category = GDPM_DEFAULT_ASSET_CATEGORY, support_e support = GDPM_DEFAULT_ASSET_SUPPORT, const string& filter = GDPM_DEFAULT_ASSET_FILTER, const std::string& user = GDPM_DEFAULT_ASSET_USER, const std::string& godot_version = GDPM_DEFAULT_ASSET_GODOT_VERSION, int max_results = GDPM_DEFAULT_ASSET_MAX_RESULTS, int page = GDPM_DEFAULT_ASSET_PAGE, sort_e sort = GDPM_DEFAULT_ASSET_SORT, bool reverse = GDPM_DEFAULT_ASSET_REVERSE, int verbose = GDPM_DEFAULT_ASSET_VERBOSE);
rapidjson::Document get_assets_list(const string& url, const request_params& params = {}, const string& filter = "");
rapidjson::Document get_asset(const string& url, int asset_id, const request_params& params = {}, const string& filter = "");
bool delete_asset(int asset_id); // ...for moderators