public void CloseIfStillOpen()
        {
            var config = GetPagerDutyConfig();
            var subject = "[IPHost] 'Parkmobile NL Web02 on web02-nl.parkmobile.com' - 'ok'";
            var api = new IntegrationApi(config);

            var incidents = api.GetOpenIncidents();

            var incident = incidents.FirstOrDefault(i => i.trigger_summary_data != null
                           && i.trigger_summary_data.IndexOf("IPHOST", StringComparison.OrdinalIgnoreCase) >= 0);

            if (incident != null)
            {
                var resolveEvent = new ResolveEvent(new IncidentEvent
                {
                    incident_key = incident.incident_key
                }, subject);

                var resResponse = api.Resolve(resolveEvent);

                Assert.IsTrue(resResponse.IsOk(), "Incident should be resolved");

            }
            else
            {
                //none open
            }
        }
        public void Resolve(string subject)
        {
            var incidents = _apiClient.GetOpenIncidents();

            var incident = incidents.FirstOrDefault(i => i.trigger_summary_data != null
                                                         &&
                                                         i.trigger_summary_data.IndexOf(subject,
                                                             StringComparison.OrdinalIgnoreCase) >= 0);

            if (incident != null)
            {

                var resolveEvent = new ResolveEvent(
                                new IncidentEvent
                                {
                                    incident_key = incident.incident_key,
                                    service_key = _config.EventAuthToken
                                }, subject);

                var resResponse = _apiClient.Resolve(resolveEvent);

                if (resResponse.IsOk())
                {
                    Console.WriteLine("Issue has been resolved: {0}", resResponse.incident_key);
                }
                else
                {
                    Console.WriteLine("Failed to resolve issue: {0} {1}",
                        resResponse.status,
                        resResponse.message);
                }
            }
            else
            {
                Console.WriteLine("No open issue found for subject.");
            }
        }
        public void CreateAcknowledgeResolve()
        {
            var config = GetPagerDutyConfig();

            /*var config = new PagerDutyConfig
                {
                    EventAuthToken = "YOUR_EVENT_API_KEY_HERE",
                    EventApiUrl = "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
                };
            */

            var incident = new IncidentEvent
                {
                    client = "UnitTest",
                    description = "Event triggered by unittest",
                    incident_key = Guid.NewGuid().ToString(),
                    service_key = config.EventAuthToken,
                };

            var apiClient = new IntegrationApi(config);

            var response = apiClient.Trigger(incident);

            Assert.IsTrue(response.IsOk(), "Incident should be created");

            var acknowledge = new AcknowledgeEvent(incident, "Working on it!");

            var ackResponse = apiClient.Acknowledge(acknowledge);

            Assert.IsTrue(ackResponse.IsOk(), "Incident should be acknowledged");

            var resolveEvent = new ResolveEvent(incident, "Fixed!");

            var resResponse = apiClient.Resolve(resolveEvent);

            Assert.IsTrue(resResponse.IsOk(), "Incident should be resolved");
        }