public void CanReorderTriggers()
        {
            var res          = api.Triggers.GetActiveTriggers().Triggers;
            Assert.AreEqual(res.Count(), 0);

            var trigger = new Trigger()
            {
                Title      = "Test Trigger1",
                Active     = true,
                Conditions = new Conditions() { All = new List<All>() { new All() { Field = "status", Operator = "is", Value = "open" } }, Any = new List<All>() },
                Actions    = new List<Action>() { new Action() { Field = "group_id", Value = "20402842" } },
                Position   = 5000
            };

            var trigger2 = new Trigger()
            {
                Title      = "Test Trigger2",
                Active     = true,
                Conditions = new Conditions() { All = new List<All>() { new All() { Field = "status", Operator = "is", Value = "open" } }, Any = new List<All>() },
                Actions    = new List<Action>() { new Action() { Field = "group_id", Value = "20402842" } },
                Position   = 6000
            };

            var res2 = api.Triggers.CreateTrigger(trigger);
            var res3 = api.Triggers.CreateTrigger(trigger2);

            List<long> ids = new List<long>() { res3.Trigger.Id.Value, res2.Trigger.Id.Value };

            Assert.True(api.Triggers.ReorderTriggers(ids));

            res = api.Triggers.GetActiveTriggers().Triggers;

            Assert.AreEqual(res[0].Id.Value, res3.Trigger.Id.Value);

            Assert.True(api.Triggers.DeleteTrigger(res2.Trigger.Id.Value));
            Assert.True(api.Triggers.DeleteTrigger(res3.Trigger.Id.Value));
        }
        public void CanCreateUpdateAndDeleteTriggers()
        {
            var trigger = new Trigger()
            {
                Title = "Test Trigger",
                Active = true,
                Conditions = new Conditions() { All = new List<All>(), Any = new List<All>() },
                Actions = new List<Action>(),
                Position = 9999
            };

            trigger.Conditions.All.Add(new All() { Field = "status", Operator = "is", Value = "open" });
            trigger.Actions.Add(new Action() { Field = "group_id", Value = "20402842" });

            var res = api.Triggers.CreateTrigger(trigger);

            Assert.Greater(res.Trigger.Id, 0);

            res.Trigger.Title = "Test Trigger Updated";
            var update        = api.Triggers.UpdateTrigger(res.Trigger);
            Assert.AreEqual(update.Trigger.Title, res.Trigger.Title);

            Assert.True(api.Triggers.DeleteTrigger(res.Trigger.Id.Value));
        }
Exemple #3
0
 public async Task<IndividualTriggerResponse> CreateTriggerAsync(Trigger trigger)
 {
     var body = new { trigger };
     return await GenericPostAsync<IndividualTriggerResponse>("triggers.json", body);
 }
Exemple #4
0
 public IndividualTriggerResponse UpdateTrigger(Trigger trigger)
 {
     var body = new { trigger };
     return GenericPut<IndividualTriggerResponse>(string.Format("triggers/{0}.json", trigger.Id), body);
 }
Exemple #5
0
 public IndividualTriggerResponse CreateTrigger(Trigger trigger)
 {
     var body = new { trigger };
     return GenericPost<IndividualTriggerResponse>("triggers.json", body);
 }
Exemple #6
0
 public async Task<IndividualTriggerResponse> UpdateTriggerAsync(Trigger trigger)
 {
     var body = new { trigger };
     return await GenericPutAsync<IndividualTriggerResponse>(string.Format("triggers/{0}.json", trigger.Id), body);
 }