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 WalletBonusTiersApi<'a> {
    pub(crate) client: &'a Client,
}

#[derive(Debug, Clone, Default, Serialize)]
pub struct ListParams {
    /// 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 CreateParams {
    /// 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: SdkCreateWalletBonusTierRequestApplicationJson,
}

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

#[derive(Debug, Clone, Serialize)]
pub struct ReplaceParams {
    /// 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: SdkReplaceWalletBonusTierRequestApplicationJson,
}

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

#[derive(Debug, Clone, Serialize)]
pub struct UpdateParams {
    /// 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: SdkUpdateWalletBonusTierRequestApplicationJson,
}

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

#[derive(Debug, Clone, Default, Serialize)]
pub struct ArchiveParams {
    /// 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 RestoreParams {
    /// 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>,
}

impl<'a> WalletBonusTiersApi<'a> {
    /// List wallet bonus tiers
    ///
    /// List current and archived store records. Requires the `wallet` or `wallet:write` API ability. 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(
        &self,
        params: ListParams,
    ) -> Result<SdkListWalletBonusTiersResponseValue200ApplicationJson, Error> {
        self.list_with_options(params, None).await
    }

    /// Variant of [`Self::list`] that accepts per-request [`crate::RequestOptions`].
    pub async fn list_with_options(
        &self,
        params: ListParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkListWalletBonusTiersResponseValue200ApplicationJson, Error> {
        self.list_raw(params, options)
            .await
            .map(|response| response.data)
    }

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

    /// Create a wallet bonus tier
    ///
    /// Create a wallet bonus tier. Requires the `wallet:write` API ability and the store wallet permission. 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 create(
        &self,
        params: CreateParams,
    ) -> Result<SdkCreateWalletBonusTierResponseValue201ApplicationJson, Error> {
        self.create_with_options(params, None).await
    }

    /// Variant of [`Self::create`] that accepts per-request [`crate::RequestOptions`].
    pub async fn create_with_options(
        &self,
        params: CreateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkCreateWalletBonusTierResponseValue201ApplicationJson, Error> {
        self.create_raw(params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn create_raw(
        &self,
        params: CreateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkCreateWalletBonusTierResponseValue201ApplicationJson>, Error>
    {
        let path = "/v2/wallet-bonus-tiers".to_string();
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("createWalletBonusTier".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/wallet-bonus-tiers",
            )
            .await
    }

    /// Update a wallet bonus tier
    ///
    /// Update a wallet bonus tier. Requires the `wallet:write` API ability and the store wallet permission. 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 replace(
        &self,
        bonus_tier: &str,
        params: ReplaceParams,
    ) -> Result<SdkReplaceWalletBonusTierResponseValue200ApplicationJson, Error> {
        self.replace_with_options(bonus_tier, params, None).await
    }

    /// Variant of [`Self::replace`] that accepts per-request [`crate::RequestOptions`].
    pub async fn replace_with_options(
        &self,
        bonus_tier: &str,
        params: ReplaceParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkReplaceWalletBonusTierResponseValue200ApplicationJson, Error> {
        self.replace_raw(bonus_tier, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn replace_raw(
        &self,
        bonus_tier: &str,
        params: ReplaceParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkReplaceWalletBonusTierResponseValue200ApplicationJson>, Error>
    {
        let bonus_tier = crate::client::path_segment(bonus_tier);
        let path = format!("/v2/wallet-bonus-tiers/{bonus_tier}");
        let method = http::Method::PUT;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("replaceWalletBonusTier".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "PUT /v2/wallet-bonus-tiers/{bonusTier}",
            )
            .await
    }

    /// Update a wallet bonus tier
    ///
    /// Update a wallet bonus tier. Requires the `wallet:write` API ability and the store wallet permission. 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 update(
        &self,
        bonus_tier: &str,
        params: UpdateParams,
    ) -> Result<SdkUpdateWalletBonusTierResponseValue200ApplicationJson, Error> {
        self.update_with_options(bonus_tier, params, None).await
    }

    /// Variant of [`Self::update`] that accepts per-request [`crate::RequestOptions`].
    pub async fn update_with_options(
        &self,
        bonus_tier: &str,
        params: UpdateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkUpdateWalletBonusTierResponseValue200ApplicationJson, Error> {
        self.update_raw(bonus_tier, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn update_raw(
        &self,
        bonus_tier: &str,
        params: UpdateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkUpdateWalletBonusTierResponseValue200ApplicationJson>, Error>
    {
        let bonus_tier = crate::client::path_segment(bonus_tier);
        let path = format!("/v2/wallet-bonus-tiers/{bonus_tier}");
        let method = http::Method::PATCH;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("updateWalletBonusTier".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "PATCH /v2/wallet-bonus-tiers/{bonusTier}",
            )
            .await
    }

    /// Archive a wallet bonus tier
    ///
    /// Archive a wallet bonus tier. Requires the `wallet:write` API ability and the store wallet permission. 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 archive(
        &self,
        bonus_tier: &str,
        params: ArchiveParams,
    ) -> Result<SdkArchiveWalletBonusTierResponseValue200ApplicationJson, Error> {
        self.archive_with_options(bonus_tier, params, None).await
    }

    /// Variant of [`Self::archive`] that accepts per-request [`crate::RequestOptions`].
    pub async fn archive_with_options(
        &self,
        bonus_tier: &str,
        params: ArchiveParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkArchiveWalletBonusTierResponseValue200ApplicationJson, Error> {
        self.archive_raw(bonus_tier, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn archive_raw(
        &self,
        bonus_tier: &str,
        params: ArchiveParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkArchiveWalletBonusTierResponseValue200ApplicationJson>, Error>
    {
        let bonus_tier = crate::client::path_segment(bonus_tier);
        let path = format!("/v2/wallet-bonus-tiers/{bonus_tier}");
        let method = http::Method::DELETE;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("archiveWalletBonusTier".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "DELETE /v2/wallet-bonus-tiers/{bonusTier}",
            )
            .await
    }

    /// Restore a wallet bonus tier
    ///
    /// Restore a wallet bonus tier. Requires the `wallet:write` API ability and the store wallet permission. 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 restore(
        &self,
        bonus_tier: &str,
        params: RestoreParams,
    ) -> Result<SdkRestoreWalletBonusTierResponseValue200ApplicationJson, Error> {
        self.restore_with_options(bonus_tier, params, None).await
    }

    /// Variant of [`Self::restore`] that accepts per-request [`crate::RequestOptions`].
    pub async fn restore_with_options(
        &self,
        bonus_tier: &str,
        params: RestoreParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkRestoreWalletBonusTierResponseValue200ApplicationJson, Error> {
        self.restore_raw(bonus_tier, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn restore_raw(
        &self,
        bonus_tier: &str,
        params: RestoreParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkRestoreWalletBonusTierResponseValue200ApplicationJson>, Error>
    {
        let bonus_tier = crate::client::path_segment(bonus_tier);
        let path = format!("/v2/wallet-bonus-tiers/{bonus_tier}/restore");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("restoreWalletBonusTier".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "POST /v2/wallet-bonus-tiers/{bonusTier}/restore",
            )
            .await
    }
}