-
Notifications
You must be signed in to change notification settings - Fork 553
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 Radar List and ListItem resources
- Loading branch information
1 parent
d62f12f
commit 08a8d2b
Showing
8 changed files
with
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
module Radar | ||
class List < Stripe::APIResource | ||
extend Stripe::APIOperations::Create | ||
include Stripe::APIOperations::Delete | ||
extend Stripe::APIOperations::List | ||
include Stripe::APIOperations::Save | ||
|
||
OBJECT_NAME = "radar.list".freeze | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
module Radar | ||
class ListItem < Stripe::APIResource | ||
extend Stripe::APIOperations::Create | ||
include Stripe::APIOperations::Delete | ||
extend Stripe::APIOperations::List | ||
|
||
OBJECT_NAME = "radar.list_item".freeze | ||
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
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,38 @@ | ||
# frozen_string_literal: true | ||
|
||
require ::File.expand_path("../../../test_helper", __FILE__) | ||
|
||
module Stripe | ||
module Radar | ||
class ListItemTest < Test::Unit::TestCase | ||
should "be listable" do | ||
items = Stripe::Radar::ListItem.list(list: "rsl_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/radar/list_items?list=rsl_123" | ||
assert items.data.is_a?(Array) | ||
assert items.first.is_a?(Stripe::Radar::ListItem) | ||
end | ||
|
||
should "be retrievable" do | ||
item = Stripe::Radar::ListItem.retrieve("rsli_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/radar/list_items/rsli_123" | ||
assert item.is_a?(Stripe::Radar::ListItem) | ||
end | ||
|
||
should "be creatable" do | ||
item = Stripe::Radar::ListItem.create( | ||
list: "rsl_123", | ||
value: "value" | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/radar/list_items" | ||
assert item.is_a?(Stripe::Radar::ListItem) | ||
end | ||
|
||
should "be deletable" do | ||
list = Stripe::Radar::ListItem.retrieve("rsli_123") | ||
list = list.delete | ||
assert_requested :delete, "#{Stripe.api_base}/v1//v1/radar/list_items/rsli_123" | ||
assert list.is_a?(Stripe::Radar::ListItem) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require ::File.expand_path("../../../test_helper", __FILE__) | ||
|
||
module Stripe | ||
module Radar | ||
class ListTest < Test::Unit::TestCase | ||
should "be listable" do | ||
lists = Stripe::Radar::List.list | ||
assert_requested :get, "#{Stripe.api_base}/v1/radar/lists" | ||
assert lists.data.is_a?(Array) | ||
assert lists.first.is_a?(Stripe::Radar::List) | ||
end | ||
|
||
should "be retrievable" do | ||
list = Stripe::Radar::List.retrieve("rsl_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/radar/lists/rsl_123" | ||
assert list.is_a?(Stripe::Radar::List) | ||
end | ||
|
||
should "be creatable" do | ||
list = Stripe::Radar::List.create( | ||
alias: "list_alias", | ||
name: "list_name" | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/radar/lists" | ||
assert list.is_a?(Stripe::Radar::List) | ||
end | ||
|
||
should "be saveable" do | ||
list = Stripe::Radar::List.retrieve("rsl_123") | ||
list.metadata["key"] = "value" | ||
list.save | ||
assert_requested :post, "#{Stripe.api_base}/v1/radar/lists/rsl_123" | ||
end | ||
|
||
should "be updateable" do | ||
list = Stripe::Radar::List.update("rsl_123", metadata: { key: "value" }) | ||
assert_requested :post, "#{Stripe.api_base}/v1/radar/lists/rsl_123" | ||
assert list.is_a?(Stripe::Radar::List) | ||
end | ||
|
||
should "be deletable" do | ||
list = Stripe::Radar::List.retrieve("rsl_123") | ||
list = list.delete | ||
assert_requested :delete, "#{Stripe.api_base}/v1//v1/radar/lists/rsl_123" | ||
assert list.is_a?(Stripe::Radar::List) | ||
end | ||
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