Skip to content

Commit

Permalink
API Updates (#1017)
Browse files Browse the repository at this point in the history
  • Loading branch information
yejia-stripe authored Nov 16, 2021
1 parent 5965767 commit d4d282d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/stripe/object_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def self.object_names_to_classes
Review::OBJECT_NAME => Review,
SetupAttempt::OBJECT_NAME => SetupAttempt,
SetupIntent::OBJECT_NAME => SetupIntent,
ShippingRate::OBJECT_NAME => ShippingRate,
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
SKU::OBJECT_NAME => SKU,
Source::OBJECT_NAME => Source,
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
require "stripe/resources/review"
require "stripe/resources/setup_attempt"
require "stripe/resources/setup_intent"
require "stripe/resources/shipping_rate"
require "stripe/resources/sigma/scheduled_query_run"
require "stripe/resources/sku"
require "stripe/resources/source"
Expand Down
12 changes: 12 additions & 0 deletions lib/stripe/resources/shipping_rate.rb
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 ShippingRate < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "shipping_rate"
end
end
36 changes: 36 additions & 0 deletions test/stripe/generated_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,26 @@ class CodegennedExampleTest < Test::Unit::TestCase
)
assert_requested :post, "#{Stripe.api_base}/v1/billing_portal/sessions"
end
should "support requests with args: success_url, cancel_url, mode, shipping_options" do
Stripe::Checkout::Session.create(
success_url: "https://example.com/success",
cancel_url: "https://example.com/cancel",
mode: "payment",
shipping_options: [
{ shipping_rate: "shr_standard" },
{
shipping_rate_data: {
display_name: "Standard",
delivery_estimate: {
minimum: { unit: "day", value: 5 },
maximum: { unit: "day", value: 7 },
},
},
},
]
)
assert_requested :post, "#{Stripe.api_base}/v1/checkout/sessions"
end
end
context "Session.expire" do
should "support requests with args: session" do
Expand Down Expand Up @@ -1335,6 +1355,22 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/setup_intents/seti_xxxxxxxxxxxxx"
end
end
context "ShippingRate.create" do
should "support requests with args: display_name, fixed_amount, type" do
Stripe::ShippingRate.create(
display_name: "Sample Shipper",
fixed_amount: { currency: "usd", amount: 400 },
type: "fixed_amount"
)
assert_requested :post, "#{Stripe.api_base}/v1/shipping_rates"
end
end
context "ShippingRate.list" do
should "work" do
Stripe::ShippingRate.list
assert_requested :get, "#{Stripe.api_base}/v1/shipping_rates?"
end
end
context "SKU.create" do
should "support requests with args: attributes, price, currency, inventory, product" do
Stripe::SKU.create(
Expand Down

0 comments on commit d4d282d

Please sign in to comment.