Skip to content

Commit 5458bed

Browse files
authored
Merge pull request #144 from docusign/bugfix/fixes-for-monitor
Added the limits to the monitor example
2 parents f0e65fe + 822c9f7 commit 5458bed

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

app/services/monitor_api/eg001_get_monitoring_dataset_service.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,28 @@ def worker
1919
#ds-snippet-start:Monitor1Step3
2020
monitor_api = DocuSign_Monitor::DataSetApi.new(api_client)
2121
begin
22-
@response = monitor_api.get_stream(args[:data_set_name], args[:version]).data
22+
cursor_value = ''
23+
limit = 100
24+
function_results = []
25+
options = DocuSign_Monitor::GetStreamOptions.new
26+
options.limit = limit
27+
28+
loop do
29+
options.cursor = cursor_value unless cursor_value.empty?
30+
31+
cursored_results = monitor_api.get_stream(args[:data_set_name], args[:version], options)
32+
end_cursor = cursored_results.end_cursor
33+
34+
break if cursor_value == end_cursor
35+
36+
cursor_value = end_cursor
37+
function_results.push(cursored_results.data)
38+
end
39+
@response = function_results
2340
#ds-snippet-end:Monitor1Step3
24-
rescue StandardError
41+
rescue Exception => e
2542
# error, probalby no Monitor enabled
26-
@response = 'Monitor not enabled'
43+
@response = e
2744
else
2845
Rails.logger.info 'Responses for loops are displayed here. Only the final loop is displayed on the response page'
2946
Rails.logger.info @response.inspect

0 commit comments

Comments
 (0)