-
Notifications
You must be signed in to change notification settings - Fork 552
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
67c88f3
commit ceab274
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 ValueList < Stripe::APIResource | ||
extend Stripe::APIOperations::Create | ||
include Stripe::APIOperations::Delete | ||
extend Stripe::APIOperations::List | ||
include Stripe::APIOperations::Save | ||
|
||
OBJECT_NAME = "radar.value_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 ValueListItem < Stripe::APIResource | ||
extend Stripe::APIOperations::Create | ||
include Stripe::APIOperations::Delete | ||
extend Stripe::APIOperations::List | ||
|
||
OBJECT_NAME = "radar.value_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 ValueListItemTest < Test::Unit::TestCase | ||
should "be listable" do | ||
items = Stripe::Radar::ValueListItem.list(value_list: "rsl_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/radar/value_list_items?value_list=rsl_123" | ||
assert items.data.is_a?(Array) | ||
assert items.first.is_a?(Stripe::Radar::ValueListItem) | ||
end | ||
|
||
should "be retrievable" do | ||
item = Stripe::Radar::ValueListItem.retrieve("rsli_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/radar/value_list_items/rsli_123" | ||
assert item.is_a?(Stripe::Radar::ValueListItem) | ||
end | ||
|
||
should "be creatable" do | ||
item = Stripe::Radar::ValueListItem.create( | ||
value_list: "rsl_123", | ||
value: "value" | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/radar/value_list_items" | ||
assert item.is_a?(Stripe::Radar::ValueListItem) | ||
end | ||
|
||
should "be deletable" do | ||
list = Stripe::Radar::ValueListItem.retrieve("rsli_123") | ||
list = list.delete | ||
assert_requested :delete, "#{Stripe.api_base}/v1/radar/value_list_items/rsli_123" | ||
assert list.is_a?(Stripe::Radar::ValueListItem) | ||
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 ValueListTest < Test::Unit::TestCase | ||
should "be listable" do | ||
lists = Stripe::Radar::ValueList.list | ||
assert_requested :get, "#{Stripe.api_base}/v1/radar/value_lists" | ||
assert lists.data.is_a?(Array) | ||
assert lists.first.is_a?(Stripe::Radar::ValueList) | ||
end | ||
|
||
should "be retrievable" do | ||
list = Stripe::Radar::ValueList.retrieve("rsl_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123" | ||
assert list.is_a?(Stripe::Radar::ValueList) | ||
end | ||
|
||
should "be creatable" do | ||
list = Stripe::Radar::ValueList.create( | ||
alias: "list_alias", | ||
name: "list_name" | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/radar/value_lists" | ||
assert list.is_a?(Stripe::Radar::ValueList) | ||
end | ||
|
||
should "be saveable" do | ||
list = Stripe::Radar::ValueList.retrieve("rsl_123") | ||
list.metadata["key"] = "value" | ||
list.save | ||
assert_requested :post, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123" | ||
end | ||
|
||
should "be updateable" do | ||
list = Stripe::Radar::ValueList.update("rsl_123", metadata: { key: "value" }) | ||
assert_requested :post, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123" | ||
assert list.is_a?(Stripe::Radar::ValueList) | ||
end | ||
|
||
should "be deletable" do | ||
list = Stripe::Radar::ValueList.retrieve("rsl_123") | ||
list = list.delete | ||
assert_requested :delete, "#{Stripe.api_base}/v1/radar/value_lists/rsl_123" | ||
assert list.is_a?(Stripe::Radar::ValueList) | ||
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