aws-sdk-pinpoint 0.28.0

AWS SDK for Amazon Pinpoint
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_push_notification_template_response_payload(
    input: &[u8],
) -> Result<
    crate::types::PushNotificationTemplateResponse,
    ::aws_smithy_json::deserialize::error::DeserializeError,
> {
    let mut tokens_owned =
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(input))
            .peekable();
    let tokens = &mut tokens_owned;
    let result =
    crate::protocol_serde::shape_push_notification_template_response::de_push_notification_template_response(tokens)?
    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("expected payload member value"));
    if tokens.next().is_some() {
        return Err(
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
                "found more JSON tokens after completing parsing",
            ),
        );
    }
    result
}

pub(crate) fn de_push_notification_template_response<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
) -> Result<
    Option<crate::types::PushNotificationTemplateResponse>,
    ::aws_smithy_json::deserialize::error::DeserializeError,
>
where
    I: Iterator<
        Item = Result<
            ::aws_smithy_json::deserialize::Token<'a>,
            ::aws_smithy_json::deserialize::error::DeserializeError,
        >,
    >,
{
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            #[allow(unused_mut)]
            let mut builder =
                crate::types::builders::PushNotificationTemplateResponseBuilder::default();
            loop {
                match tokens.next().transpose()? {
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
                        match key.to_unescaped()?.as_ref() {
                            "ADM" => {
                                builder = builder.set_adm(
                                    crate::protocol_serde::shape_android_push_notification_template::de_android_push_notification_template(tokens)?
                                );
                            }
                            "APNS" => {
                                builder = builder.set_apns(
                                    crate::protocol_serde::shape_apns_push_notification_template::de_apns_push_notification_template(tokens)?
                                );
                            }
                            "Arn" => {
                                builder = builder.set_arn(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "Baidu" => {
                                builder = builder.set_baidu(
                                    crate::protocol_serde::shape_android_push_notification_template::de_android_push_notification_template(tokens)?
                                );
                            }
                            "CreationDate" => {
                                builder = builder.set_creation_date(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "Default" => {
                                builder = builder.set_default(
                                    crate::protocol_serde::shape_default_push_notification_template::de_default_push_notification_template(tokens)?
                                );
                            }
                            "DefaultSubstitutions" => {
                                builder = builder.set_default_substitutions(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "GCM" => {
                                builder = builder.set_gcm(
                                    crate::protocol_serde::shape_android_push_notification_template::de_android_push_notification_template(tokens)?
                                );
                            }
                            "LastModifiedDate" => {
                                builder = builder.set_last_modified_date(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "RecommenderId" => {
                                builder = builder.set_recommender_id(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "tags" => {
                                builder = builder.set_tags(
                                    crate::protocol_serde::shape_map_of__string::de_map_of__string(
                                        tokens,
                                    )?,
                                );
                            }
                            "TemplateDescription" => {
                                builder = builder.set_template_description(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "TemplateName" => {
                                builder = builder.set_template_name(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            "TemplateType" => {
                                builder = builder.set_template_type(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| {
                                        s.to_unescaped()
                                            .map(|u| crate::types::TemplateType::from(u.as_ref()))
                                    })
                                    .transpose()?,
                                );
                            }
                            "Version" => {
                                builder = builder.set_version(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(
                                        tokens.next(),
                                    )?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                                );
                            }
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
                        }
                    }
                    other => {
                        return Err(
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
                                format!("expected object key or end object, found: {:?}", other),
                            ),
                        )
                    }
                }
            }
            Ok(Some(builder.build()))
        }
        _ => Err(
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
                "expected start object or null",
            ),
        ),
    }
}