aws-sdk-payments 1.1.0

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

/// <p>The details of a card payment instrument.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
pub struct Card {
    /// <p>The network the card runs on.</p>
    pub brand: ::std::option::Option<crate::types::CardBrand>,
    /// <p>The last four digits of the card number.</p>
    pub last4: ::std::string::String,
    /// <p>The calendar month that the card expires in.</p>
    pub expiration_month: ::std::option::Option<i32>,
    /// <p>The calendar year that the card expires in.</p>
    pub expiration_year: ::std::option::Option<i32>,
    /// <p>Whether the card is a credit card or a debit card.</p>
    pub card_type: ::std::option::Option<crate::types::CardType>,
    /// <p>The bank that issued the card.</p>
    pub issuing_bank: ::std::option::Option<::std::string::String>,
    /// <p>The country of the bank that issued the card.</p>
    pub issuer_country: ::std::option::Option<::std::string::String>,
}
impl Card {
    /// <p>The network the card runs on.</p>
    pub fn brand(&self) -> ::std::option::Option<&crate::types::CardBrand> {
        self.brand.as_ref()
    }
    /// <p>The last four digits of the card number.</p>
    pub fn last4(&self) -> &str {
        use std::ops::Deref;
        self.last4.deref()
    }
    /// <p>The calendar month that the card expires in.</p>
    pub fn expiration_month(&self) -> ::std::option::Option<i32> {
        self.expiration_month
    }
    /// <p>The calendar year that the card expires in.</p>
    pub fn expiration_year(&self) -> ::std::option::Option<i32> {
        self.expiration_year
    }
    /// <p>Whether the card is a credit card or a debit card.</p>
    pub fn card_type(&self) -> ::std::option::Option<&crate::types::CardType> {
        self.card_type.as_ref()
    }
    /// <p>The bank that issued the card.</p>
    pub fn issuing_bank(&self) -> ::std::option::Option<&str> {
        self.issuing_bank.as_deref()
    }
    /// <p>The country of the bank that issued the card.</p>
    pub fn issuer_country(&self) -> ::std::option::Option<&str> {
        self.issuer_country.as_deref()
    }
}
impl ::std::fmt::Debug for Card {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        let mut formatter = f.debug_struct("Card");
        formatter.field("brand", &self.brand);
        formatter.field("last4", &"*** Sensitive Data Redacted ***");
        formatter.field("expiration_month", &"*** Sensitive Data Redacted ***");
        formatter.field("expiration_year", &"*** Sensitive Data Redacted ***");
        formatter.field("card_type", &self.card_type);
        formatter.field("issuing_bank", &self.issuing_bank);
        formatter.field("issuer_country", &self.issuer_country);
        formatter.finish()
    }
}
impl Card {
    /// Creates a new builder-style object to manufacture [`Card`](crate::types::Card).
    pub fn builder() -> crate::types::builders::CardBuilder {
        crate::types::builders::CardBuilder::default()
    }
}

