public bool UpdateWebhook(string webhookId, UpdateWebhook webhook) { var request = BuildRequestAuthorization(PATCH_WEBHOOK, Method.PATCH); request.AddParameter("webhookId", webhookId, ParameterType.UrlSegment); request.AddJsonBody(webhook); var response = WebClient.Execute(request); if (response.ResponseStatus == ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.NoContent) { return(true); } if (!string.IsNullOrWhiteSpace(response.ErrorMessage)) { throw new Exception(response.ErrorMessage); } if (!string.IsNullOrWhiteSpace(response.StatusDescription) && !string.IsNullOrWhiteSpace(response.Content)) { throw new Exception($"{response.StatusDescription} || {response.Content}"); } if (!string.IsNullOrWhiteSpace(response.Content)) { throw new Exception($"{response.StatusCode} || {response.Content}"); } return(false); }
public void Update_Webhooks_Returns_Success() { // Arrange CreateWebhook(); _webhook.WebhookId.ShouldNotBeNullOrWhiteSpace(); var update = new UpdateWebhook { Url = "https://anotherurl.com", AuthUser = "******", AuthPassword = "******", Events = new List <string> { WebhookEvents.MeetingEnded, WebhookEvents.RecordingCompleted, WebhookEvents.RecordingTranscriptCompleted } }; // Act var result = _sut.Webhooks.UpdateWebhook(_webhook.WebhookId, update); // Assert result.ShouldNotBeNull(); result.ShouldBe(true); var webhook = _sut.Webhooks.GetWebhook(_webhook.WebhookId); webhook.WebhookId.ShouldNotBeNullOrWhiteSpace(); webhook.Url.ShouldBe(update.Url); webhook.AuthUser.ShouldBe(update.AuthUser); webhook.AuthPassword.ShouldBe(update.AuthPassword); }
public void Update(UpdateWebhook command) { Guard.Valid(command, nameof(command), () => "Cannot update webhook"); VerifyCreatedAndNotDeleted(); RaiseEvent(SimpleMapper.Map(command, new WebhookUpdated())); }
public async Task <IActionResult> PutWebhook(string app, Guid id, [FromBody] CreateWebhookDto request) { var schemas = request.Schemas.Select(s => SimpleMapper.Map(s, new WebhookSchema())).ToList(); var command = new UpdateWebhook { WebhookId = id, Url = request.Url, Schemas = schemas }; await CommandBus.PublishAsync(command); return(NoContent()); }
/// <summary> /// Update an existing webhook /// </summary> /// <param name="webhookId">The ID of the Webhook to update.</param> /// <param name="webhook">The webhook parameters to be updated.</param> /// <returns>The id of the updated webhook, or False if the update failed.</returns> public int UpdateWebhook(string webhookId, UpdateWebhook webhook) { var request = new RestRequest(Method.PUT); request.Resource = "/{accountId}/webhooks/{webhookId}"; request.AddUrlSegment("webhookId", webhookId); request.RequestFormat = DataFormat.Json; request.JsonSerializer = new EmmaJsonSerializer(); request.AddBody(webhook); return(Execute <int>(request)); }
public void Update_should_create_events() { CreateWebhook(); var command = new UpdateWebhook { Url = url }; sut.Update(CreateWebhookCommand(command)); sut.GetUncomittedEvents() .ShouldHaveSameEvents( CreateWebhookEvent(new WebhookUpdated { Url = url, Schemas = command.Schemas }) ); }
/// <summary> /// Update an existing webhook /// </summary> /// <param name="webhookId">The ID of the Webhook to update.</param> /// <param name="webhook">The webhook parameters to be updated.</param> /// <returns>The id of the updated webhook, or False if the update failed.</returns> public int UpdateWebhook(string webhookId, UpdateWebhook webhook) { var request = new RestRequest(Method.PUT); request.Resource = "/{accountId}/webhooks/{webhookId}"; request.AddUrlSegment("webhookId", webhookId); request.RequestFormat = DataFormat.Json; request.JsonSerializer = new EmmaJsonSerializer(); request.AddBody(webhook); return Execute<int>(request); }
protected async Task On(UpdateWebhook command, CommandContext context) { await ValidateAsync(command, () => "Failed to update content"); await handler.UpdateAsync <WebhookDomainObject>(context, c => c.Update(command)); }