From 822c9f7b7e0a0c541ffb54affda3d7d138edc86b Mon Sep 17 00:00:00 2001 From: RomanBachaloSigmaSoftware Date: Fri, 22 Dec 2023 14:04:51 +0200 Subject: [PATCH] fix monitor example --- .../eg001_get_monitoring_dataset_service.rb | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/app/services/monitor_api/eg001_get_monitoring_dataset_service.rb b/app/services/monitor_api/eg001_get_monitoring_dataset_service.rb index 7977774..7c3f1f7 100644 --- a/app/services/monitor_api/eg001_get_monitoring_dataset_service.rb +++ b/app/services/monitor_api/eg001_get_monitoring_dataset_service.rb @@ -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