aws_sdk_connect/protocol_serde/
shape_send_notification_action_definition.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_send_notification_action_definition(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::SendNotificationActionDefinition,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("DeliveryMethod").string(input.delivery_method.as_str());
8    }
9    if let Some(var_1) = &input.subject {
10        object.key("Subject").string(var_1.as_str());
11    }
12    {
13        object.key("Content").string(input.content.as_str());
14    }
15    {
16        object.key("ContentType").string(input.content_type.as_str());
17    }
18    if let Some(var_2) = &input.recipient {
19        #[allow(unused_mut)]
20        let mut object_3 = object.key("Recipient").start_object();
21        crate::protocol_serde::shape_notification_recipient_type::ser_notification_recipient_type(&mut object_3, var_2)?;
22        object_3.finish();
23    }
24    if let Some(var_4) = &input.exclusion {
25        #[allow(unused_mut)]
26        let mut object_5 = object.key("Exclusion").start_object();
27        crate::protocol_serde::shape_notification_recipient_type::ser_notification_recipient_type(&mut object_5, var_4)?;
28        object_5.finish();
29    }
30    Ok(())
31}
32
33pub(crate) fn de_send_notification_action_definition<'a, I>(
34    tokens: &mut ::std::iter::Peekable<I>,
35) -> ::std::result::Result<Option<crate::types::SendNotificationActionDefinition>, ::aws_smithy_json::deserialize::error::DeserializeError>
36where
37    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
38{
39    match tokens.next().transpose()? {
40        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
41        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
42            #[allow(unused_mut)]
43            let mut builder = crate::types::builders::SendNotificationActionDefinitionBuilder::default();
44            loop {
45                match tokens.next().transpose()? {
46                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
47                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
48                        "DeliveryMethod" => {
49                            builder = builder.set_delivery_method(
50                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
51                                    .map(|s| s.to_unescaped().map(|u| crate::types::NotificationDeliveryType::from(u.as_ref())))
52                                    .transpose()?,
53                            );
54                        }
55                        "Subject" => {
56                            builder = builder.set_subject(
57                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
58                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
59                                    .transpose()?,
60                            );
61                        }
62                        "Content" => {
63                            builder = builder.set_content(
64                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
65                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
66                                    .transpose()?,
67                            );
68                        }
69                        "ContentType" => {
70                            builder = builder.set_content_type(
71                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
72                                    .map(|s| s.to_unescaped().map(|u| crate::types::NotificationContentType::from(u.as_ref())))
73                                    .transpose()?,
74                            );
75                        }
76                        "Recipient" => {
77                            builder = builder.set_recipient(
78                                crate::protocol_serde::shape_notification_recipient_type::de_notification_recipient_type(tokens)?,
79                            );
80                        }
81                        "Exclusion" => {
82                            builder = builder.set_exclusion(
83                                crate::protocol_serde::shape_notification_recipient_type::de_notification_recipient_type(tokens)?,
84                            );
85                        }
86                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
87                    },
88                    other => {
89                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
90                            "expected object key or end object, found: {other:?}"
91                        )))
92                    }
93                }
94            }
95            Ok(Some(
96                crate::serde_util::send_notification_action_definition_correct_errors(builder)
97                    .build()
98                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
99            ))
100        }
101        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
102            "expected start object or null",
103        )),
104    }
105}