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 LicensesApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct ActivateParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkActivateLicenseKeyRequestApplicationJson,
}
impl ActivateParams {
#[allow(deprecated)]
pub fn new(body: SdkActivateLicenseKeyRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ValidateParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkValidateLicenseKeyRequestApplicationJson,
}
impl ValidateParams {
#[allow(deprecated)]
pub fn new(body: SdkValidateLicenseKeyRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ListParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl Default for ListParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
limit: Some(15),
page: Some(1),
x_store: Default::default(),
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkUpdateLicenseKeyRequestApplicationJson,
}
impl UpdateParams {
#[allow(deprecated)]
pub fn new(body: SdkUpdateLicenseKeyRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct DeactivateLicenseParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkDeactivateLicenseRequestApplicationJson,
}
impl DeactivateLicenseParams {
#[allow(deprecated)]
pub fn new(body: SdkDeactivateLicenseRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> LicensesApi<'a> {
pub async fn activate(
&self,
params: ActivateParams,
) -> Result<SdkActivateLicenseKeyResponseValue200ApplicationJson, Error> {
self.activate_with_options(params, None).await
}
pub async fn activate_with_options(
&self,
params: ActivateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkActivateLicenseKeyResponseValue200ApplicationJson, Error> {
self.activate_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn activate_raw(
&self,
params: ActivateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkActivateLicenseKeyResponseValue200ApplicationJson>, Error>
{
let path = "/v2/licenses/activate".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("activateLicenseKey".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/licenses/activate",
)
.await
}
pub async fn validate(
&self,
params: ValidateParams,
) -> Result<SdkValidateLicenseKeyResponseValue200ApplicationJson, Error> {
self.validate_with_options(params, None).await
}
pub async fn validate_with_options(
&self,
params: ValidateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkValidateLicenseKeyResponseValue200ApplicationJson, Error> {
self.validate_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn validate_raw(
&self,
params: ValidateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkValidateLicenseKeyResponseValue200ApplicationJson>, Error>
{
let path = "/v2/licenses/validate".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("validateLicenseKey".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/licenses/validate",
)
.await
}
pub async fn list(
&self,
params: ListParams,
) -> Result<SdkListLicenseKeysResponseValue200ApplicationJson, Error> {
self.list_with_options(params, None).await
}
pub async fn list_with_options(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListLicenseKeysResponseValue200ApplicationJson, Error> {
self.list_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn list_raw(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListLicenseKeysResponseValue200ApplicationJson>, Error> {
let path = "/v2/license-keys".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listLicenseKeys".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/license-keys",
)
.await
}
pub async fn get(
&self,
license_key: &str,
params: GetParams,
) -> Result<SdkGetLicenseKeyResponseValue200ApplicationJson, Error> {
self.get_with_options(license_key, params, None).await
}
pub async fn get_with_options(
&self,
license_key: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetLicenseKeyResponseValue200ApplicationJson, Error> {
self.get_raw(license_key, params, options)
.await
.map(|response| response.data)
}
pub async fn get_raw(
&self,
license_key: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetLicenseKeyResponseValue200ApplicationJson>, Error> {
let license_key = crate::client::path_segment(license_key);
let path = format!("/v2/license-keys/{license_key}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getLicenseKey".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/license-keys/{license_key}",
)
.await
}
pub async fn update(
&self,
license_key: &str,
params: UpdateParams,
) -> Result<SdkUpdateLicenseKeyResponseValue200ApplicationJson, Error> {
self.update_with_options(license_key, params, None).await
}
pub async fn update_with_options(
&self,
license_key: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateLicenseKeyResponseValue200ApplicationJson, Error> {
self.update_raw(license_key, params, options)
.await
.map(|response| response.data)
}
pub async fn update_raw(
&self,
license_key: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkUpdateLicenseKeyResponseValue200ApplicationJson>, Error> {
let license_key = crate::client::path_segment(license_key);
let path = format!("/v2/license-keys/{license_key}");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("updateLicenseKey".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/license-keys/{license_key}",
)
.await
}
pub async fn deactivate_license(
&self,
params: DeactivateLicenseParams,
) -> Result<SdkDeactivateLicenseResponseValue200ApplicationJson, Error> {
self.deactivate_license_with_options(params, None).await
}
pub async fn deactivate_license_with_options(
&self,
params: DeactivateLicenseParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkDeactivateLicenseResponseValue200ApplicationJson, Error> {
self.deactivate_license_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn deactivate_license_raw(
&self,
params: DeactivateLicenseParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkDeactivateLicenseResponseValue200ApplicationJson>, Error>
{
let path = "/v2/licenses/deactivate".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("deactivateLicense".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/licenses/deactivate",
)
.await
}
}