// ReSharper disable once UnusedMember.Global public async Task Send(EventAction eventAction, string routingKey, Severity severity, string source, string summary) { var dtoPagerDuty = new DtoPagerDuty { Event_Action = GetEventAction(eventAction), Routing_Key = routingKey, Payload = new DtoPagerDutyPayload { Severity = GetSeverity(severity), Source = source, Summary = summary } }; await this.Send(dtoPagerDuty); }
private async Task Send(DtoPagerDuty dtoPagerDuty) { try { var stringPayload = JsonConvert.SerializeObject(dtoPagerDuty, this.serializerSettings); var content = new StringContent(stringPayload, Encoding.UTF8, "application/json"); var result = await this.httpClient.PostAsync("v2/enqueue", content).ConfigureAwait(false); if (result.IsSuccessStatusCode) { this.logger.Information("Added PagerDuty alert with data {@Data}", dtoPagerDuty); } else { this.logger.Error("Adding PagerDuty alert failed with data {@Data}", dtoPagerDuty); } } catch (Exception ex) { this.logger.Error("An error occurred: {Exception}.", ex); } }