pub fn send(self) -> Result<(), Error> {
        let api_token = dotenv::var("PAGERDUTY_API_TOKEN")?;
        let service_key = dotenv::var("PAGERDUTY_INTEGRATION_KEY")?;

        let mut response = reqwest::Client::new()
            .post("https://events.pagerduty.com/generic/2010-04-15/create_event.json")
            .header(header::ACCEPT, "application/vnd.pagerduty+json;version=2")
            .header(header::AUTHORIZATION, format!("Token token={}", api_token))
            .json(&FullEvent {
                service_key,
                event: self,
            })
            .send()?;

        match response.status() {
            s if s.is_success() => Ok(()),
            Status::BAD_REQUEST => {
                let error = response.json::<InvalidEvent>()?;
                Err(format!("pagerduty error: {:?}", error))
            }
            Status::FORBIDDEN => Err("rate limited by pagerduty".to_string()),
            n => Err(format!(
                "Got a non 200 response code from pagerduty: {} with {:?}",
                n, response
            )),
        }
        .map_err(Into::into)
    }
/// Sends the event to pagerduty.
///
/// If the variant is `Trigger`, this will page whoever is on call
/// (potentially waking them up at 3 AM).
Sends the event to pagerduty.
If the variant is `Trigger`, this will page whoever is on call
(potentially waking them up at 3 AM).
Sends the event to pagerduty . If the variant is ` Trigger ` this will page whoever is on call ( potentially waking them up at 3 AM ) .
pub fn send(self) -> Result<(), Error> {
        let api_token = dotenv::var("PAGERDUTY_API_TOKEN")?;
        let service_key = dotenv::var("PAGERDUTY_INTEGRATION_KEY")?;
        let mut response = reqwest::Client::new()
            .post("https://events.pagerduty.com/generic/2010-04-15/create_event.json")
            .header(header::ACCEPT, "application/vnd.pagerduty+json;version=2")
            .header(header::AUTHORIZATION, format!("Token token={}", api_token))
            .json(&FullEvent {
                service_key,
                event: self,
            })
            .send()?;
        match response.status() {
            s if s.is_success() => Ok(()),
            Status::BAD_REQUEST => {
                let error = response.json::<InvalidEvent>()?;
                Err(format!("pagerduty error: {:?}", error))
            }
            Status::FORBIDDEN => Err("rate limited by pagerduty".to_string()),
            n => Err(format!(
                "Got a non 200 response code from pagerduty: {} with {:?}",
                n, response
            )),
        }
        .map_err(Into::into)
    }
pub fn send ( self ) -> Result < ( ) , Error > { let api_token = dotenv :: var ( " " ) ? ; let service_key = dotenv :: var ( " " ) ? ; let mut response = reqwest :: Client :: new ( ) . post ( " " ) . header ( header :: ACCEPT , " " ) . header ( header :: AUTHORIZATION , format ! ( " " api_token ) ) . json ( & FullEvent { service_key , event : self , } ) . send ( ) ? ; match response . status ( ) { s if s . is_success ( ) => Ok ( ( ) ) , Status :: BAD_REQUEST => { let error = response . json :: < InvalidEvent > ( ) ? ; Err ( format ! ( " " error ) ) } Status :: FORBIDDEN => Err ( " " . to_string ( ) ) , n => Err ( format ! ( " " n response ) ) , } . map_err ( Into :: into ) }
Sends the event to pagerduty.
Sends the event to pagerduty .
self