Skip to content

Commit

Permalink
Add method to list invoice line items (#1404)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-stripe authored May 24, 2024
1 parent 076a685 commit f774da6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/stripe/resources/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Invoice < APIResource
extend Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
extend Stripe::APIOperations::List
extend Stripe::APIOperations::NestedResource
extend Stripe::APIOperations::Search
include Stripe::APIOperations::Save

Expand All @@ -46,6 +47,8 @@ def self.object_name
"invoice"
end

nested_resource_class_methods :line, operations: %i[list]

# This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you [finalize the invoice, which allows you to [pay](#pay_invoice) or <a href="#send_invoice">send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/invoices", params: params, opts: opts)
Expand Down
9 changes: 9 additions & 0 deletions test/stripe/invoice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ class InvoiceTest < Test::Unit::TestCase
end
end

context ".list_line_items" do
should "retrieve invoice line items" do
line_items = Stripe::Invoice.list_lines("in_123")
assert_requested :get, "#{Stripe.api_base}/v1/invoices/in_123/lines"
assert line_items.data.is_a?(Array)
assert line_items.data[0].is_a?(Stripe::InvoiceLineItem)
end
end

context "#void_invoice" do
should "void invoice" do
invoice = Stripe::Invoice.retrieve("in_123")
Expand Down

0 comments on commit f774da6

Please sign in to comment.