From f774da66a786aeb9f8fc20e3616578dac2fd5497 Mon Sep 17 00:00:00 2001 From: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com> Date: Fri, 24 May 2024 10:42:33 -0700 Subject: [PATCH] Add method to list invoice line items (#1404) --- lib/stripe/resources/invoice.rb | 3 +++ test/stripe/invoice_test.rb | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/stripe/resources/invoice.rb b/lib/stripe/resources/invoice.rb index 9d86402b5..4761243a6 100644 --- a/lib/stripe/resources/invoice.rb +++ b/lib/stripe/resources/invoice.rb @@ -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 @@ -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 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) diff --git a/test/stripe/invoice_test.rb b/test/stripe/invoice_test.rb index 9a5a6d18f..2e6e818ee 100644 --- a/test/stripe/invoice_test.rb +++ b/test/stripe/invoice_test.rb @@ -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")