Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the LineItem resource and APIs #918

Merged
merged 1 commit into from May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -17,7 +17,7 @@ sudo: false
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.89.0
- STRIPE_MOCK_VERSION=0.90.0

cache:
directories:
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/object_types.rb
Expand Up @@ -49,6 +49,7 @@ def self.object_names_to_classes
Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
LineItem::OBJECT_NAME => LineItem,
LoginLink::OBJECT_NAME => LoginLink,
Mandate::OBJECT_NAME => Mandate,
Order::OBJECT_NAME => Order,
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/resources.rb
Expand Up @@ -38,6 +38,7 @@
require "stripe/resources/issuing/cardholder"
require "stripe/resources/issuing/dispute"
require "stripe/resources/issuing/transaction"
require "stripe/resources/line_item"
require "stripe/resources/login_link"
require "stripe/resources/mandate"
require "stripe/resources/order"
Expand Down
3 changes: 3 additions & 0 deletions lib/stripe/resources/checkout/session.rb
Expand Up @@ -5,8 +5,11 @@ module Checkout
class Session < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
extend Stripe::APIOperations::NestedResource

OBJECT_NAME = "checkout.session"

nested_resource_class_methods :line_item, operations: %i[list]
end
end
end
7 changes: 7 additions & 0 deletions lib/stripe/resources/line_item.rb
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module Stripe
class LineItem < APIResource
OBJECT_NAME = "item"
end
end
12 changes: 12 additions & 0 deletions test/stripe/checkout/session_test.rb
Expand Up @@ -36,6 +36,18 @@ class SessionTest < Test::Unit::TestCase
assert_requested :get, "#{Stripe.api_base}/v1/checkout/sessions/cs_123"
assert charge.is_a?(Stripe::Checkout::Session)
end

context "#list_line_items" do
should "list the session's line items" do
sources = Stripe::Checkout::Session.list_line_items(
"cs_123"
)
assert_requested :get, "#{Stripe.api_base}/v1/checkout/sessions/cs_123/line_items"
assert sources.is_a?(Stripe::ListObject)
assert sources.data.is_a?(Array)
assert sources.data[0].is_a?(Stripe::LineItem)
end
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Expand Up @@ -16,7 +16,7 @@
require ::File.expand_path("stripe_mock", __dir__)

# If changing this number, please also change it in `.travis.yml`.
MOCK_MINIMUM_VERSION = "0.89.0"
MOCK_MINIMUM_VERSION = "0.90.0"
MOCK_PORT = Stripe::StripeMock.start

# Disable all real network connections except those that are outgoing to
Expand Down