Module: Peddler::Helpers::DataKiosk20231115

Included in:
APIs::DataKiosk20231115
Defined in:
lib/peddler/helpers/data_kiosk_2023_11_15.rb,
sig/peddler/helpers/data_kiosk_2023_11_15.rbs

Instance Method Summary collapse

Instance Method Details

#download_query_document(document_id_or_url) ⇒ Peddler::Response

Convenience method to download a Data Kiosk document by its document ID or URL. This method can handle both document IDs and direct download URLs.

Parameters:

  • document_id_or_url (String)

    The document identifier or download URL

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/peddler/helpers/data_kiosk_2023_11_15.rb', line 13

def download_query_document(document_id_or_url)
  # If it looks like a URL, use direct download
  if document_id_or_url.start_with?("http")
    return download_query_document_from_url(document_id_or_url)
  end

  # Otherwise, treat it as a document ID and get the download URL first
  response = get_document(document_id_or_url)
  document_url = response.parse.document_url

  download_query_document_from_url(document_url)
end

#download_query_document_from_url(document_url) ⇒ Peddler::Response

Parameters:

  • download_url (String)

Returns:



28
29
30
31
# File 'lib/peddler/helpers/data_kiosk_2023_11_15.rb', line 28

def download_query_document_from_url(document_url)
  http_response = HTTP.use(:auto_inflate).get(document_url)
  Response.wrap(http_response)
end

#get_documentPeddler::Response

Parameters:

  • (String)

Returns:



10
# File 'sig/peddler/helpers/data_kiosk_2023_11_15.rbs', line 10

def get_document: (String) -> Peddler::Response