diff --git a/CHANGELOG.md b/CHANGELOG.md index 5335206..ccae9df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,12 @@ Versioning]. ## [Unreleased] +* Add support for Plan metadata. + ## [0.6.0] - 2023-05-12 +* Modified the `InvoiceSubscription` field to be optional. + ## [0.5.0] - 2023-05-11 * Add `amount_due` as part of `Invoice`. diff --git a/src/client/plans.rs b/src/client/plans.rs index bec5f3e..2b0adaa 100644 --- a/src/client/plans.rs +++ b/src/client/plans.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::collections::BTreeMap; + use futures_core::Stream; use reqwest::Method; use serde::{Deserialize, Serialize}; @@ -58,6 +60,9 @@ pub struct Plan { /// The time at which the plan was created. #[serde(with = "time::serde::rfc3339")] pub created_at: OffsetDateTime, + /// Arbitrary metadata that is attached to the plan. Cannot be nested, must have string values. + #[serde(default)] + pub metadata: BTreeMap, // TODO: many missing fields. } diff --git a/tests/api.rs b/tests/api.rs index 187e6a2..93f6d6c 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -503,6 +503,10 @@ async fn test_subscriptions() { assert_eq!(subscription.customer.id, customer.id); assert_eq!(subscription.plan.external_id.as_deref(), Some("test")); + assert_eq!( + subscription.plan.metadata.get("purpose"), + Some(&"test".to_string()) + ); assert_eq!(subscription.net_terms, 3); assert!(subscription.auto_collection);