Skip to content

Commit c20f76f

Browse files
Merge branch 'master' of github.com:docusign/code-examples-ruby-private
2 parents 361fa1c + 73b5e34 commit c20f76f

File tree

9 files changed

+125
-12
lines changed

9 files changed

+125
-12
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ group :test do
6767
end
6868

6969
gem 'docusign_esign', '~> 3.15.0'
70-
gem 'docusign_monitor', '~> 1.0.0'
70+
gem 'docusign_monitor', '~> 1.1.0'
7171
gem 'docusign_rooms', '~> 1.2.0.rc1'
7272
gem 'docusign_click', '~> 1.0.0'
7373
gem 'docusign_admin', '~> 1.0.0'

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ GEM
9797
json (~> 2.1, >= 2.1.0)
9898
jwt (~> 2.2, >= 2.2.1)
9999
typhoeus (~> 1.0, >= 1.0.1)
100-
docusign_esign (3.14.0)
100+
docusign_esign (3.15.0)
101101
addressable (~> 2.7, >= 2.7.0)
102102
json (~> 2.1, >= 2.1.0)
103103
jwt (~> 2.2, >= 2.2.1)
104104
typhoeus (~> 1.0, >= 1.0.1)
105-
docusign_monitor (1.0.0)
105+
docusign_monitor (1.1.0)
106106
addressable (~> 2.7, >= 2.7.0)
107107
json (~> 2.1, >= 2.1.0)
108108
jwt (~> 2.2, >= 2.2.1)
@@ -307,8 +307,8 @@ DEPENDENCIES
307307
coffee-rails (~> 5.0.0)
308308
docusign_admin (~> 1.0.0)
309309
docusign_click (~> 1.0.0)
310-
docusign_esign (~> 3.14.0)
311-
docusign_monitor (~> 1.0.0)
310+
docusign_esign (~> 3.15.0)
311+
docusign_monitor (~> 1.1.0)
312312
docusign_rooms (~> 1.2.0.rc1)
313313
jbuilder (~> 2.10.0)
314314
listen (> 3.2.1)

app/controllers/monitor_api/eg001_get_monitoring_dataset_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ def create
1010

1111
results = MonitorApi::Eg001GetMonitoringDatasetService.new(args).worker
1212

13-
@title = "Monitoring data result"
14-
@h1 = "Monitoring data result"
15-
@message = "Results from DataSet:GetStreamForDataset method:"
13+
@title = "Get monitoring data"
14+
@h1 = "Get monitoring data"
15+
@message = "Results from DataSet:getStream method:"
1616
@json = results.to_json.to_json
1717

1818
render 'ds_common/example_done'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class MonitorApi::Eg002PostWebQueryController < EgController
2+
before_action :check_auth
3+
4+
def create
5+
args = {
6+
access_token: session[:ds_access_token],
7+
data_set_name: 'monitor',
8+
account_id: session['ds_account_id'],
9+
version: '2.0',
10+
start_date: params[:start_date],
11+
end_date: params[:end_date]
12+
}
13+
14+
results = MonitorApi::Eg002PostWebQueryService.new(args).worker
15+
16+
@title = "Query monitoring data with filters"
17+
@h1 = "Query monitoring data with filters"
18+
@message = "Results from DataSet:postWebQuery method:"
19+
@json = results.to_json.to_json
20+
21+
render 'ds_common/example_done'
22+
end
23+
end
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# frozen_string_literal: true
2+
3+
class MonitorApi::Eg002PostWebQueryService
4+
attr_reader :args
5+
6+
def initialize(args)
7+
@args = args
8+
end
9+
10+
def worker
11+
# step 2 start
12+
configuration = DocuSign_Monitor::Configuration.new
13+
configuration.host = Rails.configuration.monitor_host
14+
configuration.debugging = true
15+
api_client = DocuSign_Monitor::ApiClient.new configuration
16+
api_client.set_default_header('Authorization', "Bearer #{args[:access_token]}")
17+
# step 2 end
18+
19+
# step 3 start
20+
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
29+
end
30+
31+
def get_query
32+
return {
33+
"filters": [
34+
{
35+
"FilterName": "Time",
36+
"BeginTime": args[:start_date],
37+
"EndTime": args[:end_date]
38+
},
39+
{
40+
"FilterName": "Has",
41+
"ColumnName": "AccountId",
42+
"Value": args[:account_id]
43+
}
44+
],
45+
"aggregations": [
46+
{
47+
"aggregationName": "Raw",
48+
"limit": "1",
49+
"orderby": [
50+
"Timestamp, desc"
51+
]
52+
}
53+
]
54+
}
55+
end
56+
end

