To download all your documents, we recommend looping through all the pages of the List Signature Requests endpoint to obtain all the signature_request_ids. Then loop through the list of signature_request_ids to download each document using the Get Files endpoint.
Here's an example using the Ruby SDK:
1. Initiate HelloSign with your account's API Key.
require 'hello_sign'
HelloSign.configure do |config|
config.api_key = '<api key>'
end
2. Obtain the total number of pages of Signature Requests returned from the List Signature Requests endpoint
def get_total_pages()
list = HelloSign.get_signature_requests(page_size: 100) list.data["list_info"]["num_pages"]
end
3. Loop through the pages of the signature requests to combine into one list
def get_all_requests()
signature_requests = [] page = 1 total_pages = get_total_pages()
while page < total_pages + 1 req = HelloSign.get_signature_requests(page_size: 100, page: page) signature_requests << req.data["signature_requests"] page += 1 end
signature_requests.flatten
end
4. Loop through all signature requests and downloads the completed documents
def download_requests(requests)
requests.each do |req| download = HelloSign.signature_request_files( signature_request_id: req["signature_request_id"], file_type: "zip" )
File.open("Download-#"+req["signature_request_id"]+".zip", "wb") do |file| file.write(download) end
end
end
download_requests(get_all_requests())
Comments
0 comments
Article is closed for comments.