Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[codegen] Add SubscriptionItem.create_usage_record method #825

Merged
merged 2 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/stripe/resources/subscription_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions lib/stripe/resources/subscription_schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should have been in #824.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops! good catch, thanks!

end
end
12 changes: 12 additions & 0 deletions test/stripe/subscription_item_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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