Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the
Price
resource and APIs (#917)
* Codegen for openapi f75fd88 * Fix test suite
- Loading branch information
1 parent
07f58ca
commit 622db9d
Showing
6 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
class Price < APIResource | ||
extend Stripe::APIOperations::Create | ||
extend Stripe::APIOperations::List | ||
include Stripe::APIOperations::Save | ||
|
||
OBJECT_NAME = "price" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require ::File.expand_path("../test_helper", __dir__) | ||
|
||
module Stripe | ||
class PriceTest < Test::Unit::TestCase | ||
should "be listable" do | ||
prices = Stripe::Price.list | ||
assert_requested :get, "#{Stripe.api_base}/v1/prices" | ||
assert prices.data.is_a?(Array) | ||
assert prices.data[0].is_a?(Stripe::Price) | ||
end | ||
|
||
should "be retrievable" do | ||
price = Stripe::Price.retrieve("price_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/prices/price_123" | ||
assert price.is_a?(Stripe::Price) | ||
end | ||
|
||
should "be creatable" do | ||
price = Stripe::Price.create( | ||
unit_amount: 5000, | ||
currency: "usd", | ||
recurring: { | ||
interval: "month", | ||
}, | ||
product_data: { | ||
name: "Product name", | ||
} | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/prices" | ||
assert price.is_a?(Stripe::Price) | ||
end | ||
|
||
should "be saveable" do | ||
price = Stripe::Price.retrieve("price_123") | ||
price.metadata["key"] = "value" | ||
price.save | ||
assert_requested :post, "#{Stripe.api_base}/v1/prices/#{price.id}" | ||
end | ||
|
||
should "be updateable" do | ||
price = Stripe::Price.update("price_123", metadata: { foo: "bar" }) | ||
assert_requested :post, "#{Stripe.api_base}/v1/prices/price_123" | ||
assert price.is_a?(Stripe::Price) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters