sellapp-sdk 0.1.1

Official Rust SDK for the SellApp API: manage products, orders, subscriptions, and customers.
// This file is auto-generated by oagen. Do not edit.

use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
#[allow(unused_imports)]
use serde::Serialize;

pub struct WebhookPlatformApi<'a> {
    pub(crate) client: &'a Client,
}

#[derive(Debug, Clone, Default, Serialize)]
pub struct ListWebhookEventTypesParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize)]
pub struct ListWebhookDeliveriesParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize)]
pub struct GetWebhookDeliveryParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
}

#[derive(Debug, Clone, Serialize)]
pub struct ReplayWebhookDeliveryParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkReplayWebhookDeliveryRequestApplicationJson,
}

impl ReplayWebhookDeliveryParams {
    /// Construct a new `ReplayWebhookDeliveryParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkReplayWebhookDeliveryRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

impl<'a> WebhookPlatformApi<'a> {
    /// List webhook event types
    ///
    /// List versioned outbound event types. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn list_webhook_event_types(
        &self,
        params: ListWebhookEventTypesParams,
    ) -> Result<SdkListWebhookEventTypesResponseValue200ApplicationJson, Error> {
        self.list_webhook_event_types_with_options(params, None)
            .await
    }

    /// Variant of [`Self::list_webhook_event_types`] that accepts per-request [`crate::RequestOptions`].
    pub async fn list_webhook_event_types_with_options(
        &self,
        params: ListWebhookEventTypesParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkListWebhookEventTypesResponseValue200ApplicationJson, Error> {
        self.list_webhook_event_types_raw(params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn list_webhook_event_types_raw(
        &self,
        params: ListWebhookEventTypesParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkListWebhookEventTypesResponseValue200ApplicationJson>, Error>
    {
        let path = "/v2/webhook-event-types".to_string();
        let method = http::Method::GET;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("listWebhookEventTypes".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "GET /v2/webhook-event-types",
            )
            .await
    }

    /// List webhook deliveries
    ///
    /// Destination origin only; response bodies are redacted and capped. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn list_webhook_deliveries(
        &self,
        params: ListWebhookDeliveriesParams,
    ) -> Result<SdkListWebhookDeliveriesResponseValue200ApplicationJson, Error> {
        self.list_webhook_deliveries_with_options(params, None)
            .await
    }

    /// Variant of [`Self::list_webhook_deliveries`] that accepts per-request [`crate::RequestOptions`].
    pub async fn list_webhook_deliveries_with_options(
        &self,
        params: ListWebhookDeliveriesParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkListWebhookDeliveriesResponseValue200ApplicationJson, Error> {
        self.list_webhook_deliveries_raw(params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn list_webhook_deliveries_raw(
        &self,
        params: ListWebhookDeliveriesParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkListWebhookDeliveriesResponseValue200ApplicationJson>, Error>
    {
        let path = "/v2/webhook-deliveries".to_string();
        let method = http::Method::GET;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("listWebhookDeliveries".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "GET /v2/webhook-deliveries",
            )
            .await
    }

    /// Retrieve a webhook delivery
    ///
    /// Retrieve one redacted delivery. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn get_webhook_delivery(
        &self,
        delivery: &str,
        params: GetWebhookDeliveryParams,
    ) -> Result<SdkGetWebhookDeliveryResponseValue200ApplicationJson, Error> {
        self.get_webhook_delivery_with_options(delivery, params, None)
            .await
    }

    /// Variant of [`Self::get_webhook_delivery`] that accepts per-request [`crate::RequestOptions`].
    pub async fn get_webhook_delivery_with_options(
        &self,
        delivery: &str,
        params: GetWebhookDeliveryParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkGetWebhookDeliveryResponseValue200ApplicationJson, Error> {
        self.get_webhook_delivery_raw(delivery, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn get_webhook_delivery_raw(
        &self,
        delivery: &str,
        params: GetWebhookDeliveryParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkGetWebhookDeliveryResponseValue200ApplicationJson>, Error>
    {
        let delivery = crate::client::path_segment(delivery);
        let path = format!("/v2/webhook-deliveries/{delivery}");
        let method = http::Method::GET;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("getWebhookDelivery".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "GET /v2/webhook-deliveries/{delivery}",
            )
            .await
    }

    /// Replay a webhook delivery
    ///
    /// Accept no URL, payload, or query overrides. Resolve the current channel server-side, create a new delivery ID, retain the integration-event ID, and sign with a new timestamp. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn replay_webhook_delivery(
        &self,
        delivery: &str,
        params: ReplayWebhookDeliveryParams,
    ) -> Result<SdkReplayWebhookDeliveryResponseValue201ApplicationJson, Error> {
        self.replay_webhook_delivery_with_options(delivery, params, None)
            .await
    }

    /// Variant of [`Self::replay_webhook_delivery`] that accepts per-request [`crate::RequestOptions`].
    pub async fn replay_webhook_delivery_with_options(
        &self,
        delivery: &str,
        params: ReplayWebhookDeliveryParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkReplayWebhookDeliveryResponseValue201ApplicationJson, Error> {
        self.replay_webhook_delivery_raw(delivery, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn replay_webhook_delivery_raw(
        &self,
        delivery: &str,
        params: ReplayWebhookDeliveryParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkReplayWebhookDeliveryResponseValue201ApplicationJson>, Error>
    {
        let delivery = crate::client::path_segment(delivery);
        let path = format!("/v2/webhook-deliveries/{delivery}/replay");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("replayWebhookDelivery".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/webhook-deliveries/{delivery}/replay",
            )
            .await
    }
}