-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created UpdateItem and added necessary trait implementations #18
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
188d3da
Created UpdateItem and added necessary trait implementations
tobypilling f784450
Respond to feedback on UpdateItem, unduplicate MessageDisposition (no…
tobypilling 468a45a
Also added default trait for ConflictResolution
tobypilling 4277779
Adjusted comment to use a noun phrase for ConflictResolution
tobypilling 9cfb448
Fixed formatting issues
tobypilling b1c4485
Test formatting
tobypilling aaf24c1
Fix formatting again
tobypilling 475bd39
Test broken formatting
tobypilling 8d77946
Merge branch 'main' into tobypilling/update_item
tobypilling ccae29c
Test broken formatting
tobypilling 423b52b
Fix broken formatting
tobypilling 483be7c
Update documentation and get rid of serialize-only Message type (#23)
leftmostcat d3e2e90
Add reference to EWS updateitem docs
tobypilling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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; | ||
|
||
/// A request to update properties of one or more Exchange items. | ||
tobypilling marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updateitem> | ||
#[derive(Clone, Debug, XmlSerialize)] | ||
pub struct UpdateItem { | ||
/// The action the Exchange server will take upon updating this item. | ||
/// | ||
/// This field is required for and only applicable to [`Message`] items. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updateitem#messagedisposition-attribute> | ||
#[xml_struct(attribute)] | ||
pub message_disposition: Option<MessageDisposition>, | ||
|
||
/// The method the Exchange server will use to resolve conflicts between | ||
/// updates. | ||
/// | ||
/// If omitted, the server will default to [`AutoResolve`]. | ||
/// | ||
/// [`AutoResolve`]: `ConflictResolution::AutoResolve` | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updateitem#conflictresolution-attribute> | ||
#[xml_struct(attribute)] | ||
pub conflict_resolution: Option<ConflictResolution>, | ||
|
||
/// A list of items and their corresponding updates. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/itemchanges> | ||
pub item_changes: ItemChanges, | ||
} | ||
|
||
impl Operation for UpdateItem { | ||
type Response = UpdateItemResponse; | ||
} | ||
|
||
impl EnvelopeBodyContents for UpdateItem { | ||
fn name() -> &'static str { | ||
"UpdateItem" | ||
} | ||
} | ||
|
||
/// A response to an [`UpdateItem`] request. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updateitemresponse> | ||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct UpdateItemResponse { | ||
pub response_messages: ResponseMessages, | ||
} | ||
|
||
impl OperationResponse for UpdateItemResponse {} | ||
|
||
impl EnvelopeBodyContents for UpdateItemResponse { | ||
fn name() -> &'static str { | ||
"UpdateItemResponse" | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct ResponseMessages { | ||
pub update_item_response_message: Vec<UpdateItemResponseMessage>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct UpdateItemResponseMessage { | ||
/// The status of the corresponding request, i.e. whether it succeeded or | ||
/// resulted in an error. | ||
pub response_class: ResponseClass, | ||
|
||
pub response_code: Option<ResponseCode>, | ||
|
||
pub message_text: Option<String>, | ||
|
||
pub items: Items, | ||
} | ||
|
||
/// The method used by the Exchange server to resolve conflicts between item | ||
/// updates. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updateitem#conflictresolution-attribute> | ||
#[derive(Clone, Copy, Debug, Default, XmlSerialize)] | ||
#[xml_struct(text)] | ||
pub enum ConflictResolution { | ||
/// Conflicts will cause the update to fail and return an error. | ||
NeverOverwrite, | ||
|
||
/// The Exchange server will attempt to resolve any conflicts automatically. | ||
#[default] | ||
AutoResolve, | ||
|
||
/// Conflicting fields will be overwritten with the contents of the update. | ||
AlwaysOverwrite, | ||
} | ||
|
||
/// A list of updates to items, with each element representing a single item. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/itemchanges> | ||
#[derive(Clone, Debug, XmlSerialize)] | ||
pub struct ItemChanges { | ||
pub item_changes: Vec<ItemChange>, | ||
} | ||
|
||
/// One or more updates to a single item. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/itemchange> | ||
#[derive(Clone, Debug, XmlSerialize)] | ||
pub struct ItemChange { | ||
/// The ID of the item to be updated. | ||
pub item_id: BaseItemId, | ||
|
||
/// The changes to make to the item, including appending, setting, or | ||
/// deleting fields. | ||
pub updates: Updates, | ||
} | ||
|
||
/// A list of changes to fields, with each element representing a single change. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updates-item> | ||
#[derive(Clone, Debug, XmlSerialize)] | ||
pub struct Updates { | ||
#[xml_struct(flatten)] | ||
pub inner: Vec<ItemChangeDescription>, | ||
} | ||
|
||
/// An individual change to a single field. | ||
#[derive(Clone, Debug, XmlSerialize)] | ||
pub enum ItemChangeDescription { | ||
/// An update setting the value of a single field. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/setitemfield> | ||
SetItemField { | ||
/// The field to be updated. | ||
field_uri: PathToElement, | ||
|
||
/// The new value of the specified field. | ||
message: Message, | ||
}, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.