More improvements and testing.
parent
e24039ab12
commit
a1be8c4ad5
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::core::set::SetError;
|
use crate::core::{set::SetError, RequestParams};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct CopyBlobRequest {
|
pub struct CopyBlobRequest {
|
||||||
|
@ -27,10 +27,10 @@ pub struct CopyBlobResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CopyBlobRequest {
|
impl CopyBlobRequest {
|
||||||
pub fn new(from_account_id: String, account_id: String) -> Self {
|
pub fn new(params: RequestParams, from_account_id: String) -> Self {
|
||||||
CopyBlobRequest {
|
CopyBlobRequest {
|
||||||
from_account_id,
|
from_account_id,
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
blob_ids: vec![],
|
blob_ids: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
use crate::{
|
||||||
|
core::request::{Arguments, Request},
|
||||||
|
Method,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::copy::{CopyBlobRequest, CopyBlobResponse};
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
pub fn copy_blob(&mut self, from_account_id: impl Into<String>) -> &mut CopyBlobRequest {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::CopyBlob,
|
||||||
|
Arguments::blob_copy(self.params(Method::CopyBlob), from_account_id.into()),
|
||||||
|
)
|
||||||
|
.blob_copy_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_copy_blob(self) -> crate::Result<CopyBlobResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ use crate::core::session::URLParser;
|
||||||
|
|
||||||
pub mod copy;
|
pub mod copy;
|
||||||
pub mod download;
|
pub mod download;
|
||||||
|
pub mod helpers;
|
||||||
pub mod upload;
|
pub mod upload;
|
||||||
|
|
||||||
pub enum URLParameter {
|
pub enum URLParameter {
|
||||||
|
|
|
@ -188,7 +188,7 @@ impl Client {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::email::{EmailBodyPart, Header, Property};
|
use crate::email::EmailBodyPart;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize() {
|
fn test_serialize() {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use super::RequestParams;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct ChangesRequest {
|
pub struct ChangesRequest {
|
||||||
#[serde(rename = "accountId")]
|
#[serde(rename = "accountId")]
|
||||||
|
@ -38,9 +40,9 @@ pub struct ChangesResponse<A> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChangesRequest {
|
impl ChangesRequest {
|
||||||
pub fn new(account_id: String, since_state: String) -> Self {
|
pub fn new(params: RequestParams, since_state: String) -> Self {
|
||||||
ChangesRequest {
|
ChangesRequest {
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
since_state,
|
since_state,
|
||||||
max_changes: None,
|
max_changes: None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,10 @@ use std::{collections::HashMap, fmt::Display};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::set::{Create, SetError};
|
use super::{
|
||||||
|
set::{Create, SetError},
|
||||||
|
RequestParams,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct CopyRequest<T: Create> {
|
pub struct CopyRequest<T: Create> {
|
||||||
|
@ -53,11 +56,11 @@ pub struct CopyResponse<T, U: Display> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Create> CopyRequest<T> {
|
impl<T: Create> CopyRequest<T> {
|
||||||
pub fn new(from_account_id: String, account_id: String) -> Self {
|
pub fn new(params: RequestParams, from_account_id: String) -> Self {
|
||||||
CopyRequest {
|
CopyRequest {
|
||||||
from_account_id,
|
from_account_id,
|
||||||
if_from_in_state: None,
|
if_from_in_state: None,
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
if_in_state: None,
|
if_in_state: None,
|
||||||
create: HashMap::new(),
|
create: HashMap::new(),
|
||||||
on_success_destroy_original: false,
|
on_success_destroy_original: false,
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::request::ResultReference;
|
use crate::Method;
|
||||||
|
|
||||||
|
use super::{request::ResultReference, RequestParams};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct GetRequest<T, A: Default> {
|
pub struct GetRequest<T: Display, A: Default> {
|
||||||
|
#[serde(skip)]
|
||||||
|
method: (Method, usize),
|
||||||
|
|
||||||
#[serde(rename = "accountId")]
|
#[serde(rename = "accountId")]
|
||||||
account_id: String,
|
account_id: String,
|
||||||
|
|
||||||
|
@ -35,10 +42,11 @@ pub struct GetResponse<T> {
|
||||||
not_found: Vec<String>,
|
not_found: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, A: Default> GetRequest<T, A> {
|
impl<T: Display, A: Default> GetRequest<T, A> {
|
||||||
pub fn new(account_id: String) -> Self {
|
pub fn new(params: RequestParams) -> Self {
|
||||||
GetRequest {
|
GetRequest {
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
|
method: (params.method, params.call_id),
|
||||||
ids: None,
|
ids: None,
|
||||||
ids_ref: None,
|
ids_ref: None,
|
||||||
properties: None,
|
properties: None,
|
||||||
|
@ -75,6 +83,14 @@ impl<T, A: Default> GetRequest<T, A> {
|
||||||
pub fn arguments(&mut self) -> &mut A {
|
pub fn arguments(&mut self) -> &mut A {
|
||||||
&mut self.arguments
|
&mut self.arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn result_reference(&self, property: T) -> ResultReference {
|
||||||
|
ResultReference::new(
|
||||||
|
self.method.0,
|
||||||
|
self.method.1,
|
||||||
|
format!("/list/*/{}", property),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> GetResponse<T> {
|
impl<T> GetResponse<T> {
|
||||||
|
@ -97,6 +113,9 @@ impl<T> GetResponse<T> {
|
||||||
pub fn unwrap_list(&mut self) -> Vec<T> {
|
pub fn unwrap_list(&mut self) -> Vec<T> {
|
||||||
std::mem::take(&mut self.list)
|
std::mem::take(&mut self.list)
|
||||||
}
|
}
|
||||||
|
pub fn pop(&mut self) -> Option<T> {
|
||||||
|
self.list.pop()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn unwrap_not_found(&mut self) -> Vec<String> {
|
pub fn unwrap_not_found(&mut self) -> Vec<String> {
|
||||||
std::mem::take(&mut self.not_found)
|
std::mem::take(&mut self.not_found)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use crate::Method;
|
||||||
|
|
||||||
pub mod changes;
|
pub mod changes;
|
||||||
pub mod copy;
|
pub mod copy;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
@ -8,3 +10,19 @@ pub mod request;
|
||||||
pub mod response;
|
pub mod response;
|
||||||
pub mod session;
|
pub mod session;
|
||||||
pub mod set;
|
pub mod set;
|
||||||
|
|
||||||
|
pub struct RequestParams {
|
||||||
|
pub account_id: String,
|
||||||
|
pub method: Method,
|
||||||
|
pub call_id: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RequestParams {
|
||||||
|
pub fn new(account_id: impl Into<String>, method: Method, call_id: usize) -> Self {
|
||||||
|
Self {
|
||||||
|
account_id: account_id.into(),
|
||||||
|
method,
|
||||||
|
call_id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::Method;
|
||||||
|
|
||||||
|
use super::{request::ResultReference, RequestParams};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct QueryRequest<F, S, A: Default> {
|
pub struct QueryRequest<F, S, A: Default> {
|
||||||
|
#[serde(skip)]
|
||||||
|
method: (Method, usize),
|
||||||
|
|
||||||
#[serde(rename = "accountId")]
|
#[serde(rename = "accountId")]
|
||||||
account_id: String,
|
account_id: String,
|
||||||
|
|
||||||
|
@ -97,9 +104,10 @@ pub struct QueryResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, S, A: Default> QueryRequest<F, S, A> {
|
impl<F, S, A: Default> QueryRequest<F, S, A> {
|
||||||
pub fn new(account_id: String) -> Self {
|
pub fn new(params: RequestParams) -> Self {
|
||||||
QueryRequest {
|
QueryRequest {
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
|
method: (params.method, params.call_id),
|
||||||
filter: None,
|
filter: None,
|
||||||
sort: None,
|
sort: None,
|
||||||
position: None,
|
position: None,
|
||||||
|
@ -146,9 +154,18 @@ impl<F, S, A: Default> QueryRequest<F, S, A> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn calculate_total(&mut self, calculate_total: bool) -> &mut Self {
|
||||||
|
self.calculate_total = Some(calculate_total);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn arguments(&mut self) -> &mut A {
|
pub fn arguments(&mut self) -> &mut A {
|
||||||
&mut self.arguments
|
&mut self.arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn result_reference(&self) -> ResultReference {
|
||||||
|
ResultReference::new(self.method.0, self.method.1, "/ids")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QueryResponse {
|
impl QueryResponse {
|
||||||
|
@ -160,6 +177,14 @@ impl QueryResponse {
|
||||||
&self.ids
|
&self.ids
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn id(&self, pos: usize) -> &str {
|
||||||
|
self.ids[pos].as_str()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unwrap_ids(self) -> Vec<String> {
|
||||||
|
self.ids
|
||||||
|
}
|
||||||
|
|
||||||
pub fn total(&self) -> Option<usize> {
|
pub fn total(&self) -> Option<usize> {
|
||||||
self.total
|
self.total
|
||||||
}
|
}
|
||||||
|
@ -190,8 +215,13 @@ impl<A> Comparator<A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_ascending(mut self, is_ascending: bool) -> Self {
|
pub fn descending(mut self) -> Self {
|
||||||
self.is_ascending = is_ascending;
|
self.is_ascending = false;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ascending(mut self) -> Self {
|
||||||
|
self.is_ascending = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::query::{Comparator, Filter};
|
use super::{
|
||||||
|
query::{Comparator, Filter},
|
||||||
|
RequestParams,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct QueryChangesRequest<F, S, A: Default> {
|
pub struct QueryChangesRequest<F, S, A: Default> {
|
||||||
|
@ -56,9 +59,9 @@ pub struct AddedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, S, A: Default> QueryChangesRequest<F, S, A> {
|
impl<F, S, A: Default> QueryChangesRequest<F, S, A> {
|
||||||
pub fn new(account_id: String, since_query_state: String) -> Self {
|
pub fn new(params: RequestParams, since_query_state: String) -> Self {
|
||||||
QueryChangesRequest {
|
QueryChangesRequest {
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
filter: None,
|
filter: None,
|
||||||
sort: None,
|
sort: None,
|
||||||
since_query_state,
|
since_query_state,
|
||||||
|
|
|
@ -23,6 +23,7 @@ use super::{
|
||||||
query_changes::QueryChangesRequest,
|
query_changes::QueryChangesRequest,
|
||||||
response::{MethodResponse, Response, SingleMethodResponse},
|
response::{MethodResponse, Response, SingleMethodResponse},
|
||||||
set::SetRequest,
|
set::SetRequest,
|
||||||
|
RequestParams,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
@ -98,103 +99,103 @@ pub enum Arguments {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Arguments {
|
impl Arguments {
|
||||||
pub fn changes(account_id: String, since_state: String) -> Self {
|
pub fn changes(params: RequestParams, since_state: String) -> Self {
|
||||||
Arguments::Changes(ChangesRequest::new(account_id, since_state))
|
Arguments::Changes(ChangesRequest::new(params, since_state))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_get(account_id: String) -> Self {
|
pub fn push_get(params: RequestParams) -> Self {
|
||||||
Arguments::PushGet(GetRequest::new(account_id))
|
Arguments::PushGet(GetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_set(account_id: String) -> Self {
|
pub fn push_set(params: RequestParams) -> Self {
|
||||||
Arguments::PushSet(SetRequest::new(account_id))
|
Arguments::PushSet(SetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn blob_copy(from_account_id: String, account_id: String) -> Self {
|
pub fn blob_copy(params: RequestParams, from_account_id: String) -> Self {
|
||||||
Arguments::BlobCopy(CopyBlobRequest::new(from_account_id, account_id))
|
Arguments::BlobCopy(CopyBlobRequest::new(params, from_account_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mailbox_get(account_id: String) -> Self {
|
pub fn mailbox_get(params: RequestParams) -> Self {
|
||||||
Arguments::MailboxGet(GetRequest::new(account_id))
|
Arguments::MailboxGet(GetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mailbox_query(account_id: String) -> Self {
|
pub fn mailbox_query(params: RequestParams) -> Self {
|
||||||
Arguments::MailboxQuery(QueryRequest::new(account_id))
|
Arguments::MailboxQuery(QueryRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mailbox_query_changes(account_id: String, since_query_state: String) -> Self {
|
pub fn mailbox_query_changes(params: RequestParams, since_query_state: String) -> Self {
|
||||||
Arguments::MailboxQueryChanges(QueryChangesRequest::new(account_id, since_query_state))
|
Arguments::MailboxQueryChanges(QueryChangesRequest::new(params, since_query_state))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mailbox_set(account_id: String) -> Self {
|
pub fn mailbox_set(params: RequestParams) -> Self {
|
||||||
Arguments::MailboxSet(SetRequest::new(account_id))
|
Arguments::MailboxSet(SetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn thread_get(account_id: String) -> Self {
|
pub fn thread_get(params: RequestParams) -> Self {
|
||||||
Arguments::ThreadGet(GetRequest::new(account_id))
|
Arguments::ThreadGet(GetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_get(account_id: String) -> Self {
|
pub fn email_get(params: RequestParams) -> Self {
|
||||||
Arguments::EmailGet(GetRequest::new(account_id))
|
Arguments::EmailGet(GetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_query(account_id: String) -> Self {
|
pub fn email_query(params: RequestParams) -> Self {
|
||||||
Arguments::EmailQuery(QueryRequest::new(account_id))
|
Arguments::EmailQuery(QueryRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_query_changes(account_id: String, since_query_state: String) -> Self {
|
pub fn email_query_changes(params: RequestParams, since_query_state: String) -> Self {
|
||||||
Arguments::EmailQueryChanges(QueryChangesRequest::new(account_id, since_query_state))
|
Arguments::EmailQueryChanges(QueryChangesRequest::new(params, since_query_state))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_set(account_id: String) -> Self {
|
pub fn email_set(params: RequestParams) -> Self {
|
||||||
Arguments::EmailSet(SetRequest::new(account_id))
|
Arguments::EmailSet(SetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_copy(from_account_id: String, account_id: String) -> Self {
|
pub fn email_copy(params: RequestParams, from_account_id: String) -> Self {
|
||||||
Arguments::EmailCopy(CopyRequest::new(from_account_id, account_id))
|
Arguments::EmailCopy(CopyRequest::new(params, from_account_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_import(account_id: String) -> Self {
|
pub fn email_import(params: RequestParams) -> Self {
|
||||||
Arguments::EmailImport(EmailImportRequest::new(account_id))
|
Arguments::EmailImport(EmailImportRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_parse(account_id: String) -> Self {
|
pub fn email_parse(params: RequestParams) -> Self {
|
||||||
Arguments::EmailParse(EmailParseRequest::new(account_id))
|
Arguments::EmailParse(EmailParseRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn identity_get(account_id: String) -> Self {
|
pub fn identity_get(params: RequestParams) -> Self {
|
||||||
Arguments::IdentityGet(GetRequest::new(account_id))
|
Arguments::IdentityGet(GetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn identity_set(account_id: String) -> Self {
|
pub fn identity_set(params: RequestParams) -> Self {
|
||||||
Arguments::IdentitySet(SetRequest::new(account_id))
|
Arguments::IdentitySet(SetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_submission_get(account_id: String) -> Self {
|
pub fn email_submission_get(params: RequestParams) -> Self {
|
||||||
Arguments::EmailSubmissionGet(GetRequest::new(account_id))
|
Arguments::EmailSubmissionGet(GetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_submission_query(account_id: String) -> Self {
|
pub fn email_submission_query(params: RequestParams) -> Self {
|
||||||
Arguments::EmailSubmissionQuery(QueryRequest::new(account_id))
|
Arguments::EmailSubmissionQuery(QueryRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_submission_query_changes(account_id: String, since_query_state: String) -> Self {
|
pub fn email_submission_query_changes(
|
||||||
Arguments::EmailSubmissionQueryChanges(QueryChangesRequest::new(
|
params: RequestParams,
|
||||||
account_id,
|
since_query_state: String,
|
||||||
since_query_state,
|
) -> Self {
|
||||||
))
|
Arguments::EmailSubmissionQueryChanges(QueryChangesRequest::new(params, since_query_state))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn email_submission_set(account_id: String) -> Self {
|
pub fn email_submission_set(params: RequestParams) -> Self {
|
||||||
Arguments::EmailSubmissionSet(SetRequest::new(account_id))
|
Arguments::EmailSubmissionSet(SetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vacation_response_get(account_id: String) -> Self {
|
pub fn vacation_response_get(params: RequestParams) -> Self {
|
||||||
Arguments::VacationResponseGet(GetRequest::new(account_id))
|
Arguments::VacationResponseGet(GetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vacation_response_set(account_id: String) -> Self {
|
pub fn vacation_response_set(params: RequestParams) -> Self {
|
||||||
Arguments::VacationResponseSet(SetRequest::new(account_id))
|
Arguments::VacationResponseSet(SetRequest::new(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn changes_mut(&mut self) -> &mut ChangesRequest {
|
pub fn changes_mut(&mut self) -> &mut ChangesRequest {
|
||||||
|
@ -431,308 +432,41 @@ impl<'x> Request<'x> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_method_call(&mut self, method: Method, arguments: Arguments) -> &mut Arguments {
|
pub fn params(&self, method: Method) -> RequestParams {
|
||||||
|
RequestParams {
|
||||||
|
account_id: self.default_account_id.clone(),
|
||||||
|
method,
|
||||||
|
call_id: self.method_calls.len(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_method_call(&mut self, method: Method, arguments: Arguments) -> &mut Arguments {
|
||||||
let call_id = format!("s{}", self.method_calls.len());
|
let call_id = format!("s{}", self.method_calls.len());
|
||||||
self.method_calls.push((method, arguments, call_id));
|
self.method_calls.push((method, arguments, call_id));
|
||||||
&mut self.method_calls.last_mut().unwrap().1
|
&mut self.method_calls.last_mut().unwrap().1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_push(&mut self) -> &mut GetRequest<push_subscription::Property, ()> {
|
pub fn add_capability(&mut self, uri: URI) {
|
||||||
self.add_method_call(
|
if !self.using.contains(&uri) {
|
||||||
Method::GetPushSubscription,
|
self.using.push(uri);
|
||||||
Arguments::push_get(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.push_get_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_push(&mut self) -> &mut SetRequest<PushSubscription<Set>, ()> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::SetPushSubscription,
|
|
||||||
Arguments::push_set(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.push_set_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn copy_blob(
|
|
||||||
&mut self,
|
|
||||||
from_account_id: impl Into<String>,
|
|
||||||
account_id: impl Into<String>,
|
|
||||||
) -> &mut CopyBlobRequest {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::CopyBlob,
|
|
||||||
Arguments::blob_copy(from_account_id.into(), account_id.into()),
|
|
||||||
)
|
|
||||||
.blob_copy_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_mailbox(&mut self) -> &mut GetRequest<mailbox::Property, ()> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::GetMailbox,
|
|
||||||
Arguments::mailbox_get(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.mailbox_get_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn changes_mailbox(&mut self, since_state: impl Into<String>) -> &mut ChangesRequest {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::ChangesMailbox,
|
|
||||||
Arguments::changes(self.default_account_id.clone(), since_state.into()),
|
|
||||||
)
|
|
||||||
.changes_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn query_mailbox(
|
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<
|
|
||||||
mailbox::query::Filter,
|
|
||||||
mailbox::query::Comparator,
|
|
||||||
mailbox::QueryArguments,
|
|
||||||
> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::QueryMailbox,
|
|
||||||
Arguments::mailbox_query(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.mailbox_query_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn query_mailbox_changes(
|
|
||||||
&mut self,
|
|
||||||
since_query_state: impl Into<String>,
|
|
||||||
) -> &mut QueryChangesRequest<
|
|
||||||
mailbox::query::Filter,
|
|
||||||
mailbox::query::Comparator,
|
|
||||||
mailbox::QueryArguments,
|
|
||||||
> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::QueryChangesMailbox,
|
|
||||||
Arguments::mailbox_query_changes(
|
|
||||||
self.default_account_id.clone(),
|
|
||||||
since_query_state.into(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.mailbox_query_changes_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_mailbox(&mut self) -> &mut SetRequest<Mailbox<Set>, mailbox::SetArguments> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::SetMailbox,
|
|
||||||
Arguments::mailbox_set(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.mailbox_set_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_thread(&mut self) -> &mut GetRequest<thread::Property, ()> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::GetThread,
|
|
||||||
Arguments::thread_get(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.thread_get_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn changes_thread(&mut self, since_state: impl Into<String>) -> &mut ChangesRequest {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::ChangesThread,
|
|
||||||
Arguments::changes(self.default_account_id.clone(), since_state.into()),
|
|
||||||
)
|
|
||||||
.changes_mut()
|
|
||||||
}
|
|
||||||
pub fn get_email(&mut self) -> &mut GetRequest<email::Property, email::GetArguments> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::GetEmail,
|
|
||||||
Arguments::email_get(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.email_get_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn changes_email(&mut self, since_state: impl Into<String>) -> &mut ChangesRequest {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::ChangesEmail,
|
|
||||||
Arguments::changes(self.default_account_id.clone(), since_state.into()),
|
|
||||||
)
|
|
||||||
.changes_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn query_email(
|
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<email::query::Filter, email::query::Comparator, email::QueryArguments>
|
|
||||||
{
|
|
||||||
self.add_method_call(
|
|
||||||
Method::QueryEmail,
|
|
||||||
Arguments::email_query(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.email_query_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn query_email_changes(
|
|
||||||
&mut self,
|
|
||||||
since_query_state: impl Into<String>,
|
|
||||||
) -> &mut QueryChangesRequest<
|
|
||||||
email::query::Filter,
|
|
||||||
email::query::Comparator,
|
|
||||||
email::QueryArguments,
|
|
||||||
> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::QueryChangesEmail,
|
|
||||||
Arguments::email_query_changes(
|
|
||||||
self.default_account_id.clone(),
|
|
||||||
since_query_state.into(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.email_query_changes_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_email(&mut self) -> &mut SetRequest<Email<Set>, ()> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::SetEmail,
|
|
||||||
Arguments::email_set(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.email_set_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn copy_email(
|
|
||||||
&mut self,
|
|
||||||
from_account_id: impl Into<String>,
|
|
||||||
account_id: impl Into<String>,
|
|
||||||
) -> &mut CopyRequest<Email<Set>> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::CopyEmail,
|
|
||||||
Arguments::email_copy(from_account_id.into(), account_id.into()),
|
|
||||||
)
|
|
||||||
.email_copy_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn import_email(&mut self) -> &mut EmailImportRequest {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::ImportEmail,
|
|
||||||
Arguments::email_import(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.email_import_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_email(&mut self) -> &mut EmailParseRequest {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::ParseEmail,
|
|
||||||
Arguments::email_parse(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.email_parse_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_identity(&mut self) -> &mut GetRequest<identity::Property, ()> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::GetIdentity,
|
|
||||||
Arguments::identity_get(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.identity_get_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_identity(&mut self) -> &mut SetRequest<Identity<Set>, ()> {
|
|
||||||
self.add_method_call(
|
|
||||||
Method::SetIdentity,
|
|
||||||
Arguments::identity_set(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.identity_set_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_email_submission(&mut self) -> &mut GetRequest<email_submission::Property, ()> {
|
|
||||||
if !self.using.contains(&URI::Submission) {
|
|
||||||
self.using.push(URI::Submission);
|
|
||||||
}
|
}
|
||||||
self.add_method_call(
|
|
||||||
Method::GetEmailSubmission,
|
|
||||||
Arguments::email_submission_get(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.email_submission_get_mut()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn changes_email_submission(
|
pub fn last_result_reference(&self, path: impl Into<String>) -> ResultReference {
|
||||||
&mut self,
|
|
||||||
since_state: impl Into<String>,
|
|
||||||
) -> &mut ChangesRequest {
|
|
||||||
if !self.using.contains(&URI::Submission) {
|
|
||||||
self.using.push(URI::Submission);
|
|
||||||
}
|
|
||||||
self.add_method_call(
|
|
||||||
Method::ChangesEmailSubmission,
|
|
||||||
Arguments::changes(self.default_account_id.clone(), since_state.into()),
|
|
||||||
)
|
|
||||||
.changes_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn query_email_submission(
|
|
||||||
&mut self,
|
|
||||||
) -> &mut QueryRequest<email_submission::query::Filter, email_submission::query::Comparator, ()>
|
|
||||||
{
|
|
||||||
if !self.using.contains(&URI::Submission) {
|
|
||||||
self.using.push(URI::Submission);
|
|
||||||
}
|
|
||||||
self.add_method_call(
|
|
||||||
Method::QueryEmailSubmission,
|
|
||||||
Arguments::email_submission_query(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.email_submission_query_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn query_email_submission_changes(
|
|
||||||
&mut self,
|
|
||||||
since_query_state: impl Into<String>,
|
|
||||||
) -> &mut QueryChangesRequest<
|
|
||||||
email_submission::query::Filter,
|
|
||||||
email_submission::query::Comparator,
|
|
||||||
(),
|
|
||||||
> {
|
|
||||||
if !self.using.contains(&URI::Submission) {
|
|
||||||
self.using.push(URI::Submission);
|
|
||||||
}
|
|
||||||
self.add_method_call(
|
|
||||||
Method::QueryChangesEmailSubmission,
|
|
||||||
Arguments::email_submission_query_changes(
|
|
||||||
self.default_account_id.clone(),
|
|
||||||
since_query_state.into(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.email_submission_query_changes_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_email_submission(
|
|
||||||
&mut self,
|
|
||||||
) -> &mut SetRequest<EmailSubmission<Set>, email_submission::SetArguments> {
|
|
||||||
if !self.using.contains(&URI::Submission) {
|
|
||||||
self.using.push(URI::Submission);
|
|
||||||
}
|
|
||||||
self.add_method_call(
|
|
||||||
Method::SetEmailSubmission,
|
|
||||||
Arguments::email_submission_set(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.email_submission_set_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_vacation_response(&mut self) -> &mut GetRequest<vacation_response::Property, ()> {
|
|
||||||
if !self.using.contains(&URI::VacationResponse) {
|
|
||||||
self.using.push(URI::VacationResponse);
|
|
||||||
}
|
|
||||||
self.add_method_call(
|
|
||||||
Method::GetVacationResponse,
|
|
||||||
Arguments::vacation_response_get(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.vacation_response_get_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_vacation_response(&mut self) -> &mut SetRequest<VacationResponse<Set>, ()> {
|
|
||||||
if !self.using.contains(&URI::VacationResponse) {
|
|
||||||
self.using.push(URI::VacationResponse);
|
|
||||||
}
|
|
||||||
self.add_method_call(
|
|
||||||
Method::SetVacationResponse,
|
|
||||||
Arguments::vacation_response_set(self.default_account_id.clone()),
|
|
||||||
)
|
|
||||||
.vacation_response_set_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn result_reference(&self, path: impl Into<String>) -> ResultReference {
|
|
||||||
let last_method = self.method_calls.last().unwrap();
|
let last_method = self.method_calls.last().unwrap();
|
||||||
ResultReference {
|
ResultReference {
|
||||||
result_of: last_method.2.clone(),
|
result_of: last_method.2.clone(),
|
||||||
name: last_method.0.clone(),
|
name: last_method.0,
|
||||||
|
path: path.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ResultReference {
|
||||||
|
pub fn new(method: Method, call_id: usize, path: impl Into<String>) -> Self {
|
||||||
|
ResultReference {
|
||||||
|
result_of: format!("s{}", call_id),
|
||||||
|
name: method,
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
||||||
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
use super::request::ResultReference;
|
use super::{request::ResultReference, RequestParams};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct SetRequest<T: Create, A: Default> {
|
pub struct SetRequest<T: Create, A: Default> {
|
||||||
|
@ -72,7 +72,7 @@ where
|
||||||
U: Display,
|
U: Display,
|
||||||
{
|
{
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
type_: SetErrorType,
|
pub type_: SetErrorType,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
properties: Option<Vec<U>>,
|
properties: Option<Vec<U>>,
|
||||||
}
|
}
|
||||||
|
@ -131,9 +131,9 @@ pub trait Create: Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Create, A: Default> SetRequest<T, A> {
|
impl<T: Create, A: Default> SetRequest<T, A> {
|
||||||
pub fn new(account_id: String) -> Self {
|
pub fn new(params: RequestParams) -> Self {
|
||||||
Self {
|
Self {
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
if_in_state: None,
|
if_in_state: None,
|
||||||
create: None,
|
create: None,
|
||||||
update: None,
|
update: None,
|
||||||
|
@ -166,6 +166,15 @@ impl<T: Create, A: Default> SetRequest<T, A> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_item(&mut self, item: T) -> String {
|
||||||
|
let create_id = self.create.as_ref().map_or(0, |c| c.len());
|
||||||
|
let create_id_str = format!("c{}", create_id);
|
||||||
|
self.create
|
||||||
|
.get_or_insert_with(HashMap::new)
|
||||||
|
.insert(create_id_str.clone(), item);
|
||||||
|
create_id_str
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, id: impl Into<String>) -> &mut T {
|
pub fn update(&mut self, id: impl Into<String>) -> &mut T {
|
||||||
let id: String = id.into();
|
let id: String = id.into();
|
||||||
self.update
|
self.update
|
||||||
|
@ -174,6 +183,12 @@ impl<T: Create, A: Default> SetRequest<T, A> {
|
||||||
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) {
|
||||||
|
self.update
|
||||||
|
.get_or_insert_with(HashMap::new)
|
||||||
|
.insert(id.into(), item);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn destroy<U, V>(&mut self, ids: U) -> &mut Self
|
pub fn destroy<U, V>(&mut self, ids: U) -> &mut Self
|
||||||
where
|
where
|
||||||
U: IntoIterator<Item = V>,
|
U: IntoIterator<Item = V>,
|
||||||
|
|
|
@ -10,10 +10,18 @@ impl Email<Get> {
|
||||||
self.id.as_ref().unwrap()
|
self.id.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unwrap_id(self) -> String {
|
||||||
|
self.id.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn blob_id(&self) -> &str {
|
pub fn blob_id(&self) -> &str {
|
||||||
self.blob_id.as_ref().unwrap()
|
self.blob_id.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unwrap_blob_id(self) -> String {
|
||||||
|
self.blob_id.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn thread_id(&self) -> &str {
|
pub fn thread_id(&self) -> &str {
|
||||||
self.thread_id.as_ref().unwrap()
|
self.thread_id.as_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -184,11 +192,11 @@ impl EmailBodyValue<Get> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_encoding_problem(&self) -> bool {
|
pub fn is_encoding_problem(&self) -> bool {
|
||||||
self.is_encoding_problem
|
self.is_encoding_problem.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_truncated(&self) -> bool {
|
pub fn is_truncated(&self) -> bool {
|
||||||
self.is_truncated
|
self.is_truncated.unwrap_or(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,37 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
client::Client,
|
client::Client,
|
||||||
core::{
|
core::{
|
||||||
query::{Comparator, Filter, QueryResponse},
|
changes::{ChangesRequest, ChangesResponse},
|
||||||
response::{EmailGetResponse, EmailSetResponse},
|
copy::CopyRequest,
|
||||||
|
get::GetRequest,
|
||||||
|
query::{Comparator, Filter, QueryRequest, QueryResponse},
|
||||||
|
query_changes::{QueryChangesRequest, QueryChangesResponse},
|
||||||
|
request::{Arguments, Request},
|
||||||
|
response::{EmailCopyResponse, EmailGetResponse, EmailSetResponse},
|
||||||
|
set::SetRequest,
|
||||||
},
|
},
|
||||||
|
Method, Set,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
import::EmailImportResponse, parse::EmailParseResponse, BodyProperty, Email, Property,
|
import::{EmailImportRequest, EmailImportResponse},
|
||||||
|
parse::{EmailParseRequest, EmailParseResponse},
|
||||||
|
BodyProperty, Email, Property,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
pub async fn email_import<T, U>(
|
pub async fn email_import<T, U, V, W>(
|
||||||
&mut self,
|
&mut self,
|
||||||
raw_message: Vec<u8>,
|
raw_message: Vec<u8>,
|
||||||
mailbox_ids: T,
|
mailbox_ids: T,
|
||||||
keywords: Option<T>,
|
keywords: Option<V>,
|
||||||
received_at: Option<i64>,
|
received_at: Option<i64>,
|
||||||
) -> crate::Result<Email>
|
) -> crate::Result<Email>
|
||||||
where
|
where
|
||||||
T: IntoIterator<Item = U>,
|
T: IntoIterator<Item = U>,
|
||||||
U: Into<String>,
|
U: Into<String>,
|
||||||
|
V: IntoIterator<Item = W>,
|
||||||
|
W: Into<String>,
|
||||||
{
|
{
|
||||||
let blob_id = self.upload(raw_message, None).await?.unwrap_blob_id();
|
let blob_id = self.upload(raw_message, None).await?.unwrap_blob_id();
|
||||||
let mut request = self.build();
|
let mut request = self.build();
|
||||||
|
@ -119,6 +130,16 @@ impl Client {
|
||||||
.map(|mut r| r.unwrap_list().pop())
|
.map(|mut r| r.unwrap_list().pop())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn email_changes(
|
||||||
|
&mut self,
|
||||||
|
since_state: impl Into<String>,
|
||||||
|
max_changes: usize,
|
||||||
|
) -> crate::Result<ChangesResponse<()>> {
|
||||||
|
let mut request = self.build();
|
||||||
|
request.changes_email(since_state).max_changes(max_changes);
|
||||||
|
request.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn email_query(
|
pub async fn email_query(
|
||||||
&mut self,
|
&mut self,
|
||||||
filter: Option<impl Into<Filter<super::query::Filter>>>,
|
filter: Option<impl Into<Filter<super::query::Filter>>>,
|
||||||
|
@ -164,3 +185,117 @@ impl Client {
|
||||||
.and_then(|mut r| r.parsed(blob_id))
|
.and_then(|mut r| r.parsed(blob_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
pub fn get_email(&mut self) -> &mut GetRequest<super::Property, super::GetArguments> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::GetEmail,
|
||||||
|
Arguments::email_get(self.params(Method::GetEmail)),
|
||||||
|
)
|
||||||
|
.email_get_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_get_email(self) -> crate::Result<EmailGetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn changes_email(&mut self, since_state: impl Into<String>) -> &mut ChangesRequest {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::ChangesEmail,
|
||||||
|
Arguments::changes(self.params(Method::ChangesEmail), since_state.into()),
|
||||||
|
)
|
||||||
|
.changes_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_changes_email(self) -> crate::Result<ChangesResponse<()>> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn query_email(
|
||||||
|
&mut self,
|
||||||
|
) -> &mut QueryRequest<super::query::Filter, super::query::Comparator, super::QueryArguments>
|
||||||
|
{
|
||||||
|
self.add_method_call(
|
||||||
|
Method::QueryEmail,
|
||||||
|
Arguments::email_query(self.params(Method::QueryEmail)),
|
||||||
|
)
|
||||||
|
.email_query_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_query_email(self) -> crate::Result<QueryResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn query_email_changes(
|
||||||
|
&mut self,
|
||||||
|
since_query_state: impl Into<String>,
|
||||||
|
) -> &mut QueryChangesRequest<
|
||||||
|
super::query::Filter,
|
||||||
|
super::query::Comparator,
|
||||||
|
super::QueryArguments,
|
||||||
|
> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::QueryChangesEmail,
|
||||||
|
Arguments::email_query_changes(
|
||||||
|
self.params(Method::QueryChangesEmail),
|
||||||
|
since_query_state.into(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.email_query_changes_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_query_email_changes(self) -> crate::Result<QueryChangesResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_email(&mut self) -> &mut SetRequest<Email<Set>, ()> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::SetEmail,
|
||||||
|
Arguments::email_set(self.params(Method::SetEmail)),
|
||||||
|
)
|
||||||
|
.email_set_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_set_email(self) -> crate::Result<EmailSetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy_email(
|
||||||
|
&mut self,
|
||||||
|
from_account_id: impl Into<String>,
|
||||||
|
) -> &mut CopyRequest<Email<Set>> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::CopyEmail,
|
||||||
|
Arguments::email_copy(self.params(Method::CopyEmail), from_account_id.into()),
|
||||||
|
)
|
||||||
|
.email_copy_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_copy_email(self) -> crate::Result<EmailCopyResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn import_email(&mut self) -> &mut EmailImportRequest {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::ImportEmail,
|
||||||
|
Arguments::email_import(self.params(Method::ImportEmail)),
|
||||||
|
)
|
||||||
|
.email_import_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_import_email(self) -> crate::Result<EmailImportResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_email(&mut self) -> &mut EmailParseRequest {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::ParseEmail,
|
||||||
|
Arguments::email_parse(self.params(Method::ParseEmail)),
|
||||||
|
)
|
||||||
|
.email_parse_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_parse_email(self) -> crate::Result<EmailParseResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use crate::{
|
||||||
core::{
|
core::{
|
||||||
request::ResultReference,
|
request::ResultReference,
|
||||||
set::{from_timestamp, SetError},
|
set::{from_timestamp, SetError},
|
||||||
|
RequestParams,
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
|
@ -69,9 +70,9 @@ pub struct EmailImportResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmailImportRequest {
|
impl EmailImportRequest {
|
||||||
pub fn new(account_id: String) -> Self {
|
pub fn new(params: RequestParams) -> Self {
|
||||||
EmailImportRequest {
|
EmailImportRequest {
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
if_in_state: None,
|
if_in_state: None,
|
||||||
emails: HashMap::new(),
|
emails: HashMap::new(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,10 +225,12 @@ pub struct EmailBodyValue<State = Get> {
|
||||||
value: String,
|
value: String,
|
||||||
|
|
||||||
#[serde(rename = "isEncodingProblem")]
|
#[serde(rename = "isEncodingProblem")]
|
||||||
is_encoding_problem: bool,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
is_encoding_problem: Option<bool>,
|
||||||
|
|
||||||
#[serde(rename = "isTruncated")]
|
#[serde(rename = "isTruncated")]
|
||||||
is_truncated: bool,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
is_truncated: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::Error;
|
use crate::{core::RequestParams, Error};
|
||||||
|
|
||||||
use super::{BodyProperty, Email, Property};
|
use super::{BodyProperty, Email, Property};
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ pub struct EmailParseResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmailParseRequest {
|
impl EmailParseRequest {
|
||||||
pub fn new(account_id: String) -> Self {
|
pub fn new(params: RequestParams) -> Self {
|
||||||
EmailParseRequest {
|
EmailParseRequest {
|
||||||
account_id,
|
account_id: params.account_id,
|
||||||
blob_ids: Vec::new(),
|
blob_ids: Vec::new(),
|
||||||
properties: None,
|
properties: None,
|
||||||
body_properties: None,
|
body_properties: None,
|
||||||
|
|
|
@ -224,14 +224,13 @@ impl Filter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn header<U, V>(value: U) -> Self
|
pub fn header(header: impl Into<String>, v: Option<impl Into<String>>) -> Self {
|
||||||
where
|
let mut value = Vec::with_capacity(2);
|
||||||
U: IntoIterator<Item = V>,
|
value.push(header.into());
|
||||||
V: Into<String>,
|
if let Some(v) = v {
|
||||||
{
|
value.push(v.into());
|
||||||
Filter::Header {
|
|
||||||
value: value.into_iter().map(|v| v.into()).collect(),
|
|
||||||
}
|
}
|
||||||
|
Filter::Header { value }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,8 +289,8 @@ impl From<String> for EmailBodyValue {
|
||||||
fn from(value: String) -> Self {
|
fn from(value: String) -> Self {
|
||||||
EmailBodyValue {
|
EmailBodyValue {
|
||||||
value,
|
value,
|
||||||
is_encoding_problem: false,
|
is_encoding_problem: None,
|
||||||
is_truncated: false,
|
is_truncated: None,
|
||||||
_state: Default::default(),
|
_state: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,8 +300,8 @@ impl From<&str> for EmailBodyValue {
|
||||||
fn from(value: &str) -> Self {
|
fn from(value: &str) -> Self {
|
||||||
EmailBodyValue {
|
EmailBodyValue {
|
||||||
value: value.to_string(),
|
value: value.to_string(),
|
||||||
is_encoding_problem: false,
|
is_encoding_problem: None,
|
||||||
is_truncated: false,
|
is_truncated: None,
|
||||||
_state: Default::default(),
|
_state: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
use crate::{
|
||||||
|
core::{
|
||||||
|
changes::{ChangesRequest, ChangesResponse},
|
||||||
|
get::GetRequest,
|
||||||
|
query::{QueryRequest, QueryResponse},
|
||||||
|
query_changes::{QueryChangesRequest, QueryChangesResponse},
|
||||||
|
request::{Arguments, Request},
|
||||||
|
response::{EmailSubmissionGetResponse, EmailSubmissionSetResponse},
|
||||||
|
set::SetRequest,
|
||||||
|
},
|
||||||
|
Method, Set, URI,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::EmailSubmission;
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
pub fn get_email_submission(&mut self) -> &mut GetRequest<super::Property, ()> {
|
||||||
|
self.add_capability(URI::Submission);
|
||||||
|
self.add_method_call(
|
||||||
|
Method::GetEmailSubmission,
|
||||||
|
Arguments::email_submission_get(self.params(Method::GetEmailSubmission)),
|
||||||
|
)
|
||||||
|
.email_submission_get_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_get_email_submission(self) -> crate::Result<EmailSubmissionGetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn changes_email_submission(
|
||||||
|
&mut self,
|
||||||
|
since_state: impl Into<String>,
|
||||||
|
) -> &mut ChangesRequest {
|
||||||
|
self.add_capability(URI::Submission);
|
||||||
|
self.add_method_call(
|
||||||
|
Method::ChangesEmailSubmission,
|
||||||
|
Arguments::changes(
|
||||||
|
self.params(Method::ChangesEmailSubmission),
|
||||||
|
since_state.into(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.changes_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_changes_email_submission(self) -> crate::Result<ChangesResponse<()>> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn query_email_submission(
|
||||||
|
&mut self,
|
||||||
|
) -> &mut QueryRequest<super::query::Filter, super::query::Comparator, ()> {
|
||||||
|
self.add_capability(URI::Submission);
|
||||||
|
self.add_method_call(
|
||||||
|
Method::QueryEmailSubmission,
|
||||||
|
Arguments::email_submission_query(self.params(Method::QueryEmailSubmission)),
|
||||||
|
)
|
||||||
|
.email_submission_query_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_query_email_submission(self) -> crate::Result<QueryResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn query_email_submission_changes(
|
||||||
|
&mut self,
|
||||||
|
since_query_state: impl Into<String>,
|
||||||
|
) -> &mut QueryChangesRequest<super::query::Filter, super::query::Comparator, ()> {
|
||||||
|
self.add_capability(URI::Submission);
|
||||||
|
self.add_method_call(
|
||||||
|
Method::QueryChangesEmailSubmission,
|
||||||
|
Arguments::email_submission_query_changes(
|
||||||
|
self.params(Method::QueryChangesEmailSubmission),
|
||||||
|
since_query_state.into(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.email_submission_query_changes_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_query_email_submission_changes(self) -> crate::Result<QueryChangesResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_email_submission(
|
||||||
|
&mut self,
|
||||||
|
) -> &mut SetRequest<EmailSubmission<Set>, super::SetArguments> {
|
||||||
|
self.add_capability(URI::Submission);
|
||||||
|
self.add_method_call(
|
||||||
|
Method::SetEmailSubmission,
|
||||||
|
Arguments::email_submission_set(self.params(Method::SetEmailSubmission)),
|
||||||
|
)
|
||||||
|
.email_submission_set_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_set_email_submission(self) -> crate::Result<EmailSubmissionSetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod get;
|
pub mod get;
|
||||||
|
pub mod helpers;
|
||||||
pub mod query;
|
pub mod query;
|
||||||
pub mod set;
|
pub mod set;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
use crate::{
|
||||||
|
core::{
|
||||||
|
get::GetRequest,
|
||||||
|
request::{Arguments, Request},
|
||||||
|
response::{IdentityGetResponse, IdentitySetResponse},
|
||||||
|
set::SetRequest,
|
||||||
|
},
|
||||||
|
Method, Set,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::Identity;
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
pub fn get_identity(&mut self) -> &mut GetRequest<super::Property, ()> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::GetIdentity,
|
||||||
|
Arguments::identity_get(self.params(Method::GetIdentity)),
|
||||||
|
)
|
||||||
|
.identity_get_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_get_identity(self) -> crate::Result<IdentityGetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_identity(&mut self) -> &mut SetRequest<Identity<Set>, ()> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::SetIdentity,
|
||||||
|
Arguments::identity_set(self.params(Method::SetIdentity)),
|
||||||
|
)
|
||||||
|
.identity_set_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_set_identity(self) -> crate::Result<IdentitySetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod get;
|
pub mod get;
|
||||||
|
pub mod helpers;
|
||||||
pub mod set;
|
pub mod set;
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub enum URI {
|
||||||
Calendars,
|
Calendars,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub enum Method {
|
pub enum Method {
|
||||||
#[serde(rename = "Core/echo")]
|
#[serde(rename = "Core/echo")]
|
||||||
Echo,
|
Echo,
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
client::Client,
|
client::Client,
|
||||||
core::{
|
core::{
|
||||||
query::{Comparator, Filter, QueryResponse},
|
changes::{ChangesRequest, ChangesResponse},
|
||||||
|
get::GetRequest,
|
||||||
|
query::{Comparator, Filter, QueryRequest, QueryResponse},
|
||||||
|
query_changes::{QueryChangesRequest, QueryChangesResponse},
|
||||||
|
request::{Arguments, Request},
|
||||||
response::{MailboxGetResponse, MailboxSetResponse},
|
response::{MailboxGetResponse, MailboxSetResponse},
|
||||||
set::Create,
|
set::{Create, SetRequest},
|
||||||
},
|
},
|
||||||
|
Method, Set,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{Mailbox, Property, Role};
|
use super::{Mailbox, Property, Role};
|
||||||
|
@ -128,3 +133,80 @@ impl Client {
|
||||||
request.send_single::<QueryResponse>().await
|
request.send_single::<QueryResponse>().await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
pub fn get_mailbox(&mut self) -> &mut GetRequest<super::Property, ()> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::GetMailbox,
|
||||||
|
Arguments::mailbox_get(self.params(Method::GetMailbox)),
|
||||||
|
)
|
||||||
|
.mailbox_get_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_get_mailbox(self) -> crate::Result<MailboxGetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn changes_mailbox(&mut self, since_state: impl Into<String>) -> &mut ChangesRequest {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::ChangesMailbox,
|
||||||
|
Arguments::changes(self.params(Method::ChangesMailbox), since_state.into()),
|
||||||
|
)
|
||||||
|
.changes_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_changes_mailbox(
|
||||||
|
self,
|
||||||
|
) -> crate::Result<ChangesResponse<super::ChangesResponse>> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn query_mailbox(
|
||||||
|
&mut self,
|
||||||
|
) -> &mut QueryRequest<super::query::Filter, super::query::Comparator, super::QueryArguments>
|
||||||
|
{
|
||||||
|
self.add_method_call(
|
||||||
|
Method::QueryMailbox,
|
||||||
|
Arguments::mailbox_query(self.params(Method::QueryMailbox)),
|
||||||
|
)
|
||||||
|
.mailbox_query_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_query_mailbox(self) -> crate::Result<QueryResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn query_mailbox_changes(
|
||||||
|
&mut self,
|
||||||
|
since_query_state: impl Into<String>,
|
||||||
|
) -> &mut QueryChangesRequest<
|
||||||
|
super::query::Filter,
|
||||||
|
super::query::Comparator,
|
||||||
|
super::QueryArguments,
|
||||||
|
> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::QueryChangesMailbox,
|
||||||
|
Arguments::mailbox_query_changes(
|
||||||
|
self.params(Method::QueryChangesMailbox),
|
||||||
|
since_query_state.into(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.mailbox_query_changes_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_query_mailbox_changes(self) -> crate::Result<QueryChangesResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_mailbox(&mut self) -> &mut SetRequest<Mailbox<Set>, super::SetArguments> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::SetMailbox,
|
||||||
|
Arguments::mailbox_set(self.params(Method::SetMailbox)),
|
||||||
|
)
|
||||||
|
.mailbox_set_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_set_mailbox(self) -> crate::Result<MailboxSetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
use crate::{
|
||||||
|
core::{
|
||||||
|
get::GetRequest,
|
||||||
|
request::{Arguments, Request},
|
||||||
|
response::{PushSubscriptionGetResponse, PushSubscriptionSetResponse},
|
||||||
|
set::SetRequest,
|
||||||
|
},
|
||||||
|
Method, Set,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::PushSubscription;
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
pub fn get_push_subscription(&mut self) -> &mut GetRequest<super::Property, ()> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::GetPushSubscription,
|
||||||
|
Arguments::push_get(self.params(Method::GetPushSubscription)),
|
||||||
|
)
|
||||||
|
.push_get_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_get_push_subscription(self) -> crate::Result<PushSubscriptionGetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_push_subscription(&mut self) -> &mut SetRequest<PushSubscription<Set>, ()> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::SetPushSubscription,
|
||||||
|
Arguments::push_set(self.params(Method::SetPushSubscription)),
|
||||||
|
)
|
||||||
|
.push_set_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_set_push_subscription(self) -> crate::Result<PushSubscriptionSetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod get;
|
pub mod get;
|
||||||
|
pub mod helpers;
|
||||||
pub mod set;
|
pub mod set;
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
use crate::{client::Client, core::response::ThreadGetResponse};
|
use crate::{
|
||||||
|
client::Client,
|
||||||
|
core::{
|
||||||
|
changes::{ChangesRequest, ChangesResponse},
|
||||||
|
get::GetRequest,
|
||||||
|
request::{Arguments, Request},
|
||||||
|
response::ThreadGetResponse,
|
||||||
|
},
|
||||||
|
Method,
|
||||||
|
};
|
||||||
|
|
||||||
use super::Thread;
|
use super::Thread;
|
||||||
|
|
||||||
|
@ -12,3 +21,29 @@ impl Client {
|
||||||
.map(|mut r| r.unwrap_list().pop())
|
.map(|mut r| r.unwrap_list().pop())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
pub fn get_thread(&mut self) -> &mut GetRequest<super::Property, ()> {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::GetThread,
|
||||||
|
Arguments::thread_get(self.params(Method::GetThread)),
|
||||||
|
)
|
||||||
|
.thread_get_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_get_thread(self) -> crate::Result<ThreadGetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn changes_thread(&mut self, since_state: impl Into<String>) -> &mut ChangesRequest {
|
||||||
|
self.add_method_call(
|
||||||
|
Method::ChangesThread,
|
||||||
|
Arguments::changes(self.params(Method::ChangesThread), since_state.into()),
|
||||||
|
)
|
||||||
|
.changes_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_changes_thread(self) -> crate::Result<ChangesResponse<()>> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
pub mod get;
|
pub mod get;
|
||||||
pub mod helpers;
|
pub mod helpers;
|
||||||
|
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -17,3 +19,12 @@ pub enum Property {
|
||||||
#[serde(rename = "emailIds")]
|
#[serde(rename = "emailIds")]
|
||||||
EmailIds,
|
EmailIds,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for Property {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Property::Id => write!(f, "id"),
|
||||||
|
Property::EmailIds => write!(f, "emailIds"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
use crate::{
|
||||||
|
core::{
|
||||||
|
get::GetRequest,
|
||||||
|
request::{Arguments, Request},
|
||||||
|
response::{VacationResponseGetResponse, VacationResponseSetResponse},
|
||||||
|
set::SetRequest,
|
||||||
|
},
|
||||||
|
Method, Set, URI,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::VacationResponse;
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
pub fn get_vacation_response(&mut self) -> &mut GetRequest<super::Property, ()> {
|
||||||
|
self.add_capability(URI::VacationResponse);
|
||||||
|
self.add_method_call(
|
||||||
|
Method::GetVacationResponse,
|
||||||
|
Arguments::vacation_response_get(self.params(Method::GetVacationResponse)),
|
||||||
|
)
|
||||||
|
.vacation_response_get_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_get_vacation_response(self) -> crate::Result<VacationResponseGetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_vacation_response(&mut self) -> &mut SetRequest<VacationResponse<Set>, ()> {
|
||||||
|
self.add_capability(URI::VacationResponse);
|
||||||
|
self.add_method_call(
|
||||||
|
Method::SetVacationResponse,
|
||||||
|
Arguments::vacation_response_set(self.params(Method::GetVacationResponse)),
|
||||||
|
)
|
||||||
|
.vacation_response_set_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_set_vacation_response(self) -> crate::Result<VacationResponseSetResponse> {
|
||||||
|
self.send_single().await
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod get;
|
pub mod get;
|
||||||
|
pub mod helpers;
|
||||||
pub mod set;
|
pub mod set;
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
Loading…
Reference in New Issue