Skip to content

Commit ca12e28

Browse files
committed
Monitor API - checking if you have this enabled
As well as some comments updates
1 parent 490ffc9 commit ca12e28

File tree

6 files changed

+57
-26
lines changed

6 files changed

+57
-26
lines changed

app/controllers/monitor_api/eg001_get_monitoring_dataset_controller.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ def create
1212

1313
@title = "Get monitoring data"
1414
@h1 = "Get monitoring data"
15-
@message = "Results from DataSet:getStream method:"
16-
@json = results.to_json.to_json
15+
16+
if results != "Monitor not enabled"
17+
@message = "Results from DataSet:getStream method:"
18+
@json = results.to_json.to_json
19+
else
20+
@message = "You do not have Monitor enabled for your account, follow <a target='_blank' href='https://developers.docusign.com/docs/monitor-api/how-to/enable-monitor/'>How to enable Monitor for your account</a> to get it enabled."
21+
end
1722

1823
render 'ds_common/example_done'
1924
end

app/controllers/monitor_api/eg002_post_web_query_controller.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ def create
1515

1616
@title = "Query monitoring data with filters"
1717
@h1 = "Query monitoring data with filters"
18-
@message = "Results from DataSet:postWebQuery method:"
19-
@json = results.to_json.to_json
18+
19+
if results != "Monitor not enabled"
20+
@message = "Results from DataSet:postWebQuery method:"
21+
@json = results.to_json.to_json
22+
else
23+
@message = "You do not have Monitor enabled for your account, follow <a target='_blank' href='https://developers.docusign.com/docs/monitor-api/how-to/enable-monitor/'>How to enable Monitor for your account</a> to get it enabled."
24+
end
2025

2126
render 'ds_common/example_done'
2227
end

app/services/e_sign/eg039_signing_in_person_service.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,26 @@ def worker
1717
host_name = args[:host_name]
1818
signer_name = args[:signer_name]
1919

20-
# Step 1. Create the envelope definition
2120
envelope = make_envelope(pdf_filename, host_email, host_name, signer_name)
2221

23-
# Step 2. Call DocuSign to create the envelope
22+
# Step 3 start
2423
envelope_api = create_envelope_api(args)
2524

2625
results = envelope_api.create_envelope args[:account_id], envelope
26+
# Step 3 end
27+
2728
envelope_id = results.envelope_id
2829

29-
# Step 3. Create the recipient view for the embedded signing
30+
31+
# Step 5 start
3032
view_request = make_recipient_view_request(ds_return_url, ds_ping_url, host_email, host_name
3133
)
3234

3335
# Call the CreateRecipientView API
3436
results = envelope_api.create_recipient_view args[:account_id], envelope_id, view_request
37+
# Step 5 end
3538

36-
# Step 4. Redirect the user to the embedded signing
39+
# Redirect the user to the embedded signing
3740
# Don't use an iframe!
3841
# State can be stored/recovered using the framework's session or a
3942
# query parameter on the returnUrl (see the makeRecipientViewRequest method)
@@ -43,6 +46,7 @@ def worker
4346

4447
private
4548

49+
# Step 4 start
4650
def make_recipient_view_request(ds_return_url, ds_ping_url, host_email, host_name)
4751
view_request = DocuSign_eSign::RecipientViewRequest.new
4852
# Set the URL where you want the recipient to go once they are done signing
@@ -74,7 +78,9 @@ def make_recipient_view_request(ds_return_url, ds_ping_url, host_email, host_nam
7478

7579
view_request
7680
end
81+
# Step 4 end
7782

83+
# Step 2 start
7884
def make_envelope(pdf_filename, host_email, host_name, signer_name)
7985
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new
8086
envelope_definition.email_subject = 'Please sign this document sent from Ruby SDK'
@@ -118,5 +124,5 @@ def make_envelope(pdf_filename, host_email, host_name, signer_name)
118124
envelope_definition.status = 'sent'
119125
envelope_definition
120126
end
121-
# ***DS.snippet.0.end
127+
# Step 2 end
122128
end

app/services/e_sign/eg040_set_document_visibility_service.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,24 @@ def initialize(args)
99
end
1010

1111
def worker
12-
# 1. Create the envelope request object
12+
# Step 3-1 start
1313
envelope_definition = make_envelope args[:envelope_args]
14-
# 2. Call Envelopes::create API method
14+
# Step 3-1 end
15+
1516
# Exceptions will be caught by the calling function
17+
# Step 4 start
1618
envelope_api = create_envelope_api(args)
1719

1820
results = envelope_api.create_envelope args[:account_id], envelope_definition
1921
envelope_id = results.envelope_id
22+
# Step 4 end
23+
2024
{ 'envelope_id' => envelope_id }
2125
end
2226

2327
private
2428

29+
# Step 3-2 start
2530
def make_envelope(envelope_args)
2631
# document 1 (HTML) has tag **signature_1**
2732
# document 2 (DOCX) has tag /sn1/
@@ -141,6 +146,7 @@ def make_envelope(envelope_args)
141146
envelope_definition.status = envelope_args[:status]
142147
envelope_definition
143148
end
149+
# Step 3-2 end
144150

145151
def create_document1(args)
146152
"

app/services/monitor_api/eg001_get_monitoring_dataset_service.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ def worker
1818

1919
# step 3 start
2020
monitor_api = DocuSign_Monitor::DataSetApi.new(api_client)
21-
@response = monitor_api.get_stream(args[:data_set_name], args[:version]).data
21+
begin
22+
@response = monitor_api.get_stream(args[:data_set_name], args[:version]).data
23+
# step 3 end
24+
rescue
25+
# error, probalby no Monitor enabled
26+
@response = "Monitor not enabled"
27+
else
28+
Rails.logger.info "Responses for loops are displayed here. Only the final loop is displayed on the response page"
29+
Rails.logger.info @response.inspect
30+
ensure
31+
return @response
32+
end
2233

23-
# step 3 end
24-
25-
Rails.logger.info "Responses for loops are displayed here. Only the final loop is displayed on the response page"
26-
Rails.logger.info @response.inspect
27-
28-
return @response
2934
end
3035
end

app/services/monitor_api/eg002_post_web_query_service.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ def worker
1818

1919
# step 3 start
2020
monitor_api = DocuSign_Monitor::DataSetApi.new(api_client)
21-
@response = monitor_api.post_web_query(args[:data_set_name], args[:version], get_query)
22-
23-
# step 3 end
24-
25-
Rails.logger.info "Responses for loops are displayed here. Only the final loop is displayed on the response page"
26-
Rails.logger.info @response.inspect
27-
28-
return @response
21+
begin
22+
@response = monitor_api.post_web_query(args[:data_set_name], args[:version], get_query)
23+
# step 3 end
24+
rescue
25+
# error, probalby no Monitor enabled
26+
@response = "Monitor not enabled"
27+
else
28+
Rails.logger.info "Responses for loops are displayed here. Only the final loop is displayed on the response page"
29+
Rails.logger.info @response.inspect
30+
ensure
31+
return @response
32+
end
2933
end
3034

3135
def get_query

0 commit comments

Comments
 (0)