//handles fetching a list of craft from KerbalX, processes the response for certain craft attributes and //assembles a Dictionary which is passed into the callback. private void fetch_craft_list(string path, CraftListCallback callback) { HTTP.get(url_to(path)).send(this, (resp, status_code) => { if (status_code == 200) { callback(process_craft_data( resp, "id", "name", "version", "url", "type", "part_count", "crew_capacity", "cost", "mass", "stages", "created_at", "updated_at", "description" ), status_code); } else { callback(null, status_code); } }); }
//Get the craft the user has uploaded (really rather similar to fetch_existing_craft, just slightly different info, will try to unify these two at some point) public void fetch_users_craft(CraftListCallback callback) { fetch_craft_list("api/user_craft.json", callback); }
//Get the craft the user has previously downloaded public void fetch_past_downloads(CraftListCallback callback) { fetch_craft_list("api/past_downloads.json", callback); }
//Get the craft the user has favourited public void fetch_favoutite_craft(CraftListCallback callback) { fetch_craft_list("api/favourite_craft.json", callback); }
//Craft GET requests //Get the craft the user has tagged for download public void fetch_download_queue(CraftListCallback callback) { fetch_craft_list("api/download_queue.json", callback); }