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

impl<'a> OAuthManagementApi<'a> {
    /// Read your CLI connection
    ///
    /// Read your active official CLI connection, its account-wide grant model and granted scopes.
    pub async fn get_oauth_installation(
        &self,
    ) -> Result<SdkGetOAuthInstallationResponseValue200ApplicationJson, Error> {
        self.get_oauth_installation_with_options(None).await
    }

    /// Variant of [`Self::get_oauth_installation`] that accepts per-request [`crate::RequestOptions`].
    pub async fn get_oauth_installation_with_options(
        &self,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkGetOAuthInstallationResponseValue200ApplicationJson, Error> {
        self.get_oauth_installation_raw(options)
            .await
            .map(|response| response.data)
    }

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

    /// Disconnect your CLI connection
    ///
    /// Disconnect your official CLI connection and revoke its authorization codes and token families. Run sellapp login to reconnect.
    pub async fn delete_oauth_installation(&self) -> Result<(), Error> {
        self.delete_oauth_installation_with_options(None).await
    }

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

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