diff --git a/lib/stripe/resources/subscription_item.rb b/lib/stripe/resources/subscription_item.rb index 99bd624b7..8c30987fe 100644 --- a/lib/stripe/resources/subscription_item.rb +++ b/lib/stripe/resources/subscription_item.rb @@ -6,9 +6,12 @@ class SubscriptionItem < APIResource include Stripe::APIOperations::Delete extend Stripe::APIOperations::List include Stripe::APIOperations::Save + extend Stripe::APIOperations::NestedResource OBJECT_NAME = "subscription_item".freeze + nested_resource_class_methods :usage_record, operations: %i[create] + def usage_record_summaries(params = {}, opts = {}) resp, opts = request(:get, resource_url + "/usage_record_summaries", params, opts) Util.convert_to_stripe_object(resp.data, opts) diff --git a/lib/stripe/resources/subscription_schedule.rb b/lib/stripe/resources/subscription_schedule.rb index 94c5ebf18..27385046a 100644 --- a/lib/stripe/resources/subscription_schedule.rb +++ b/lib/stripe/resources/subscription_schedule.rb @@ -28,10 +28,5 @@ def release(params = {}, opts = {}) opts: opts ) end - - def revisions(params = {}, opts = {}) - resp, opts = request(:get, resource_url + "/revisions", params, opts) - Util.convert_to_stripe_object(resp.data, opts) - end end end diff --git a/test/stripe/subscription_item_test.rb b/test/stripe/subscription_item_test.rb index 88dd40ba2..7107fe53e 100644 --- a/test/stripe/subscription_item_test.rb +++ b/test/stripe/subscription_item_test.rb @@ -59,5 +59,17 @@ class SubscriptionItemTest < Test::Unit::TestCase assert item.is_a?(Stripe::SubscriptionItem) end end + + context "#create_usage_record" do + should "create a usage record" do + Stripe::SubscriptionItem.create_usage_record( + "si_123", + quantity: 5000, + timestamp: Time.now.to_i, + action: "increment" + ) + assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/si_123/usage_records" + end + end end end