Esempio n. 1
0
 public IEnumerable<Webhook> GetWebhook()
 {
     var data = downloadWebPage(getFullUrl("/admin/webhooks.xml"), HttpMethod.GET);
     var x = XDocument.Parse(data);
     foreach (var item in x.Root.Elements())
     {
         var img = new Webhook();
         img.LoadXElement(item);
         yield return img;
     }
 }
Esempio n. 2
0
 public Webhook GetWebhook(int webhookID)
 {
     var data = downloadWebPage(getFullUrl("/admin/webhooks/" + webhookID + ".xml"), HttpMethod.GET);
     var x = XDocument.Parse(data).Root;
     var img = new Webhook();
     img.LoadXElement(x);
     return img;
 }
            public void AuthCredentials()
            {
                var webhook = new Webhook
                {
                    AuthCredentials = new
                    {
                        access_token = "<oauth token>",
                        ExpiresIn = 3600
                    }
                };

                var dictionary = dataMapper.ToDictionary(webhook);
                var authRequestDetails = dictionary["auth_credentials"] as Dictionary<string, object>;
                authRequestDetails["access_token"].ShouldEqual("<oauth token>");
                authRequestDetails["expires_in"].ShouldEqual(3600);
            }
Esempio n. 4
0
 public void AddWebhook(Webhook image)
 {
     var data = downloadWebPage(getFullUrl("/admin/webhooks.xml"), HttpMethod.POST, image.ToXElement().ToString());
     var x = XDocument.Parse(data).Root;
     image.LoadXElement(x);
 }
 public void Name()
 {
     var webhook = new Webhook {Name = Guid.NewGuid().ToString()};
     dataMapper.ToDictionary(webhook)["name"].ShouldEqual(webhook.Name);
 }
 public void Target()
 {
     var webhook = new Webhook {Target = Guid.NewGuid().ToString()};
     dataMapper.ToDictionary(webhook)["target"].ShouldEqual(webhook.Target);
 }
 public void AuthType()
 {
     var webhook = new Webhook {AuthType = Guid.NewGuid().ToString()};
     dataMapper.ToDictionary(webhook)["auth_type"].ShouldEqual(webhook.AuthType);
 }
            public void Events()
            {
                var first = Guid.NewGuid().ToString();
                var second = Guid.NewGuid().ToString();

                var webhook = new Webhook();
                webhook.Events.Add(first);
                webhook.Events.Add(second);

                var dictionary = dataMapper.ToDictionary(webhook);
                var events = dictionary["events"] as IEnumerable<object>;
                events.Count().ShouldEqual(2);
                events.ShouldContain(first);
                events.ShouldContain(second);
            }
            public void AuthRequestDetails()
            {
                var webhook = new Webhook
                {
                    AuthRequestDetails = new
                    {
                        Url = "https://oauth.myurl.com/tokens",
                        Body = new {ClientId = "<oauth client id>", ClientSecret = "<oauth client secret>"}
                    }
                };

                var dictionary = dataMapper.ToDictionary(webhook);
                var authRequestDetails = dictionary["auth_request_details"].CastAs<IDictionary<string, object>>();
                authRequestDetails["url"].ShouldEqual("https://oauth.myurl.com/tokens");

                authRequestDetails["body"]
                    .CastAs<IDictionary<string, object>>()
                    ["client_id"]
                    .ShouldEqual("<oauth client id>");

                authRequestDetails["body"]
                    .CastAs<IDictionary<string, object>>()
                    ["client_secret"]
                    .ShouldEqual("<oauth client secret>");
            }
 internal static WebhookInput ToInput(this Webhook webhook) =>
 new WebhookInput(webhook.Id, webhook.TenantId, webhook.EventTypeIds.ToValues(), webhook.PostbackUrl, webhook.Secret);
        public object Post()
        {
            var transaction = Webhook.GetWebhook(this.ControllerContext.Request);

            return(transaction);
        }
 /// <summary>
 /// <para>Updates the Webhook specified in the URL.</para>
 /// <para>The request body is limited to the name, events, callbackUrl, enabled and version attributes.</para>
 /// <para>It mirrors To the following Smartsheet REST API method: PUT /webhooks/{webhookId}</para>
 /// </summary>
 /// <param name="webhook"> the webhook To update </param>
 /// <returns> the updated webhook </returns>
 /// <exception cref="System.InvalidOperationException"> if any argument is null or empty string </exception>
 /// <exception cref="InvalidRequestException"> if there is any problem with the REST API request </exception>
 /// <exception cref="AuthorizationException"> if there is any problem with  the REST API authorization (access token) </exception>
 /// <exception cref="ResourceNotFoundException"> if the resource cannot be found </exception>
 /// <exception cref="ServiceUnavailableException"> if the REST API service is not available (possibly due To rate limiting) </exception>
 /// <exception cref="SmartsheetException"> if there is any other error during the operation </exception>
 public virtual Webhook UpdateWebhook(Webhook webhook)
 {
     return(this.UpdateResource("webhooks/" + webhook.Id, typeof(Webhook), webhook));
 }
 /// <summary>
 /// <para>Creates a new Webhook.</para>
 /// <para>The request body is limited to name(required), callbackUrl (required), scope (required)
 /// scopeObjectId (required), events(required), version(required)</para>
 /// <para>It mirrors To the following Smartsheet REST API method:POST /webhooks</para>
 /// </summary>
 /// <param name="webhook"> the webhook to be created </param>
 /// <returns> the created webhook </returns>
 /// <exception cref="System.InvalidOperationException"> if any argument is null or empty string </exception>
 /// <exception cref="InvalidRequestException"> if there is any problem with the REST API request </exception>
 /// <exception cref="AuthorizationException"> if there is any problem with  the REST API authorization (access token) </exception>
 /// <exception cref="ResourceNotFoundException"> if the resource cannot be found </exception>
 /// <exception cref="ServiceUnavailableException"> if the REST API service is not available (possibly due To rate limiting) </exception>
 /// <exception cref="SmartsheetException"> if there is any other error during the operation </exception>
 public virtual Webhook CreateWebhook(Webhook webhook)
 {
     return(this.CreateResource("webhooks", typeof(Webhook), webhook));
 }