pub(crate) fn de_contact_information<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
) -> Result<Option<crate::types::ContactInformation>, ::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::ContactInformationBuilder::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() {
"FullName" => {
builder = builder.set_full_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"AddressLine1" => {
builder = builder.set_address_line1(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"AddressLine2" => {
builder = builder.set_address_line2(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"AddressLine3" => {
builder = builder.set_address_line3(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"City" => {
builder = builder.set_city(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"StateOrRegion" => {
builder = builder.set_state_or_region(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"DistrictOrCounty" => {
builder = builder.set_district_or_county(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"PostalCode" => {
builder = builder.set_postal_code(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"CountryCode" => {
builder = builder.set_country_code(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"PhoneNumber" => {
builder = builder.set_phone_number(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"CompanyName" => {
builder = builder.set_company_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"WebsiteUrl" => {
builder = builder.set_website_url(
::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(crate::serde_util::contact_information_correct_errors(builder).build().map_err(
|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
)?))
}
_ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
)),
}
}
pub fn ser_contact_information(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::ContactInformation,
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("FullName").string(input.full_name.as_str());
}
{
object.key("AddressLine1").string(input.address_line1.as_str());
}
if let Some(var_1) = &input.address_line2 {
object.key("AddressLine2").string(var_1.as_str());
}
if let Some(var_2) = &input.address_line3 {
object.key("AddressLine3").string(var_2.as_str());
}
{
object.key("City").string(input.city.as_str());
}
if let Some(var_3) = &input.state_or_region {
object.key("StateOrRegion").string(var_3.as_str());
}
if let Some(var_4) = &input.district_or_county {
object.key("DistrictOrCounty").string(var_4.as_str());
}
{
object.key("PostalCode").string(input.postal_code.as_str());
}
{
object.key("CountryCode").string(input.country_code.as_str());
}
{
object.key("PhoneNumber").string(input.phone_number.as_str());
}
if let Some(var_5) = &input.company_name {
object.key("CompanyName").string(var_5.as_str());
}
if let Some(var_6) = &input.website_url {
object.key("WebsiteUrl").string(var_6.as_str());
}
Ok(())
}