Use of associated types + Identity and EmailSubmission helpers.

This commit is contained in:
Mauro D
2022-06-01 11:48:02 +00:00
parent 8c1d49353d
commit 1b27e6e146
38 changed files with 734 additions and 325 deletions

View File

@@ -1,4 +1,4 @@
use crate::Get;
use crate::{core::get::GetObject, Get, Set};
use super::VacationResponse;
@@ -31,3 +31,11 @@ impl VacationResponse<Get> {
self.html_body.as_deref()
}
}
impl GetObject for VacationResponse<Set> {
type GetArguments = ();
}
impl GetObject for VacationResponse<Get> {
type GetArguments = ();
}

View File

@@ -11,7 +11,7 @@ use crate::{
use super::VacationResponse;
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_method_call(
Method::GetVacationResponse,
@@ -24,7 +24,7 @@ impl Request<'_> {
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_method_call(
Method::SetVacationResponse,

View File

@@ -4,9 +4,10 @@ pub mod set;
use std::fmt::Display;
use crate::core::changes::ChangesObject;
use crate::core::set::date_not_set;
use crate::core::set::string_not_set;
use crate::core::Type;
use crate::core::Object;
use crate::Get;
use crate::Set;
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 {
true
}
}
impl Type for Property {
impl Object for VacationResponse<Get> {
type Property = Property;
fn requires_account_id() -> bool {
true
}
}
impl ChangesObject for VacationResponse<Set> {
type ChangesResponse = ();
}
impl ChangesObject for VacationResponse<Get> {
type ChangesResponse = ();
}

View File

@@ -1,6 +1,7 @@
use crate::{
core::set::{from_timestamp, Create},
Set,
core::set::{from_timestamp, SetObject},
email_submission::SetArguments,
Get, Set,
};
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 {
VacationResponse {
_create_id,
@@ -56,3 +59,15 @@ impl Create for VacationResponse<Set> {
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
}
}