From 81ea988b36a76397a6b575aaf98bb814c2ee439b Mon Sep 17 00:00:00 2001 From: Tan Jay Jun Date: Tue, 13 Jun 2017 10:53:53 +0800 Subject: [PATCH] Add invoice line items support --- lib/stripe/invoice.ex | 7 +++---- lib/stripe/line_item.ex | 16 ++++++++++++++++ test/stripe/util_test.exs | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 lib/stripe/line_item.ex diff --git a/lib/stripe/invoice.ex b/lib/stripe/invoice.ex index da33852e..510ca547 100644 --- a/lib/stripe/invoice.ex +++ b/lib/stripe/invoice.ex @@ -8,9 +8,7 @@ defmodule Stripe.Invoice do - Retrieve an invoice - Update an invoice - Does not yet implement `lines`. - - Does not yet render lists or take options. + Does not take options yet. Stripe API reference: https://stripe.com/docs/api#invoice """ @@ -21,7 +19,7 @@ defmodule Stripe.Invoice do :id, :object, :amount_due, :application_fee, :attempt_count, :attempted, :charge, :closed, :currency, :customer, :date, :description, :discount, - :ending_balance, :forgiven, :livemode, :metadata, + :ending_balance, :forgiven, :lines, :livemode, :metadata, :next_payment_attempt, :paid, :period_end, :period_start, :receipt_number, :starting_balance, :statement_descriptor, :subscription, :subscription_proration_date, :subtotal, :tax, @@ -45,6 +43,7 @@ defmodule Stripe.Invoice do ending_balance: [:retrieve], forgiven: [:retrieve, :update], id: [:retrieve], + lines: [:retrieve], livemode: [:retrieve], metadata: [:create, :retrieve, :update], next_payment_attempt: [:retrieve], diff --git a/lib/stripe/line_item.ex b/lib/stripe/line_item.ex new file mode 100644 index 00000000..d6bb02ad --- /dev/null +++ b/lib/stripe/line_item.ex @@ -0,0 +1,16 @@ +defmodule Stripe.LineItem do + @moduledoc """ + Work with Stripe (invoice) line item objects. + + Stripe API reference: https://stripe.com/docs/api/ruby#invoice_line_item_object + """ + + @type t :: %__MODULE__{} + + defstruct [ + :id, :object, + :amount, :currency, :description, :discountable, :livemode, :metadata, + :period, :plan, :proration, :quantity, :subscription, :subscription_item, + :type + ] +end diff --git a/test/stripe/util_test.exs b/test/stripe/util_test.exs index c16080e6..557fd662 100644 --- a/test/stripe/util_test.exs +++ b/test/stripe/util_test.exs @@ -14,6 +14,7 @@ defmodule Stripe.UtilTest do assert object_name_to_module("external_account") == Stripe.ExternalAccount assert object_name_to_module("file_upload") == Stripe.FileUpload assert object_name_to_module("invoice") == Stripe.Invoice + assert object_name_to_module("line_item") == Stripe.LineItem assert object_name_to_module("list") == Stripe.List assert object_name_to_module("plan") == Stripe.Plan assert object_name_to_module("refund") == Stripe.Refund