Skip to content

Commit

Permalink
Merge pull request #144 from docusign/bugfix/fixes-for-monitor
Browse files Browse the repository at this point in the history
Added the limits to the monitor example
  • Loading branch information
meihDS authored Dec 28, 2023
2 parents f0e65fe + 822c9f7 commit 5458bed
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions app/services/monitor_api/eg001_get_monitoring_dataset_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@ def worker
#ds-snippet-start:Monitor1Step3
monitor_api = DocuSign_Monitor::DataSetApi.new(api_client)
begin
@response = monitor_api.get_stream(args[:data_set_name], args[:version]).data
cursor_value = ''
limit = 100
function_results = []
options = DocuSign_Monitor::GetStreamOptions.new
options.limit = limit

loop do
options.cursor = cursor_value unless cursor_value.empty?

cursored_results = monitor_api.get_stream(args[:data_set_name], args[:version], options)
end_cursor = cursored_results.end_cursor

break if cursor_value == end_cursor

cursor_value = end_cursor
function_results.push(cursored_results.data)
end
@response = function_results
#ds-snippet-end:Monitor1Step3
rescue StandardError
rescue Exception => e
# error, probalby no Monitor enabled
@response = 'Monitor not enabled'
@response = e
else
Rails.logger.info 'Responses for loops are displayed here. Only the final loop is displayed on the response page'
Rails.logger.info @response.inspect
Expand Down

0 comments on commit 5458bed

Please sign in to comment.