Skip to content

Commit

Permalink
Add support for the LineItem resource and APIs (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed May 12, 2020
1 parent 4c5b67b commit cfac8d7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
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

0 comments on commit cfac8d7

Please sign in to comment.