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

Invoiced::Invoice#payment_plan returns the payment plan ID when it should return an Invoiced::PaymentPlan instance #21

Open
arthurhess opened this issue Nov 1, 2024 · 0 comments

Comments

@arthurhess
Copy link

arthurhess commented Nov 1, 2024

Hi!

I'm trying to retrieve a payment plan from an Invoiced::Invoice object, but here's what I'm getting.

api_client = Invoiced::Client.new(...)
invoice = api_client.Invoice.retrieve(...)
invoice.payment_plan
# => (payment plan id, integer)

I'm guessing it's returning the attribute from @values. I might have time to investigate it later and suggest something through a PR, but it may take a while as this isn't urgent for me.

I'm working around it by instantiating Invoiced::PaymentPlan and calling retrieve on it directly:

Invoiced::PaymentPlan.new(api_client).set_endpoint_base("/invoices/#{invoice.id}").retrieve
# => (instance of Invoiced::PaymentPlan)

I wanted to leave this here anyway, in case someone else coming across this issue has time to fix it (or just use the workaround above)

Edit: I realize Invoiced::Object#set_endpoint_base is probably private API, so I'll be locking this gem's version in my project for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant