public void PostsToTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new WebhooksClient(connection); var newWebhook = new NewWebhook("https://test.com", "*", "*"); client.Create(newWebhook); connection.Received().Post <Webhook>(Arg.Is <Uri>(u => u.ToString() == "webhooks"), Arg.Is <NewWebhook>(df => df.EventAction == "*" && df.EventObject == "*" && df.SubscriptionUrl == "https://test.com")); }
public async Task CanCreate() { var pipedrive = Helper.GetAuthenticatedClient(); var fixture = pipedrive.Webhook; var newWebhook = new NewWebhook("http://example.com", Models.Common.Webhooks.EventAction.All, Models.Common.Webhooks.EventObject.All); var webhook = await fixture.Create(newWebhook); Assert.NotNull(webhook); var retrieved = await fixture.GetAll(); Assert.True(retrieved.Count > 0, "Expected count to be greater than 0."); // Cleanup await fixture.Delete(webhook.Id); }
public async Task <Webhook> CreateAsync(NewWebhook webhook, WebhookRequest request) { var createLink = await _linkFactory.CreateLinkAsync("webhooks").ConfigureAwait(_halClient); return(await _halClient.PostAsync <Webhook>(createLink, webhook, request).ConfigureAwait(_halClient)); }
public Task <Webhook> CreateAsync(NewWebhook webhook) { return(CreateAsync(webhook, new WebhookRequest())); }