/// <summary> /// deleteVoiceUri is a method that allows you to remove one of your voice URIs. /// </summary> /// <param name="voiceUriId">Required parameter: The identifier of the voice uri.</param> /// <return>Returns the void response from the API call</return> public async Task DeleteVoiceUriAsync( string voiceUriId) { //the base uri for api requests string baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder queryBuilder = new StringBuilder(baseUri); queryBuilder.Append("/services/rest/configuration/voiceuri/{voiceUriId}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object>() { { "voiceUriId", voiceUriId } }); //validate and preprocess url string queryUrl = APIHelper.CleanUrl(queryBuilder); //prepare and invoke the API call request to fetch the response HttpRequest request = Unirest.delete(queryUrl) //append request with appropriate headers and parameters .header("User-Agent", "APIMATIC 2.0") .basicAuth(basicAuthUserName, basicAuthPassword); //invoke request and get response HttpResponse <String> response = await request.asStringAsync(); //Error handling using HTTP status codes if ((response.Code < 200) || (response.Code > 206)) //[200,206] = HTTP OK { throw new APIException(@"HTTP Response Not OK", response.Code); } }
private void lst_SelectedIndexChanged(object sender, EventArgs e) { if (lst.SelectedIndex == -1) { return; } string name = lst.SelectedItem.ToString().Split('>')[0].Trim(); var product = products.Find(p => p.Name == name); if (MessageBox.Show($"Delete {name}?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } var delete = new { SellerID = You.ID, Name = product.Name }; var json = JsonConvert.SerializeObject(delete); var response = Unirest.delete("http://localhost/products") .body(json) .asJson <String>(); GetProducts(); }
/// <summary> /// Deletes an email address from a user account. If _User is null, deletes for current user. /// </summary> /// <param name="_Config"></param> /// <param name="_Email"></param> /// <param name="_User"></param> public static void Delete(Config _Config, Email _Email, User _User = null) { try { string URI = _Config.APIUrl; if (_User == null) { URI += "user/emails/" + _Email.id.ToString(); } else { URI += "users/" + _User.id.ToString() + "/emails/" + _Email.id.ToString(); } HttpResponse <string> R = Unirest.delete(URI) .header("accept", "application/json") .header("PRIVATE-TOKEN", _Config.APIKey) .asString(); if (R.Code < 200 || R.Code >= 300) { throw new GitLabServerErrorException(R.Body, R.Code); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Delete snippet from a project. /// </summary> /// <param name="_Config"></param> /// <param name="_Project"></param> /// <param name="_Snippet"></param> /// <returns></returns> public static Snippet Delete(Config _Config, Project _Project, Snippet _Snippet) { Snippet RetVal; try { string URI = _Config.APIUrl + "projects/" + _Project.id.ToString() + "/snippets/" + _Snippet.id.ToString(); HttpResponse <string> R = Unirest.delete(URI) .header("accept", "application/json") .header("PRIVATE-TOKEN", _Config.APIKey) .asString(); if (R.Code < 200 || R.Code >= 300) { throw new GitLabServerErrorException(R.Body, R.Code); } else { RetVal = JsonConvert.DeserializeObject <Snippet>(R.Body.ToString()); } } catch (Exception ex) { throw ex; } return(RetVal); }
public static void Unirest_Should_Return_Correct_URL() { Assert.Equal("http://localhost", Unirest.get("http://localhost").URL.OriginalString); Assert.Equal("http://localhost", Unirest.post("http://localhost").URL.OriginalString); Assert.Equal("http://localhost", Unirest.delete("http://localhost").URL.OriginalString); Assert.Equal("http://localhost", Unirest.patch("http://localhost").URL.OriginalString); Assert.Equal("http://localhost", Unirest.put("http://localhost").URL.OriginalString); }
public static void Unirest_Should_Return_Correct_Verb() { Assert.Equal(HttpMethod.Get, Unirest.get("http://localhost").HttpMethod); Assert.Equal(HttpMethod.Post, Unirest.post("http://localhost").HttpMethod); Assert.Equal(HttpMethod.Delete, Unirest.delete("http://localhost").HttpMethod); Assert.Equal(new HttpMethod("PATCH"), Unirest.patch("http://localhost").HttpMethod); Assert.Equal(HttpMethod.Put, Unirest.put("http://localhost").HttpMethod); }
public void Unirest_Should_Return_Correct_URL() { Unirest.get("http://localhost").URL.OriginalString.Should().Be("http://localhost"); Unirest.post("http://localhost").URL.OriginalString.Should().Be("http://localhost"); Unirest.delete("http://localhost").URL.OriginalString.Should().Be("http://localhost"); Unirest.patch("http://localhost").URL.OriginalString.Should().Be("http://localhost"); Unirest.put("http://localhost").URL.OriginalString.Should().Be("http://localhost"); }
public void Unirest_Should_Return_Correct_Verb() { Unirest.get("http://localhost").HttpMethod.Should().Be(HttpMethod.Get); Unirest.post("http://localhost").HttpMethod.Should().Be(HttpMethod.Post); Unirest.delete("http://localhost").HttpMethod.Should().Be(HttpMethod.Delete); Unirest.patch("http://localhost").HttpMethod.Should().Be(new HttpMethod("PATCH")); Unirest.put("http://localhost").HttpMethod.Should().Be(HttpMethod.Put); }
/// <summary> /// Deletes a project /// </summary> /// <param name="_Config"></param> /// <param name="_Project"></param> public static void Delete(Config _Config, Project _Project) { HttpResponse <string> R = Unirest.delete(_Config.APIUrl + "projects/" + _Project.id.ToString()) .header("accept", "application/json") .header("PRIVATE-TOKEN", _Config.APIKey) .asString(); if (R.Code < 200 || R.Code >= 300) { throw new GitLabServerErrorException(R.Body, R.Code); } }
/// <summary> /// Removes user from group. /// </summary> /// <param name="_Config"></param> /// <param name="_Group"></param> /// <param name="_User"></param> public static void DeleteMember(Config _Config, Group _Group, User _User) { string URI = _Config.APIUrl + "groups/" + _Group.id.ToString() + "/members/" + _User.id; HttpResponse <string> R = Unirest.delete(URI) .header("accept", "application/json") .header("PRIVATE-TOKEN", _Config.APIKey) .asString(); if (R.Code < 200 || R.Code >= 300) { throw new GitLabServerErrorException(R.Body, R.Code); } }
/// <summary> /// Deletes a project webhook from the server. /// </summary> /// <param name="_Config"></param> /// <param name="_Webhook"></param> /// <param name="_Project"></param> public static void Delete(Config _Config, Webhook _Webhook, Project _Project) { try { string URI = _Config.APIUrl + "/projects/" + _Project.id.ToString() + "/hooks" + _Webhook.id; HttpResponse <string> R = Unirest.delete(URI) .header("accept", "application/json") .header("PRIVATE-TOKEN", _Config.APIKey) .asString(); if (R.Code < 200 || R.Code >= 300) { throw new GitLabServerErrorException(R.Body, R.Code); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Deletes a user. /// </summary> /// <param name="_Config"></param> /// <param name="_User"></param> public static void Delete(Config _Config, User _User) { try { string URI = _Config.APIUrl + "users/"; URI += _User.id.ToString(); HttpResponse <string> R = Unirest.delete(URI) .header("accept", "application/json") .header("PRIVATE-TOKEN", _Config.APIKey) .asString(); if (R.Code < 200 || R.Code >= 300) { throw new GitLabServerErrorException(R.Body, R.Code); } } catch (Exception ex) { throw ex; } }
/// <summary> /// deleteCart is a method that allows you to delete a cart and all its content from your list of carts. /// </summary> /// <param name="cartIdentifier">Required parameter: The identifier of the cart.</param> /// <return>Returns the dynamic response from the API call</return> public async Task <dynamic> DeleteCartAsync( string cartIdentifier) { //the base uri for api requests string baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder queryBuilder = new StringBuilder(baseUri); queryBuilder.Append("/services/rest/ordering/cart/{cartIdentifier}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object>() { { "cartIdentifier", cartIdentifier } }); //validate and preprocess url string queryUrl = APIHelper.CleanUrl(queryBuilder); //prepare and invoke the API call request to fetch the response HttpRequest request = Unirest.delete(queryUrl) //append request with appropriate headers and parameters .header("User-Agent", "APIMATIC 2.0") .header("Accept", "application/json") .basicAuth(basicAuthUserName, basicAuthPassword); //invoke request and get response HttpResponse <String> response = await request.asStringAsync(); //Error handling using HTTP status codes if ((response.Code < 200) || (response.Code > 206)) //[200,206] = HTTP OK { throw new APIException(@"HTTP Response Not OK", response.Code); } return(APIHelper.JsonDeserialize <dynamic>(response.Body)); }
/// <summary> /// Delete one object /// </summary> /// <param name="pk">Required parameter: CustomerID</param> /// <return>Returns the CustomersModel response from the API call</return> public async Task <CustomersModel> DeleteOneCustomersAsync( string pk) { //the base uri for api requests string baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder queryBuilder = new StringBuilder(baseUri); queryBuilder.Append("/Customers/{pk}"); //process optional query parameters APIHelper.AppendUrlWithTemplateParameters(queryBuilder, new Dictionary <string, object>() { { "pk", pk } }); //validate and preprocess url string queryUrl = APIHelper.CleanUrl(queryBuilder); //prepare and invoke the API call request to fetch the response HttpRequest request = Unirest.delete(queryUrl) //append request with appropriate headers and parameters .header("User-Agent", "APIMATIC 2.0") .header("Accept", "application/json"); //invoke request and get response HttpResponse <String> response = await request.asStringAsync(); //Error handling using HTTP status codes if ((response.Code < 200) || (response.Code > 206)) //[200,206] = HTTP OK { throw new APIException(@"HTTP Response Not OK", response.Code); } return(APIHelper.JsonDeserialize <CustomersModel>(response.Body)); }
public static HttpRequest Delete(string url, long timeout = 30) { return(Unirest.delete(Config.ServerUrl + url, timeout).AddRTCHead()); }
public void WhenICallTheAPIToDeleteTheUserSDetails() { HttpResponse <string> jsonResponse = Unirest.delete(GivenIHaveTheAPIUrlToDeleteAUserSDetails()).asString(); responseStatus = jsonResponse.Code.ToString(); }