Esempio n. 1
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="body">Optional parameter: Example: </param>
        /// <return>Returns the void response from the API call</return>
        public async Task CreateDispatchWebhookAsync(DefaultWebhookPayloadModel body = null)
        {
            //the base uri for api requests
            var baseUri = Configuration.GetBaseURI();

            //prepare query string for API call
            var queryBuilder = new StringBuilder(baseUri);

            queryBuilder.Append("/yourdomain.com/your/registered/web-hook/address");


            //validate and preprocess url
            var queryUrl = APIHelper.CleanUrl(queryBuilder);

            //append request with appropriate headers and parameters
            var headers = APIHelper.GetContentRequestHeaders();

            //append body params
            var serializedBody = APIHelper.JsonSerialize(body);

            //prepare the API call request to fetch the response
            var request = ClientInstance.PostBody(queryUrl, headers, serializedBody);

            //invoke request and get response
            var response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(request).ConfigureAwait(false);

            var context = new HTTPContext(request, response);

            //handle errors defined at the API level
            ValidateResponse(response, context);
        }
        public async Task TestDispatchWebhook()
        {
            // Parameters for the API call
            DefaultWebhookPayloadModel body = null;

            // Perform API call

            try
            {
                await _controller.CreateDispatchWebhookAsync(body);
            }
            catch (APIException) {};

            // Test response code
            Assert.AreEqual(200, HTTPCallBackHandler.Response.StatusCode,
                            "Status should be 200");

            // Test headers
            var headers = new Dictionary <string, string>
            {
                { "Content-Type", "application/json" }
            };

            Assert.IsTrue(TestHelper.AreHeadersProperSubsetOf(
                              headers, HTTPCallBackHandler.Response.Headers),
                          "Headers should match");
        }
Esempio n. 3
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="body">Optional parameter: Example: </param>
        /// <return>Returns the void response from the API call</return>
        public void CreateDispatchWebhook(DefaultWebhookPayloadModel body = null)
        {
            var t = CreateDispatchWebhookAsync(body);

            APIHelper.RunTaskSynchronously(t);
        }