Skip to content

Commit 7a50747

Browse files
refactored code
2 parents 91205b0 + e940b78 commit 7a50747

File tree

122 files changed

+1779
-2314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1779
-2314
lines changed

Gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
source 'https://rubygems.org'
44
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

6-
ruby '~>2.7.2'
6+
ruby '~>3.0.2'
77

88
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
99
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.9'
13+
gem 'puma', '~> 4.3.11'
1414
# Use SCSS for stylesheets
1515
gem 'sass-rails', '~> 6.0.0'
1616
# Use Uglifier as compressor for JavaScript assets
@@ -49,7 +49,7 @@ end
4949

5050
group :development do
5151
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
52-
gem 'listen', '~> 3.2.1'
52+
gem 'listen', '> 3.2.1'
5353
gem 'web-console', '~> 4.0.1'
5454
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
5555
gem 'pry-nav', '~> 0.3.0'
@@ -77,3 +77,5 @@ gem 'omniauth-rails_csrf_protection'
7777
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
7878
gem 'tzinfo-data', '~> 1.2019.3', platforms: %i[mingw mswin x64_mingw jruby]
7979
gem 'wdm', '>= 0.1.0', platforms: %i[mingw mswin x64_mingw]
80+
81+
gem "webrick", "~> 1.7"

Gemfile.lock

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ GEM
113113
jwt (~> 2.2, >= 2.2.1)
114114
typhoeus (~> 1.0, >= 1.0.1)
115115
erubi (1.10.0)
116-
ethon (0.15.0)
116+
ethon (0.14.0)
117117
ffi (>= 1.15.0)
118118
execjs (2.8.1)
119119
faraday (1.9.3)
@@ -140,6 +140,7 @@ GEM
140140
faraday-rack (1.0.0)
141141
faraday-retry (1.0.3)
142142
ffi (1.15.5)
143+
ffi (1.15.5-x64-mingw32)
143144
globalid (1.0.0)
144145
activesupport (>= 5.0)
145146
hashie (5.0.0)
@@ -148,17 +149,17 @@ GEM
148149
io-like (0.3.1)
149150
jbuilder (2.10.2)
150151
activesupport (>= 5.0.0)
151-
json (2.6.1)
152-
jwt (2.3.0)
153-
listen (3.2.1)
152+
json (2.5.1)
153+
jwt (2.2.3)
154+
listen (3.7.0)
154155
rb-fsevent (~> 0.10, >= 0.10.3)
155156
rb-inotify (~> 0.9, >= 0.9.10)
156157
loofah (2.13.0)
157158
crass (~> 1.0.2)
158159
nokogiri (>= 1.5.9)
159160
mail (2.7.1)
160161
mini_mime (>= 0.1.1)
161-
marcel (1.0.2)
162+
marcel (1.0.1)
162163
method_source (0.9.2)
163164
mini_mime (1.1.2)
164165
minitest (5.15.0)
@@ -167,6 +168,8 @@ GEM
167168
multi_xml (0.6.0)
168169
multipart-post (2.1.1)
169170
nio4r (2.5.8)
171+
nokogiri (1.13.1-x64-mingw32)
172+
racc (~> 1.4)
170173
nokogiri (1.13.1-x86_64-darwin)
171174
racc (~> 1.4)
172175
nokogiri (1.13.1-x86_64-linux)
@@ -181,7 +184,7 @@ GEM
181184
hashie (>= 3.4.6)
182185
rack (>= 1.6.2, < 3)
183186
rack-protection
184-
omniauth-oauth2 (1.7.2)
187+
omniauth-oauth2 (1.7.1)
185188
oauth2 (~> 1.4)
186189
omniauth (>= 1.9, < 3)
187190
omniauth-rails_csrf_protection (1.0.0)
@@ -195,9 +198,9 @@ GEM
195198
pry-rails (0.3.9)
196199
pry (>= 0.10.4)
197200
public_suffix (4.0.6)
198-
puma (4.3.10)
201+
puma (4.3.11)
199202
nio4r (~> 2.0)
200-
racc (1.6.0)
203+
racc (1.5.2)
201204
rack (2.2.3)
202205
rack-protection (2.1.0)
203206
rack
@@ -240,6 +243,8 @@ GEM
240243
sassc-rails (~> 2.1, >= 2.1.1)
241244
sassc (2.4.0)
242245
ffi (~> 1.9)
246+
sassc (2.4.0-x64-mingw32)
247+
ffi (~> 1.9)
243248
sassc-rails (2.1.2)
244249
railties (>= 4.0.0)
245250
sassc (>= 2.0)
@@ -271,13 +276,17 @@ GEM
271276
ethon (>= 0.9.0)
272277
tzinfo (1.2.9)
273278
thread_safe (~> 0.1)
279+
tzinfo-data (1.2019.3)
280+
tzinfo (>= 1.0.0)
274281
uglifier (4.2.0)
275282
execjs (>= 0.3.0, < 3)
283+
wdm (0.1.1)
276284
web-console (4.0.4)
277285
actionview (>= 6.0.0)
278286
activemodel (>= 6.0.0)
279287
bindex (>= 0.4.0)
280288
railties (>= 6.0.0)
289+
webrick (1.7.0)
281290
websocket-driver (0.7.5)
282291
websocket-extensions (>= 0.1.0)
283292
websocket-extensions (0.1.5)
@@ -286,6 +295,7 @@ GEM
286295
zeitwerk (2.5.3)
287296

