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

#[derive(Debug, Clone, Default, Serialize)]
pub struct ListDisputesParams {
    /// 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 GetDisputeParams {
    /// 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> DisputesApi<'a> {
    /// List disputes
    ///
    /// Read-only, redacted, store-scoped disputes that may reference an Order or Charge. 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_disputes(
        &self,
        params: ListDisputesParams,
    ) -> Result<SdkListDisputesResponseValue200ApplicationJson, Error> {
        self.list_disputes_with_options(params, None).await
    }

    /// Variant of [`Self::list_disputes`] that accepts per-request [`crate::RequestOptions`].
    pub async fn list_disputes_with_options(
        &self,
        params: ListDisputesParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkListDisputesResponseValue200ApplicationJson, Error> {
        self.list_disputes_raw(params, options)
            .await
            .map(|response| response.data)
    }

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

    /// Retrieve a dispute
    ///
    /// Retrieve one redacted dispute. No dispute mutations are exposed. 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_dispute(
        &self,
        dispute: &str,
        params: GetDisputeParams,
    ) -> Result<SdkGetDisputeResponseValue200ApplicationJson, Error> {
        self.get_dispute_with_options(dispute, params, None).await
    }

    /// Variant of [`Self::get_dispute`] that accepts per-request [`crate::RequestOptions`].
    pub async fn get_dispute_with_options(
        &self,
        dispute: &str,
        params: GetDisputeParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkGetDisputeResponseValue200ApplicationJson, Error> {
        self.get_dispute_raw(dispute, params, options)
            .await
            .map(|response| response.data)
    }

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