app/views/.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<h4>2. Query monitoring data with filters</h4>
2+
<p>Demonstrates how to query an organization's data based on specified filters and aggregations.</p>
3+
4+
<p>API method used:
5+
<a target='_blank' href="https://developers.docusign.com/docs/monitor-api/reference/monitor/dataset/postwebquery/">DataSet:postWebQuery</a>.
6+
</p>
7+
8+
<p>
9+
View source file <a target="_blank" href="<%= @source_url %>"><%= @source_file %></a> on GitHub.
10+
</p>
11+
12+
<p>
13+
Please select start and end dates.
14+
</p>
15+
<form class="eg" action="" method="post" data-busy="form">
16+
<div class="form-group">
17+
<label for="start_date">Start date</label>
18+
<input type="date" class="form-control" id="start_date" name="start_date" value=<%= Time.now - 10.days %> max=<%= Time.now %>>
19+
</div>
20+
<div class="form-group">
21+
<label for="end_date">End date</label>
22+
<input type="date" class="form-control" id="end_date" name="end_date" value=<%= Time.now %> max=<%= Time.now %>>
23+
</div>
24+
<button type="submit" class="btn btn-docu">Continue</button>
25+
</form>

app/views/monitor_api/index.html.erb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<tr>
66
<td>
77
<h1 class="display-4">Ruby Launcher</h1>
8-
<p class="Xlead">Welcome to the Ruby code examples for DocuSign Monitor API with JWT Grant authentication</p>
8+
<p class="Xlead">Run and explore Monitor API code examples with JWT Grant authentication</p>
99
</td>
1010
<td>
1111
<img src="banner-code.png" />
@@ -22,8 +22,6 @@
2222
<p><a target='_blank' href='<%= :documentation %>'>Documentation</a> on using JWT Authorization from a Ruby Rails application.</p>
2323
<% end %>
2424

25-
<h2>Monitor API Code examples</h2>
26-
2725
<h4 id="get_stream_for_dataset">1. <a href="eg001">Get monitoring data</a></h4>
2826
<p>
2927
Demonstrates how to get and display all of your organization’s monitoring data.
@@ -33,7 +31,16 @@
3331
<a target='_blank' href="https://developers.docusign.com/docs/monitor-api/reference/monitor/dataset/getstream/">DataSet:GetStream</a>
3432
</p>
3533

34+
<h4 id="post_web_query">2. <a href="eg002">Query monitoring data with filters</a></h4>
35+
<p>
36+
Demonstrates how to query an organization's data based on specified filters and aggregations.
37+
</p>
38+
<p>
39+
API method used:
40+
<a target='_blank' href="https://developers.docusign.com/docs/monitor-api/reference/monitor/dataset/postwebquery/">DataSet:postWebQuery</a>.
41+
</p>
42+
3643
</div>
3744
<!-- anchor-js is only for the index page -->
3845
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.1.1/anchor.min.js"></script>
39-
<script>anchors.options.placement = 'left'; anchors.add('h4')</script>
46+
<script>anchors.options.placement = 'left'; anchors.add('h4')</script>

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
scope module: 'monitor_api' do
5555
get 'eg001' => 'eg001_get_monitoring_dataset#get'
5656
post 'eg001' => 'eg001_get_monitoring_dataset#create'
57+
get 'eg002' => 'eg002_post_web_query#get'
58+
post 'eg002' => 'eg002_post_web_query#create'
5759
end
5860
end
5961
constraints lambda { |req| req.session[:examples_API] == "Admin" } do

0 commit comments

Comments
 (0)