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 user's subscription to a plan for an app.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Subscription {
    /// The ID of the app that the subscription belongs to.
    pub app_id: ::std::string::String,
    /// The opaque end-user identifier that the subscription belongs to.
    pub user_id: ::std::string::String,
    /// The ID of the plan that the user is subscribed to.
    pub plan_id: ::std::option::Option<::std::string::String>,
    /// The time when the subscription took effect.
    pub effective_at: ::aws_smithy_types::DateTime,
    /// The fixed reference instant the recurring billing cycle is measured from. It is set when the subscription first takes effect and stays fixed as periods roll forward, so it is normally an older date than the current period — not the start of the current period. For the end of the current cycle, use `currentPeriodEndsAt` on GetSubscriptionResponse (derived from this anchor and the billing cycle) rather than this value.
    pub billing_anchor_date: ::aws_smithy_types::DateTime,
    /// The billing cycle of the subscription, such as monthly or annual.
    pub billing_cycle: ::std::option::Option<crate::types::BillingCycle>,
}
impl Subscription {
    /// The ID of the app that the subscription belongs to.
    pub fn app_id(&self) -> &str {
        use std::ops::Deref;
        self.app_id.deref()
    }
    /// The opaque end-user identifier that the subscription belongs to.
    pub fn user_id(&self) -> &str {
        use std::ops::Deref;
        self.user_id.deref()
    }
    /// The ID of the plan that the user is subscribed to.
    pub fn plan_id(&self) -> ::std::option::Option<&str> {
        self.plan_id.as_deref()
    }
    /// The time when the subscription took effect.
    pub fn effective_at(&self) -> &::aws_smithy_types::DateTime {
        &self.effective_at
    }
    /// The fixed reference instant the recurring billing cycle is measured from. It is set when the subscription first takes effect and stays fixed as periods roll forward, so it is normally an older date than the current period — not the start of the current period. For the end of the current cycle, use `currentPeriodEndsAt` on GetSubscriptionResponse (derived from this anchor and the billing cycle) rather than this value.
    pub fn billing_anchor_date(&self) -> &::aws_smithy_types::DateTime {
        &self.billing_anchor_date
    }
    /// The billing cycle of the subscription, such as monthly or annual.
    pub fn billing_cycle(&self) -> ::std::option::Option<&crate::types::BillingCycle> {
        self.billing_cycle.as_ref()
    }
}
impl Subscription {
    /// Creates a new builder-style object to manufacture [`Subscription`](crate::types::Subscription).
    pub fn builder() -> crate::types::builders::SubscriptionBuilder {
        crate::types::builders::SubscriptionBuilder::default()
    }
}

/// A builder for [`Subscription`](crate::types::Subscription).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct SubscriptionBuilder {
    pub(crate) app_id: ::std::option::Option<::std::string::String>,
    pub(crate) user_id: ::std::option::Option<::std::string::String>,
    pub(crate) plan_id: ::std::option::Option<::std::string::String>,
    pub(crate) effective_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) billing_anchor_date: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) billing_cycle: ::std::option::Option<crate::types::BillingCycle>,
}
impl SubscriptionBuilder {
    /// The ID of the app that the subscription belongs to.
    /// This field is required.
    pub fn app_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.app_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The ID of the app that the subscription belongs to.
    pub fn set_app_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.app_id = input;
        self
    }
    /// The ID of the app that the subscription belongs to.
    pub fn get_app_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.app_id
    }
    /// The opaque end-user identifier that the subscription belongs to.
    /// This field is required.
    pub fn user_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.user_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The opaque end-user identifier that the subscription belongs to.
    pub fn set_user_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.user_id = input;
        self
    }
    /// The opaque end-user identifier that the subscription belongs to.
    pub fn get_user_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.user_id
    }
    /// The ID of the plan that the user is subscribed to.
    pub fn plan_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.plan_id = ::std::option::Option::Some(input.into());
        self
    }
    /// The ID of the plan that the user is subscribed to.
    pub fn set_plan_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.plan_id = input;
        self
    }
    /// The ID of the plan that the user is subscribed to.
    pub fn get_plan_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.plan_id
    }
    /// The time when the subscription took effect.
    /// This field is required.
    pub fn effective_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.effective_at = ::std::option::Option::Some(input);
        self
    }
    /// The time when the subscription took effect.
    pub fn set_effective_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.effective_at = input;
        self
    }
    /// The time when the subscription took effect.
    pub fn get_effective_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.effective_at
    }
    /// The fixed reference instant the recurring billing cycle is measured from. It is set when the subscription first takes effect and stays fixed as periods roll forward, so it is normally an older date than the current period — not the start of the current period. For the end of the current cycle, use `currentPeriodEndsAt` on GetSubscriptionResponse (derived from this anchor and the billing cycle) rather than this value.
    /// This field is required.
    pub fn billing_anchor_date(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.billing_anchor_date = ::std::option::Option::Some(input);
        self
    }
    /// The fixed reference instant the recurring billing cycle is measured from. It is set when the subscription first takes effect and stays fixed as periods roll forward, so it is normally an older date than the current period — not the start of the current period. For the end of the current cycle, use `currentPeriodEndsAt` on GetSubscriptionResponse (derived from this anchor and the billing cycle) rather than this value.
    pub fn set_billing_anchor_date(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.billing_anchor_date = input;
        self
    }
    /// The fixed reference instant the recurring billing cycle is measured from. It is set when the subscription first takes effect and stays fixed as periods roll forward, so it is normally an older date than the current period — not the start of the current period. For the end of the current cycle, use `currentPeriodEndsAt` on GetSubscriptionResponse (derived from this anchor and the billing cycle) rather than this value.
    pub fn get_billing_anchor_date(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.billing_anchor_date
    }
    /// The billing cycle of the subscription, such as monthly or annual.
    pub fn billing_cycle(mut self, input: crate::types::BillingCycle) -> Self {
        self.billing_cycle = ::std::option::Option::Some(input);
        self
    }
    /// The billing cycle of the subscription, such as monthly or annual.
    pub fn set_billing_cycle(mut self, input: ::std::option::Option<crate::types::BillingCycle>) -> Self {
        self.billing_cycle = input;
        self
    }
    /// The billing cycle of the subscription, such as monthly or annual.
    pub fn get_billing_cycle(&self) -> &::std::option::Option<crate::types::BillingCycle> {
        &self.billing_cycle
    }
    /// Consumes the builder and constructs a [`Subscription`](crate::types::Subscription).
    /// This method will fail if any of the following fields are not set:
    /// - [`app_id`](crate::types::builders::SubscriptionBuilder::app_id)
    /// - [`user_id`](crate::types::builders::SubscriptionBuilder::user_id)
    /// - [`effective_at`](crate::types::builders::SubscriptionBuilder::effective_at)
    /// - [`billing_anchor_date`](crate::types::builders::SubscriptionBuilder::billing_anchor_date)
    pub fn build(self) -> ::std::result::Result<crate::types::Subscription, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Subscription {
            app_id: self.app_id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "app_id",
                    "app_id was not specified but it is required when building Subscription",
                )
            })?,
            user_id: self.user_id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "user_id",
                    "user_id was not specified but it is required when building Subscription",
                )
            })?,
            plan_id: self.plan_id,
            effective_at: self.effective_at.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "effective_at",
                    "effective_at was not specified but it is required when building Subscription",
                )
            })?,
            billing_anchor_date: self.billing_anchor_date.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "billing_anchor_date",
                    "billing_anchor_date was not specified but it is required when building Subscription",
                )
            })?,
            billing_cycle: self.billing_cycle,
        })
    }
}