Use of associated types + Identity and EmailSubmission helpers.
parent
8c1d49353d
commit
1b27e6e146
|
@ -1,6 +1,10 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::RequestParams;
|
use super::{Object, RequestParams};
|
||||||
|
|
||||||
|
pub trait ChangesObject: Object {
|
||||||
|
type ChangesResponse;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct ChangesRequest {
|
pub struct ChangesRequest {
|
||||||
|
@ -16,7 +20,7 @@ pub struct ChangesRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct ChangesResponse<A> {
|
pub struct ChangesResponse<O: ChangesObject> {
|
||||||
#[serde(rename = "accountId")]
|
#[serde(rename = "accountId")]
|
||||||
account_id: String,
|
account_id: String,
|
||||||
|
|
||||||
|
@ -36,7 +40,7 @@ pub struct ChangesResponse<A> {
|
||||||
destroyed: Vec<String>,
|
destroyed: Vec<String>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
arguments: A,
|
arguments: O::ChangesResponse,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChangesRequest {
|
impl ChangesRequest {
|
||||||
|
@ -59,7 +63,7 @@ impl ChangesRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> ChangesResponse<A> {
|
impl<O: ChangesObject> ChangesResponse<O> {
|
||||||
pub fn account_id(&self) -> &str {
|
pub fn account_id(&self) -> &str {
|
||||||
&self.account_id
|
&self.account_id
|
||||||
}
|
}
|
||||||
|
@ -88,7 +92,7 @@ impl<A> ChangesResponse<A> {
|
||||||
&self.destroyed
|
&self.destroyed
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arguments(&self) -> &A {
|
pub fn arguments(&self) -> &O::ChangesResponse {
|
||||||
&self.arguments
|
&self.arguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use std::{collections::HashMap, fmt::Display};
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
set::{Create, SetError},
|
set::{SetError, SetObject},
|
||||||
RequestParams,
|
RequestParams,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct CopyRequest<T: Create> {
|
pub struct CopyRequest<O: SetObject> {
|
||||||
#[serde(rename = "fromAccountId")]
|
#[serde(rename = "fromAccountId")]
|
||||||
from_account_id: String,
|
from_account_id: String,
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ pub struct CopyRequest<T: Create> {
|
||||||
if_in_state: Option<String>,
|
if_in_state: Option<String>,
|
||||||
|
|
||||||
#[serde(rename = "create")]
|
#[serde(rename = "create")]
|
||||||
create: HashMap<String, T>,
|
create: HashMap<String, O>,
|
||||||
|
|
||||||
#[serde(rename = "onSuccessDestroyOriginal")]
|
#[serde(rename = "onSuccessDestroyOriginal")]
|
||||||
on_success_destroy_original: bool,
|
on_success_destroy_original: bool,
|
||||||
|
@ -35,7 +35,7 @@ pub struct CopyRequest<T: Create> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct CopyResponse<T, U: Display> {
|
pub struct CopyResponse<O: SetObject> {
|
||||||
#[serde(rename = "fromAccountId")]
|
#[serde(rename = "fromAccountId")]
|
||||||
from_account_id: String,
|
from_account_id: String,
|
||||||
|
|
||||||
|
@ -49,13 +49,13 @@ pub struct CopyResponse<T, U: Display> {
|
||||||
new_state: String,
|
new_state: String,
|
||||||
|
|
||||||
#[serde(rename = "created")]
|
#[serde(rename = "created")]
|
||||||
created: Option<HashMap<String, T>>,
|
created: Option<HashMap<String, O>>,
|
||||||
|
|
||||||
#[serde(rename = "notCreated")]
|
#[serde(rename = "notCreated")]
|
||||||
not_created: Option<HashMap<String, SetError<U>>>,
|
not_created: Option<HashMap<String, SetError<O::Property>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Create> CopyRequest<T> {
|
impl<T: SetObject> CopyRequest<T> {
|
||||||
pub fn new(params: RequestParams, from_account_id: String) -> Self {
|
pub fn new(params: RequestParams, from_account_id: String) -> Self {
|
||||||
CopyRequest {
|
CopyRequest {
|
||||||
from_account_id,
|
from_account_id,
|
||||||
|
@ -105,7 +105,7 @@ impl<T: Create> CopyRequest<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, U: Display> CopyResponse<T, U> {
|
impl<O: SetObject> CopyResponse<O> {
|
||||||
pub fn from_account_id(&self) -> &str {
|
pub fn from_account_id(&self) -> &str {
|
||||||
&self.from_account_id
|
&self.from_account_id
|
||||||
}
|
}
|
||||||
|
@ -122,11 +122,11 @@ impl<T, U: Display> CopyResponse<T, U> {
|
||||||
&self.new_state
|
&self.new_state
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn created(&self, id: &str) -> Option<&T> {
|
pub fn created(&self, id: &str) -> Option<&O> {
|
||||||
self.created.as_ref().and_then(|created| created.get(id))
|
self.created.as_ref().and_then(|created| created.get(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn not_created(&self, id: &str) -> Option<&SetError<U>> {
|
pub fn not_created(&self, id: &str) -> Option<&SetError<O::Property>> {
|
||||||
self.not_created
|
self.not_created
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|not_created| not_created.get(id))
|
.and_then(|not_created| not_created.get(id))
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
use std::fmt::Display;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::Method;
|
use crate::Method;
|
||||||
|
|
||||||
use super::{request::ResultReference, RequestParams, Type};
|
use super::{request::ResultReference, Object, RequestParams};
|
||||||
|
|
||||||
|
pub trait GetObject: Object {
|
||||||
|
type GetArguments: Default;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct GetRequest<T: Display + Type, A: Default> {
|
pub struct GetRequest<O: GetObject> {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
method: (Method, usize),
|
method: (Method, usize),
|
||||||
|
|
||||||
|
@ -24,10 +26,10 @@ pub struct GetRequest<T: Display + Type, A: Default> {
|
||||||
ids_ref: Option<ResultReference>,
|
ids_ref: Option<ResultReference>,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
properties: Option<Vec<T>>,
|
properties: Option<Vec<O::Property>>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
arguments: A,
|
arguments: O::GetArguments,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
@ -43,10 +45,10 @@ pub struct GetResponse<T> {
|
||||||
not_found: Vec<String>,
|
not_found: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Display + Type, A: Default> GetRequest<T, A> {
|
impl<O: GetObject> GetRequest<O> {
|
||||||
pub fn new(params: RequestParams) -> Self {
|
pub fn new(params: RequestParams) -> Self {
|
||||||
GetRequest {
|
GetRequest {
|
||||||
account_id: if T::requires_account_id() {
|
account_id: if O::requires_account_id() {
|
||||||
params.account_id.into()
|
params.account_id.into()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -55,12 +57,12 @@ impl<T: Display + Type, A: Default> GetRequest<T, A> {
|
||||||
ids: None,
|
ids: None,
|
||||||
ids_ref: None,
|
ids_ref: None,
|
||||||
properties: None,
|
properties: None,
|
||||||
arguments: A::default(),
|
arguments: O::GetArguments::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn account_id(&mut self, account_id: impl Into<String>) -> &mut Self {
|
pub fn account_id(&mut self, account_id: impl Into<String>) -> &mut Self {
|
||||||
if T::requires_account_id() {
|
if O::requires_account_id() {
|
||||||
self.account_id = Some(account_id.into());
|
self.account_id = Some(account_id.into());
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
|
@ -82,16 +84,16 @@ impl<T: Display + Type, A: Default> GetRequest<T, A> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn properties(&mut self, properties: impl IntoIterator<Item = T>) -> &mut Self {
|
pub fn properties(&mut self, properties: impl IntoIterator<Item = O::Property>) -> &mut Self {
|
||||||
self.properties = Some(properties.into_iter().collect());
|
self.properties = Some(properties.into_iter().collect());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arguments(&mut self) -> &mut A {
|
pub fn arguments(&mut self) -> &mut O::GetArguments {
|
||||||
&mut self.arguments
|
&mut self.arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn result_reference(&self, property: T) -> ResultReference {
|
pub fn result_reference(&self, property: O::Property) -> ResultReference {
|
||||||
ResultReference::new(
|
ResultReference::new(
|
||||||
self.method.0,
|
self.method.0,
|
||||||
self.method.1,
|
self.method.1,
|
||||||
|
@ -100,7 +102,7 @@ impl<T: Display + Type, A: Default> GetRequest<T, A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> GetResponse<T> {
|
impl<O> GetResponse<O> {
|
||||||
pub fn account_id(&self) -> &str {
|
pub fn account_id(&self) -> &str {
|
||||||
self.account_id.as_ref().unwrap()
|
self.account_id.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -109,7 +111,7 @@ impl<T> GetResponse<T> {
|
||||||
&self.state
|
&self.state
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list(&self) -> &[T] {
|
pub fn list(&self) -> &[O] {
|
||||||
&self.list
|
&self.list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,10 +119,10 @@ impl<T> GetResponse<T> {
|
||||||
&self.not_found
|
&self.not_found
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_list(&mut self) -> Vec<T> {
|
pub fn unwrap_list(&mut self) -> Vec<O> {
|
||||||
std::mem::take(&mut self.list)
|
std::mem::take(&mut self.list)
|
||||||
}
|
}
|
||||||
pub fn pop(&mut self) -> Option<T> {
|
pub fn pop(&mut self) -> Option<O> {
|
||||||
self.list.pop()
|
self.list.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::Method;
|
use crate::Method;
|
||||||
|
|
||||||
pub mod changes;
|
pub mod changes;
|
||||||
|
@ -27,6 +31,7 @@ impl RequestParams {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Type {
|
pub trait Object: Sized {
|
||||||
|
type Property: Display + Serialize + for<'de> Deserialize<'de>;
|
||||||
fn requires_account_id() -> bool;
|
fn requires_account_id() -> bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,16 @@ use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::Method;
|
use crate::Method;
|
||||||
|
|
||||||
use super::{request::ResultReference, RequestParams};
|
use super::{request::ResultReference, Object, RequestParams};
|
||||||
|
|
||||||
|
pub trait QueryObject: Object {
|
||||||
|
type QueryArguments: Default + Serialize;
|
||||||
|
type Filter: Serialize;
|
||||||
|
type Sort: Serialize;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct QueryRequest<F, S, A: Default> {
|
pub struct QueryRequest<O: QueryObject> {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
method: (Method, usize),
|
method: (Method, usize),
|
||||||
|
|
||||||
|
@ -14,11 +20,11 @@ pub struct QueryRequest<F, S, A: Default> {
|
||||||
|
|
||||||
#[serde(rename = "filter")]
|
#[serde(rename = "filter")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
filter: Option<Filter<F>>,
|
filter: Option<Filter<O::Filter>>,
|
||||||
|
|
||||||
#[serde(rename = "sort")]
|
#[serde(rename = "sort")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
sort: Option<Vec<Comparator<S>>>,
|
sort: Option<Vec<Comparator<O::Sort>>>,
|
||||||
|
|
||||||
#[serde(rename = "position")]
|
#[serde(rename = "position")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
@ -41,7 +47,7 @@ pub struct QueryRequest<F, S, A: Default> {
|
||||||
calculate_total: Option<bool>,
|
calculate_total: Option<bool>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
arguments: A,
|
arguments: O::QueryArguments,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
@ -103,7 +109,7 @@ pub struct QueryResponse {
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, S, A: Default> QueryRequest<F, S, A> {
|
impl<O: QueryObject> QueryRequest<O> {
|
||||||
pub fn new(params: RequestParams) -> Self {
|
pub fn new(params: RequestParams) -> Self {
|
||||||
QueryRequest {
|
QueryRequest {
|
||||||
account_id: params.account_id,
|
account_id: params.account_id,
|
||||||
|
@ -115,7 +121,7 @@ impl<F, S, A: Default> QueryRequest<F, S, A> {
|
||||||
anchor_offset: None,
|
anchor_offset: None,
|
||||||
limit: None,
|
limit: None,
|
||||||
calculate_total: None,
|
calculate_total: None,
|
||||||
arguments: A::default(),
|
arguments: O::QueryArguments::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,12 +130,12 @@ impl<F, S, A: Default> QueryRequest<F, S, A> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn filter(&mut self, filter: impl Into<Filter<F>>) -> &mut Self {
|
pub fn filter(&mut self, filter: impl Into<Filter<O::Filter>>) -> &mut Self {
|
||||||
self.filter = Some(filter.into());
|
self.filter = Some(filter.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sort(&mut self, sort: impl IntoIterator<Item = Comparator<S>>) -> &mut Self {
|
pub fn sort(&mut self, sort: impl IntoIterator<Item = Comparator<O::Sort>>) -> &mut Self {
|
||||||
self.sort = Some(sort.into_iter().collect());
|
self.sort = Some(sort.into_iter().collect());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -159,7 +165,7 @@ impl<F, S, A: Default> QueryRequest<F, S, A> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arguments(&mut self) -> &mut A {
|
pub fn arguments(&mut self) -> &mut O::QueryArguments {
|
||||||
&mut self.arguments
|
&mut self.arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
query::{Comparator, Filter},
|
query::{Comparator, Filter, QueryObject},
|
||||||
RequestParams,
|
RequestParams,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct QueryChangesRequest<F, S, A: Default> {
|
pub struct QueryChangesRequest<O: QueryObject> {
|
||||||
#[serde(rename = "accountId")]
|
#[serde(rename = "accountId")]
|
||||||
account_id: String,
|
account_id: String,
|
||||||
|
|
||||||
#[serde(rename = "filter")]
|
#[serde(rename = "filter")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
filter: Option<Filter<F>>,
|
filter: Option<Filter<O::Filter>>,
|
||||||
|
|
||||||
#[serde(rename = "sort")]
|
#[serde(rename = "sort")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
sort: Option<Vec<Comparator<S>>>,
|
sort: Option<Vec<Comparator<O::Sort>>>,
|
||||||
|
|
||||||
#[serde(rename = "sinceQueryState")]
|
#[serde(rename = "sinceQueryState")]
|
||||||
since_query_state: String,
|
since_query_state: String,
|
||||||
|
@ -33,7 +33,7 @@ pub struct QueryChangesRequest<F, S, A: Default> {
|
||||||
calculate_total: bool,
|
calculate_total: bool,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
arguments: A,
|
arguments: O::QueryArguments,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
@ -58,7 +58,7 @@ pub struct AddedItem {
|
||||||
index: usize,
|
index: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, S, A: Default> QueryChangesRequest<F, S, A> {
|
impl<O: QueryObject> QueryChangesRequest<O> {
|
||||||
pub fn new(params: RequestParams, since_query_state: String) -> Self {
|
pub fn new(params: RequestParams, since_query_state: String) -> Self {
|
||||||
QueryChangesRequest {
|
QueryChangesRequest {
|
||||||
account_id: params.account_id,
|
account_id: params.account_id,
|
||||||
|
@ -68,7 +68,7 @@ impl<F, S, A: Default> QueryChangesRequest<F, S, A> {
|
||||||
max_changes: None,
|
max_changes: None,
|
||||||
up_to_id: None,
|
up_to_id: None,
|
||||||
calculate_total: false,
|
calculate_total: false,
|
||||||
arguments: A::default(),
|
arguments: O::QueryArguments::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,12 +77,12 @@ impl<F, S, A: Default> QueryChangesRequest<F, S, A> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn filter(&mut self, filter: impl Into<Filter<F>>) -> &mut Self {
|
pub fn filter(&mut self, filter: impl Into<Filter<O::Filter>>) -> &mut Self {
|
||||||
self.filter = Some(filter.into());
|
self.filter = Some(filter.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sort(&mut self, sort: impl IntoIterator<Item = Comparator<S>>) -> &mut Self {
|
pub fn sort(&mut self, sort: impl IntoIterator<Item = Comparator<O::Sort>>) -> &mut Self {
|
||||||
self.sort = Some(sort.into_iter().collect());
|
self.sort = Some(sort.into_iter().collect());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ impl<F, S, A: Default> QueryChangesRequest<F, S, A> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arguments(&mut self) -> &mut A {
|
pub fn arguments(&mut self) -> &mut O::QueryArguments {
|
||||||
&mut self.arguments
|
&mut self.arguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@ use serde::{de::DeserializeOwned, Serialize};
|
||||||
use crate::{
|
use crate::{
|
||||||
blob::copy::CopyBlobRequest,
|
blob::copy::CopyBlobRequest,
|
||||||
client::Client,
|
client::Client,
|
||||||
email::{self, import::EmailImportRequest, parse::EmailParseRequest, Email},
|
email::{import::EmailImportRequest, parse::EmailParseRequest, Email},
|
||||||
email_submission::{self, EmailSubmission},
|
email_submission::EmailSubmission,
|
||||||
identity::{self, Identity},
|
identity::Identity,
|
||||||
mailbox::{self, Mailbox},
|
mailbox::Mailbox,
|
||||||
push_subscription::{self, PushSubscription},
|
push_subscription::PushSubscription,
|
||||||
thread,
|
thread::Thread,
|
||||||
vacation_response::{self, VacationResponse},
|
vacation_response::VacationResponse,
|
||||||
Error, Method, Set, URI,
|
Error, Method, Set, URI,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,47 +55,29 @@ pub struct ResultReference {
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum Arguments {
|
pub enum Arguments {
|
||||||
Changes(ChangesRequest),
|
Changes(ChangesRequest),
|
||||||
PushGet(GetRequest<push_subscription::Property, ()>),
|
PushGet(GetRequest<PushSubscription<Set>>),
|
||||||
PushSet(SetRequest<PushSubscription<Set>, ()>),
|
PushSet(SetRequest<PushSubscription<Set>>),
|
||||||
BlobCopy(CopyBlobRequest),
|
BlobCopy(CopyBlobRequest),
|
||||||
MailboxGet(GetRequest<mailbox::Property, ()>),
|
MailboxGet(GetRequest<Mailbox<Set>>),
|
||||||
MailboxQuery(
|
MailboxQuery(QueryRequest<Mailbox<Set>>),
|
||||||
QueryRequest<mailbox::query::Filter, mailbox::query::Comparator, mailbox::QueryArguments>,
|
MailboxQueryChanges(QueryChangesRequest<Mailbox<Set>>),
|
||||||
),
|
MailboxSet(SetRequest<Mailbox<Set>>),
|
||||||
MailboxQueryChanges(
|
ThreadGet(GetRequest<Thread>),
|
||||||
QueryChangesRequest<
|
EmailGet(GetRequest<Email<Set>>),
|
||||||
mailbox::query::Filter,
|
EmailQuery(QueryRequest<Email<Set>>),
|
||||||
mailbox::query::Comparator,
|
EmailQueryChanges(QueryChangesRequest<Email<Set>>),
|
||||||
mailbox::QueryArguments,
|
EmailSet(SetRequest<Email<Set>>),
|
||||||
>,
|
|
||||||
),
|
|
||||||
MailboxSet(SetRequest<Mailbox<Set>, mailbox::SetArguments>),
|
|
||||||
ThreadGet(GetRequest<thread::Property, ()>),
|
|
||||||
EmailGet(GetRequest<email::Property, email::GetArguments>),
|
|
||||||
EmailQuery(QueryRequest<email::query::Filter, email::query::Comparator, email::QueryArguments>),
|
|
||||||
EmailQueryChanges(
|
|
||||||
QueryChangesRequest<email::query::Filter, email::query::Comparator, email::QueryArguments>,
|
|
||||||
),
|
|
||||||
EmailSet(SetRequest<Email<Set>, ()>),
|
|
||||||
EmailCopy(CopyRequest<Email<Set>>),
|
EmailCopy(CopyRequest<Email<Set>>),
|
||||||
EmailImport(EmailImportRequest),
|
EmailImport(EmailImportRequest),
|
||||||
EmailParse(EmailParseRequest),
|
EmailParse(EmailParseRequest),
|
||||||
IdentityGet(GetRequest<identity::Property, ()>),
|
IdentityGet(GetRequest<Identity<Set>>),
|
||||||
IdentitySet(SetRequest<Identity<Set>, ()>),
|
IdentitySet(SetRequest<Identity<Set>>),
|
||||||
EmailSubmissionGet(GetRequest<email_submission::Property, ()>),
|
EmailSubmissionGet(GetRequest<EmailSubmission<Set>>),
|
||||||
EmailSubmissionQuery(
|
EmailSubmissionQuery(QueryRequest<EmailSubmission<Set>>),
|
||||||
QueryRequest<email_submission::query::Filter, email_submission::query::Comparator, ()>,
|
EmailSubmissionQueryChanges(QueryChangesRequest<EmailSubmission<Set>>),
|
||||||
),
|
EmailSubmissionSet(SetRequest<EmailSubmission<Set>>),
|
||||||
EmailSubmissionQueryChanges(
|
VacationResponseGet(GetRequest<VacationResponse<Set>>),
|
||||||
QueryChangesRequest<
|
VacationResponseSet(SetRequest<VacationResponse<Set>>),
|
||||||
email_submission::query::Filter,
|
|
||||||
email_submission::query::Comparator,
|
|
||||||
(),
|
|
||||||
>,
|
|
||||||
),
|
|
||||||
EmailSubmissionSet(SetRequest<EmailSubmission<Set>, email_submission::SetArguments>),
|
|
||||||
VacationResponseGet(GetRequest<vacation_response::Property, ()>),
|
|
||||||
VacationResponseSet(SetRequest<VacationResponse<Set>, ()>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Arguments {
|
impl Arguments {
|
||||||
|
@ -205,14 +187,14 @@ impl Arguments {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_get_mut(&mut self) -> &mut GetRequest<push_subscription::Property, ()> {
|
pub fn push_get_mut(&mut self) -> &mut GetRequest<PushSubscription<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::PushGet(ref mut r) => r,
|
Arguments::PushGet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_set_mut(&mut self) -> &mut SetRequest<PushSubscription<Set>, ()> {
|
pub fn push_set_mut(&mut self) -> &mut SetRequest<PushSubscription<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::PushSet(ref mut r) => r,
|
Arguments::PushSet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -226,84 +208,63 @@ impl Arguments {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mailbox_get_mut(&mut self) -> &mut GetRequest<mailbox::Property, ()> {
|
pub fn mailbox_get_mut(&mut self) -> &mut GetRequest<Mailbox<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::MailboxGet(ref mut r) => r,
|
Arguments::MailboxGet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mailbox_query_mut(
|
pub fn mailbox_query_mut(&mut self) -> &mut QueryRequest<Mailbox<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<
|
|
||||||
mailbox::query::Filter,
|
|
||||||
mailbox::query::Comparator,
|
|
||||||
mailbox::QueryArguments,
|
|
||||||
> {
|
|
||||||
match self {
|
match self {
|
||||||
Arguments::MailboxQuery(ref mut r) => r,
|
Arguments::MailboxQuery(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mailbox_query_changes_mut(
|
pub fn mailbox_query_changes_mut(&mut self) -> &mut QueryChangesRequest<Mailbox<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryChangesRequest<
|
|
||||||
mailbox::query::Filter,
|
|
||||||
mailbox::query::Comparator,
|
|
||||||
mailbox::QueryArguments,
|
|
||||||
> {
|
|
||||||
match self {
|
match self {
|
||||||
Arguments::MailboxQueryChanges(ref mut r) => r,
|
Arguments::MailboxQueryChanges(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mailbox_set_mut(&mut self) -> &mut SetRequest<Mailbox<Set>, mailbox::SetArguments> {
|
pub fn mailbox_set_mut(&mut self) -> &mut SetRequest<Mailbox<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::MailboxSet(ref mut r) => r,
|
Arguments::MailboxSet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn thread_get_mut(&mut self) -> &mut GetRequest<thread::Property, ()> {
|
pub fn thread_get_mut(&mut self) -> &mut GetRequest<Thread> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::ThreadGet(ref mut r) => r,
|
Arguments::ThreadGet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_get_mut(&mut self) -> &mut GetRequest<email::Property, email::GetArguments> {
|
pub fn email_get_mut(&mut self) -> &mut GetRequest<Email<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::EmailGet(ref mut r) => r,
|
Arguments::EmailGet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_query_mut(
|
pub fn email_query_mut(&mut self) -> &mut QueryRequest<Email<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<email::query::Filter, email::query::Comparator, email::QueryArguments>
|
|
||||||
{
|
|
||||||
match self {
|
match self {
|
||||||
Arguments::EmailQuery(ref mut r) => r,
|
Arguments::EmailQuery(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_query_changes_mut(
|
pub fn email_query_changes_mut(&mut self) -> &mut QueryChangesRequest<Email<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryChangesRequest<
|
|
||||||
email::query::Filter,
|
|
||||||
email::query::Comparator,
|
|
||||||
email::QueryArguments,
|
|
||||||
> {
|
|
||||||
match self {
|
match self {
|
||||||
Arguments::EmailQueryChanges(ref mut r) => r,
|
Arguments::EmailQueryChanges(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_set_mut(&mut self) -> &mut SetRequest<Email<Set>, ()> {
|
pub fn email_set_mut(&mut self) -> &mut SetRequest<Email<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::EmailSet(ref mut r) => r,
|
Arguments::EmailSet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -331,31 +292,28 @@ impl Arguments {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn identity_get_mut(&mut self) -> &mut GetRequest<identity::Property, ()> {
|
pub fn identity_get_mut(&mut self) -> &mut GetRequest<Identity<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::IdentityGet(ref mut r) => r,
|
Arguments::IdentityGet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn identity_set_mut(&mut self) -> &mut SetRequest<Identity<Set>, ()> {
|
pub fn identity_set_mut(&mut self) -> &mut SetRequest<Identity<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::IdentitySet(ref mut r) => r,
|
Arguments::IdentitySet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_submission_get_mut(&mut self) -> &mut GetRequest<email_submission::Property, ()> {
|
pub fn email_submission_get_mut(&mut self) -> &mut GetRequest<EmailSubmission<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::EmailSubmissionGet(ref mut r) => r,
|
Arguments::EmailSubmissionGet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_submission_query_mut(
|
pub fn email_submission_query_mut(&mut self) -> &mut QueryRequest<EmailSubmission<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<email_submission::query::Filter, email_submission::query::Comparator, ()>
|
|
||||||
{
|
|
||||||
match self {
|
match self {
|
||||||
Arguments::EmailSubmissionQuery(ref mut r) => r,
|
Arguments::EmailSubmissionQuery(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -364,36 +322,28 @@ impl Arguments {
|
||||||
|
|
||||||
pub fn email_submission_query_changes_mut(
|
pub fn email_submission_query_changes_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> &mut QueryChangesRequest<
|
) -> &mut QueryChangesRequest<EmailSubmission<Set>> {
|
||||||
email_submission::query::Filter,
|
|
||||||
email_submission::query::Comparator,
|
|
||||||
(),
|
|
||||||
> {
|
|
||||||
match self {
|
match self {
|
||||||
Arguments::EmailSubmissionQueryChanges(ref mut r) => r,
|
Arguments::EmailSubmissionQueryChanges(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_submission_set_mut(
|
pub fn email_submission_set_mut(&mut self) -> &mut SetRequest<EmailSubmission<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut SetRequest<EmailSubmission<Set>, email_submission::SetArguments> {
|
|
||||||
match self {
|
match self {
|
||||||
Arguments::EmailSubmissionSet(ref mut r) => r,
|
Arguments::EmailSubmissionSet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vacation_response_get_mut(
|
pub fn vacation_response_get_mut(&mut self) -> &mut GetRequest<VacationResponse<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut GetRequest<vacation_response::Property, ()> {
|
|
||||||
match self {
|
match self {
|
||||||
Arguments::VacationResponseGet(ref mut r) => r,
|
Arguments::VacationResponseGet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vacation_response_set_mut(&mut self) -> &mut SetRequest<VacationResponse<Set>, ()> {
|
pub fn vacation_response_set_mut(&mut self) -> &mut SetRequest<VacationResponse<Set>> {
|
||||||
match self {
|
match self {
|
||||||
Arguments::VacationResponseSet(ref mut r) => r,
|
Arguments::VacationResponseSet(ref mut r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
|
@ -4,13 +4,13 @@ use serde::{de::Visitor, Deserialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
blob::copy::CopyBlobResponse,
|
blob::copy::CopyBlobResponse,
|
||||||
email::{self, import::EmailImportResponse, parse::EmailParseResponse, Email},
|
email::{import::EmailImportResponse, parse::EmailParseResponse, Email},
|
||||||
email_submission::{self, EmailSubmission},
|
email_submission::EmailSubmission,
|
||||||
identity::{self, Identity},
|
identity::Identity,
|
||||||
mailbox::{self, Mailbox},
|
mailbox::Mailbox,
|
||||||
push_subscription::{self, PushSubscription},
|
push_subscription::PushSubscription,
|
||||||
thread::Thread,
|
thread::Thread,
|
||||||
vacation_response::{self, VacationResponse},
|
vacation_response::VacationResponse,
|
||||||
Get, Method,
|
Get, Method,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,28 +93,26 @@ pub enum Error {
|
||||||
Error,
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PushSubscriptionSetResponse =
|
pub type PushSubscriptionSetResponse = SetResponse<PushSubscription<Get>>;
|
||||||
SetResponse<PushSubscription<Get>, push_subscription::Property>;
|
|
||||||
pub type PushSubscriptionGetResponse = GetResponse<PushSubscription<Get>>;
|
pub type PushSubscriptionGetResponse = GetResponse<PushSubscription<Get>>;
|
||||||
pub type MaiboxChangesResponse = ChangesResponse<mailbox::ChangesResponse>;
|
pub type MaiboxChangesResponse = ChangesResponse<Mailbox<Get>>;
|
||||||
pub type MailboxSetResponse = SetResponse<Mailbox<Get>, mailbox::Property>;
|
pub type MailboxSetResponse = SetResponse<Mailbox<Get>>;
|
||||||
pub type MailboxGetResponse = GetResponse<Mailbox<Get>>;
|
pub type MailboxGetResponse = GetResponse<Mailbox<Get>>;
|
||||||
pub type ThreadGetResponse = GetResponse<Thread>;
|
pub type ThreadGetResponse = GetResponse<Thread>;
|
||||||
pub type ThreadChangesResponse = ChangesResponse<()>;
|
pub type ThreadChangesResponse = ChangesResponse<Thread>;
|
||||||
pub type EmailGetResponse = GetResponse<Email<Get>>;
|
pub type EmailGetResponse = GetResponse<Email<Get>>;
|
||||||
pub type EmailSetResponse = SetResponse<Email<Get>, email::Property>;
|
pub type EmailSetResponse = SetResponse<Email<Get>>;
|
||||||
pub type EmailCopyResponse = CopyResponse<Email<Get>, email::Property>;
|
pub type EmailCopyResponse = CopyResponse<Email<Get>>;
|
||||||
pub type EmailChangesResponse = ChangesResponse<()>;
|
pub type EmailChangesResponse = ChangesResponse<Email<Get>>;
|
||||||
pub type SearchSnippetGetResponse = GetResponse<String>;
|
pub type SearchSnippetGetResponse = GetResponse<String>;
|
||||||
pub type IdentitySetResponse = SetResponse<Identity<Get>, identity::Property>;
|
pub type IdentitySetResponse = SetResponse<Identity<Get>>;
|
||||||
pub type IdentityGetResponse = GetResponse<Identity<Get>>;
|
pub type IdentityGetResponse = GetResponse<Identity<Get>>;
|
||||||
pub type IdentityChangesResponse = ChangesResponse<()>;
|
pub type IdentityChangesResponse = ChangesResponse<Identity<Get>>;
|
||||||
pub type EmailSubmissionSetResponse = SetResponse<EmailSubmission<Get>, email_submission::Property>;
|
pub type EmailSubmissionSetResponse = SetResponse<EmailSubmission<Get>>;
|
||||||
pub type EmailSubmissionGetResponse = GetResponse<EmailSubmission<Get>>;
|
pub type EmailSubmissionGetResponse = GetResponse<EmailSubmission<Get>>;
|
||||||
pub type EmailSubmissionChangesResponse = ChangesResponse<()>;
|
pub type EmailSubmissionChangesResponse = ChangesResponse<EmailSubmission<Get>>;
|
||||||
pub type VacationResponseGetResponse = GetResponse<VacationResponse<Get>>;
|
pub type VacationResponseGetResponse = GetResponse<VacationResponse<Get>>;
|
||||||
pub type VacationResponseSetResponse =
|
pub type VacationResponseSetResponse = SetResponse<VacationResponse<Get>>;
|
||||||
SetResponse<VacationResponse<Get>, vacation_response::Property>;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TaggedMethodResponse {
|
pub struct TaggedMethodResponse {
|
||||||
|
|
|
@ -7,10 +7,17 @@ use std::{
|
||||||
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
use super::{request::ResultReference, RequestParams, Type};
|
use super::{request::ResultReference, Object, RequestParams};
|
||||||
|
|
||||||
|
pub trait SetObject: Object {
|
||||||
|
type SetArguments: Default;
|
||||||
|
|
||||||
|
fn new(create_id: Option<usize>) -> Self;
|
||||||
|
fn create_id(&self) -> Option<String>;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct SetRequest<T: Create + Type, A: Default> {
|
pub struct SetRequest<O: SetObject> {
|
||||||
#[serde(rename = "accountId")]
|
#[serde(rename = "accountId")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
account_id: Option<String>,
|
account_id: Option<String>,
|
||||||
|
@ -20,10 +27,10 @@ pub struct SetRequest<T: Create + Type, A: Default> {
|
||||||
if_in_state: Option<String>,
|
if_in_state: Option<String>,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
create: Option<HashMap<String, T>>,
|
create: Option<HashMap<String, O>>,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
update: Option<HashMap<String, T>>,
|
update: Option<HashMap<String, O>>,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
destroy: Option<Vec<String>>,
|
destroy: Option<Vec<String>>,
|
||||||
|
@ -34,11 +41,11 @@ pub struct SetRequest<T: Create + Type, A: Default> {
|
||||||
destroy_ref: Option<ResultReference>,
|
destroy_ref: Option<ResultReference>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
arguments: A,
|
arguments: O::SetArguments,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct SetResponse<T, U: Display> {
|
pub struct SetResponse<O: SetObject> {
|
||||||
#[serde(rename = "accountId")]
|
#[serde(rename = "accountId")]
|
||||||
account_id: Option<String>,
|
account_id: Option<String>,
|
||||||
|
|
||||||
|
@ -49,22 +56,22 @@ pub struct SetResponse<T, U: Display> {
|
||||||
new_state: Option<String>,
|
new_state: Option<String>,
|
||||||
|
|
||||||
#[serde(rename = "created")]
|
#[serde(rename = "created")]
|
||||||
created: Option<HashMap<String, T>>,
|
created: Option<HashMap<String, O>>,
|
||||||
|
|
||||||
#[serde(rename = "updated")]
|
#[serde(rename = "updated")]
|
||||||
updated: Option<HashMap<String, Option<T>>>,
|
updated: Option<HashMap<String, Option<O>>>,
|
||||||
|
|
||||||
#[serde(rename = "destroyed")]
|
#[serde(rename = "destroyed")]
|
||||||
destroyed: Option<Vec<String>>,
|
destroyed: Option<Vec<String>>,
|
||||||
|
|
||||||
#[serde(rename = "notCreated")]
|
#[serde(rename = "notCreated")]
|
||||||
not_created: Option<HashMap<String, SetError<U>>>,
|
not_created: Option<HashMap<String, SetError<O::Property>>>,
|
||||||
|
|
||||||
#[serde(rename = "notUpdated")]
|
#[serde(rename = "notUpdated")]
|
||||||
not_updated: Option<HashMap<String, SetError<U>>>,
|
not_updated: Option<HashMap<String, SetError<O::Property>>>,
|
||||||
|
|
||||||
#[serde(rename = "notDestroyed")]
|
#[serde(rename = "notDestroyed")]
|
||||||
not_destroyed: Option<HashMap<String, SetError<U>>>,
|
not_destroyed: Option<HashMap<String, SetError<O::Property>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
@ -126,15 +133,10 @@ pub enum SetErrorType {
|
||||||
CannotUnsend,
|
CannotUnsend,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Create: Sized {
|
impl<O: SetObject> SetRequest<O> {
|
||||||
fn new(create_id: Option<usize>) -> Self;
|
|
||||||
fn create_id(&self) -> Option<String>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Create + Type, A: Default> SetRequest<T, A> {
|
|
||||||
pub fn new(params: RequestParams) -> Self {
|
pub fn new(params: RequestParams) -> Self {
|
||||||
Self {
|
Self {
|
||||||
account_id: if T::requires_account_id() {
|
account_id: if O::requires_account_id() {
|
||||||
params.account_id.into()
|
params.account_id.into()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -149,7 +151,7 @@ impl<T: Create + Type, A: Default> SetRequest<T, A> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn account_id(&mut self, account_id: impl Into<String>) -> &mut Self {
|
pub fn account_id(&mut self, account_id: impl Into<String>) -> &mut Self {
|
||||||
if T::requires_account_id() {
|
if O::requires_account_id() {
|
||||||
self.account_id = Some(account_id.into());
|
self.account_id = Some(account_id.into());
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
|
@ -160,12 +162,12 @@ impl<T: Create + Type, A: Default> SetRequest<T, A> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(&mut self) -> &mut T {
|
pub fn create(&mut self) -> &mut O {
|
||||||
let create_id = self.create.as_ref().map_or(0, |c| c.len());
|
let create_id = self.create.as_ref().map_or(0, |c| c.len());
|
||||||
let create_id_str = format!("c{}", create_id);
|
let create_id_str = format!("c{}", create_id);
|
||||||
self.create
|
self.create
|
||||||
.get_or_insert_with(HashMap::new)
|
.get_or_insert_with(HashMap::new)
|
||||||
.insert(create_id_str.clone(), T::new(create_id.into()));
|
.insert(create_id_str.clone(), O::new(create_id.into()));
|
||||||
self.create
|
self.create
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -173,7 +175,7 @@ impl<T: Create + Type, A: Default> SetRequest<T, A> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_item(&mut self, item: T) -> String {
|
pub fn create_item(&mut self, item: O) -> String {
|
||||||
let create_id = self.create.as_ref().map_or(0, |c| c.len());
|
let create_id = self.create.as_ref().map_or(0, |c| c.len());
|
||||||
let create_id_str = format!("c{}", create_id);
|
let create_id_str = format!("c{}", create_id);
|
||||||
self.create
|
self.create
|
||||||
|
@ -182,15 +184,15 @@ impl<T: Create + Type, A: Default> SetRequest<T, A> {
|
||||||
create_id_str
|
create_id_str
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, id: impl Into<String>) -> &mut T {
|
pub fn update(&mut self, id: impl Into<String>) -> &mut O {
|
||||||
let id: String = id.into();
|
let id: String = id.into();
|
||||||
self.update
|
self.update
|
||||||
.get_or_insert_with(HashMap::new)
|
.get_or_insert_with(HashMap::new)
|
||||||
.insert(id.clone(), T::new(None));
|
.insert(id.clone(), O::new(None));
|
||||||
self.update.as_mut().unwrap().get_mut(&id).unwrap()
|
self.update.as_mut().unwrap().get_mut(&id).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_item(&mut self, id: impl Into<String>, item: T) {
|
pub fn update_item(&mut self, id: impl Into<String>, item: O) {
|
||||||
self.update
|
self.update
|
||||||
.get_or_insert_with(HashMap::new)
|
.get_or_insert_with(HashMap::new)
|
||||||
.insert(id.into(), item);
|
.insert(id.into(), item);
|
||||||
|
@ -214,12 +216,12 @@ impl<T: Create + Type, A: Default> SetRequest<T, A> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arguments(&mut self) -> &mut A {
|
pub fn arguments(&mut self) -> &mut O::SetArguments {
|
||||||
&mut self.arguments
|
&mut self.arguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, U: Display> SetResponse<T, U> {
|
impl<O: SetObject> SetResponse<O> {
|
||||||
pub fn account_id(&self) -> &str {
|
pub fn account_id(&self) -> &str {
|
||||||
self.account_id.as_ref().unwrap()
|
self.account_id.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -232,7 +234,7 @@ impl<T, U: Display> SetResponse<T, U> {
|
||||||
self.new_state.as_ref().unwrap()
|
self.new_state.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn created(&mut self, id: &str) -> crate::Result<T> {
|
pub fn created(&mut self, id: &str) -> crate::Result<O> {
|
||||||
if let Some(result) = self.created.as_mut().and_then(|r| r.remove(id)) {
|
if let Some(result) = self.created.as_mut().and_then(|r| r.remove(id)) {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
} else if let Some(error) = self.not_created.as_mut().and_then(|r| r.remove(id)) {
|
} else if let Some(error) = self.not_created.as_mut().and_then(|r| r.remove(id)) {
|
||||||
|
@ -242,7 +244,7 @@ impl<T, U: Display> SetResponse<T, U> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn updated(&mut self, id: &str) -> crate::Result<Option<T>> {
|
pub fn updated(&mut self, id: &str) -> crate::Result<Option<O>> {
|
||||||
if let Some(result) = self.updated.as_mut().and_then(|r| r.remove(id)) {
|
if let Some(result) = self.updated.as_mut().and_then(|r| r.remove(id)) {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
} else if let Some(error) = self.not_updated.as_mut().and_then(|r| r.remove(id)) {
|
} else if let Some(error) = self.not_updated.as_mut().and_then(|r| r.remove(id)) {
|
||||||
|
@ -378,6 +380,6 @@ pub fn date_not_set(date: &Option<DateTime<Utc>>) -> bool {
|
||||||
matches!(date, Some(date) if date.timestamp() == 0)
|
matches!(date, Some(date) if date.timestamp() == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_not_set<T>(list: &Option<Vec<T>>) -> bool {
|
pub fn list_not_set<O>(list: &Option<Vec<O>>) -> bool {
|
||||||
matches!(list, Some(list) if list.is_empty() )
|
matches!(list, Some(list) if list.is_empty() )
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::Get;
|
use crate::{core::get::GetObject, Get, Set};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Email, EmailAddress, EmailAddressGroup, EmailBodyPart, EmailBodyValue, EmailHeader, Header,
|
Email, EmailAddress, EmailAddressGroup, EmailBodyPart, EmailBodyValue, EmailHeader,
|
||||||
HeaderValue,
|
GetArguments, Header, HeaderValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Email<Get> {
|
impl Email<Get> {
|
||||||
|
@ -229,3 +229,11 @@ impl EmailHeader<Get> {
|
||||||
self.value.as_str()
|
self.value.as_str()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetObject for Email<Set> {
|
||||||
|
type GetArguments = GetArguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GetObject for Email<Get> {
|
||||||
|
type GetArguments = GetArguments;
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
response::{EmailCopyResponse, EmailGetResponse, EmailSetResponse},
|
response::{EmailCopyResponse, EmailGetResponse, EmailSetResponse},
|
||||||
set::SetRequest,
|
set::SetRequest,
|
||||||
},
|
},
|
||||||
Method, Set,
|
Get, Method, Set,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -118,7 +118,7 @@ impl Client {
|
||||||
&mut self,
|
&mut self,
|
||||||
id: &str,
|
id: &str,
|
||||||
properties: Option<impl IntoIterator<Item = Property>>,
|
properties: Option<impl IntoIterator<Item = Property>>,
|
||||||
) -> crate::Result<Option<Email>> {
|
) -> crate::Result<Option<Email<Get>>> {
|
||||||
let mut request = self.build();
|
let mut request = self.build();
|
||||||
let get_request = request.get_email().ids([id]);
|
let get_request = request.get_email().ids([id]);
|
||||||
if let Some(properties) = properties {
|
if let Some(properties) = properties {
|
||||||
|
@ -134,7 +134,7 @@ impl Client {
|
||||||
&mut self,
|
&mut self,
|
||||||
since_state: impl Into<String>,
|
since_state: impl Into<String>,
|
||||||
max_changes: usize,
|
max_changes: usize,
|
||||||
) -> crate::Result<ChangesResponse<()>> {
|
) -> crate::Result<ChangesResponse<Email<Get>>> {
|
||||||
let mut request = self.build();
|
let mut request = self.build();
|
||||||
request.changes_email(since_state).max_changes(max_changes);
|
request.changes_email(since_state).max_changes(max_changes);
|
||||||
request.send_single().await
|
request.send_single().await
|
||||||
|
@ -187,7 +187,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request<'_> {
|
||||||
pub fn get_email(&mut self) -> &mut GetRequest<super::Property, super::GetArguments> {
|
pub fn get_email(&mut self) -> &mut GetRequest<Email<Set>> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::GetEmail,
|
Method::GetEmail,
|
||||||
Arguments::email_get(self.params(Method::GetEmail)),
|
Arguments::email_get(self.params(Method::GetEmail)),
|
||||||
|
@ -207,14 +207,11 @@ impl Request<'_> {
|
||||||
.changes_mut()
|
.changes_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_changes_email(self) -> crate::Result<ChangesResponse<()>> {
|
pub async fn send_changes_email(self) -> crate::Result<ChangesResponse<Email<Get>>> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query_email(
|
pub fn query_email(&mut self) -> &mut QueryRequest<Email<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<super::query::Filter, super::query::Comparator, super::QueryArguments>
|
|
||||||
{
|
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::QueryEmail,
|
Method::QueryEmail,
|
||||||
Arguments::email_query(self.params(Method::QueryEmail)),
|
Arguments::email_query(self.params(Method::QueryEmail)),
|
||||||
|
@ -229,11 +226,7 @@ impl Request<'_> {
|
||||||
pub fn query_email_changes(
|
pub fn query_email_changes(
|
||||||
&mut self,
|
&mut self,
|
||||||
since_query_state: impl Into<String>,
|
since_query_state: impl Into<String>,
|
||||||
) -> &mut QueryChangesRequest<
|
) -> &mut QueryChangesRequest<Email<Set>> {
|
||||||
super::query::Filter,
|
|
||||||
super::query::Comparator,
|
|
||||||
super::QueryArguments,
|
|
||||||
> {
|
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::QueryChangesEmail,
|
Method::QueryChangesEmail,
|
||||||
Arguments::email_query_changes(
|
Arguments::email_query_changes(
|
||||||
|
@ -248,7 +241,7 @@ impl Request<'_> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_email(&mut self) -> &mut SetRequest<Email<Set>, ()> {
|
pub fn set_email(&mut self) -> &mut SetRequest<Email<Set>> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::SetEmail,
|
Method::SetEmail,
|
||||||
Arguments::email_set(self.params(Method::SetEmail)),
|
Arguments::email_set(self.params(Method::SetEmail)),
|
||||||
|
|
|
@ -14,10 +14,34 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
core::{request::ResultReference, Type},
|
core::{changes::ChangesObject, request::ResultReference, Object},
|
||||||
Get, Set,
|
Get, Set,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
impl Object for Email<Set> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
|
fn requires_account_id() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Object for Email<Get> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
|
fn requires_account_id() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for Email<Set> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for Email<Get> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
pub struct Email<State = Get> {
|
pub struct Email<State = Get> {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
@ -816,18 +840,6 @@ impl SubmissionCapabilities {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Email<Set> {
|
|
||||||
fn requires_account_id() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Type for Property {
|
|
||||||
fn requires_account_id() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::core::{query, set::from_timestamp};
|
use crate::{
|
||||||
|
core::{
|
||||||
|
query::{self, QueryObject},
|
||||||
|
set::from_timestamp,
|
||||||
|
},
|
||||||
|
Set,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::{Email, QueryArguments};
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug)]
|
#[derive(Serialize, Clone, Debug)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
@ -279,3 +287,11 @@ impl Comparator {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl QueryObject for Email<Set> {
|
||||||
|
type QueryArguments = QueryArguments;
|
||||||
|
|
||||||
|
type Filter = Filter;
|
||||||
|
|
||||||
|
type Sort = Comparator;
|
||||||
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ use std::collections::HashMap;
|
||||||
use crate::{
|
use crate::{
|
||||||
core::{
|
core::{
|
||||||
request::ResultReference,
|
request::ResultReference,
|
||||||
set::{from_timestamp, Create},
|
set::{from_timestamp, SetObject},
|
||||||
},
|
},
|
||||||
Set,
|
Get, Set,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -177,7 +177,9 @@ impl Email<Set> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Create for Email<Set> {
|
impl SetObject for Email<Set> {
|
||||||
|
type SetArguments = ();
|
||||||
|
|
||||||
fn new(_create_id: Option<usize>) -> Email<Set> {
|
fn new(_create_id: Option<usize>) -> Email<Set> {
|
||||||
Email {
|
Email {
|
||||||
_create_id,
|
_create_id,
|
||||||
|
@ -218,6 +220,18 @@ impl Create for Email<Set> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SetObject for Email<Get> {
|
||||||
|
type SetArguments = ();
|
||||||
|
|
||||||
|
fn new(_create_id: Option<usize>) -> Email<Get> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_id(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl EmailBodyPart {
|
impl EmailBodyPart {
|
||||||
pub fn new() -> EmailBodyPart<Set> {
|
pub fn new() -> EmailBodyPart<Set> {
|
||||||
EmailBodyPart {
|
EmailBodyPart {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::Get;
|
use crate::{Get, core::get::GetObject, Set};
|
||||||
|
|
||||||
use super::{Address, Delivered, DeliveryStatus, Displayed, EmailSubmission, UndoStatus};
|
use super::{Address, Delivered, DeliveryStatus, Displayed, EmailSubmission, UndoStatus};
|
||||||
|
|
||||||
|
@ -78,3 +78,11 @@ impl DeliveryStatus {
|
||||||
&self.displayed
|
&self.displayed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetObject for EmailSubmission<Set> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GetObject for EmailSubmission<Get> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
|
@ -1,20 +1,137 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
client::Client,
|
||||||
core::{
|
core::{
|
||||||
changes::{ChangesRequest, ChangesResponse},
|
changes::{ChangesRequest, ChangesResponse},
|
||||||
get::GetRequest,
|
get::GetRequest,
|
||||||
query::{QueryRequest, QueryResponse},
|
query::{Comparator, Filter, QueryRequest, QueryResponse},
|
||||||
query_changes::{QueryChangesRequest, QueryChangesResponse},
|
query_changes::{QueryChangesRequest, QueryChangesResponse},
|
||||||
request::{Arguments, Request},
|
request::{Arguments, Request},
|
||||||
response::{EmailSubmissionGetResponse, EmailSubmissionSetResponse},
|
response::{EmailSubmissionGetResponse, EmailSubmissionSetResponse},
|
||||||
set::SetRequest,
|
set::{SetObject, SetRequest},
|
||||||
},
|
},
|
||||||
Method, Set, URI,
|
Get, Method, Set, URI,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::EmailSubmission;
|
use super::{Address, EmailSubmission, Property, UndoStatus};
|
||||||
|
|
||||||
|
impl Client {
|
||||||
|
pub async fn email_submission_create(
|
||||||
|
&mut self,
|
||||||
|
email_id: impl Into<String>,
|
||||||
|
identity_id: impl Into<String>,
|
||||||
|
) -> crate::Result<EmailSubmission<Get>> {
|
||||||
|
let mut request = self.build();
|
||||||
|
let id = request
|
||||||
|
.set_email_submission()
|
||||||
|
.create()
|
||||||
|
.email_id(email_id)
|
||||||
|
.identity_id(identity_id)
|
||||||
|
.create_id()
|
||||||
|
.unwrap();
|
||||||
|
request
|
||||||
|
.send_single::<EmailSubmissionSetResponse>()
|
||||||
|
.await?
|
||||||
|
.created(&id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn email_submission_create_envelope<T, U>(
|
||||||
|
&mut self,
|
||||||
|
email_id: impl Into<String>,
|
||||||
|
identity_id: impl Into<String>,
|
||||||
|
mail_from: U,
|
||||||
|
rcpt_to: T,
|
||||||
|
) -> crate::Result<EmailSubmission<Get>>
|
||||||
|
where
|
||||||
|
T: IntoIterator<Item = U>,
|
||||||
|
U: Into<Address>,
|
||||||
|
{
|
||||||
|
let mut request = self.build();
|
||||||
|
let id = request
|
||||||
|
.set_email_submission()
|
||||||
|
.create()
|
||||||
|
.email_id(email_id)
|
||||||
|
.identity_id(identity_id)
|
||||||
|
.envelope(mail_from, rcpt_to)
|
||||||
|
.create_id()
|
||||||
|
.unwrap();
|
||||||
|
request
|
||||||
|
.send_single::<EmailSubmissionSetResponse>()
|
||||||
|
.await?
|
||||||
|
.created(&id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn email_submission_change_status(
|
||||||
|
&mut self,
|
||||||
|
id: &str,
|
||||||
|
undo_status: UndoStatus,
|
||||||
|
) -> crate::Result<Option<EmailSubmission>> {
|
||||||
|
let mut request = self.build();
|
||||||
|
request
|
||||||
|
.set_email_submission()
|
||||||
|
.update(id)
|
||||||
|
.undo_status(undo_status);
|
||||||
|
request
|
||||||
|
.send_single::<EmailSubmissionSetResponse>()
|
||||||
|
.await?
|
||||||
|
.updated(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn email_submission_destroy(&mut self, id: &str) -> crate::Result<()> {
|
||||||
|
let mut request = self.build();
|
||||||
|
request.set_email_submission().destroy([id]);
|
||||||
|
request
|
||||||
|
.send_single::<EmailSubmissionSetResponse>()
|
||||||
|
.await?
|
||||||
|
.destroyed(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn email_submission_get(
|
||||||
|
&mut self,
|
||||||
|
id: &str,
|
||||||
|
properties: Option<Vec<Property>>,
|
||||||
|
) -> crate::Result<Option<EmailSubmission>> {
|
||||||
|
let mut request = self.build();
|
||||||
|
let get_request = request.get_email_submission().ids([id]);
|
||||||
|
if let Some(properties) = properties {
|
||||||
|
get_request.properties(properties.into_iter());
|
||||||
|
}
|
||||||
|
request
|
||||||
|
.send_single::<EmailSubmissionGetResponse>()
|
||||||
|
.await
|
||||||
|
.map(|mut r| r.unwrap_list().pop())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn email_submission_query(
|
||||||
|
&mut self,
|
||||||
|
filter: Option<impl Into<Filter<super::query::Filter>>>,
|
||||||
|
sort: Option<impl IntoIterator<Item = Comparator<super::query::Comparator>>>,
|
||||||
|
) -> crate::Result<QueryResponse> {
|
||||||
|
let mut request = self.build();
|
||||||
|
let query_request = request.query_email_submission();
|
||||||
|
if let Some(filter) = filter {
|
||||||
|
query_request.filter(filter);
|
||||||
|
}
|
||||||
|
if let Some(sort) = sort {
|
||||||
|
query_request.sort(sort.into_iter());
|
||||||
|
}
|
||||||
|
request.send_single::<QueryResponse>().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn email_submission_changes(
|
||||||
|
&mut self,
|
||||||
|
since_state: impl Into<String>,
|
||||||
|
max_changes: usize,
|
||||||
|
) -> crate::Result<ChangesResponse<EmailSubmission<Get>>> {
|
||||||
|
let mut request = self.build();
|
||||||
|
request
|
||||||
|
.changes_email_submission(since_state)
|
||||||
|
.max_changes(max_changes);
|
||||||
|
request.send_single().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request<'_> {
|
||||||
pub fn get_email_submission(&mut self) -> &mut GetRequest<super::Property, ()> {
|
pub fn get_email_submission(&mut self) -> &mut GetRequest<EmailSubmission<Set>> {
|
||||||
self.add_capability(URI::Submission);
|
self.add_capability(URI::Submission);
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::GetEmailSubmission,
|
Method::GetEmailSubmission,
|
||||||
|
@ -42,13 +159,13 @@ impl Request<'_> {
|
||||||
.changes_mut()
|
.changes_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_changes_email_submission(self) -> crate::Result<ChangesResponse<()>> {
|
pub async fn send_changes_email_submission(
|
||||||
|
self,
|
||||||
|
) -> crate::Result<ChangesResponse<EmailSubmission<Get>>> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query_email_submission(
|
pub fn query_email_submission(&mut self) -> &mut QueryRequest<EmailSubmission<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<super::query::Filter, super::query::Comparator, ()> {
|
|
||||||
self.add_capability(URI::Submission);
|
self.add_capability(URI::Submission);
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::QueryEmailSubmission,
|
Method::QueryEmailSubmission,
|
||||||
|
@ -64,7 +181,7 @@ impl Request<'_> {
|
||||||
pub fn query_email_submission_changes(
|
pub fn query_email_submission_changes(
|
||||||
&mut self,
|
&mut self,
|
||||||
since_query_state: impl Into<String>,
|
since_query_state: impl Into<String>,
|
||||||
) -> &mut QueryChangesRequest<super::query::Filter, super::query::Comparator, ()> {
|
) -> &mut QueryChangesRequest<EmailSubmission<Set>> {
|
||||||
self.add_capability(URI::Submission);
|
self.add_capability(URI::Submission);
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::QueryChangesEmailSubmission,
|
Method::QueryChangesEmailSubmission,
|
||||||
|
@ -80,9 +197,7 @@ impl Request<'_> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_email_submission(
|
pub fn set_email_submission(&mut self) -> &mut SetRequest<EmailSubmission<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut SetRequest<EmailSubmission<Set>, super::SetArguments> {
|
|
||||||
self.add_capability(URI::Submission);
|
self.add_capability(URI::Submission);
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::SetEmailSubmission,
|
Method::SetEmailSubmission,
|
||||||
|
|
|
@ -8,7 +8,11 @@ use std::{collections::HashMap, fmt::Display};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{core::Type, email::Email, Get, Set};
|
use crate::{
|
||||||
|
core::{changes::ChangesObject, Object},
|
||||||
|
email::Email,
|
||||||
|
Get, Set,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Default)]
|
#[derive(Debug, Clone, Serialize, Default)]
|
||||||
pub struct SetArguments {
|
pub struct SetArguments {
|
||||||
|
@ -168,14 +172,26 @@ impl Display for Property {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for EmailSubmission<Set> {
|
impl Object for EmailSubmission<Set> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Property {
|
impl Object for EmailSubmission<Get> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for EmailSubmission<Set> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for EmailSubmission<Get> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::core::{query, set::from_timestamp};
|
use crate::{
|
||||||
|
core::{
|
||||||
|
query::{self, QueryObject},
|
||||||
|
set::from_timestamp,
|
||||||
|
},
|
||||||
|
Set,
|
||||||
|
};
|
||||||
|
|
||||||
use super::UndoStatus;
|
use super::{EmailSubmission, UndoStatus};
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug)]
|
#[derive(Serialize, Clone, Debug)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
@ -106,3 +112,11 @@ impl Comparator {
|
||||||
query::Comparator::new(Comparator::SentAt)
|
query::Comparator::new(Comparator::SentAt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl QueryObject for EmailSubmission<Set> {
|
||||||
|
type QueryArguments = ();
|
||||||
|
|
||||||
|
type Filter = Filter;
|
||||||
|
|
||||||
|
type Sort = Comparator;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{core::set::Create, Set};
|
use crate::{core::set::SetObject, Get, Set};
|
||||||
|
|
||||||
use super::{Address, EmailSubmission, Envelope, UndoStatus};
|
use super::{Address, EmailSubmission, Envelope, UndoStatus};
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@ impl EmailSubmission<Set> {
|
||||||
|
|
||||||
pub fn envelope<T, U>(&mut self, mail_from: U, rcpt_to: T) -> &mut Self
|
pub fn envelope<T, U>(&mut self, mail_from: U, rcpt_to: T) -> &mut Self
|
||||||
where
|
where
|
||||||
T: Iterator<Item = U>,
|
T: IntoIterator<Item = U>,
|
||||||
U: Into<Address>,
|
U: Into<Address>,
|
||||||
{
|
{
|
||||||
self.envelope = Some(Envelope {
|
self.envelope = Some(Envelope {
|
||||||
mail_from: mail_from.into(),
|
mail_from: mail_from.into(),
|
||||||
rcpt_to: rcpt_to.map(|s| s.into()).collect(),
|
rcpt_to: rcpt_to.into_iter().map(|s| s.into()).collect(),
|
||||||
});
|
});
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,9 @@ impl EmailSubmission<Set> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Create for EmailSubmission<Set> {
|
impl SetObject for EmailSubmission<Set> {
|
||||||
|
type SetArguments = ();
|
||||||
|
|
||||||
fn new(_create_id: Option<usize>) -> Self {
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
EmailSubmission {
|
EmailSubmission {
|
||||||
_create_id,
|
_create_id,
|
||||||
|
@ -56,6 +58,18 @@ impl Create for EmailSubmission<Set> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SetObject for EmailSubmission<Get> {
|
||||||
|
type SetArguments = ();
|
||||||
|
|
||||||
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_id(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Address {
|
impl Address {
|
||||||
pub fn new(email: String) -> Address<Set> {
|
pub fn new(email: String) -> Address<Set> {
|
||||||
Address {
|
Address {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{email::EmailAddress, Get};
|
use crate::{core::get::GetObject, email::EmailAddress, Get, Set};
|
||||||
|
|
||||||
use super::Identity;
|
use super::Identity;
|
||||||
|
|
||||||
|
@ -7,6 +7,10 @@ impl Identity<Get> {
|
||||||
self.id.as_ref().unwrap()
|
self.id.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unwrap_id(self) -> String {
|
||||||
|
self.id.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> Option<&str> {
|
pub fn name(&self) -> Option<&str> {
|
||||||
self.name.as_deref()
|
self.name.as_deref()
|
||||||
}
|
}
|
||||||
|
@ -35,3 +39,11 @@ impl Identity<Get> {
|
||||||
self.may_delete.unwrap_or(false)
|
self.may_delete.unwrap_or(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetObject for Identity<Set> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GetObject for Identity<Get> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,77 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
client::Client,
|
||||||
core::{
|
core::{
|
||||||
|
changes::{ChangesRequest, ChangesResponse},
|
||||||
get::GetRequest,
|
get::GetRequest,
|
||||||
request::{Arguments, Request},
|
request::{Arguments, Request},
|
||||||
response::{IdentityGetResponse, IdentitySetResponse},
|
response::{IdentityGetResponse, IdentitySetResponse},
|
||||||
set::SetRequest,
|
set::{SetObject, SetRequest},
|
||||||
},
|
},
|
||||||
Method, Set,
|
Get, Method, Set,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::Identity;
|
use super::{Identity, Property};
|
||||||
|
|
||||||
|
impl Client {
|
||||||
|
pub async fn identity_create(
|
||||||
|
&mut self,
|
||||||
|
name: impl Into<String>,
|
||||||
|
email: impl Into<String>,
|
||||||
|
) -> crate::Result<Identity> {
|
||||||
|
let mut request = self.build();
|
||||||
|
let id = request
|
||||||
|
.set_identity()
|
||||||
|
.create()
|
||||||
|
.name(name)
|
||||||
|
.email(email)
|
||||||
|
.create_id()
|
||||||
|
.unwrap();
|
||||||
|
request
|
||||||
|
.send_single::<IdentitySetResponse>()
|
||||||
|
.await?
|
||||||
|
.created(&id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn identity_destroy(&mut self, id: &str) -> crate::Result<()> {
|
||||||
|
let mut request = self.build();
|
||||||
|
request.set_identity().destroy([id]);
|
||||||
|
request
|
||||||
|
.send_single::<IdentitySetResponse>()
|
||||||
|
.await?
|
||||||
|
.destroyed(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn identity_get(
|
||||||
|
&mut self,
|
||||||
|
id: &str,
|
||||||
|
properties: Option<Vec<Property>>,
|
||||||
|
) -> crate::Result<Option<Identity>> {
|
||||||
|
let mut request = self.build();
|
||||||
|
let get_request = request.get_identity().ids([id]);
|
||||||
|
if let Some(properties) = properties {
|
||||||
|
get_request.properties(properties.into_iter());
|
||||||
|
}
|
||||||
|
request
|
||||||
|
.send_single::<IdentityGetResponse>()
|
||||||
|
.await
|
||||||
|
.map(|mut r| r.unwrap_list().pop())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn identity_changes(
|
||||||
|
&mut self,
|
||||||
|
since_state: impl Into<String>,
|
||||||
|
max_changes: usize,
|
||||||
|
) -> crate::Result<ChangesResponse<Identity<Get>>> {
|
||||||
|
let mut request = self.build();
|
||||||
|
request
|
||||||
|
.changes_identity(since_state)
|
||||||
|
.max_changes(max_changes);
|
||||||
|
request.send_single().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request<'_> {
|
||||||
pub fn get_identity(&mut self) -> &mut GetRequest<super::Property, ()> {
|
pub fn get_identity(&mut self) -> &mut GetRequest<Identity<Set>> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::GetIdentity,
|
Method::GetIdentity,
|
||||||
Arguments::identity_get(self.params(Method::GetIdentity)),
|
Arguments::identity_get(self.params(Method::GetIdentity)),
|
||||||
|
@ -23,7 +83,7 @@ impl Request<'_> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_identity(&mut self) -> &mut SetRequest<Identity<Set>, ()> {
|
pub fn set_identity(&mut self) -> &mut SetRequest<Identity<Set>> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::SetIdentity,
|
Method::SetIdentity,
|
||||||
Arguments::identity_set(self.params(Method::SetIdentity)),
|
Arguments::identity_set(self.params(Method::SetIdentity)),
|
||||||
|
@ -34,4 +94,16 @@ impl Request<'_> {
|
||||||
pub async fn send_set_identity(self) -> crate::Result<IdentitySetResponse> {
|
pub async fn send_set_identity(self) -> crate::Result<IdentitySetResponse> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn changes_identity(&mut self, since_state: impl Into<String>) -> &mut ChangesRequest {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::ChangesIdentity,
|
||||||
|
Arguments::changes(self.params(Method::ChangesIdentity), since_state.into()),
|
||||||
|
)
|
||||||
|
.changes_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_changes_identity(self) -> crate::Result<ChangesResponse<Identity<Get>>> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,9 @@ pub mod set;
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
|
use crate::core::changes::ChangesObject;
|
||||||
use crate::core::set::list_not_set;
|
use crate::core::set::list_not_set;
|
||||||
use crate::core::Type;
|
use crate::core::Object;
|
||||||
use crate::Set;
|
use crate::Set;
|
||||||
use crate::{email::EmailAddress, Get};
|
use crate::{email::EmailAddress, Get};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -86,14 +87,26 @@ impl Display for Property {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Identity<Set> {
|
impl Object for Identity<Set> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Property {
|
impl Object for Identity<Get> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for Identity<Set> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for Identity<Get> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::{core::set::Create, email::EmailAddress, Set};
|
use crate::{core::set::SetObject, email::EmailAddress, Get, Set};
|
||||||
|
|
||||||
use super::Identity;
|
use super::Identity;
|
||||||
|
|
||||||
impl Identity<Set> {
|
impl Identity<Set> {
|
||||||
pub fn name(&mut self, name: String) -> &mut Self {
|
pub fn name(&mut self, name: impl Into<String>) -> &mut Self {
|
||||||
self.name = Some(name);
|
self.name = Some(name.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email(&mut self, email: String) -> &mut Self {
|
pub fn email(&mut self, email: impl Into<String>) -> &mut Self {
|
||||||
self.email = Some(email);
|
self.email = Some(email.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,18 +31,20 @@ impl Identity<Set> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text_signature(&mut self, text_signature: String) -> &mut Self {
|
pub fn text_signature(&mut self, text_signature: impl Into<String>) -> &mut Self {
|
||||||
self.text_signature = Some(text_signature);
|
self.text_signature = Some(text_signature.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn html_signature(&mut self, html_signature: String) -> &mut Self {
|
pub fn html_signature(&mut self, html_signature: impl Into<String>) -> &mut Self {
|
||||||
self.html_signature = Some(html_signature);
|
self.html_signature = Some(html_signature.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Create for Identity<Set> {
|
impl SetObject for Identity<Set> {
|
||||||
|
type SetArguments = ();
|
||||||
|
|
||||||
fn new(_create_id: Option<usize>) -> Self {
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
Identity {
|
Identity {
|
||||||
_create_id,
|
_create_id,
|
||||||
|
@ -62,3 +64,15 @@ impl Create for Identity<Set> {
|
||||||
self._create_id.map(|id| format!("c{}", id))
|
self._create_id.map(|id| format!("c{}", id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SetObject for Identity<Get> {
|
||||||
|
type SetArguments = ();
|
||||||
|
|
||||||
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_id(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::Get;
|
use crate::{core::get::GetObject, Get, Set};
|
||||||
|
|
||||||
use super::{Mailbox, Role};
|
use super::{Mailbox, Role};
|
||||||
|
|
||||||
|
@ -83,3 +83,11 @@ impl Mailbox<Get> {
|
||||||
self.my_rights.as_ref().unwrap().may_submit
|
self.my_rights.as_ref().unwrap().may_submit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetObject for Mailbox<Set> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GetObject for Mailbox<Get> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ use crate::{
|
||||||
query_changes::{QueryChangesRequest, QueryChangesResponse},
|
query_changes::{QueryChangesRequest, QueryChangesResponse},
|
||||||
request::{Arguments, Request},
|
request::{Arguments, Request},
|
||||||
response::{MailboxGetResponse, MailboxSetResponse},
|
response::{MailboxGetResponse, MailboxSetResponse},
|
||||||
set::{Create, SetRequest},
|
set::{SetObject, SetRequest},
|
||||||
},
|
},
|
||||||
Method, Set,
|
Get, Method, Set,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{Mailbox, Property, Role};
|
use super::{Mailbox, Property, Role};
|
||||||
|
@ -137,7 +137,7 @@ impl Client {
|
||||||
&mut self,
|
&mut self,
|
||||||
since_state: impl Into<String>,
|
since_state: impl Into<String>,
|
||||||
max_changes: usize,
|
max_changes: usize,
|
||||||
) -> crate::Result<ChangesResponse<super::ChangesResponse>> {
|
) -> crate::Result<ChangesResponse<Mailbox<Get>>> {
|
||||||
let mut request = self.build();
|
let mut request = self.build();
|
||||||
request
|
request
|
||||||
.changes_mailbox(since_state)
|
.changes_mailbox(since_state)
|
||||||
|
@ -147,7 +147,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request<'_> {
|
||||||
pub fn get_mailbox(&mut self) -> &mut GetRequest<super::Property, ()> {
|
pub fn get_mailbox(&mut self) -> &mut GetRequest<Mailbox<Set>> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::GetMailbox,
|
Method::GetMailbox,
|
||||||
Arguments::mailbox_get(self.params(Method::GetMailbox)),
|
Arguments::mailbox_get(self.params(Method::GetMailbox)),
|
||||||
|
@ -167,16 +167,11 @@ impl Request<'_> {
|
||||||
.changes_mut()
|
.changes_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_changes_mailbox(
|
pub async fn send_changes_mailbox(self) -> crate::Result<ChangesResponse<Mailbox<Get>>> {
|
||||||
self,
|
|
||||||
) -> crate::Result<ChangesResponse<super::ChangesResponse>> {
|
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query_mailbox(
|
pub fn query_mailbox(&mut self) -> &mut QueryRequest<Mailbox<Set>> {
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<super::query::Filter, super::query::Comparator, super::QueryArguments>
|
|
||||||
{
|
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::QueryMailbox,
|
Method::QueryMailbox,
|
||||||
Arguments::mailbox_query(self.params(Method::QueryMailbox)),
|
Arguments::mailbox_query(self.params(Method::QueryMailbox)),
|
||||||
|
@ -191,11 +186,7 @@ impl Request<'_> {
|
||||||
pub fn query_mailbox_changes(
|
pub fn query_mailbox_changes(
|
||||||
&mut self,
|
&mut self,
|
||||||
since_query_state: impl Into<String>,
|
since_query_state: impl Into<String>,
|
||||||
) -> &mut QueryChangesRequest<
|
) -> &mut QueryChangesRequest<Mailbox<Set>> {
|
||||||
super::query::Filter,
|
|
||||||
super::query::Comparator,
|
|
||||||
super::QueryArguments,
|
|
||||||
> {
|
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::QueryChangesMailbox,
|
Method::QueryChangesMailbox,
|
||||||
Arguments::mailbox_query_changes(
|
Arguments::mailbox_query_changes(
|
||||||
|
@ -210,7 +201,7 @@ impl Request<'_> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_mailbox(&mut self) -> &mut SetRequest<Mailbox<Set>, super::SetArguments> {
|
pub fn set_mailbox(&mut self) -> &mut SetRequest<Mailbox<Set>> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::SetMailbox,
|
Method::SetMailbox,
|
||||||
Arguments::mailbox_set(self.params(Method::SetMailbox)),
|
Arguments::mailbox_set(self.params(Method::SetMailbox)),
|
||||||
|
|
|
@ -5,7 +5,9 @@ pub mod set;
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use crate::core::{set::string_not_set, Type};
|
use crate::core::changes::ChangesObject;
|
||||||
|
use crate::core::set::string_not_set;
|
||||||
|
use crate::core::Object;
|
||||||
use crate::mailbox::set::role_not_set;
|
use crate::mailbox::set::role_not_set;
|
||||||
use crate::{Get, Set};
|
use crate::{Get, Set};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -184,14 +186,26 @@ impl ChangesResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Mailbox<Set> {
|
impl Object for Mailbox<Set> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Property {
|
impl Object for Mailbox<Get> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for Mailbox<Set> {
|
||||||
|
type ChangesResponse = ChangesResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for Mailbox<Get> {
|
||||||
|
type ChangesResponse = ChangesResponse;
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::core::query::{self};
|
use crate::{
|
||||||
|
core::query::{self, QueryObject},
|
||||||
|
Set,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{QueryArguments, Role};
|
use super::{Mailbox, QueryArguments, Role};
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug)]
|
#[derive(Serialize, Clone, Debug)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
@ -97,3 +100,11 @@ impl QueryArguments {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl QueryObject for Mailbox<Set> {
|
||||||
|
type QueryArguments = QueryArguments;
|
||||||
|
|
||||||
|
type Filter = Filter;
|
||||||
|
|
||||||
|
type Sort = Comparator;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{core::set::Create, Set};
|
use crate::{core::set::SetObject, Get, Set};
|
||||||
|
|
||||||
use super::{Mailbox, Role, SetArguments};
|
use super::{Mailbox, Role, SetArguments};
|
||||||
|
|
||||||
|
@ -37,7 +37,9 @@ pub fn role_not_set(role: &Option<Role>) -> bool {
|
||||||
matches!(role, Some(Role::None))
|
matches!(role, Some(Role::None))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Create for Mailbox<Set> {
|
impl SetObject for Mailbox<Set> {
|
||||||
|
type SetArguments = SetArguments;
|
||||||
|
|
||||||
fn new(_create_id: Option<usize>) -> Self {
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
Mailbox {
|
Mailbox {
|
||||||
_create_id,
|
_create_id,
|
||||||
|
@ -61,6 +63,18 @@ impl Create for Mailbox<Set> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SetObject for Mailbox<Get> {
|
||||||
|
type SetArguments = SetArguments;
|
||||||
|
|
||||||
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_id(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SetArguments {
|
impl SetArguments {
|
||||||
pub fn on_destroy_remove_emails(&mut self, value: bool) -> &mut Self {
|
pub fn on_destroy_remove_emails(&mut self, value: bool) -> &mut Self {
|
||||||
self.on_destroy_remove_emails = value.into();
|
self.on_destroy_remove_emails = value.into();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{Get, TypeState};
|
use crate::{core::get::GetObject, Get, TypeState, Set};
|
||||||
|
|
||||||
use super::{Keys, PushSubscription};
|
use super::{Keys, PushSubscription};
|
||||||
|
|
||||||
|
@ -45,3 +45,11 @@ impl Keys {
|
||||||
base64::decode_config(&self.auth, base64::URL_SAFE).ok()
|
base64::decode_config(&self.auth, base64::URL_SAFE).ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetObject for PushSubscription<Set> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GetObject for PushSubscription<Get> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
get::GetRequest,
|
get::GetRequest,
|
||||||
request::{Arguments, Request},
|
request::{Arguments, Request},
|
||||||
response::{PushSubscriptionGetResponse, PushSubscriptionSetResponse},
|
response::{PushSubscriptionGetResponse, PushSubscriptionSetResponse},
|
||||||
set::{Create, SetRequest},
|
set::{SetObject, SetRequest},
|
||||||
},
|
},
|
||||||
Method, Set, TypeState,
|
Method, Set, TypeState,
|
||||||
};
|
};
|
||||||
|
@ -76,7 +76,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request<'_> {
|
||||||
pub fn get_push_subscription(&mut self) -> &mut GetRequest<super::Property, ()> {
|
pub fn get_push_subscription(&mut self) -> &mut GetRequest<PushSubscription<Set>> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::GetPushSubscription,
|
Method::GetPushSubscription,
|
||||||
Arguments::push_get(self.params(Method::GetPushSubscription)),
|
Arguments::push_get(self.params(Method::GetPushSubscription)),
|
||||||
|
@ -88,7 +88,7 @@ impl Request<'_> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_push_subscription(&mut self) -> &mut SetRequest<PushSubscription<Set>, ()> {
|
pub fn set_push_subscription(&mut self) -> &mut SetRequest<PushSubscription<Set>> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::SetPushSubscription,
|
Method::SetPushSubscription,
|
||||||
Arguments::push_set(self.params(Method::SetPushSubscription)),
|
Arguments::push_set(self.params(Method::SetPushSubscription)),
|
||||||
|
|
|
@ -7,8 +7,9 @@ use std::fmt::Display;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::core::changes::ChangesObject;
|
||||||
use crate::core::set::list_not_set;
|
use crate::core::set::list_not_set;
|
||||||
use crate::core::Type;
|
use crate::core::Object;
|
||||||
use crate::{Get, Set, TypeState};
|
use crate::{Get, Set, TypeState};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -86,14 +87,26 @@ pub struct Keys {
|
||||||
auth: String,
|
auth: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for PushSubscription<Set> {
|
impl Object for PushSubscription<Set> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Property {
|
impl Object for PushSubscription<Get> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for PushSubscription<Set> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for PushSubscription<Get> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
core::set::{from_timestamp, Create},
|
core::set::{from_timestamp, SetObject},
|
||||||
Set, TypeState,
|
email_submission::SetArguments,
|
||||||
|
Get, Set, TypeState,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{Keys, PushSubscription};
|
use super::{Keys, PushSubscription};
|
||||||
|
@ -37,7 +38,9 @@ impl PushSubscription<Set> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Create for PushSubscription<Set> {
|
impl SetObject for PushSubscription<Set> {
|
||||||
|
type SetArguments = SetArguments;
|
||||||
|
|
||||||
fn new(_create_id: Option<usize>) -> Self {
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
PushSubscription {
|
PushSubscription {
|
||||||
_create_id,
|
_create_id,
|
||||||
|
@ -57,6 +60,18 @@ impl Create for PushSubscription<Set> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SetObject for PushSubscription<Get> {
|
||||||
|
type SetArguments = SetArguments;
|
||||||
|
|
||||||
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_id(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Keys {
|
impl Keys {
|
||||||
pub fn new(p256dh: &[u8], auth: &[u8]) -> Self {
|
pub fn new(p256dh: &[u8], auth: &[u8]) -> Self {
|
||||||
Keys {
|
Keys {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
client::Client,
|
client::Client,
|
||||||
core::{
|
core::{
|
||||||
changes::{ChangesRequest, ChangesResponse},
|
changes::{ChangesRequest, ChangesResponse},
|
||||||
get::GetRequest,
|
get::{GetObject, GetRequest},
|
||||||
request::{Arguments, Request},
|
request::{Arguments, Request},
|
||||||
response::ThreadGetResponse,
|
response::ThreadGetResponse,
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request<'_> {
|
||||||
pub fn get_thread(&mut self) -> &mut GetRequest<super::Property, ()> {
|
pub fn get_thread(&mut self) -> &mut GetRequest<Thread> {
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::GetThread,
|
Method::GetThread,
|
||||||
Arguments::thread_get(self.params(Method::GetThread)),
|
Arguments::thread_get(self.params(Method::GetThread)),
|
||||||
|
@ -43,7 +43,11 @@ impl Request<'_> {
|
||||||
.changes_mut()
|
.changes_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_changes_thread(self) -> crate::Result<ChangesResponse<()>> {
|
pub async fn send_changes_thread(self) -> crate::Result<ChangesResponse<Thread>> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetObject for Thread {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::core::Type;
|
use crate::core::{Object, changes::ChangesObject};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Thread {
|
pub struct Thread {
|
||||||
|
@ -22,7 +22,9 @@ pub enum Property {
|
||||||
EmailIds,
|
EmailIds,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Property {
|
impl Object for Thread {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -36,3 +38,8 @@ impl Display for Property {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for Thread {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::Get;
|
use crate::{core::get::GetObject, Get, Set};
|
||||||
|
|
||||||
use super::VacationResponse;
|
use super::VacationResponse;
|
||||||
|
|
||||||
|
@ -31,3 +31,11 @@ impl VacationResponse<Get> {
|
||||||
self.html_body.as_deref()
|
self.html_body.as_deref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetObject for VacationResponse<Set> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GetObject for VacationResponse<Get> {
|
||||||
|
type GetArguments = ();
|
||||||
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::{
|
||||||
use super::VacationResponse;
|
use super::VacationResponse;
|
||||||
|
|
||||||
impl Request<'_> {
|
impl Request<'_> {
|
||||||
pub fn get_vacation_response(&mut self) -> &mut GetRequest<super::Property, ()> {
|
pub fn get_vacation_response(&mut self) -> &mut GetRequest<VacationResponse<Set>> {
|
||||||
self.add_capability(URI::VacationResponse);
|
self.add_capability(URI::VacationResponse);
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::GetVacationResponse,
|
Method::GetVacationResponse,
|
||||||
|
@ -24,7 +24,7 @@ impl Request<'_> {
|
||||||
self.send_single().await
|
self.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_vacation_response(&mut self) -> &mut SetRequest<VacationResponse<Set>, ()> {
|
pub fn set_vacation_response(&mut self) -> &mut SetRequest<VacationResponse<Set>> {
|
||||||
self.add_capability(URI::VacationResponse);
|
self.add_capability(URI::VacationResponse);
|
||||||
self.add_method_call(
|
self.add_method_call(
|
||||||
Method::SetVacationResponse,
|
Method::SetVacationResponse,
|
||||||
|
|
|
@ -4,9 +4,10 @@ pub mod set;
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
|
use crate::core::changes::ChangesObject;
|
||||||
use crate::core::set::date_not_set;
|
use crate::core::set::date_not_set;
|
||||||
use crate::core::set::string_not_set;
|
use crate::core::set::string_not_set;
|
||||||
use crate::core::Type;
|
use crate::core::Object;
|
||||||
use crate::Get;
|
use crate::Get;
|
||||||
use crate::Set;
|
use crate::Set;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
@ -81,14 +82,26 @@ impl Display for Property {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for VacationResponse<Set> {
|
impl Object for VacationResponse<Set> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Type for Property {
|
impl Object for VacationResponse<Get> {
|
||||||
|
type Property = Property;
|
||||||
|
|
||||||
fn requires_account_id() -> bool {
|
fn requires_account_id() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for VacationResponse<Set> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChangesObject for VacationResponse<Get> {
|
||||||
|
type ChangesResponse = ();
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
core::set::{from_timestamp, Create},
|
core::set::{from_timestamp, SetObject},
|
||||||
Set,
|
email_submission::SetArguments,
|
||||||
|
Get, Set,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::VacationResponse;
|
use super::VacationResponse;
|
||||||
|
@ -37,7 +38,9 @@ impl VacationResponse<Set> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Create for VacationResponse<Set> {
|
impl SetObject for VacationResponse<Set> {
|
||||||
|
type SetArguments = SetArguments;
|
||||||
|
|
||||||
fn new(_create_id: Option<usize>) -> Self {
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
VacationResponse {
|
VacationResponse {
|
||||||
_create_id,
|
_create_id,
|
||||||
|
@ -56,3 +59,15 @@ impl Create for VacationResponse<Set> {
|
||||||
self._create_id.map(|id| format!("c{}", id))
|
self._create_id.map(|id| format!("c{}", id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SetObject for VacationResponse<Get> {
|
||||||
|
type SetArguments = SetArguments;
|
||||||
|
|
||||||
|
fn new(_create_id: Option<usize>) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_id(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue