Skip to content

Commit 50f1ff4

Browse files
Merge branch 'master' of github.com:docusign/code-examples-ruby-private
2 parents 3fca121 + 694f066 commit 50f1ff4

File tree

10 files changed

+179
-13
lines changed

10 files changed

+179
-13
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gem 'rails', '~> 6.0.4.1'
1010
# Use sqlite3 as the database for Active Record
1111
gem 'sqlite3', '~> 1.4.2'
1212
# Use Puma as the app server
13-
gem 'puma', '~> 4.3.11'
13+
gem 'puma', '~> 4.3.12'
1414
# Use SCSS for stylesheets
1515
gem 'sass-rails', '~> 6.0.0'
1616
# Use Uglifier as compressor for JavaScript assets

Gemfile.lock

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ GEM
8787
coffee-script-source (1.12.2)
8888
concurrent-ruby (1.1.9)
8989
crass (1.0.6)
90-
docusign_admin (1.0.0)
90+
docusign_admin (1.1.0)
9191
addressable (~> 2.7, >= 2.7.0)
9292
json (~> 2.1, >= 2.1.0)
9393
jwt (~> 2.2, >= 2.2.1)
@@ -97,7 +97,7 @@ 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.15.0)
100+
docusign_esign (3.17.0)
101101
addressable (~> 2.7, >= 2.7.0)
102102
json (~> 2.1, >= 2.1.0)
103103
jwt (~> 2.2, >= 2.2.1)
@@ -168,11 +168,11 @@ GEM
168168
multi_xml (0.6.0)
169169
multipart-post (2.1.1)
170170
nio4r (2.5.8)
171-
nokogiri (1.13.1-x64-mingw32)
171+
nokogiri (1.13.6-x64-mingw32)
172172
racc (~> 1.4)
173-
nokogiri (1.13.1-x86_64-darwin)
173+
nokogiri (1.13.6-x86_64-darwin)
174174
racc (~> 1.4)
175-
nokogiri (1.13.1-x86_64-linux)
175+
nokogiri (1.13.6-x86_64-linux)
176176
racc (~> 1.4)
177177
oauth2 (1.4.7)
178178
faraday (>= 0.8, < 2.0)
@@ -198,9 +198,9 @@ GEM
198198
pry-rails (0.3.9)
199199
pry (>= 0.10.4)
200200
public_suffix (4.0.6)
201-
puma (4.3.11)
201+
puma (4.3.12)
202202
nio4r (~> 2.0)
203-
racc (1.5.2)
203+
racc (1.6.0)
204204
rack (2.2.3)
205205
rack-protection (2.1.0)
206206
rack
@@ -297,6 +297,7 @@ GEM
297297
PLATFORMS
298298
x64-mingw32
299299
x86_64-darwin-20
300+
x86_64-darwin-21
300301
x86_64-linux
301302

302303
DEPENDENCIES
@@ -305,9 +306,9 @@ DEPENDENCIES
305306
capybara (~> 3.31.0)
306307
chromedriver-helper (~> 2.1.1)
307308
coffee-rails (~> 5.0.0)
308-
docusign_admin (~> 1.0.0)
309+
docusign_admin (~> 1.1.0)
309310
docusign_click (~> 1.0.0)
310-
docusign_esign (~> 3.15.0)
311+
docusign_esign (~> 3.17.0)
311312
docusign_monitor (~> 1.1.0)
312313
docusign_rooms (~> 1.2.0.rc1)
313314
jbuilder (~> 2.10.0)
@@ -316,7 +317,7 @@ DEPENDENCIES
316317
omniauth-rails_csrf_protection
317318
pry-nav (~> 0.3.0)
318319
pry-rails (~> 0.3.9)
319-
puma (~> 4.3.11)
320+
puma (~> 4.3.12)
320321
rails (~> 6.0.4.1)
321322
sass-rails (~> 6.0.0)
322323
selenium-webdriver (~> 3.142.7)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class AdminApi::Eg006GetUserProfileByEmailController < EgController
2+
include ApiCreator
3+
before_action :check_auth
4+
5+
def create
6+
begin
7+
if session[:organization_id].nil?
8+
session[:organization_id] = AdminApi::GetDataService.new(session).get_organization_id
9+
end
10+
11+
args = {
12+
access_token: session['ds_access_token'],
13+
organization_id: session['organization_id'],
14+
email: param_gsub(params['email'])
15+
}
16+
17+
results = AdminApi::Eg006GetUserProfileByEmailService.new(args).worker
18+
19+
@title = 'Retrieve the user’s DocuSign profile using an email address'
20+
@h1 = 'Retrieve the user’s DocuSign profile using an email address'
21+
@message = "Results from MultiProductUserManagement:getUserDSProfilesByEmail method:"
22+
@json = results.to_json.to_json
23+
render 'ds_common/example_done'
24+
rescue DocuSign_Admin::ApiError => e
25+
handle_error(e)
26+
end
27+
end
28+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class AdminApi::Eg007GetUserProfileByUserIdController < EgController
2+
include ApiCreator
3+
before_action :check_auth
4+
5+
def create
6+
begin
7+
if session[:organization_id].nil?
8+
session[:organization_id] = AdminApi::GetDataService.new(session).get_organization_id
9+
end
10+
11+
args = {
12+
access_token: session['ds_access_token'],
13+
organization_id: session['organization_id'],
14+
user_id: param_gsub(params['user_id'])
15+
}
16+
17+
results = AdminApi::Eg007GetUserProfileByUserIdService.new(args).worker
18+
19+
@title = 'Retrieve the user’s DocuSign profile using a User ID'
20+
@h1 = 'Retrieve the user’s DocuSign profile using a User ID'
21+
@message = "Results from MultiProductUserManagement:getUserDSProfile method:"
22+
@json = results.to_json.to_json
23+
render 'ds_common/example_done'
24+
rescue DocuSign_Admin::ApiError => e
25+
handle_error(e)
26+
end
27+
end
28+
end
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# frozen_string_literal: true
2+
3+
class AdminApi::Eg006GetUserProfileByEmailService
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_Admin::Configuration.new
13+
configuration.host = Rails.configuration.admin_host
14+
15+
api_client = DocuSign_Admin::ApiClient.new(configuration)
16+
api_client.set_default_header("Authorization", "Bearer #{args[:access_token]}")
17+
# Step 2 end
18+
19+
# Step 3 start
20+
users_api = DocuSign_Admin::UsersApi.new(api_client)
21+
22+
options = DocuSign_Admin::GetUserDSProfilesByEmailOptions.new
23+
options.email = args[:email]
24+
response = users_api.get_user_ds_profiles_by_email(args[:organization_id], options)
25+
# Step 3 end
26+
end
27+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
class AdminApi::Eg007GetUserProfileByUserIdService
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_Admin::Configuration.new
13+
configuration.host = Rails.configuration.admin_host
14+
15+
api_client = DocuSign_Admin::ApiClient.new(configuration)
16+
api_client.set_default_header("Authorization", "Bearer #{args[:access_token]}")
17+
# Step 2 end
18+
19+
# Step 3 start
20+
users_api = DocuSign_Admin::UsersApi.new(api_client)
21+
response = users_api.get_user_ds_profile(args[:organization_id], args[:user_id])
22+
# Step 3 end
23+
end
24+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<h4>6. Retrieve the user's DocuSign profile using an email address</h4>
2+
<p>Demonstrates how to obtain the user’s DocuSign profile information across all DocuSign accounts by specifying the user’s email address.</p>
3+
4+
<p>API method used:
5+
<a target="_blank" rel='noopener noreferrer'
6+
href="https://developers.docusign.com/docs/admin-api/reference/usermanagement/multiproductusermanagement/getuserdsprofilesbyemail/">MultiProductUserManagement:getUserDSProfilesByEmail.</a>
7+
</p>
8+
9+
<p>
10+
View source file <a target="_blank" href="<%= @source_url %>"><%= @source_file %></a> on GitHub.
11+
</p>
12+
13+
<form class="eg" action="" method="post" data-busy="form">
14+
<div class="form-group">
15+
<label for="email">Email address</label>
16+
<input type="email" class="form-control" id="email" name="email"
17+
aria-describedby="emailHelp" required>
18+
<small id="emailHelp" class="form-text text-muted">We will never share your email with anyone else.</small>
19+
</div>
20+
<button type="submit" class="btn btn-docu">Submit</button>
21+
</form>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<h4>7. Retrieve the user's DocuSign profile using a User ID</h4>
2+
<p>Demonstrates how to obtain the user’s DocuSign profile information across all DocuSign accounts by specifying the user’s User ID.</p>
3+
4+
<p>API method used:
5+
<a target="_blank" rel='noopener noreferrer'
6+
href="https://developers.docusign.com/docs/admin-api/reference/usermanagement/multiproductusermanagement/getuserdsprofile/">MultiProductUserManagement:getUserDSProfile.</a>
7+
</p>
8+
9+
<form class="eg" action="" method="post" data-busy="form">
10+
<div class="form-group">
11+
<label for="user_id">User ID</label>
12+
<input type="text" class="form-control" id="user_id" name="user_id"
13+
placeholder="00000000-0000-0000-0000-000000000000" required
14+
pattern="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}">
15+
</div>
16+
<button type="submit" class="btn btn-docu">Submit</button>
17+
</form>

app/views/admin_api/index.html.erb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
<p><a target='_blank' href='<%= :documentation %>'>Documentation</a> on using JWT Grant or Authorization Code Grant from a Ruby on Rails application.</p>
2222
<% end %>
2323

24-
<h2>DocuSign Admin API Code Examples</h2>
25-
2624
<h4 id="create_active_esignature_user">1. <a href="eg001">Create a new active eSignature user</a></h4>
2725
<p>
2826
Demonstrates how to create a new eSignature user and activate their account automatically.</p>
@@ -85,6 +83,22 @@
8583
href="https://developers.docusign.com/docs/admin-api/reference/usermanagement/esignusermanagement/getuserprofiles/">eSignUserManagement:getUserProfiles</a>
8684
</p>
8785

86+
<h4 id="get_user_ds_profiles_by_email">6. <a href="eg006">Retrieve the user's DocuSign profile using an email address</a></h4>
87+
<p>Demonstrates how to obtain the user’s DocuSign profile information across all DocuSign accounts by specifying the user’s email address.</p>
88+
89+
<p>API method used:
90+
<a target="_blank" rel='noopener noreferrer'
91+
href="https://developers.docusign.com/docs/admin-api/reference/usermanagement/multiproductusermanagement/getuserdsprofilesbyemail/">MultiProductUserManagement:getUserDSProfilesByEmail</a>
92+
</p>
93+
94+
<h4 id="eg007_get_user_profile_by_user_id">7. <a href="eg007">Retrieve the user's DocuSign profile using a User ID</a></h4>
95+
<p>Demonstrates how to obtain the user’s DocuSign profile information across all DocuSign accounts by specifying the user’s User ID.</p>
96+
97+
<p>API method used:
98+
<a target="_blank" rel='noopener noreferrer'
99+
href="https://developers.docusign.com/docs/admin-api/reference/usermanagement/multiproductusermanagement/getuserdsprofile/">MultiProductUserManagement:getUserDSProfile</a>
100+
</p>
101+
88102
</div>
89103
<!-- anchor-js is only for the index page -->
90104
<script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/4.1.1/anchor.min.js"></script>

config/routes.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@
7575

7676
get 'eg005' => 'eg005_audit_users#get'
7777
post 'eg005' => 'eg005_audit_users#create'
78+
79+
get 'eg006' => 'eg006_get_user_profile_by_email#get'
80+
post 'eg006' => 'eg006_get_user_profile_by_email#create'
81+
82+
get 'eg007' => 'eg007_get_user_profile_by_user_id#get'
83+
post 'eg007' => 'eg007_get_user_profile_by_user_id#create'
7884
end
7985
end
8086
constraints lambda { |req| req.session[:examples_API] == "eSignature" } do

0 commit comments

Comments
 (0)