#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use serde::{Serialize, Deserialize};
use crate::tools_ozone::report::AssignmentActivity;
use crate::tools_ozone::report::CloseActivity;
use crate::tools_ozone::report::EscalationActivity;
use crate::tools_ozone::report::NoteActivity;
use crate::tools_ozone::report::QueueActivity;
use crate::tools_ozone::report::ReopenActivity;
use crate::tools_ozone::report::ReportActivityView;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CreateActivity<S: BosStr = DefaultStr> {
pub activity: CreateActivityActivity<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub internal_note: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_create_activity_is_automated")]
pub is_automated: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub public_note: Option<S>,
pub report_id: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum CreateActivityActivity<S: BosStr = DefaultStr> {
#[serde(rename = "tools.ozone.report.defs#queueActivity")]
QueueActivity(Box<QueueActivity<S>>),
#[serde(rename = "tools.ozone.report.defs#assignmentActivity")]
AssignmentActivity(Box<AssignmentActivity<S>>),
#[serde(rename = "tools.ozone.report.defs#escalationActivity")]
EscalationActivity(Box<EscalationActivity<S>>),
#[serde(rename = "tools.ozone.report.defs#closeActivity")]
CloseActivity(Box<CloseActivity<S>>),
#[serde(rename = "tools.ozone.report.defs#reopenActivity")]
ReopenActivity(Box<ReopenActivity<S>>),
#[serde(rename = "tools.ozone.report.defs#noteActivity")]
NoteActivity(Box<NoteActivity<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CreateActivityOutput<S: BosStr = DefaultStr> {
pub activity: ReportActivityView<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic
)]
#[serde(tag = "error", content = "message")]
pub enum CreateActivityError {
#[serde(rename = "ReportNotFound")]
ReportNotFound(Option<SmolStr>),
#[serde(rename = "InvalidStateTransition")]
InvalidStateTransition(Option<SmolStr>),
#[serde(rename = "AlreadyInTargetState")]
AlreadyInTargetState(Option<SmolStr>),
#[serde(untagged)]
Other { error: SmolStr, message: Option<SmolStr> },
}
impl core::fmt::Display for CreateActivityError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::ReportNotFound(msg) => {
write!(f, "ReportNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::InvalidStateTransition(msg) => {
write!(f, "InvalidStateTransition")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::AlreadyInTargetState(msg) => {
write!(f, "AlreadyInTargetState")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
pub struct CreateActivityResponse;
impl jacquard_common::xrpc::XrpcResp for CreateActivityResponse {
const NSID: &'static str = "tools.ozone.report.createActivity";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CreateActivityOutput<S>;
type Err = CreateActivityError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for CreateActivity<S> {
const NSID: &'static str = "tools.ozone.report.createActivity";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = CreateActivityResponse;
}
pub struct CreateActivityRequest;
impl jacquard_common::xrpc::XrpcEndpoint for CreateActivityRequest {
const PATH: &'static str = "/xrpc/tools.ozone.report.createActivity";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<S: BosStr> = CreateActivity<S>;
type Response = CreateActivityResponse;
}
fn _default_create_activity_is_automated() -> Option<bool> {
Some(false)
}
pub mod create_activity_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Activity;
type ReportId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Activity = Unset;
type ReportId = Unset;
}
pub struct SetActivity<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetActivity<St> {}
impl<St: State> State for SetActivity<St> {
type Activity = Set<members::activity>;
type ReportId = St::ReportId;
}
pub struct SetReportId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetReportId<St> {}
impl<St: State> State for SetReportId<St> {
type Activity = St::Activity;
type ReportId = Set<members::report_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct activity(());
pub struct report_id(());
}
}
pub struct CreateActivityBuilder<
St: create_activity_state::State,
S: BosStr = DefaultStr,
> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<CreateActivityActivity<S>>,
Option<S>,
Option<bool>,
Option<S>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl CreateActivity<DefaultStr> {
pub fn new() -> CreateActivityBuilder<create_activity_state::Empty, DefaultStr> {
CreateActivityBuilder::new()
}
}
impl<S: BosStr> CreateActivity<S> {
pub fn builder() -> CreateActivityBuilder<create_activity_state::Empty, S> {
CreateActivityBuilder::builder()
}
}
impl CreateActivityBuilder<create_activity_state::Empty, DefaultStr> {
pub fn new() -> Self {
CreateActivityBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> CreateActivityBuilder<create_activity_state::Empty, S> {
pub fn builder() -> Self {
CreateActivityBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> CreateActivityBuilder<St, S>
where
St: create_activity_state::State,
St::Activity: create_activity_state::IsUnset,
{
pub fn activity(
mut self,
value: impl Into<CreateActivityActivity<S>>,
) -> CreateActivityBuilder<create_activity_state::SetActivity<St>, S> {
self._fields.0 = Option::Some(value.into());
CreateActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: create_activity_state::State, S: BosStr> CreateActivityBuilder<St, S> {
pub fn internal_note(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_internal_note(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<St: create_activity_state::State, S: BosStr> CreateActivityBuilder<St, S> {
pub fn is_automated(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_is_automated(mut self, value: Option<bool>) -> Self {
self._fields.2 = value;
self
}
}
impl<St: create_activity_state::State, S: BosStr> CreateActivityBuilder<St, S> {
pub fn public_note(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_public_note(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<St, S: BosStr> CreateActivityBuilder<St, S>
where
St: create_activity_state::State,
St::ReportId: create_activity_state::IsUnset,
{
pub fn report_id(
mut self,
value: impl Into<i64>,
) -> CreateActivityBuilder<create_activity_state::SetReportId<St>, S> {
self._fields.4 = Option::Some(value.into());
CreateActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> CreateActivityBuilder<St, S>
where
St: create_activity_state::State,
St::Activity: create_activity_state::IsSet,
St::ReportId: create_activity_state::IsSet,
{
pub fn build(self) -> CreateActivity<S> {
CreateActivity {
activity: self._fields.0.unwrap(),
internal_note: self._fields.1,
is_automated: self._fields.2.or_else(|| Some(false)),
public_note: self._fields.3,
report_id: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> CreateActivity<S> {
CreateActivity {
activity: self._fields.0.unwrap(),
internal_note: self._fields.1,
is_automated: self._fields.2.or_else(|| Some(false)),
public_note: self._fields.3,
report_id: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}