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

Add ReportRun#contents to get the actual report data #1157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

willbryant
Copy link

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.

@CLAassistant
Copy link

CLAassistant commented Dec 19, 2022

CLA assistant check
All committers have signed the CLA.

@richardm-stripe
Copy link
Contributor

richardm-stripe commented Feb 25, 2023

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

@willbryant
Copy link
Author

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.

@msf-caesar
Copy link

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.

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

Successfully merging this pull request may close these issues.

4 participants