288297
PLATFORMS
298+
x64-mingw32
289299
x86_64-darwin-20
290300
x86_64-linux
291301

@@ -301,12 +311,12 @@ DEPENDENCIES
301311
docusign_monitor (~> 1.0.0)
302312
docusign_rooms (~> 1.2.0.rc1)
303313
jbuilder (~> 2.10.0)
304-
listen (~> 3.2.1)
314+
listen (> 3.2.1)
305315
omniauth-oauth2 (~> 1.7.1)
306316
omniauth-rails_csrf_protection
307317
pry-nav (~> 0.3.0)
308318
pry-rails (~> 0.3.9)
309-
puma (~> 4.3.9)
319+
puma (~> 4.3.11)
310320
rails (~> 6.0.4.1)
311321
sass-rails (~> 6.0.0)
312322
selenium-webdriver (~> 3.142.7)
@@ -318,9 +328,10 @@ DEPENDENCIES
318328
uglifier (~> 4.2.0)
319329
wdm (>= 0.1.0)
320330
web-console (~> 4.0.1)
331+
webrick (~> 1.7)
321332

322333
RUBY VERSION
323-
ruby 2.7.2p137
334+
ruby 3.0.2p107
324335

325336
BUNDLED WITH
326-
2.2.16
337+
2.2.31

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ For a list of code examples that use the Admin API, select the Ruby tab under [E
6161

6262
To use [Authorization Code Grant](https://developers.docusign.com/platform/auth/authcode/), you will need an integration key and a secret key. See [Installation steps](#installation-steps) for details.
6363

64-
To use [JWT Grant](https://developers.docusign.com/platform/auth/jwt/), you will need an integration key, an RSA key pair, and the API Username GUID of the impersonated user. See [Installation steps for JWT Grant authentication](#installation-steps-for-jwt-grant-authentication) for details.
64+
To use [JWT Grant](https://developers.docusign.com/platform/auth/jwt/), you will need an integration key, an RSA key pair, and the User ID GUID of the impersonated user. See [Installation steps for JWT Grant authentication](#installation-steps-for-jwt-grant-authentication) for details.
6565

6666
For both authentication flows:
6767

@@ -110,7 +110,7 @@ Also, in order to select JSON Web Token authentication in the launcher, in confi
110110
`cd <Quickstart folder>` or `cd code-examples-ruby`
111111
1. Install the dependencies: `bundler install`
112112
1. To configure the launcher for [JWT Grant](https://developers.docusign.com/platform/auth/jwt/) authentication, create a copy of the file config/appsettings.example.yml and save the copy as config/appsettings.yml.
113-
1. Add your API Username. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **API Username** GUID and save it in appsettings.yml as your `impersonated_user_guid`.
113+
1. Add your User ID. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **User ID** GUID and save it in appsettings.yml as your `impersonated_user_guid`.
114114
1. Add your integration key. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **Apps and Integration Keys**, choose the app to use, then select **Actions** > **Edit**. Under **General Info**, copy the **Integration Key** GUID and save it in appsettings.yml as your `jwt_integration_key`.
115115
1. Generate an RSA key pair, if you don’t already have one. Under **Authentication**, select **+ GENERATE RSA**. Copy the private key and save it in a new file named config/docusign_private_key.txt.
116116
1. Add the launcher’s redirect URI. Under **Additional settings**, select **+ ADD URI**, and set a redirect URI of http://localhost:3000/auth/docusign/callback. Select **SAVE**.

app/assets/images/favicon.ico

25.3 KB
Binary file not shown.

app/controllers/admin_api/eg001_create_user_controller.rb

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,42 @@ class AdminApi::Eg001CreateUserController < EgController
44

55
def create
66
begin
7-
results = AdminApi::Eg001CreateUserService.new(session, request).call
7+
args = {
8+
account_id: session['ds_account_id'],
9+
base_path: session['ds_base_path'],
10+
access_token: session['ds_access_token'],
11+
organization_id: session['organization_id']
12+
}
13+
user_data = {
14+
user_name: param_gsub(params['user_name']),
15+
first_name: param_gsub(params['first_name']),
16+
last_name: param_gsub(params['last_name']),
17+
email: param_gsub(params['email']),
18+
auto_activate_memberships: true,
19+
accounts: [
20+
{
21+
id: args[:account_id],
22+
permission_profile: {
23+
id: request['permission_profile_id']
24+
},
25+
groups: [
26+
{
27+
id: request['group_id']
28+
}
29+
]
30+
}
31+
]
32+
}
33+
34+
results = AdminApi::Eg001CreateUserService.new(args, user_data).worker
835

936
@title = 'Create a new active eSignature user'
1037
@h1 = 'Create a new active eSignature user'
1138
@message = "Results from eSignUserManagement:createUser method:"
1239
@json = results.to_json.to_json
1340
render 'ds_common/example_done'
1441
rescue DocuSign_Admin::ApiError => e
15-
error = JSON.parse e.response_body
16-
@error_code = e.code
17-
@error_message = error['error_description']
18-
render 'ds_common/error'
42+
handle_error(e)
1943
end
2044
end
2145

@@ -37,14 +61,4 @@ def get
3761
@groups = groups_api.list_groups(args[:account_id]).groups
3862
end
3963

40-
private
41-
42-
def check_auth
43-
minimum_buffer_min = 10
44-
token_ok = check_token(minimum_buffer_min)
45-
unless token_ok
46-
flash[:messages] = 'Sorry, you need to re-authenticate.'
47-
redirect_to '/ds/mustAuthenticate'
48-
end
49-
end
5064
end

app/controllers/admin_api/eg002_create_active_clm_esign_user_controller.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,23 @@ class AdminApi::Eg002CreateActiveClmEsignUserController < EgController
33

44
def create
55
begin
6-
results = AdminApi::Eg002CreateActiveClmEsignUserService.new(session, request).call
6+
args = {
7+
user_name: params[:user_name],
8+
first_name: params[:first_name],
9+
last_name: params[:last_name],
10+
email: params[:email],
11+
clm_permission_profile_id: params[:clm_permission_profile_id],
12+
esign_permission_profile_id: params[:esign_permission_profile_id],
13+
clm_product_id: params[:clm_product_id],
14+
esign_product_id: params[:esign_product_id],
15+
ds_group_id: params[:ds_group_id],
16+
account_id: session[:ds_account_id],
17+
organization_id: session['organization_id'],
18+
base_path: session[:ds_base_path],
19+
access_token: session[:ds_access_token]
20+
}
21+
22+
results = AdminApi::Eg002CreateActiveClmEsignUserService.new(args).worker
723

824
@title = "Create a new active user for CLM and eSignature"
925
@h1 = "Create a new active user for CLM and eSignature"
@@ -12,10 +28,7 @@ def create
1228

1329
render 'ds_common/example_done'
1430
rescue DocuSign_Admin::ApiError => e
15-
error = JSON.parse e.response_body
16-
@error_code = e.code
17-
@error_message = error['error_description']
18-
render 'ds_common/error'
31+
handle_error(e)
1932
end
2033
end
2134

@@ -37,17 +50,4 @@ def get
3750
end
3851
@ds_groups = AdminApi::GetDataService.new(session).get_ds_groups
3952
end
40-
41-
private
42-
43-
def check_auth
44-
minimum_buffer_min = 10
45-
token_ok = check_token(minimum_buffer_min)
46-
unless token_ok
47-
flash[:messages] = 'Sorry, you need to re-authenticate.'
48-
# We could store the parameters of the requested operation so it could be restarted automatically
49-
# But since it should be rare to have a token issue here, we'll make the user re-enter the form data after authentication
50-
redirect_to '/ds/mustAuthenticate'
51-
end
52-
end
5353
end

app/controllers/admin_api/eg003_bulk_export_user_data_controller.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,27 @@ def create
99
file_path = File.expand_path(File.join(File.dirname(__FILE__), '../../../data/exportedUserData.csv'))
1010

1111
begin
12-
results = AdminApi::Eg003BulkExportUserDataService.new(session, request, file_path).call
12+
request_body = {
13+
type: 'organization_memberships_export'
14+
}
15+
args = {
16+
account_id: session['ds_account_id'],
17+
base_path: session['ds_base_path'],
18+
access_token: session['ds_access_token'],
19+
organization_id: session['organization_id'],
20+
file_path: file_path,
21+
request_body: request_body
22+
}
23+
24+
results = AdminApi::Eg003BulkExportUserDataService.new(args).worker
1325

1426
@title = 'Bulk-export user data'
1527
@h1 = 'Bulk-export user data'
1628
@message = "User data exported to #{file_path}. </br> Results from UserExport::getUserListExport method:"
1729
@json = results.to_json.to_json
1830
render 'ds_common/example_done'
1931
rescue DocuSign_Admin::ApiError => e
20-
error = JSON.parse e.response_body
21-
@error_code = e.code
22-
@error_message = error['error_description']
23-
render 'ds_common/error'
24-
end
25-
end
26-
27-
private
28-
29-
def check_auth
30-
minimum_buffer_min = 10
31-
token_ok = check_token(minimum_buffer_min)
32-
unless token_ok
33-
flash[:messages] = 'Sorry, you need to re-authenticate.'
34-
redirect_to '/ds/mustAuthenticate'
32+
handle_error(e)
3533
end
3634
end
3735
end

app/controllers/admin_api/eg004_import_user_controller.rb

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ def create
99
file_path = File.expand_path(File.join(File.dirname(__FILE__), '../../../data/userData.csv'))
1010

1111
begin
12-
results = AdminApi::Eg004ImportUserService.new(session, request, file_path).call
12+
args = {
13+
account_id: session['ds_account_id'],
14+
base_path: session['ds_base_path'],
15+
access_token: session['ds_access_token'],
16+
organization_id: session['organization_id'],
17+
csv_file_path: file_path
18+
}
19+
20+
results = AdminApi::Eg004ImportUserService.new(args).worker
1321
session[:import_id] = results.id
1422

1523
@title = 'Add users via bulk import'
@@ -19,10 +27,7 @@ def create
1927
@json = results.to_json.to_json
2028
render 'ds_common/example_done'
2129
rescue DocuSign_Admin::ApiError => e
22-
error = JSON.parse e.response_body
23-
@error_code = e.code
24-
@error_message = error['error_description']
25-
render 'ds_common/error'
30+
handle_error(e)
2631
end
2732
end
2833

@@ -48,15 +53,4 @@ def check_status
4853
render 'ds_common/error'
4954
end
5055
end
51-
52-
private
53-
54-
def check_auth
55-
minimum_buffer_min = 10
56-
token_ok = check_token(minimum_buffer_min)
57-
unless token_ok
58-
flash[:messages] = 'Sorry, you need to re-authenticate.'
59-
redirect_to '/ds/mustAuthenticate'
60-
end
61-
end
6256
end

0 commit comments

Comments
 (0)