From a0935c246d9d3121e0855d3990ee47696bddbb13 Mon Sep 17 00:00:00 2001 From: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com> Date: Wed, 16 Nov 2022 11:35:51 -0800 Subject: [PATCH 1/7] Next major release changes (#1144) --- lib/stripe/api_operations/save.rb | 5 ++ lib/stripe/api_version.rb | 2 +- lib/stripe/object_types.rb | 2 - lib/stripe/resources.rb | 2 - lib/stripe/resources/order.rb | 89 -------------------------- lib/stripe/resources/refund.rb | 4 -- lib/stripe/resources/sku.rb | 19 ------ lib/stripe/resources/subscription.rb | 25 -------- test/stripe/generated_examples_test.rb | 38 ----------- test/stripe/sku_test.rb | 60 ----------------- 10 files changed, 6 insertions(+), 240 deletions(-) delete mode 100644 lib/stripe/resources/order.rb delete mode 100644 lib/stripe/resources/sku.rb delete mode 100644 test/stripe/sku_test.rb diff --git a/lib/stripe/api_operations/save.rb b/lib/stripe/api_operations/save.rb index 8b08c88b..89c7f38c 100644 --- a/lib/stripe/api_operations/save.rb +++ b/lib/stripe/api_operations/save.rb @@ -33,6 +33,9 @@ module Stripe end end + # The `save` method is DEPRECATED and will be removed in a future major + # version of the library. Use the `update` method on the resource instead. + # # Creates or updates an API resource. # # If the resource doesn't yet have an assigned ID and the resource is one @@ -68,6 +71,8 @@ module Stripe resp, opts = execute_resource_request(:post, save_url, values, opts) initialize_from(resp.data, opts) end + extend Gem::Deprecate + deprecate :save, :update, 2022, 11 def self.included(base) # Set `metadata` as additive so that when it's set directly we remember diff --git a/lib/stripe/api_version.rb b/lib/stripe/api_version.rb index 9244d4ee..b348fbad 100644 --- a/lib/stripe/api_version.rb +++ b/lib/stripe/api_version.rb @@ -3,6 +3,6 @@ module Stripe module ApiVersion - CURRENT = "2022-08-01" + CURRENT = "2022-11-15" end end diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index a6013274..e62425bc 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -62,7 +62,6 @@ module Stripe LineItem::OBJECT_NAME => LineItem, LoginLink::OBJECT_NAME => LoginLink, Mandate::OBJECT_NAME => Mandate, - Order::OBJECT_NAME => Order, PaymentIntent::OBJECT_NAME => PaymentIntent, PaymentLink::OBJECT_NAME => PaymentLink, PaymentMethod::OBJECT_NAME => PaymentMethod, @@ -85,7 +84,6 @@ module Stripe SetupIntent::OBJECT_NAME => SetupIntent, ShippingRate::OBJECT_NAME => ShippingRate, Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun, - SKU::OBJECT_NAME => SKU, Source::OBJECT_NAME => Source, SourceTransaction::OBJECT_NAME => SourceTransaction, Subscription::OBJECT_NAME => Subscription, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 01da2aea..b0b3029a 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -49,7 +49,6 @@ require "stripe/resources/issuing/transaction" require "stripe/resources/line_item" require "stripe/resources/login_link" require "stripe/resources/mandate" -require "stripe/resources/order" require "stripe/resources/payment_intent" require "stripe/resources/payment_link" require "stripe/resources/payment_method" @@ -72,7 +71,6 @@ 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" require "stripe/resources/source_transaction" require "stripe/resources/subscription" diff --git a/lib/stripe/resources/order.rb b/lib/stripe/resources/order.rb deleted file mode 100644 index 0ca6e75d..00000000 --- a/lib/stripe/resources/order.rb +++ /dev/null @@ -1,89 +0,0 @@ -# File generated from our OpenAPI spec -# frozen_string_literal: true - -module Stripe - # An Order describes a purchase being made by a customer, including the - # products & quantities being purchased, the order status, the payment information, - # and the billing/shipping details. - # - # Related guide: [Orders overview](https://stripe.com/docs/orders) - class Order < APIResource - extend Stripe::APIOperations::Create - extend Stripe::APIOperations::List - include Stripe::APIOperations::Save - - OBJECT_NAME = "order" - - def cancel(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/orders/%s/cancel", { id: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - def list_line_items(params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/orders/%s/line_items", { id: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - def reopen(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/orders/%s/reopen", { id: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - def submit(params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/orders/%s/submit", { id: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - def self.cancel(id, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/orders/%s/cancel", { id: CGI.escape(id) }), - params: params, - opts: opts - ) - end - - def self.list_line_items(id, params = {}, opts = {}) - request_stripe_object( - method: :get, - path: format("/v1/orders/%s/line_items", { id: CGI.escape(id) }), - params: params, - opts: opts - ) - end - - def self.reopen(id, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/orders/%s/reopen", { id: CGI.escape(id) }), - params: params, - opts: opts - ) - end - - def self.submit(id, params = {}, opts = {}) - request_stripe_object( - method: :post, - path: format("/v1/orders/%s/submit", { id: CGI.escape(id) }), - params: params, - opts: opts - ) - end - end -end diff --git a/lib/stripe/resources/refund.rb b/lib/stripe/resources/refund.rb index 7d8ce075..f7aa8a55 100644 --- a/lib/stripe/resources/refund.rb +++ b/lib/stripe/resources/refund.rb @@ -6,10 +6,6 @@ module Stripe # but not yet refunded. Funds will be refunded to the credit or debit card that # was originally charged. # - # Stripe Tax users with recurring payments and invoices can create [Credit Notes](https://stripe.com/docs/api/credit_notes), - # which reduce overall tax liability because tax is correctly recalculated and - # apportioned to the related invoice. - # # Related guide: [Refunds](https://stripe.com/docs/refunds). class Refund < APIResource extend Stripe::APIOperations::Create diff --git a/lib/stripe/resources/sku.rb b/lib/stripe/resources/sku.rb deleted file mode 100644 index f7d72b2e..00000000 --- a/lib/stripe/resources/sku.rb +++ /dev/null @@ -1,19 +0,0 @@ -# File generated from our OpenAPI spec -# frozen_string_literal: true - -module Stripe - # Stores representations of [stock keeping units](http://en.wikipedia.org/wiki/Stock_keeping_unit). - # SKUs describe specific product variations, taking into account any combination of: attributes, - # currency, and cost. For example, a product may be a T-shirt, whereas a specific SKU represents - # the `size: large`, `color: red` version of that shirt. - # - # Can also be used to manage inventory. - class SKU < APIResource - extend Stripe::APIOperations::Create - include Stripe::APIOperations::Delete - extend Stripe::APIOperations::List - include Stripe::APIOperations::Save - - OBJECT_NAME = "sku" - end -end diff --git a/lib/stripe/resources/subscription.rb b/lib/stripe/resources/subscription.rb index 7c9cbb1e..ee14a68f 100644 --- a/lib/stripe/resources/subscription.rb +++ b/lib/stripe/resources/subscription.rb @@ -50,31 +50,6 @@ module Stripe end save_nested_resource :source - def delete(params = {}, opts = {}) - request_stripe_object( - method: :delete, - path: format("/v1/subscriptions/%s", { subscription_exposed_id: CGI.escape(self["id"]) }), - params: params, - opts: opts - ) - end - - def self.delete(subscription_exposed_id, params = {}, opts = {}) - request_stripe_object( - method: :delete, - path: format("/v1/subscriptions/%s", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }), - params: params, - opts: opts - ) - end - - extend Gem::Deprecate - deprecate :delete, "Stripe::Subscription.cancel", 2022, 7 - - class << self - extend Gem::Deprecate - deprecate :delete, "Stripe::Subscription#cancel", 2022, 7 - end def self.search(params = {}, opts = {}) _search("/v1/subscriptions/search", params, opts) diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index 2fbc1220..4837c259 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -1815,44 +1815,6 @@ module Stripe assert_requested :get, "#{Stripe.api_base}/v1/sigma/scheduled_query_runs/sqr_xxxxxxxxxxxxx?" end end - context "SKU.create" do - should "support requests with args: attributes, price, currency, inventory, product" do - Stripe::SKU.create( - { - attributes: { size: "Medium", gender: "Unisex" }, - price: 1500, - currency: "usd", - inventory: { type: "finite", quantity: 500 }, - product: "prod_xxxxxxxxxxxxx", - } - ) - assert_requested :post, "#{Stripe.api_base}/v1/skus" - end - end - context "SKU.delete" do - should "support requests with args: id" do - Stripe::SKU.delete("sku_xxxxxxxxxxxxx") - assert_requested :delete, "#{Stripe.api_base}/v1/skus/sku_xxxxxxxxxxxxx?" - end - end - context "SKU.list" do - should "support requests with args: limit" do - Stripe::SKU.list({ limit: 3 }) - assert_requested :get, "#{Stripe.api_base}/v1/skus?limit=3" - end - end - context "SKU.retrieve" do - should "support requests with args: id" do - Stripe::SKU.retrieve("sku_xxxxxxxxxxxxx") - assert_requested :get, "#{Stripe.api_base}/v1/skus/sku_xxxxxxxxxxxxx?" - end - end - context "SKU.update" do - should "support requests with args: metadata, id" do - Stripe::SKU.update("sku_xxxxxxxxxxxxx", { metadata: { order_id: "6735" } }) - assert_requested :post, "#{Stripe.api_base}/v1/skus/sku_xxxxxxxxxxxxx" - end - end context "Source.retrieve" do should "support requests with args: id" do Stripe::Source.retrieve("src_xxxxxxxxxxxxx") diff --git a/test/stripe/sku_test.rb b/test/stripe/sku_test.rb deleted file mode 100644 index ec383f85..00000000 --- a/test/stripe/sku_test.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -require ::File.expand_path("../test_helper", __dir__) - -module Stripe - class SKUTest < Test::Unit::TestCase - should "be listable" do - skus = Stripe::SKU.list - assert_requested :get, "#{Stripe.api_base}/v1/skus" - assert skus.data.is_a?(Array) - assert skus.data[0].is_a?(Stripe::SKU) - end - - should "be retrievable" do - sku = Stripe::SKU.retrieve("sku_123") - assert_requested :get, "#{Stripe.api_base}/v1/skus/sku_123" - assert sku.is_a?(Stripe::SKU) - end - - should "be creatable" do - _ = Stripe::SKU.create( - currency: "USD", - inventory: { type: "finite", quantity: 500 }, - price: 100, - product: "prod_123" - ) - assert_requested :post, "#{Stripe.api_base}/v1/skus" - end - - should "be saveable" do - sku = Stripe::SKU.retrieve("sku_123") - sku.metadata["key"] = "value" - sku.save - assert_requested :post, "#{Stripe.api_base}/v1/skus/#{sku.id}" - end - - should "be updateable" do - sku = Stripe::SKU.update("sku_123", metadata: { foo: "bar" }) - assert_requested :post, "#{Stripe.api_base}/v1/skus/sku_123" - assert sku.is_a?(Stripe::SKU) - end - - context "#delete" do - should "be deletable" do - sku = Stripe::SKU.retrieve("sku_123") - sku = sku.delete - assert_requested :delete, "#{Stripe.api_base}/v1/skus/#{sku.id}" - assert sku.is_a?(Stripe::SKU) - end - end - - context ".delete" do - should "be deletable" do - sku = Stripe::SKU.delete("sku_123") - assert_requested :delete, "#{Stripe.api_base}/v1/skus/sku_123" - assert sku.is_a?(Stripe::SKU) - end - end - end -end From 24312f9f49bb5cd4c2e04e920efd69b1fd8af634 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Wed, 16 Nov 2022 12:04:21 -0800 Subject: [PATCH 2/7] Bump version to 8.0.0 --- CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++ VERSION | 2 +- lib/stripe/version.rb | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33c2d5ab..fe32b01b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 8.0.0 - 2022-11-16 +* [#1144](https://github.com/stripe/stripe-ruby/pull/1144) Next major release changes + +Breaking changes that arose during code generation of the library that we postponed for the next major version. For changes to the Stripe products, read more at https://stripe.com/docs/upgrades#2022-11-15. + +"⚠️" symbol highlights breaking changes. + +### Deprecated +- The `save` method is deprecated. Prefer the static `update` method that doesn't require retrieval of the resource to update it. + ``` ruby + # before + refund = Stripe::Refund.retrieve("re_123") + refund.description = "Refund description" + refund.save + + # after + Stripe::Refund.update("re_123", description: "Refund description") + ``` + +### ⚠️ Removed +- Removed deprecated `Sku` resource. +- Removed deprecated `Orders` resource. +- Removed deprecated `delete` method on `Subscription` resource. Please use `cancel` method instead. + ```ruby + # before + Stripe::Subscription::delete("sub_12345") + + # after + Stripe::Subscription::cancel("sub_12345") + ``` + + ## 7.1.0 - 2022-08-19 * [#1116](https://github.com/stripe/stripe-ruby/pull/1116) API Updates * Add support for new resource `CustomerCashBalanceTransaction` diff --git a/VERSION b/VERSION index a3fcc712..ae9a76b9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.1.0 +8.0.0 diff --git a/lib/stripe/version.rb b/lib/stripe/version.rb index 95f1f764..85311780 100644 --- a/lib/stripe/version.rb +++ b/lib/stripe/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Stripe - VERSION = "7.1.0" + VERSION = "8.0.0" end From a96e6f3b426b2d21566cc6bea0de800ed42eef0e Mon Sep 17 00:00:00 2001 From: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com> Date: Wed, 23 Nov 2022 11:20:04 -0800 Subject: [PATCH 3/7] Add tests for update (#1150) * Add tests for update * Apply suggestions from code review Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com> * Lint Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com> --- test/stripe/api_resource_test.rb | 53 +++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/test/stripe/api_resource_test.rb b/test/stripe/api_resource_test.rb index 706801ee..948bfbbb 100644 --- a/test/stripe/api_resource_test.rb +++ b/test/stripe/api_resource_test.rb @@ -314,7 +314,7 @@ module Stripe assert_equal c.created, 12_345 end - should "updating an object should issue a POST request with only the changed properties" do + should "saving an object should issue a POST request with only the changed properties" do stub_request(:post, "#{Stripe.api_base}/v1/customers/cus_123") .with(body: { "description" => "another_mn" }) .to_return(body: JSON.generate(customer_fixture)) @@ -323,7 +323,15 @@ module Stripe c.save end - should "updating should merge in returned properties" do + should "updating an object should issue a POST request with the specified properties" do + stub_request(:post, "#{Stripe.api_base}/v1/customers/cus_123") + .with(body: { "description" => "another_mn" }) + .to_return(body: JSON.generate(customer_fixture)) + Stripe::Customer.construct_from(customer_fixture) + Stripe::Customer.update("cus_123", { description: "another_mn" }) + end + + should "saving should merge in returned properties" do stub_request(:post, "#{Stripe.api_base}/v1/customers/cus_123") .with(body: { "description" => "another_mn" }) .to_return(body: JSON.generate(customer_fixture)) @@ -333,14 +341,21 @@ module Stripe assert_equal false, c.livemode end - should "updating should fail if api_key is overwritten with nil" do + should "saving should fail if api_key is overwritten with nil" do c = Stripe::Customer.new assert_raises TypeError do c.save({}, api_key: nil) end end - should "updating should use the supplied api_key" do + should "updating should fail if api_key is nil" do + Stripe::Customer.new("cus_123") + assert_raises TypeError do + Stripe::Customer.update("cus_123", {}, { api_key: nil }) + end + end + + should "saving should use the supplied api_key" do stub_request(:post, "#{Stripe.api_base}/v1/customers") .with(headers: { "Authorization" => "Bearer sk_test_local" }) .to_return(body: JSON.generate(customer_fixture)) @@ -349,6 +364,14 @@ module Stripe assert_equal false, c.livemode end + should "updating should use the supplied api_key" do + stub_request(:post, "#{Stripe.api_base}/v1/customers") + .with(headers: { "Authorization" => "Bearer sk_test_local" }) + .to_return(body: JSON.generate(customer_fixture)) + Stripe::Customer.new("cus_123") + Stripe::Customer.update("cus_123", {}, api_key: "sk_test_local") + end + should "deleting should send no props and result in an object that has no props other deleted" do stub_request(:delete, "#{Stripe.api_base}/v1/customers/cus_123") .to_return(body: JSON.generate("id" => "cus_123", "deleted" => true)) @@ -385,7 +408,7 @@ module Stripe c.save end - should "add key to nested objects" do + should "add key to nested objects on save" do acct = Stripe::Account.construct_from(id: "myid", legal_entity: { size: "l", @@ -401,6 +424,14 @@ module Stripe acct.save end + should "update with a nested object" do + stub_request(:post, "#{Stripe.api_base}/v1/accounts/myid") + .with(body: { business_profile: { name: "Bob" } }) + .to_return(body: JSON.generate("id" => "myid")) + + Stripe::Account.update("myid", { business_profile: { name: "Bob" } }) + end + should "save nothing if nothing changes" do acct = Stripe::Account.construct_from(id: "acct_id", metadata: { @@ -429,7 +460,7 @@ module Stripe ch.save end - should "correctly handle replaced nested objects" do + should "correctly handle replaced nested objects on save" do acct = Stripe::Account.construct_from( id: "acct_123", company: { @@ -449,7 +480,7 @@ module Stripe acct.save end - should "correctly handle array setting" do + should "correctly handle array setting on save" do acct = Stripe::Account.construct_from(id: "myid", legal_entity: {}) @@ -461,7 +492,7 @@ module Stripe acct.save end - should "correctly handle array insertion" do + should "correctly handle array insertion on save" do acct = Stripe::Account.construct_from(id: "myid", legal_entity: { additional_owners: [], @@ -478,7 +509,7 @@ module Stripe acct.save end - should "correctly handle array updates" do + should "correctly handle array updates on save" do acct = Stripe::Account.construct_from(id: "myid", legal_entity: { additional_owners: [{ first_name: "Bob" }, { first_name: "Jane" }], @@ -495,7 +526,7 @@ module Stripe acct.save end - should "correctly handle array noops" do + should "correctly handle array noops on save" do acct = Stripe::Account.construct_from(id: "myid", legal_entity: { additional_owners: [{ first_name: "Bob" }], @@ -509,7 +540,7 @@ module Stripe acct.save end - should "correctly handle hash noops" do + should "correctly handle hash noops on save" do acct = Stripe::Account.construct_from(id: "myid", legal_entity: { address: { line1: "1 Two Three" }, From b87cfbec980f4b83f4e431686d11fe7e2efcdd4e Mon Sep 17 00:00:00 2001 From: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com> Date: Thu, 8 Dec 2022 12:04:58 -0800 Subject: [PATCH 4/7] Update jruby version (#1154) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0784a7d9..bb9824cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, jruby-9.2.16.0, truffleruby-head] + ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, jruby-9.4.0.0, truffleruby-head] steps: - uses: actions/checkout@v2 - name: Set up Ruby From 4bd92239d5ac59c0e0ef183b8811c05d61f7e57b Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 8 Dec 2022 12:08:24 -0800 Subject: [PATCH 5/7] Set version to 8.0.0 to simplify merge --- VERSION | 2 +- lib/stripe/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 4118162f..ae9a76b9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.2.0-beta.5 +8.0.0 diff --git a/lib/stripe/version.rb b/lib/stripe/version.rb index eb19da53..85311780 100644 --- a/lib/stripe/version.rb +++ b/lib/stripe/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Stripe - VERSION = "7.2.0-beta.5" + VERSION = "8.0.0" end From 21f31edff49f95882b530e1e47d366f80c47285d Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 8 Dec 2022 12:08:24 -0800 Subject: [PATCH 6/7] Reset version to 7.2.0-beta.5 --- VERSION | 2 +- lib/stripe/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index ae9a76b9..4118162f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.0 +7.2.0-beta.5 diff --git a/lib/stripe/version.rb b/lib/stripe/version.rb index 85311780..eb19da53 100644 --- a/lib/stripe/version.rb +++ b/lib/stripe/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Stripe - VERSION = "8.0.0" + VERSION = "7.2.0-beta.5" end From ea91a6f0b9c16705f1e86aa85548f2d5e864accb Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 8 Dec 2022 12:08:39 -0800 Subject: [PATCH 7/7] Codegen for openapi v212 --- OPENAPI_VERSION | 2 +- lib/stripe/object_types.rb | 1 + lib/stripe/resources.rb | 1 + lib/stripe/resources/order.rb | 89 ++++++++++++++++++++++++++ test/stripe/generated_examples_test.rb | 57 ----------------- 5 files changed, 92 insertions(+), 58 deletions(-) create mode 100644 lib/stripe/resources/order.rb diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 976ca98c..eaf5acec 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v205 \ No newline at end of file +v212 \ No newline at end of file diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index c6f6c926..aa2049ac 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -68,6 +68,7 @@ module Stripe LineItem::OBJECT_NAME => LineItem, LoginLink::OBJECT_NAME => LoginLink, Mandate::OBJECT_NAME => Mandate, + Order::OBJECT_NAME => Order, PaymentIntent::OBJECT_NAME => PaymentIntent, PaymentLink::OBJECT_NAME => PaymentLink, PaymentMethod::OBJECT_NAME => PaymentMethod, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 63bf811c..b9d75af7 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -55,6 +55,7 @@ require "stripe/resources/issuing/transaction" require "stripe/resources/line_item" require "stripe/resources/login_link" require "stripe/resources/mandate" +require "stripe/resources/order" require "stripe/resources/payment_intent" require "stripe/resources/payment_link" require "stripe/resources/payment_method" diff --git a/lib/stripe/resources/order.rb b/lib/stripe/resources/order.rb new file mode 100644 index 00000000..0ca6e75d --- /dev/null +++ b/lib/stripe/resources/order.rb @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + # An Order describes a purchase being made by a customer, including the + # products & quantities being purchased, the order status, the payment information, + # and the billing/shipping details. + # + # Related guide: [Orders overview](https://stripe.com/docs/orders) + class Order < APIResource + extend Stripe::APIOperations::Create + extend Stripe::APIOperations::List + include Stripe::APIOperations::Save + + OBJECT_NAME = "order" + + def cancel(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/orders/%s/cancel", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + def list_line_items(params = {}, opts = {}) + request_stripe_object( + method: :get, + path: format("/v1/orders/%s/line_items", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + def reopen(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/orders/%s/reopen", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + def submit(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/orders/%s/submit", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + def self.cancel(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/orders/%s/cancel", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + def self.list_line_items(id, params = {}, opts = {}) + request_stripe_object( + method: :get, + path: format("/v1/orders/%s/line_items", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + def self.reopen(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/orders/%s/reopen", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + def self.submit(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/orders/%s/submit", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + end +end diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index 66bd806f..4837c259 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -1070,63 +1070,6 @@ module Stripe assert_requested :get, "#{Stripe.api_base}/v1/mandates/mandate_xxxxxxxxxxxxx?" end end - context "Order.cancel" do - should "support requests with args: order" do - Stripe::Order.cancel("order_xyz") - assert_requested :post, "#{Stripe.api_base}/v1/orders/order_xyz/cancel?" - end - end - context "Order.create" do - should "support requests with args: description, currency, line_items" do - Stripe::Order.create( - { - description: "description", - currency: "usd", - line_items: [{ description: "my line item" }], - } - ) - assert_requested :post, "#{Stripe.api_base}/v1/orders" - end - end - context "Order.list" do - should "support requests with args: limit" do - Stripe::Order.list({ limit: 3 }) - assert_requested :get, "#{Stripe.api_base}/v1/orders?limit=3" - end - end - context "Order.list_line_items" do - should "support requests with args: order" do - Stripe::Order.list_line_items("order_xyz") - assert_requested :get, "#{Stripe.api_base}/v1/orders/order_xyz/line_items?" - end - end - context "Order.reopen" do - should "support requests with args: order" do - Stripe::Order.reopen("order_xyz") - assert_requested :post, "#{Stripe.api_base}/v1/orders/order_xyz/reopen?" - end - end - context "Order.retrieve" do - should "support requests with args: order" do - Stripe::Order.retrieve("order_xyz") - assert_requested :get, "#{Stripe.api_base}/v1/orders/order_xyz?" - end - end - context "Order.submit" do - should "support requests with args: order, expected_total" do - Stripe::Order.submit("order_xyz", { expected_total: 100 }) - assert_requested :post, "#{Stripe.api_base}/v1/orders/order_xyz/submit" - end - end - context "Order.update" do - should "support requests with args: order, metadata, ip_address" do - Stripe::Order.update( - "order_xyz", - { metadata: { reference_number: "123" }, ip_address: "0.0.0.0" } - ) - assert_requested :post, "#{Stripe.api_base}/v1/orders/order_xyz" - end - end context "PaymentIntent.apply_customer_balance" do should "support requests with args: id" do Stripe::PaymentIntent.apply_customer_balance("pi_xxxxxxxxxxxxx")