|
| 1 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | + |
| 5 | +use serde::Deserialize; |
| 6 | +use xml_struct::XmlSerialize; |
| 7 | + |
| 8 | +use crate::types::sealed::EnvelopeBodyContents; |
| 9 | +use crate::{ |
| 10 | + BaseItemId, Operation, OperationResponse, ResponseClass, ResponseCode, MESSAGES_NS_URI, |
| 11 | +}; |
| 12 | + |
| 13 | +/// The manner in which the item or items are deleted. |
| 14 | +/// |
| 15 | +/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem#deletetype-attribute> |
| 16 | +#[derive(Debug, XmlSerialize)] |
| 17 | +#[xml_struct(text)] |
| 18 | +pub enum DeleteType { |
| 19 | + HardDelete, |
| 20 | + SoftDelete, |
| 21 | + MoveToDeletedItems, |
| 22 | +} |
| 23 | + |
| 24 | +/// Whether to send meeting cancellations when deleting a calendar item. |
| 25 | +/// |
| 26 | +/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem#sendmeetingcancellations-attribute> |
| 27 | +#[derive(Debug, XmlSerialize)] |
| 28 | +#[xml_struct(text)] |
| 29 | +pub enum SendMeetingCancellations { |
| 30 | + SendToNone, |
| 31 | + SendOnlyToAll, |
| 32 | + SendToAllAndSaveCopy, |
| 33 | +} |
| 34 | + |
| 35 | +/// Which tasks should be impacted when deleting a task item. |
| 36 | +/// |
| 37 | +/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem#affectedtaskoccurrences-attribute> |
| 38 | +#[derive(Debug, XmlSerialize)] |
| 39 | +#[xml_struct(text)] |
| 40 | +pub enum AffectedTaskOccurrences { |
| 41 | + AllOccurrences, |
| 42 | + SpecifiedOccurrenceOnly, |
| 43 | +} |
| 44 | + |
| 45 | +/// A request to delete one or more Exchange items. |
| 46 | +/// |
| 47 | +/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem> |
| 48 | +#[derive(Debug, XmlSerialize)] |
| 49 | +#[xml_struct(default_ns = MESSAGES_NS_URI)] |
| 50 | +pub struct DeleteItem { |
| 51 | + /// The method the EWS server will use to perform the deletion. |
| 52 | + /// |
| 53 | + /// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem#deletetype-attribute> |
| 54 | + #[xml_struct(attribute)] |
| 55 | + pub delete_type: DeleteType, |
| 56 | + |
| 57 | + /// The action the EWS server will take when deleting a calendar item. |
| 58 | + /// |
| 59 | + /// Required when deleting calendar items, otherwise it has no effect. |
| 60 | + /// |
| 61 | + /// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem#sendmeetingcancellations-attribute> |
| 62 | + #[xml_struct(attribute)] |
| 63 | + pub send_meeting_cancellations: Option<SendMeetingCancellations>, |
| 64 | + |
| 65 | + /// The task item(s) to delete. |
| 66 | + /// |
| 67 | + /// Required when deleting task items, otherwise it has no effect. |
| 68 | + /// |
| 69 | + /// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem#affectedtaskoccurrences-attribute> |
| 70 | + #[xml_struct(attribute)] |
| 71 | + pub affected_task_occurrences: Option<AffectedTaskOccurrences>, |
| 72 | + |
| 73 | + /// Whether to suppress read receipts for the deleted item(s). |
| 74 | + /// |
| 75 | + /// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem#attributes> |
| 76 | + #[xml_struct(attribute)] |
| 77 | + pub suppress_read_receipts: Option<bool>, |
| 78 | + |
| 79 | + /// A list of items to delete. |
| 80 | + /// |
| 81 | + /// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/itemids> |
| 82 | + pub item_ids: Vec<BaseItemId>, |
| 83 | +} |
| 84 | + |
| 85 | +impl Operation for DeleteItem { |
| 86 | + type Response = DeleteItemResponse; |
| 87 | +} |
| 88 | + |
| 89 | +impl EnvelopeBodyContents for DeleteItem { |
| 90 | + fn name() -> &'static str { |
| 91 | + "DeleteItem" |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +/// A response to a [`DeleteItem`] request. |
| 96 | +/// |
| 97 | +/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitemresponse> |
| 98 | +#[derive(Debug, Deserialize)] |
| 99 | +#[serde(rename_all = "PascalCase")] |
| 100 | +pub struct DeleteItemResponse { |
| 101 | + pub response_messages: ResponseMessages, |
| 102 | +} |
| 103 | + |
| 104 | +impl OperationResponse for DeleteItemResponse {} |
| 105 | + |
| 106 | +impl EnvelopeBodyContents for DeleteItemResponse { |
| 107 | + fn name() -> &'static str { |
| 108 | + "DeleteItemResponse" |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +#[derive(Debug, Deserialize)] |
| 113 | +#[serde(rename_all = "PascalCase")] |
| 114 | +pub struct ResponseMessages { |
| 115 | + pub delete_item_response_message: Vec<DeleteItemResponseMessage>, |
| 116 | +} |
| 117 | + |
| 118 | +#[derive(Debug, Deserialize)] |
| 119 | +#[serde(rename_all = "PascalCase")] |
| 120 | +pub struct DeleteItemResponseMessage { |
| 121 | + /// The status of the corresponding request, i.e. whether it succeeded or |
| 122 | + /// resulted in an error. |
| 123 | + #[serde(rename = "@ResponseClass")] |
| 124 | + pub response_class: ResponseClass, |
| 125 | + |
| 126 | + pub response_code: Option<ResponseCode>, |
| 127 | + |
| 128 | + pub message_text: Option<String>, |
| 129 | +} |
0 commit comments