/// <summary> /// Update a webhook. You can update individual attributes or all of them by submitting a PATCH request to the /webhooks/messages endpoint (the same endpoint used above to delete a webhook) /// A successful request to the retrieve webhook endpoint will return a response body as follows: /// ``` /// { /// "url": "https://webhook.com", /// "method": "POST", /// "id": "04442623-0961-464e-9cbc-ec50804e0413", /// "encoding": "JSON", /// "events": [ /// "RECEIVED_SMS" /// ], /// "headers": {}, /// "template": "{\"id\":\"$mtId\", \"status\":\"$statusCode\"}" /// } /// ``` /// *Note: Only pre-created webhooks can be deleted. If an invalid or non existent webhook ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned.* /// </summary> /// <param name="webhookId">Required parameter: Example: </param> /// <param name="body">Required parameter: Example: </param> /// <return>Returns the dynamic response from the API call</return> public dynamic UpdateWebhook(Guid webhookId, Models.UpdateWebhookRequest body) { Task <dynamic> t = UpdateWebhookAsync(webhookId, body); APIHelper.RunTaskSynchronously(t); return(t.Result); }
/// <summary> /// Update a webhook. You can update individual attributes or all of them by submitting a PATCH request to the /webhooks/messages endpoint (the same endpoint used above to delete a webhook) /// A successful request to the retrieve webhook endpoint will return a response body as follows: /// ``` /// { /// "url": "https://webhook.com", /// "method": "POST", /// "id": "04442623-0961-464e-9cbc-ec50804e0413", /// "encoding": "JSON", /// "events": [ /// "RECEIVED_SMS" /// ], /// "headers": {}, /// "template": "{\"id\":\"$mtId\", \"status\":\"$statusCode\"}" /// } /// ``` /// *Note: Only pre-created webhooks can be deleted. If an invalid or non existent webhook ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned.* /// </summary> /// <param name="webhookId">Required parameter: Example: </param> /// <param name="body">Required parameter: Example: </param> /// <return>Returns the dynamic response from the API call</return> public async Task <dynamic> UpdateWebhookAsync(Guid webhookId, Models.UpdateWebhookRequest body) { //the base uri for api requests string _baseUri = Configuration.BaseUri; //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v1/webhooks/messages/{webhookId}"); //process optional template parameters APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "webhookId", webhookId } }); //validate and preprocess url string _queryUrl = APIHelper.CleanUrl(_queryBuilder); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", "messagesmedia-webhooks" }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" } }; //append body params var _body = APIHelper.JsonSerialize(body); //prepare the API call request to fetch the response HttpRequest _request = ClientInstance.PatchBody(_queryUrl, _headers, _body, Configuration.BasicAuthUserName, Configuration.BasicAuthPassword); //invoke request and get response HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); //Error handling using HTTP status codes if (_response.StatusCode == 400) { throw new UpdateWebhook400ResponseException(@"Unexpected error in API call. See HTTP response body for details.", _context); } if (_response.StatusCode == 404) { throw new APIException(@"", _context); } //handle errors defined at the API level base.ValidateResponse(_response, _context); try { return(APIHelper.JsonDeserialize <dynamic>(_response.Body)); } catch (Exception _ex) { throw new APIException("Failed to parse the response: " + _ex.Message, _context); } }