aws_sdk_connect/protocol_serde/
shape_send_notification_action_definition.rs1pub 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 _value: &'a [u8],
36) -> ::std::result::Result<Option<crate::types::SendNotificationActionDefinition>, ::aws_smithy_json::deserialize::error::DeserializeError>
37where
38 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
39{
40 match tokens.next().transpose()? {
41 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
42 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
43 #[allow(unused_mut)]
44 let mut builder = crate::types::builders::SendNotificationActionDefinitionBuilder::default();
45 loop {
46 match tokens.next().transpose()? {
47 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
48 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
49 "DeliveryMethod" => {
50 builder = builder.set_delivery_method(
51 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
52 .map(|s| s.to_unescaped().map(|u| crate::types::NotificationDeliveryType::from(u.as_ref())))
53 .transpose()?,
54 );
55 }
56 "Subject" => {
57 builder = builder.set_subject(
58 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
59 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
60 .transpose()?,
61 );
62 }
63 "Content" => {
64 builder = builder.set_content(
65 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
66 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
67 .transpose()?,
68 );
69 }
70 "ContentType" => {
71 builder = builder.set_content_type(
72 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
73 .map(|s| s.to_unescaped().map(|u| crate::types::NotificationContentType::from(u.as_ref())))
74 .transpose()?,
75 );
76 }
77 "Recipient" => {
78 builder = builder.set_recipient(
79 crate::protocol_serde::shape_notification_recipient_type::de_notification_recipient_type(tokens, _value)?,
80 );
81 }
82 "Exclusion" => {
83 builder = builder.set_exclusion(
84 crate::protocol_serde::shape_notification_recipient_type::de_notification_recipient_type(tokens, _value)?,
85 );
86 }
87 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
88 },
89 other => {
90 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
91 "expected object key or end object, found: {other:?}"
92 )))
93 }
94 }
95 }
96 Ok(Some(
97 crate::serde_util::send_notification_action_definition_correct_errors(builder)
98 .build()
99 .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
100 ))
101 }
102 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
103 "expected start object or null",
104 )),
105 }
106}