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 CustomerSessionsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateCustomerSessionParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: CreateCustomerSessionParamsBodyOneOf,
}
impl CreateCustomerSessionParams {
#[allow(deprecated)]
pub fn new(body: CreateCustomerSessionParamsBodyOneOf) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct RevokeCustomerSessionParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl<'a> CustomerSessionsApi<'a> {
pub async fn create_customer_session(
&self,
params: CreateCustomerSessionParams,
) -> Result<SdkCreateCustomerSessionResponseValue201ApplicationJson, Error> {
self.create_customer_session_with_options(params, None)
.await
}
pub async fn create_customer_session_with_options(
&self,
params: CreateCustomerSessionParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateCustomerSessionResponseValue201ApplicationJson, Error> {
self.create_customer_session_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn create_customer_session_raw(
&self,
params: CreateCustomerSessionParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkCreateCustomerSessionResponseValue201ApplicationJson>, Error>
{
let path = "/v2/customer-sessions".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createCustomerSession".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/customer-sessions",
)
.await
}
pub async fn revoke_customer_session(
&self,
session: &str,
params: RevokeCustomerSessionParams,
) -> Result<SdkRevokeCustomerSessionResponseValue200ApplicationJson, Error> {
self.revoke_customer_session_with_options(session, params, None)
.await
}
pub async fn revoke_customer_session_with_options(
&self,
session: &str,
params: RevokeCustomerSessionParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkRevokeCustomerSessionResponseValue200ApplicationJson, Error> {
self.revoke_customer_session_raw(session, params, options)
.await
.map(|response| response.data)
}
pub async fn revoke_customer_session_raw(
&self,
session: &str,
params: RevokeCustomerSessionParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkRevokeCustomerSessionResponseValue200ApplicationJson>, Error>
{
let session = crate::client::path_segment(session);
let path = format!("/v2/customer-sessions/{session}");
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("revokeCustomerSession".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"DELETE /v2/customer-sessions/{session}",
)
.await
}
}