Reputation: 1695
I have implemented Docusign in my Ruby on Rails App. I'm trying to get the Status of send documents. I can easily get it one by one using the envelope id like this.
response = client.get_envelope_recipients(
envelope_id: envelope_id
)
Problem is that I have a page that shows the list of documents sent and I want to show the status of each one along with this list. So it is difficult and time consuming to get the status of each docs one by one with envelope_id.
Is there any way I can get the status of a list of envelopes sent from a same account. I also wants to know if there is something I could do so that after the user signs the doc it gets redirected to a specific url(then i can update the database with the status as soon as the user signs the doc)
Upvotes: 0
Views: 255
Reputation: 9356
Yes the DocuSign platform does indeed let you query for a set of envelopes in a single API call instead of one-by-one per envelope ID, you just need to make the right API call. Looking at the Ruby library you have referenced it looks like they already include the call, it's called get_envelope_statuses
and it lets you query for envelopes through date ranges and statuses:
# Public retrieves the statuses of envelopes matching the given query
#
# from_date - Docusign formatted Date/DateTime. Only return items after this date.
#
# to_date - Docusign formatted Date/DateTime. Only return items up to this date.
# Defaults to the time of the call.
#
# from_to_status - The status of the envelope checked for in the from_date - to_date period.
# Defaults to 'changed'
#
# status - The current status of the envelope. Defaults to any status.
#
# Returns an array of hashes containing envelope statuses, ids, and similar information.
def get_envelope_statuses(options={})
content_type = { 'Content-Type' => 'application/json' }
content_type.merge(options[:headers]) if options[:headers]
query_params = options.slice(:from_date, :to_date, :from_to_status, :status)
uri = build_uri("/accounts/#{acct_id}/envelopes?#{query_params.to_query}")
http = initialize_net_http_ssl(uri)
request = Net::HTTP::Get.new(uri.request_uri, headers(content_type))
response = http.request(request)
JSON.parse(response.body)
end
And here is the corresponding API call from the DocuSign REST API Documentation.
Upvotes: 2