parcelwing 0.1.0

Official Rust SDK for the Parcel Wing API.
Documentation
use std::sync::Arc;

use crate::error::Error;
use crate::http::HttpClient;
use crate::types::{AutomationEvent, AutomationTrackRequest, ResourceResponse};

#[derive(Clone, Debug)]
pub struct AutomationsResource {
    http: Arc<HttpClient>,
}

impl AutomationsResource {
    pub(crate) fn new(http: Arc<HttpClient>) -> Self {
        Self { http }
    }

    pub async fn track(&self, input: AutomationTrackRequest) -> Result<AutomationEvent, Error> {
        let response: ResourceResponse<AutomationEvent> =
            self.http.post("/api/automations/events", &input).await?;

        Ok(response.data)
    }
}