コード例 #1
0
        public static Webhook MapToWebhook(WebhookModel model)
        {
            var webhook = new Webhook(model.Name, model.Endpoint);

            if (model.Inactive)
            {
                webhook.Deactivate();
            }
            if (!string.IsNullOrWhiteSpace(model.Token))
            {
                webhook.SetToken(model.Token);
            }
            webhook.SetDefaultRequest(model.DefaultRequest);
            foreach (var header in model.DefaultHeaders ?? new Dictionary <string, object>())
            {
                webhook.DefaultHeaders[header.Key] = header.Value;
            }
            foreach (var action in model.Actions ?? Enumerable.Empty <WebhookActionModel>())
            {
                webhook.AddAction(WebhookActionModel.MapToWebhookAction(action));
            }
            foreach (var trigger in model.Triggers ?? Enumerable.Empty <WebhookTriggerModel>())
            {
                webhook.AddTrigger(WebhookTriggerModel.MapToWebhookTrigger(trigger));
            }

            return(webhook);
        }
コード例 #2
0
        public static WebhookAction MapToWebhookAction(WebhookActionModel model)
        {
            var action = new WebhookAction(model.Name, model.Url, model.Request);

            action.SetCodename(model.Codename);
            if (model.Inactive)
            {
                action.Deactivate();
            }
            foreach (var header in model.Headers ?? new Dictionary <string, object>())
            {
                action.Headers[header.Key] = header.Value;
            }

            return(action);
        }