Skip to content
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

Add DeleteType enum #25

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod soap;

pub mod create_item;
pub mod delete_item;
pub mod delete_folder;
pub mod get_folder;
pub mod get_item;
pub mod sync_folder_hierarchy;
Expand Down
11 changes: 11 additions & 0 deletions src/types/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ pub struct FolderId {
pub change_key: Option<String>,
}

/// The element that determines how elements are deleted.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deletetype>
#[derive(Clone, Debug, XmlSerialize)]
#[xml_struct(text)]
pub enum DeleteType {
HardDelete,
MoveToDeletedItems,
SoftDelete,
}

/// An identifier for an Exchange item.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/itemids>
Expand Down
75 changes: 75 additions & 0 deletions src/types/delete_folder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* 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 serde::Deserialize;
use xml_struct::XmlSerialize;

use crate::{
types::sealed::EnvelopeBodyContents, BaseFolderId, DeleteType, Operation, OperationResponse,
ResponseClass, ResponseCode, MESSAGES_NS_URI,
};

/// A request to delete a folder.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deletefolder>
#[derive(Clone, Debug, XmlSerialize)]
#[xml_struct(default_ns = MESSAGES_NS_URI)]
pub struct DeleteFolder {
/// DeleteFolder uses the DeleteType attribute
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deleteitem#deletetype-attribute>
#[xml_struct(attribute)]
pub delete_type: DeleteType,

/// DeleteFolder requires FolderIds which is an array of FolderId and DistinguishedFolderId elements
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/folderids>
pub folder_ids: Vec<BaseFolderId>,
}

impl Operation for DeleteFolder {
type Response = DeleteFolderResponse;
}

impl EnvelopeBodyContents for DeleteFolder {
fn name() -> &'static str {
"DeleteFolder"
}
}

/// A response to a [`DeleteFolder`] request.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/deletefolderresponse>
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DeleteFolderResponse {
pub response_messages: ResponseMessages,
}

impl OperationResponse for DeleteFolderResponse {}

impl EnvelopeBodyContents for DeleteFolderResponse {
fn name() -> &'static str {
"DeleteFolderResponse"
}
}

#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ResponseMessages {
pub delete_folder_response_message: Vec<DeleteFolderResponseMessage>,
}

#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DeleteFolderResponseMessage {
/// 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<ResponseCode>,

pub message_text: Option<String>,
}
Loading