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);
            }
Пример #3
0
        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));
        }
Пример #4
0
 public Task <Webhook> CreateAsync(NewWebhook webhook)
 {
     return(CreateAsync(webhook, new WebhookRequest()));
 }