// 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 TicketsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct ListParams {
/// Number of items to return per page.
///
/// Defaults to `15`.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
/// Page number to return.
///
/// Defaults to `1`.
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<i64>,
}
impl Default for ListParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
limit: Some(15),
page: Some(1),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct SearchParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkSearchTicketsRequestApplicationJson,
}
impl SearchParams {
/// Construct a new `SearchParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkSearchTicketsRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2ListTicketsParams {
/// Number of items to return per page.
///
/// Defaults to `15`.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
/// Page number to return.
///
/// Defaults to `1`.
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<i64>,
/// 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 Default for V2ListTicketsParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
limit: Some(15),
page: Some(1),
x_store: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct V2SearchTicketsParams {
/// 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: SdkV2SearchTicketsRequestApplicationJson,
}
impl V2SearchTicketsParams {
/// Construct a new `V2SearchTicketsParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkV2SearchTicketsRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct V2GetTicketParams {
/// 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 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: SdkUpdateTicketRequestApplicationJson,
}
impl UpdateParams {
/// Construct a new `UpdateParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkUpdateTicketRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> TicketsApi<'a> {
/// List all tickets
///
/// List your store's support tickets, 15 per page by default.
pub async fn list(
&self,
params: ListParams,
) -> Result<SdkListTicketsResponseValue200ApplicationJson, 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<SdkListTicketsResponseValue200ApplicationJson, 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<SdkListTicketsResponseValue200ApplicationJson>, Error> {
let path = "/v1/tickets".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listTickets".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(method, &path, ¶ms, options, "GET /v1/tickets")
.await
}
/// Retrieve specific ticket
///
/// Retrieve a support ticket by its ID.
pub async fn get(
&self,
ticket: &str,
) -> Result<SdkGetTicketResponseValue200ApplicationJson, Error> {
self.get_with_options(ticket, None).await
}
/// Variant of [`Self::get`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_with_options(
&self,
ticket: &str,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetTicketResponseValue200ApplicationJson, Error> {
self.get_raw(ticket, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_raw(
&self,
ticket: &str,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetTicketResponseValue200ApplicationJson>, Error> {
let ticket = crate::client::path_segment(ticket);
let path = format!("/v1/tickets/{ticket}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getTicket".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"GET /v1/tickets/{ticket}",
)
.await
}
/// Search tickets
///
/// Search tickets using JSON body filters, search terms, includes, and sort instructions.
pub async fn search(
&self,
params: SearchParams,
) -> Result<SdkSearchTicketsResponseValue200ApplicationJson, Error> {
self.search_with_options(params, None).await
}
/// Variant of [`Self::search`] that accepts per-request [`crate::RequestOptions`].
pub async fn search_with_options(
&self,
params: SearchParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkSearchTicketsResponseValue200ApplicationJson, Error> {
self.search_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn search_raw(
&self,
params: SearchParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkSearchTicketsResponseValue200ApplicationJson>, Error> {
let path = "/v1/tickets/search".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("searchTickets".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v1/tickets/search",
)
.await
}
/// List all tickets
///
/// List your store's support tickets, 15 per page by default. This v2 route is store-scoped. 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 v_2_list_tickets(
&self,
params: V2ListTicketsParams,
) -> Result<SdkV2ListTicketsResponseValue200ApplicationJson, Error> {
self.v_2_list_tickets_with_options(params, None).await
}
/// Variant of [`Self::v_2_list_tickets`] that accepts per-request [`crate::RequestOptions`].
pub async fn v_2_list_tickets_with_options(
&self,
params: V2ListTicketsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2ListTicketsResponseValue200ApplicationJson, Error> {
self.v_2_list_tickets_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn v_2_list_tickets_raw(
&self,
params: V2ListTicketsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2ListTicketsResponseValue200ApplicationJson>, Error> {
let path = "/v2/tickets".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2ListTickets".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(method, &path, ¶ms, options, "GET /v2/tickets")
.await
}
/// Search tickets
///
/// Search tickets using JSON body filters, search terms, includes, and sort instructions. This v2 route is store-scoped. 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 v_2_search_tickets(
&self,
params: V2SearchTicketsParams,
) -> Result<SdkV2SearchTicketsResponseValue200ApplicationJson, Error> {
self.v_2_search_tickets_with_options(params, None).await
}
/// Variant of [`Self::v_2_search_tickets`] that accepts per-request [`crate::RequestOptions`].
pub async fn v_2_search_tickets_with_options(
&self,
params: V2SearchTicketsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2SearchTicketsResponseValue200ApplicationJson, Error> {
self.v_2_search_tickets_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn v_2_search_tickets_raw(
&self,
params: V2SearchTicketsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2SearchTicketsResponseValue200ApplicationJson>, Error> {
let path = "/v2/tickets/search".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2SearchTickets".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/tickets/search",
)
.await
}
/// Retrieve specific ticket
///
/// Retrieve a support ticket by its ID. This v2 route is store-scoped. 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 v_2_get_ticket(
&self,
ticket: &str,
params: V2GetTicketParams,
) -> Result<SdkV2GetTicketResponseValue200ApplicationJson, Error> {
self.v_2_get_ticket_with_options(ticket, params, None).await
}
/// Variant of [`Self::v_2_get_ticket`] that accepts per-request [`crate::RequestOptions`].
pub async fn v_2_get_ticket_with_options(
&self,
ticket: &str,
params: V2GetTicketParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkV2GetTicketResponseValue200ApplicationJson, Error> {
self.v_2_get_ticket_raw(ticket, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn v_2_get_ticket_raw(
&self,
ticket: &str,
params: V2GetTicketParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkV2GetTicketResponseValue200ApplicationJson>, Error> {
let ticket = crate::client::path_segment(ticket);
let path = format!("/v2/tickets/{ticket}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("v2GetTicket".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/tickets/{ticket}",
)
.await
}
/// Close, reopen, or archive a ticket
///
/// Change ticket status or archive state in the selected store. Requires the ticket API-key ability and store ticket permission. Send status OPEN to reopen or CLOSED to close; closing sends the existing customer notification only when the status changes. Send archived true to archive or false to restore. You may send both fields together; omitted fields stay unchanged. Use the same optional Idempotency-Key and identical body after a lost response. 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,
ticket: &str,
params: UpdateParams,
) -> Result<SdkUpdateTicketResponseValue200ApplicationJson, Error> {
self.update_with_options(ticket, params, None).await
}
/// Variant of [`Self::update`] that accepts per-request [`crate::RequestOptions`].
pub async fn update_with_options(
&self,
ticket: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateTicketResponseValue200ApplicationJson, Error> {
self.update_raw(ticket, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn update_raw(
&self,
ticket: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkUpdateTicketResponseValue200ApplicationJson>, Error> {
let ticket = crate::client::path_segment(ticket);
let path = format!("/v2/tickets/{ticket}");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("updateTicket".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/tickets/{ticket}",
)
.await
}
}