forked from stripe/stripe-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
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 /v1/topups endpoints.
- Loading branch information
1 parent
16704d9
commit 0be2268
Showing
5 changed files
with
55 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Stripe | ||
class Topup < APIResource | ||
extend Stripe::APIOperations::List | ||
extend Stripe::APIOperations::Create | ||
include Stripe::APIOperations::Save | ||
|
||
OBJECT_NAME = "topup".freeze | ||
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
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,43 @@ | ||
require File.expand_path("../../test_helper", __FILE__) | ||
|
||
module Stripe | ||
class TopupTest < Test::Unit::TestCase | ||
should "be listable" do | ||
topups = Stripe::Topup.list | ||
assert_requested :get, "#{Stripe.api_base}/v1/topups" | ||
assert topups.data.is_a?(Array) | ||
assert topups.data[0].is_a?(Stripe::Topup) | ||
end | ||
|
||
should "be retrievable" do | ||
topup = Stripe::Topup.retrieve("tu_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/topups/tu_123" | ||
assert topup.is_a?(Stripe::Topup) | ||
end | ||
|
||
should "be creatable" do | ||
topup = Stripe::Topup.create( | ||
amount: 100, | ||
currency: "USD", | ||
source: "src_123", | ||
description: "description", | ||
statement_descriptor: "statement descriptor" | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/topups" | ||
assert topup.is_a?(Stripe::Topup) | ||
end | ||
|
||
should "be saveable" do | ||
topup = Stripe::Topup.retrieve("tu_123") | ||
topup.metadata["key"] = "value" | ||
topup.save | ||
assert_requested :post, "#{Stripe.api_base}/v1/topups/#{topup.id}" | ||
end | ||
|
||
should "be updateable" do | ||
topup = Stripe::Topup.update("tu_123", metadata: { foo: "bar" }) | ||
assert_requested :post, "#{Stripe.api_base}/v1/topups/tu_123" | ||
assert topup.is_a?(Stripe::Topup) | ||
end | ||
end | ||
end |