aws-sdk-appmonetization 1.0.0

AWS SDK for AWS App Monetization
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// A monetary amount in a single currency.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Price {
    /// The ISO 4217 currency code (three uppercase letters, for example, "USD").
    pub currency_code: ::std::string::String,
    /// An arbitrary-precision decimal represented as a string (for example, "9.99").
    pub amount: ::std::string::String,
}
impl Price {
    /// The ISO 4217 currency code (three uppercase letters, for example, "USD").
    pub fn currency_code(&self) -> &str {
        use std::ops::Deref;
        self.currency_code.deref()
    }
    /// An arbitrary-precision decimal represented as a string (for example, "9.99").
    pub fn amount(&self) -> &str {
        use std::ops::Deref;
        self.amount.deref()
    }
}
impl Price {
    /// Creates a new builder-style object to manufacture [`Price`](crate::types::Price).
    pub fn builder() -> crate::types::builders::PriceBuilder {
        crate::types::builders::PriceBuilder::default()
    }
}

/// A builder for [`Price`](crate::types::Price).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct PriceBuilder {
    pub(crate) currency_code: ::std::option::Option<::std::string::String>,
    pub(crate) amount: ::std::option::Option<::std::string::String>,
}
impl PriceBuilder {
    /// The ISO 4217 currency code (three uppercase letters, for example, "USD").
    /// This field is required.
    pub fn currency_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.currency_code = ::std::option::Option::Some(input.into());
        self
    }
    /// The ISO 4217 currency code (three uppercase letters, for example, "USD").
    pub fn set_currency_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.currency_code = input;
        self
    }
    /// The ISO 4217 currency code (three uppercase letters, for example, "USD").
    pub fn get_currency_code(&self) -> &::std::option::Option<::std::string::String> {
        &self.currency_code
    }
    /// An arbitrary-precision decimal represented as a string (for example, "9.99").
    /// This field is required.
    pub fn amount(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.amount = ::std::option::Option::Some(input.into());
        self
    }
    /// An arbitrary-precision decimal represented as a string (for example, "9.99").
    pub fn set_amount(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.amount = input;
        self
    }
    /// An arbitrary-precision decimal represented as a string (for example, "9.99").
    pub fn get_amount(&self) -> &::std::option::Option<::std::string::String> {
        &self.amount
    }
    /// Consumes the builder and constructs a [`Price`](crate::types::Price).
    /// This method will fail if any of the following fields are not set:
    /// - [`currency_code`](crate::types::builders::PriceBuilder::currency_code)
    /// - [`amount`](crate::types::builders::PriceBuilder::amount)
    pub fn build(self) -> ::std::result::Result<crate::types::Price, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Price {
            currency_code: self.currency_code.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "currency_code",
                    "currency_code was not specified but it is required when building Price",
                )
            })?,
            amount: self.amount.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "amount",
                    "amount was not specified but it is required when building Price",
                )
            })?,
        })
    }
}