Add ReportRun#contents to get the actual report data
As far as I can see the Ruby client currently only has methods to create a report run and retrieve it (ie. its metadata), not the actual report content.
This PR adds an action to download the content, based on Quote#pdf.
I tried to add a test to cover it, but found that stripe-mock doesn't have mocked reponses for the binary contents endpoint on files (only the file metadata endpoint), so I can't add a working test at this time.
Hi @willbryant,
Thank you for the submission. I think this is valuable. Instead of this interface:
report_run = Stripe::Reporting::ReportRun.retrieve("...")
report_run.contents do |bytes|
file.write(bytes)
end
What do you think of a method on the File class instead?
report_run = Stripe::Reporting::ReportRun.retrieve("...")
if report_run.result
report_run.result.download do |bytes|
file.write(bytes)
end
end
I think it's less discoverable on the File class, but it also then generalizes and provides similar methods for all file types in the Stripe API, not just report runs. Also I think it's nicer with respect to the possibility of report_run.result being nil.
(Please just discuss for now, don't change your implementation)
cc @pakrym-stripe @anniel-stripe
That would be fine too, but it's not the approach taken for the existing Quote API. It seems File is only used for file resources, not for all file-like downloadables? So at the moment there is no way to construct a File object for anything other than an actual file resource, which is not exposed for report runs by the API.
Try with manually downloading the report content using the provided metadata. Check if the report run has a PDF file associated with it and try accessing the PDF file directly through its URL. If this approach doesn't work, consider contacting the Stripe support team for further assistance.