//Fetches data on the users current craft on the site. This is kept in a Dictionary of craft_id => Dict of key value pairs....here let me explain it in Ruby; //{craft_id => {:id => craft.id, :name => craft.name, :version => craft.ksp_version, :url => craft.unique_url}, ...} public void fetch_existing_craft(RequestCallback callback) { HTTP.get(url_to("api/existing_craft.json")).send(this, (resp, status_code) => { if (status_code == 200) { user_craft_container = process_craft_data(resp, "id", "name", "version", "url", "type", "part_count", "crew_capacity", "cost", "mass", "stages", "created_at", "updated_at", "description"); } callback("", status_code); }); }
//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); } }); }
public void fetch_geo_cache(int geo_cache_id, RequestCallback callback) { HTTP.get(url_to("api/geo_caches/" + geo_cache_id)).send(this, callback); }
//GeoCache GET requests public void fetch_geo_cache_list(RequestCallback callback) { HTTP.get(url_to("api/geo_caches.json")).send(this, callback); }
//Does exactly what is says on the tin, it fetches a craft by ID from KerbalX. //Just to note though, the ID must be for a craft that is either in the users download queue, has been downloaded before or is one of the users craft public void download_craft(int id, RequestCallback callback) { HTTP.get(url_to("api/craft/" + id)).send(this, callback); }
//Remove a craft from the list of craft the user has tagged for download public void remove_from_queue(int craft_id, RequestCallback callback) { HTTP.get(url_to("api/remove_from_queue/" + craft_id)).send(this, callback); }
public void check_for_updates(RequestCallback callback) { HTTP.get(url_to("api/mod_update_available")).send(this, callback); }
public void deferred_downloads_enabled(RequestCallback callback) { HTTP.get(url_to("api/deferred_downloads_enabled")).send(this, callback); }
//test public void test_connection(RequestCallback callback) { HTTP.get(url_to("api/test_connection")).send(this, callback); }