Skip to content

Commit

Permalink
Add support for Plan metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
arusahni committed Nov 22, 2023
1 parent 4eca261 commit ab15dff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ Versioning].

## [Unreleased] <!-- #release:date -->

* 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`.
Expand Down
5 changes: 5 additions & 0 deletions src/client/plans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<String, String>,
// TODO: many missing fields.
}

Expand Down
4 changes: 4 additions & 0 deletions tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ab15dff

Please sign in to comment.