aws_sdk_pinpointsmsvoicev2/protocol_serde/
shape_phone_number_information.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_phone_number_information<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::PhoneNumberInformation>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            #[allow(unused_mut)]
12            let mut builder = crate::types::builders::PhoneNumberInformationBuilder::default();
13            loop {
14                match tokens.next().transpose()? {
15                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
17                        "PhoneNumberArn" => {
18                            builder = builder.set_phone_number_arn(
19                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
20                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
21                                    .transpose()?,
22                            );
23                        }
24                        "PhoneNumberId" => {
25                            builder = builder.set_phone_number_id(
26                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
28                                    .transpose()?,
29                            );
30                        }
31                        "PhoneNumber" => {
32                            builder = builder.set_phone_number(
33                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
34                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
35                                    .transpose()?,
36                            );
37                        }
38                        "Status" => {
39                            builder = builder.set_status(
40                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
41                                    .map(|s| s.to_unescaped().map(|u| crate::types::NumberStatus::from(u.as_ref())))
42                                    .transpose()?,
43                            );
44                        }
45                        "IsoCountryCode" => {
46                            builder = builder.set_iso_country_code(
47                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
48                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
49                                    .transpose()?,
50                            );
51                        }
52                        "MessageType" => {
53                            builder = builder.set_message_type(
54                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
55                                    .map(|s| s.to_unescaped().map(|u| crate::types::MessageType::from(u.as_ref())))
56                                    .transpose()?,
57                            );
58                        }
59                        "NumberCapabilities" => {
60                            builder = builder
61                                .set_number_capabilities(crate::protocol_serde::shape_number_capability_list::de_number_capability_list(tokens)?);
62                        }
63                        "NumberType" => {
64                            builder = builder.set_number_type(
65                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
66                                    .map(|s| s.to_unescaped().map(|u| crate::types::NumberType::from(u.as_ref())))
67                                    .transpose()?,
68                            );
69                        }
70                        "MonthlyLeasingPrice" => {
71                            builder = builder.set_monthly_leasing_price(
72                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
73                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
74                                    .transpose()?,
75                            );
76                        }
77                        "TwoWayEnabled" => {
78                            builder = builder.set_two_way_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
79                        }
80                        "TwoWayChannelArn" => {
81                            builder = builder.set_two_way_channel_arn(
82                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
83                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
84                                    .transpose()?,
85                            );
86                        }
87                        "TwoWayChannelRole" => {
88                            builder = builder.set_two_way_channel_role(
89                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
90                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
91                                    .transpose()?,
92                            );
93                        }
94                        "SelfManagedOptOutsEnabled" => {
95                            builder =
96                                builder.set_self_managed_opt_outs_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
97                        }
98                        "OptOutListName" => {
99                            builder = builder.set_opt_out_list_name(
100                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
101                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
102                                    .transpose()?,
103                            );
104                        }
105                        "InternationalSendingEnabled" => {
106                            builder =
107                                builder.set_international_sending_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
108                        }
109                        "DeletionProtectionEnabled" => {
110                            builder =
111                                builder.set_deletion_protection_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
112                        }
113                        "PoolId" => {
114                            builder = builder.set_pool_id(
115                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
116                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
117                                    .transpose()?,
118                            );
119                        }
120                        "RegistrationId" => {
121                            builder = builder.set_registration_id(
122                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
123                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
124                                    .transpose()?,
125                            );
126                        }
127                        "CreatedTimestamp" => {
128                            builder = builder.set_created_timestamp(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
129                                tokens.next(),
130                                ::aws_smithy_types::date_time::Format::EpochSeconds,
131                            )?);
132                        }
133                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
134                    },
135                    other => {
136                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
137                            "expected object key or end object, found: {other:?}"
138                        )))
139                    }
140                }
141            }
142            Ok(Some(
143                crate::serde_util::phone_number_information_correct_errors(builder)
144                    .build()
145                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
146            ))
147        }
148        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
149            "expected start object or null",
150        )),
151    }
152}