From 147ed181ceab0c26745204ff31836107dce1dd86 Mon Sep 17 00:00:00 2001 From: tobypilling Date: Fri, 8 Nov 2024 10:03:48 -0500 Subject: [PATCH] Changes to support XML serialization --- src/types/common.rs | 1 + src/types/update_item.rs | 36 +++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/types/common.rs b/src/types/common.rs index 41df889..68d5d2a 100644 --- a/src/types/common.rs +++ b/src/types/common.rs @@ -533,6 +533,7 @@ pub struct Message { pub conversation_topic: Option, pub from: Option, pub internet_message_id: Option, + #[xml_struct(ns_prefix = "t")] pub is_read: Option, pub is_response_requested: Option, pub reply_to: Option, diff --git a/src/types/update_item.rs b/src/types/update_item.rs index ea3cd82..553c63d 100644 --- a/src/types/update_item.rs +++ b/src/types/update_item.rs @@ -2,18 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use crate::types::common::{BaseItemId, Message, MessageDisposition, PathToElement}; -use crate::{ - types::sealed::EnvelopeBodyContents, Items, Operation, OperationResponse, ResponseClass, - ResponseCode, -}; -use serde::Deserialize; -use xml_struct::XmlSerialize; + use crate::types::common::{BaseItemId, Message, MessageDisposition, PathToElement}; + use crate::{ + types::sealed::EnvelopeBodyContents, Items, Operation, OperationResponse, ResponseClass, + ResponseCode, MESSAGES_NS_URI, + }; + use serde::Deserialize; + use xml_struct::XmlSerialize; /// A request to update properties of one or more Exchange items. /// /// See #[derive(Clone, Debug, XmlSerialize)] +#[xml_struct(default_ns = MESSAGES_NS_URI)] pub struct UpdateItem { /// The action the Exchange server will take upon updating this item. /// @@ -21,7 +22,7 @@ pub struct UpdateItem { /// /// See #[xml_struct(attribute)] - pub message_disposition: Option, + pub message_disposition: MessageDisposition, /// The method the Exchange server will use to resolve conflicts between /// updates. @@ -37,7 +38,7 @@ pub struct UpdateItem { /// A list of items and their corresponding updates. /// /// See - pub item_changes: ItemChanges, + pub item_changes: Vec, } impl Operation for UpdateItem { @@ -78,6 +79,7 @@ pub struct ResponseMessages { pub struct UpdateItemResponseMessage { /// The status of the corresponding request, i.e. whether it succeeded or /// resulted in an error. + #[serde(rename = "@ResponseClass")] pub response_class: ResponseClass, pub response_code: Option, @@ -110,19 +112,28 @@ pub enum ConflictResolution { /// See #[derive(Clone, Debug, XmlSerialize)] pub struct ItemChanges { + #[xml_struct(ns_prefix = "t")] pub item_changes: Vec, } +#[derive(Clone, Debug, XmlSerialize)] +#[xml_struct(variant_ns_prefix = "t")] +pub enum ItemChange{ + ItemChange(ItemChangeInner), +} + /// One or more updates to a single item. /// /// See #[derive(Clone, Debug, XmlSerialize)] -pub struct ItemChange { +pub struct ItemChangeInner { /// The ID of the item to be updated. + #[xml_struct(flatten, ns_prefix = "t")] pub item_id: BaseItemId, /// The changes to make to the item, including appending, setting, or /// deleting fields. + #[xml_struct(ns_prefix = "t")] pub updates: Updates, } @@ -131,21 +142,24 @@ pub struct ItemChange { /// See #[derive(Clone, Debug, XmlSerialize)] pub struct Updates { - #[xml_struct(flatten)] + #[xml_struct(flatten, ns_prefix = "t")] pub inner: Vec, } /// An individual change to a single field. #[derive(Clone, Debug, XmlSerialize)] +#[xml_struct(variant_ns_prefix = "t")] pub enum ItemChangeDescription { /// An update setting the value of a single field. /// /// See SetItemField { /// The field to be updated. + #[xml_struct(flatten, ns_prefix = "t")] field_uri: PathToElement, /// The new value of the specified field. + #[xml_struct(ns_prefix = "t")] message: Message, }, }