Skip to content

Commit

Permalink
Codegen for openapi v212
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym-stripe committed Dec 8, 2022
1 parent 21f31ed commit ea91a6f
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 58 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v205
v212
1 change: 1 addition & 0 deletions lib/stripe/object_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
89 changes: 89 additions & 0 deletions lib/stripe/resources/order.rb
Original file line number Diff line number Diff line change
@@ -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/%<id>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/%<id>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/%<id>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/%<id>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/%<id>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/%<id>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/%<id>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/%<id>s/submit", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
end
end
57 changes: 0 additions & 57 deletions test/stripe/generated_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ea91a6f

Please sign in to comment.