Module: Peddler::Helpers::Reports20210630
- Included in:
- APIs::Reports20210630
- Defined in:
- lib/peddler/helpers/reports_2021_06_30.rb,
sig/peddler/helpers/reports_2021_06_30.rbs
Instance Method Summary collapse
-
#download_report_document(report_document_id_or_url) ⇒ HTTP::Response
Convenience method to download a report by its document ID or URL.
-
#download_report_document_from_url(download_url) ⇒ Peddler::Response
-
#get_report_document ⇒ Peddler::Response
This method is expected to be defined by the API class that includes this helper.
Instance Method Details
#download_report_document(report_document_id_or_url) ⇒ HTTP::Response
Convenience method to download a report by its document ID or URL. This method can handle both document IDs and direct download URLs.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/peddler/helpers/reports_2021_06_30.rb', line 13 def download_report_document(report_document_id_or_url) # If it looks like a URL, use direct download if report_document_id_or_url.start_with?("http") return download_report_document_from_url(report_document_id_or_url) end # Otherwise, treat it as a document ID and get the download URL first document_info = get_report_document(report_document_id_or_url) download_url = document_info.dig("url") download_report_document_from_url(download_url) end |
#download_report_document_from_url(download_url) ⇒ Peddler::Response
28 29 30 31 |
# File 'lib/peddler/helpers/reports_2021_06_30.rb', line 28 def download_report_document_from_url(download_url) http_response = HTTP.get(download_url) Response.wrap(http_response) end |
#get_report_document ⇒ Peddler::Response
This method is expected to be defined by the API class that includes this helper
7 |
# File 'sig/peddler/helpers/reports_2021_06_30.rbs', line 7
def get_report_document: (String report_document_id) -> Peddler::Response
|