Skip to content

Commit

Permalink
API Updates (#1031)
Browse files Browse the repository at this point in the history
* Codegen for openapi 4d2f301
  • Loading branch information
richardm-stripe authored Jan 20, 2022
1 parent 3e47670 commit 917e512
Show file tree
Hide file tree
Showing 4 changed files with 53 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 @@ -59,6 +59,7 @@ def self.object_names_to_classes
Order::OBJECT_NAME => Order,
OrderReturn::OBJECT_NAME => OrderReturn,
PaymentIntent::OBJECT_NAME => PaymentIntent,
PaymentLink::OBJECT_NAME => PaymentLink,
PaymentMethod::OBJECT_NAME => PaymentMethod,
Payout::OBJECT_NAME => Payout,
Person::OBJECT_NAME => Person,
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
require "stripe/resources/order"
require "stripe/resources/order_return"
require "stripe/resources/payment_intent"
require "stripe/resources/payment_link"
require "stripe/resources/payment_method"
require "stripe/resources/payout"
require "stripe/resources/person"
Expand Down
23 changes: 23 additions & 0 deletions lib/stripe/resources/payment_link.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true

module Stripe
class PaymentLink < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "payment_link"

custom_method :list_line_items, http_verb: :get, http_path: "line_items"

def list_line_items(params = {}, opts = {})
request_stripe_object(
method: :get,
path: resource_url + "/line_items",
params: params,
opts: opts
)
end
end
end
28 changes: 28 additions & 0 deletions test/stripe/generated_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,14 @@ class CodegennedExampleTest < Test::Unit::TestCase
)
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents"
end
should "support requests with args: amount, currency, automatic_payment_methods" do
Stripe::PaymentIntent.create(
amount: 1099,
currency: "eur",
automatic_payment_methods: { enabled: true }
)
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents"
end
end
context "PaymentIntent.list" do
should "support requests with args: limit" do
Expand All @@ -879,6 +887,26 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_xxxxxxxxxxxxx"
end
end
context "PaymentLink.create" do
should "support requests with args: line_items" do
Stripe::PaymentLink.create(
line_items: [{ price: "price_xxxxxxxxxxxxx", quantity: 1 }]
)
assert_requested :post, "#{Stripe.api_base}/v1/payment_links"
end
end
context "PaymentLink.list_line_items" do
should "support requests with args: payment_link" do
Stripe::PaymentLink.list_line_items("pl_xyz")
assert_requested :get, "#{Stripe.api_base}/v1/payment_links/pl_xyz/line_items?"
end
end
context "PaymentLink.retrieve" do
should "support requests with args: payment_link" do
Stripe::PaymentLink.retrieve("pl_xyz")
assert_requested :get, "#{Stripe.api_base}/v1/payment_links/pl_xyz?"
end
end
context "PaymentMethod.attach" do
should "support requests with args: customer, id" do
Stripe::PaymentMethod.attach(
Expand Down

0 comments on commit 917e512

Please sign in to comment.