/// A builder for [`Card`](crate::types::Card).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
#[non_exhaustive]
pub struct CardBuilder {
    pub(crate) brand: ::std::option::Option<crate::types::CardBrand>,
    pub(crate) last4: ::std::option::Option<::std::string::String>,
    pub(crate) expiration_month: ::std::option::Option<i32>,
    pub(crate) expiration_year: ::std::option::Option<i32>,
    pub(crate) card_type: ::std::option::Option<crate::types::CardType>,
    pub(crate) issuing_bank: ::std::option::Option<::std::string::String>,
    pub(crate) issuer_country: ::std::option::Option<::std::string::String>,
}
impl CardBuilder {
    /// <p>The network the card runs on.</p>
    pub fn brand(mut self, input: crate::types::CardBrand) -> Self {
        self.brand = ::std::option::Option::Some(input);
        self
    }
    /// <p>The network the card runs on.</p>
    pub fn set_brand(mut self, input: ::std::option::Option<crate::types::CardBrand>) -> Self {
        self.brand = input;
        self
    }
    /// <p>The network the card runs on.</p>
    pub fn get_brand(&self) -> &::std::option::Option<crate::types::CardBrand> {
        &self.brand
    }
    /// <p>The last four digits of the card number.</p>
    /// This field is required.
    pub fn last4(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.last4 = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The last four digits of the card number.</p>
    pub fn set_last4(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.last4 = input;
        self
    }
    /// <p>The last four digits of the card number.</p>
    pub fn get_last4(&self) -> &::std::option::Option<::std::string::String> {
        &self.last4
    }
    /// <p>The calendar month that the card expires in.</p>
    pub fn expiration_month(mut self, input: i32) -> Self {
        self.expiration_month = ::std::option::Option::Some(input);
        self
    }
    /// <p>The calendar month that the card expires in.</p>
    pub fn set_expiration_month(mut self, input: ::std::option::Option<i32>) -> Self {
        self.expiration_month = input;
        self
    }
    /// <p>The calendar month that the card expires in.</p>
    pub fn get_expiration_month(&self) -> &::std::option::Option<i32> {
        &self.expiration_month
    }
    /// <p>The calendar year that the card expires in.</p>
    pub fn expiration_year(mut self, input: i32) -> Self {
        self.expiration_year = ::std::option::Option::Some(input);
        self
    }
    /// <p>The calendar year that the card expires in.</p>
    pub fn set_expiration_year(mut self, input: ::std::option::Option<i32>) -> Self {
        self.expiration_year = input;
        self
    }
    /// <p>The calendar year that the card expires in.</p>
    pub fn get_expiration_year(&self) -> &::std::option::Option<i32> {
        &self.expiration_year
    }
    /// <p>Whether the card is a credit card or a debit card.</p>
    pub fn card_type(mut self, input: crate::types::CardType) -> Self {
        self.card_type = ::std::option::Option::Some(input);
        self
    }
    /// <p>Whether the card is a credit card or a debit card.</p>
    pub fn set_card_type(mut self, input: ::std::option::Option<crate::types::CardType>) -> Self {
        self.card_type = input;
        self
    }
    /// <p>Whether the card is a credit card or a debit card.</p>
    pub fn get_card_type(&self) -> &::std::option::Option<crate::types::CardType> {
        &self.card_type
    }
    /// <p>The bank that issued the card.</p>
    pub fn issuing_bank(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.issuing_bank = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The bank that issued the card.</p>
    pub fn set_issuing_bank(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.issuing_bank = input;
        self
    }
    /// <p>The bank that issued the card.</p>
    pub fn get_issuing_bank(&self) -> &::std::option::Option<::std::string::String> {
        &self.issuing_bank
    }
    /// <p>The country of the bank that issued the card.</p>
    pub fn issuer_country(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.issuer_country = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The country of the bank that issued the card.</p>
    pub fn set_issuer_country(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.issuer_country = input;
        self
    }
    /// <p>The country of the bank that issued the card.</p>
    pub fn get_issuer_country(&self) -> &::std::option::Option<::std::string::String> {
        &self.issuer_country
    }
    /// Consumes the builder and constructs a [`Card`](crate::types::Card).
    /// This method will fail if any of the following fields are not set:
    /// - [`last4`](crate::types::builders::CardBuilder::last4)
    pub fn build(self) -> ::std::result::Result<crate::types::Card, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Card {
            brand: self.brand,
            last4: self.last4.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "last4",
                    "last4 was not specified but it is required when building Card",
                )
            })?,
            expiration_month: self.expiration_month,
            expiration_year: self.expiration_year,
            card_type: self.card_type,
            issuing_bank: self.issuing_bank,
            issuer_country: self.issuer_country,
        })
    }
}
impl ::std::fmt::Debug for CardBuilder {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        let mut formatter = f.debug_struct("CardBuilder");
        formatter.field("brand", &self.brand);
        formatter.field("last4", &"*** Sensitive Data Redacted ***");
        formatter.field("expiration_month", &"*** Sensitive Data Redacted ***");
        formatter.field("expiration_year", &"*** Sensitive Data Redacted ***");
        formatter.field("card_type", &self.card_type);
        formatter.field("issuing_bank", &self.issuing_bank);
        formatter.field("issuer_country", &self.issuer_country);
        formatter.finish()
    }
}