public void search_geo_caches(WWWForm search_params, RequestCallback callback) { HTTP http = HTTP.post(url_to("api/geo_caches/search"), search_params); http.set_header("Content-Type", "multipart/form-data"); http.send(this, callback); }
public void destroy_geo_cache(int geo_cache_id, RequestCallback callback) { HTTP http = HTTP.post(url_to("api/geo_caches/" + geo_cache_id)); http.request.method = "DELETE"; http.send(this, callback); }
//Craft POST and PUT requests //Send new craft to Mun....or KerbalX.com as a POST request public void upload_craft(WWWForm craft_data, RequestCallback callback) { HTTP http = HTTP.post(url_to("api/craft"), craft_data); http.set_header("Content-Type", "multipart/form-data"); http.send(this, callback); }
public void lookup_parts(WWWForm part_info, RequestCallback callback) { HTTP http = HTTP.post(url_to("api/lookup_parts"), part_info); http.set_header("Content-Type", "multipart/form-data"); http.send(this, callback); }
public void update_geo_cache(int geo_cache_id, WWWForm geo_cache_data, RequestCallback callback) { HTTP http = HTTP.post(url_to("api/geo_caches/" + geo_cache_id), geo_cache_data); http.request.method = "PUT"; http.set_header("Content-Type", "multipart/form-data"); http.send(this, callback); }
//Update existing craft on KerbalX as a PUT request with the KerbalX database ID of the craft to be updated public void update_craft(int id, WWWForm craft_data, RequestCallback callback) { HTTP http = HTTP.post(url_to("api/craft/" + id), craft_data); http.request.method = "PUT"; //because unity's PUT method doesn't take a form, so we create a POST with the form and then change the verb. http.set_header("Content-Type", "multipart/form-data"); http.send(this, callback); }
//make request to site to authenticate token. If token authentication fails, no error message is shown, it just sets the login window to show u-name/password fields. private void authenticate_token(string current_token, RequestCallback callback) { NameValueCollection data = new NameValueCollection() { { "token", current_token } }; RequestHandler.show_401_message = false; //don't show standard 401 error dialog HTTP.post(url_to("api/authenticate"), data).send(this, callback, false); }
//Internal Authentication POST requests //make request to site to authenticate username and password and get token back internal void login(string username, string password, RequestCallback callback) { KXAPI.log("Logging into KerbalX.com..."); NameValueCollection data = new NameValueCollection() { { "username", username }, { "password", password } }; RequestHandler.show_401_message = false; //don't show standard 401 error dialog HTTP.post(url_to("api/login"), data).send(this, (resp, code) => { if (code == 200) { KXAPI.log("Logged in"); var resp_data = JSON.Parse(resp); KerbalXAPI.token = resp_data["token"]; KerbalXAPI.save_token(resp_data["token"]); KerbalXAPI.kx_username = resp_data["username"]; } callback(resp, code); }, false); }
public void upload_geo_cache(WWWForm geo_cache_data, RequestCallback callback) { HTTP.post(url_to("api/geo_caches"), geo_cache_data).send(this, callback); }
public void enable_deferred_downloads(RequestCallback callback) { HTTP.post(url_to("api/enable_deferred_downloads")).send(this, callback); }
//General requests //Tells KerbalX not to bug this user about the current minor/patch version update available //There is no callback for this request. public void dismiss_current_update_notification() { HTTP.post(url_to("api/dismiss_update_notification")).send(this, (resp, code) => { }); }