Esempio n. 1
0
        public async Task Can_Create_Webhook()
        {
            // Arrange
            var client             = this.GetClient();
            var setWebhookCriteria = new SetWebhookCriteria(
                id: "test-webhook",
                applicationId: applicationId,
                baseUrl: "https://test-webhook.test-site.com/",
                headers: new Dictionary <string, string> {
                { "Authorization", "Bearer 123456" }
            },
                format: WebhookFormats.json,
                templateId: string.Empty,
                templateFields: null,
                downlinkApiKey: string.Empty,
                uplinkMessagePath: string.Empty,
                joinAcceptPath: string.Empty,
                downlinkAckPath: string.Empty,
                downlinkNackPath: string.Empty,
                downlinkSentPath: string.Empty,
                downlinkFailedPath: string.Empty,
                downlinkQueuedPath: string.Empty,
                downlinkQueueInvalidatedPath: string.Empty,
                locationSolvedPath: string.Empty,
                serviceDataPath: string.Empty);

            // Act
            var createWebhookResponse = await client.CreateApplicationWebhook(applicationId : applicationId, setWebhookCriteria : setWebhookCriteria);

            // Assert
            Assert.IsNotNull(value: createWebhookResponse, message: "createWebhookResponse is expected to not be null");
        }
Esempio n. 2
0
        public static async Task <Webhook> UpdateApplicationWebhook(this TheThingsStackIntegrationClient thingsStackIntegrationClient, string webhookId, string applicationId, SetWebhookCriteria setWebhookCriteria)
        {
            var fieldMasks = new[] {
                "base_url",
                "downlink_ack",
                "downlink_api_key",
                "downlink_failed",
                "downlink_nack",
                "downlink_queue_invalidated",
                "downlink_queued",
                "downlink_sent",
                "format",
                "headers",
                "ids",
                "ids.application_ids",
                "ids.application_ids.application_id",
                "ids.webhook_id",
                "join_accept",
                "location_solved",
                "service_data",
                "uplink_message",
                "uplink_message.path"
            };

            var data = new SetWebhookRequestCriteria(setWebhookCriteria: setWebhookCriteria, fieldMask: new FieldMaskCriteria(fieldMasks));

            return(await thingsStackIntegrationClient.PutAsync <Webhook>(resourceUrl : $"{resourceUrl}/{applicationId}/{webhookId}", data : data));
        }