diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 976ca98c1..eaf5acec6 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 c6f6c9260..aa2049acb 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -68,6 +68,7 @@ def self.object_names_to_classes 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 63bf811cb..b9d75af70 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -55,6 +55,7 @@ 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 000000000..0ca6e75df --- /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 66bd806fe..4837c2599 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -1070,63 +1070,6 @@ class CodegennedExampleTest < Test::Unit::TestCase 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")