-
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 the
PromotionCode
resource and APIs (#937)
* Codegen for openapi f71053e * Add tests
- Loading branch information
1 parent
f240405
commit cf8b2c5
Showing
7 changed files
with
59 additions
and
3 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,12 @@ | ||
# File generated from our OpenAPI spec | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
class PromotionCode < APIResource | ||
extend Stripe::APIOperations::Create | ||
extend Stripe::APIOperations::List | ||
include Stripe::APIOperations::Save | ||
|
||
OBJECT_NAME = "promotion_code" | ||
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,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require ::File.expand_path("../test_helper", __dir__) | ||
|
||
module Stripe | ||
class PromotionCodeTest < Test::Unit::TestCase | ||
should "be listable" do | ||
promotion_codes = Stripe::PromotionCode.list | ||
assert_requested :get, "#{Stripe.api_base}/v1/promotion_codes" | ||
assert promotion_codes.data.is_a?(Array) | ||
assert promotion_codes.first.is_a?(Stripe::PromotionCode) | ||
end | ||
|
||
should "be retrievable" do | ||
coupon = Stripe::PromotionCode.retrieve("PROMO_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/promotion_codes/PROMO_123" | ||
assert coupon.is_a?(Stripe::PromotionCode) | ||
end | ||
|
||
should "be creatable" do | ||
coupon = Stripe::PromotionCode.create( | ||
coupon: "co_123", | ||
code: "MYCODE" | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes" | ||
assert coupon.is_a?(Stripe::PromotionCode) | ||
end | ||
|
||
should "be saveable" do | ||
coupon = Stripe::PromotionCode.retrieve("PROMO_123") | ||
coupon.metadata["key"] = "value" | ||
coupon.save | ||
assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes/#{coupon.id}" | ||
end | ||
|
||
should "be updateable" do | ||
coupon = Stripe::PromotionCode.update("PROMO_123", metadata: { key: "value" }) | ||
assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes/PROMO_123" | ||
assert coupon.is_a?(Stripe::PromotionCode) | ||
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