Skip to content

Commit c3471bb

Browse files
add example
1 parent 0d081c2 commit c3471bb

File tree

8 files changed

+226
-82
lines changed

8 files changed

+226
-82
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# frozen_string_literal: true
2+
3+
class ESign::Eeg045DeleteRestoreEnvelopeController < EgController
4+
before_action -> { check_auth('eSignature') }
5+
before_action -> { @example = Utils::ManifestUtils.new.get_example(@manifest, 45, 'eSignature') }
6+
7+
DELETE_FOLDER_ID = 'recyclebin'
8+
RESTORE_FOLDER_ID = 'sentitems'
9+
10+
def delete_envelope
11+
args = {
12+
account_id: session['ds_account_id'],
13+
base_path: session['ds_base_path'],
14+
access_token: session['ds_access_token'],
15+
envelope_id: param_gsub(params['envelope_id']),
16+
folder_id: DELETE_FOLDER_ID
17+
}
18+
19+
delete_restore_envelope_service = ESign::Eg045DeleteRestoreEnvelopeService.new(args)
20+
21+
delete_restore_envelope_service.move_envelope
22+
23+
session[:envelope_id] = args[:envelope_id]
24+
additional_page_data = @example['AdditionalPage'].find { |p| p['Name'] == 'envelope_is_deleted' }
25+
@title = @example['ExampleName']
26+
@message = additional_page_data['ResultsPageText']
27+
@redirect_url = "/#{session[:eg]}restore"
28+
29+
render 'ds_common/example_done'
30+
end
31+
32+
def restore_envelope
33+
args = {
34+
account_id: session['ds_account_id'],
35+
base_path: session['ds_base_path'],
36+
access_token: session['ds_access_token'],
37+
envelope_id: param_gsub(session[:envelope_id]),
38+
folder_id: RESTORE_FOLDER_ID,
39+
from_folder_id: DELETE_FOLDER_ID
40+
}
41+
42+
delete_restore_envelope_service = ESign::Eg045DeleteRestoreEnvelopeService.new(args)
43+
44+
delete_restore_envelope_service.move_envelope
45+
46+
session[:envelope_id] = args[:envelope_id]
47+
@title = @example['ExampleName']
48+
@message = @example['ResultsPageText']
49+
render 'ds_common/example_done'
50+
end
51+
52+
def get_delete_envelope
53+
get
54+
@envelope_id = session[:envelope_id]
55+
@submit_button_text = @manifest['SupportingTexts']['HelpingTexts']['SubmitButtonDeleteText']
56+
57+
render 'e_sign/eeg045_delete_restore_envelope/delete'
58+
end
59+
60+
def get_restore_envelope
61+
return redirect_to "/#{session[:eg]}" if session[:envelope_id].nil?
62+
63+
get
64+
@envelope_id = session[:envelope_id]
65+
@submit_button_text = @manifest['SupportingTexts']['HelpingTexts']['SubmitButtonRestoreText']
66+
67+
render 'e_sign/eeg045_delete_restore_envelope/restore'
68+
end
69+
end

app/services/api_creator.rb

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,60 @@
1-
# frozen_string_literal: true
2-
3-
module ApiCreator
4-
def create_initial_api_client(host: nil, client_module: DocuSign_eSign, debugging: false)
5-
configuration = client_module::Configuration.new
6-
configuration.debugging = debugging
7-
api_client = client_module::ApiClient.new(configuration)
8-
api_client.set_oauth_base_path(host)
9-
api_client
10-
end
11-
12-
def create_account_api(args)
13-
# Obtain your OAuth token
14-
configuration = DocuSign_eSign::Configuration.new
15-
configuration.host = args[:base_path]
16-
api_client = DocuSign_eSign::ApiClient.new configuration
17-
18-
# Construct your API headers
19-
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
20-
21-
# Construct your request body
22-
DocuSign_eSign::AccountsApi.new api_client
23-
end
24-
25-
def create_template_api(args)
26-
configuration = DocuSign_eSign::Configuration.new
27-
configuration.host = args[:base_path]
28-
api_client = DocuSign_eSign::ApiClient.new configuration
29-
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
30-
DocuSign_eSign::TemplatesApi.new api_client
31-
end
32-
33-
def create_envelope_api(args)
34-
# Obtain your OAuth token
35-
#ds-snippet-start:eSignRubyStep2
36-
configuration = DocuSign_eSign::Configuration.new
37-
configuration.host = args[:base_path]
38-
api_client = DocuSign_eSign::ApiClient.new configuration
39-
40-
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
41-
#ds-snippet-end:eSignRubyStep2
42-
DocuSign_eSign::EnvelopesApi.new api_client
43-
end
44-
45-
def create_group_api(args)
46-
configuration = DocuSign_eSign::Configuration.new
47-
configuration.host = args[:base_path]
48-
api_client = DocuSign_eSign::ApiClient.new configuration
49-
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
50-
DocuSign_eSign::GroupsApi.new api_client
51-
end
52-
end
1+
# frozen_string_literal: true
2+
3+
module ApiCreator
4+
def create_initial_api_client(host: nil, client_module: DocuSign_eSign, debugging: false)
5+
configuration = client_module::Configuration.new
6+
configuration.debugging = debugging
7+
api_client = client_module::ApiClient.new(configuration)
8+
api_client.set_oauth_base_path(host)
9+
api_client
10+
end
11+
12+
def create_account_api(args)
13+
# Obtain your OAuth token
14+
configuration = DocuSign_eSign::Configuration.new
15+
configuration.host = args[:base_path]
16+
api_client = DocuSign_eSign::ApiClient.new configuration
17+
18+
# Construct your API headers
19+
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
20+
21+
# Construct your request body
22+
DocuSign_eSign::AccountsApi.new api_client
23+
end
24+
25+
def create_template_api(args)
26+
configuration = DocuSign_eSign::Configuration.new
27+
configuration.host = args[:base_path]
28+
api_client = DocuSign_eSign::ApiClient.new configuration
29+
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
30+
DocuSign_eSign::TemplatesApi.new api_client
31+
end
32+
33+
def create_envelope_api(args)
34+
# Obtain your OAuth token
35+
#ds-snippet-start:eSignRubyStep2
36+
configuration = DocuSign_eSign::Configuration.new
37+
configuration.host = args[:base_path]
38+
api_client = DocuSign_eSign::ApiClient.new configuration
39+
40+
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
41+
#ds-snippet-end:eSignRubyStep2
42+
DocuSign_eSign::EnvelopesApi.new api_client
43+
end
44+
45+
def create_group_api(args)
46+
configuration = DocuSign_eSign::Configuration.new
47+
configuration.host = args[:base_path]
48+
api_client = DocuSign_eSign::ApiClient.new configuration
49+
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
50+
DocuSign_eSign::GroupsApi.new api_client
51+
end
52+
53+
def create_folders_api(args)
54+
configuration = DocuSign_eSign::Configuration.new
55+
configuration.host = args[:base_path]
56+
api_client = DocuSign_eSign::ApiClient.new configuration
57+
api_client.default_headers['Authorization'] = "Bearer #{args[:access_token]}"
58+
DocuSign_eSign::FoldersApi.new api_client
59+
end
60+
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 ESign::Eg045DeleteRestoreEnvelopeService
4+
attr_reader :args
5+
6+
include ApiCreator
7+
8+
def initialize(args)
9+
@args = args
10+
end
11+
12+
def move_envelope
13+
#ds-snippet-start:eSign45Step2
14+
folders_api = create_folders_api(args)
15+
#ds-snippet-end:eSign45Step2
16+
17+
#ds-snippet-start:eSign45Step3
18+
folders_request = DocuSign_eSign::FoldersRequest.new
19+
folders_request.envelope_ids = [args[:envelope_id]]
20+
folders_request.from_folder_id = args[:from_folder_id] unless args[:from_folder_id].nil?
21+
#ds-snippet-end:eSign45Step3
22+
23+
#ds-snippet-start:eSign45Step4
24+
folders_api.move_envelopes(args[:account_id], args[:folder_id], folders_request)
25+
#ds-snippet-end:eSign45Step4
26+
end
27+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<%= render('partials/example_info') %>
2+
3+
<% form_index = 0 %>
4+
<% envelope_id_index = 0 %>
5+
6+
<form class="eg" action="" method="post" data-busy="form">
7+
<% if @example["Forms"][form_index]["FormName"] %>
8+
<%= sanitize @example["Forms"][form_index]["FormName"] %>
9+
<% end %>
10+
11+
<div class="form-group">
12+
<label for="envelope_id"><%= @example["Forms"][form_index]["Inputs"][envelope_id_index]["InputName"] %></label>
13+
<input type="text" class="form-control" id="envelope_id" name="envelope_id"
14+
aria-describedby="envelope_id_help" value="<%= @envelope_id %>" required
15+
placeholder="<%= @example["Forms"][form_index]["Inputs"][envelope_id_index]["InputPlaceholder"] %>">
16+
<small id="envelope_id_help" class="form-text text-muted"><%= @manifest["SupportingTexts"]["HelpingTexts"]["DefaultEnvelopeId"] %></small>
17+
</div>
18+
19+
<%= render('partials/submit_button') %>
20+
</form>
21+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<h4><%= @example["ExampleName"] %></h4>
2+
<p><%= sanitize @example["ExampleDescription"] %></p>
3+
<%= sanitize format_string(@manifest["SupportingTexts"]["HelpingTexts"]["EnvelopeWillBeRestored"], @envelope_id) %>
4+
5+
<% form_index = 0 %>
6+
7+
<form class="eg" action="" method="post" data-busy="form">
8+
<% if @example["Forms"][form_index]["FormName"] %>
9+
<%= sanitize @example["Forms"][form_index]["FormName"] %>
10+
<% end %>
11+
12+
<%= render('partials/submit_button') %>
13+
</form>
14+
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
<h4><%= @example["ExampleName"] %></h4>
2-
<p><%= sanitize @example["ExampleDescription"] %></p>
3-
4-
<% if @show_doc %>
5-
<p><a target='_blank' href='<%= @documentation %>'>Documentation</a> about this example.</p>
6-
<% end %>
7-
8-
<% if @example["Note"] %>
9-
<%= sanitize @example["Note"] %>
10-
<% end %>
11-
12-
<% if @example["LinksToAPIMethod"] %>
13-
<% if @example["LinksToAPIMethod"].length > 1 %>
14-
<%= sanitize @manifest["SupportingTexts"]["APIMethodUsedPlural"] %>
15-
<% else %>
16-
<%= sanitize @manifest["SupportingTexts"]["APIMethodUsed"] %>
17-
<% end %>
18-
19-
<% @example["LinksToAPIMethod"].each do |link| %>
20-
<a target='_blank' href="<%= link["Path"] %>"><%= link["PathName"] %></a>
21-
<% end %>
22-
<% end %>
23-
24-
<% if @example["LinkToHowTo"] %>
25-
<p>Prerequisite: See <a target='_blank' href="<%= @example["LinkToHowTo"][0]["Path"] %>"><%= @example["LinkToHowTo"][0]["PathName"] %></a></p>
26-
<% end %>
27-
28-
<p>
29-
<%= sanitize format_string(@manifest["SupportingTexts"]["ViewSourceFile"], "<a target='_blank' href='#{@source_url}'>#{@source_file}</a>" ) %>
1+
<h4><%= @example["ExampleName"] %></h4>
2+
<p><%= sanitize @example["ExampleDescription"] %></p>
3+
4+
<% if @show_doc %>
5+
<p><a target='_blank' href='<%= @documentation %>'>Documentation</a> about this example.</p>
6+
<% end %>
7+
8+
<% if @example["Notes"] %>
9+
<%= sanitize @example["Notes"] %>
10+
<% end %>
11+
12+
<% if @example["LinksToAPIMethod"] %>
13+
<% if @example["LinksToAPIMethod"].length > 1 %>
14+
<%= sanitize @manifest["SupportingTexts"]["APIMethodUsedPlural"] %>
15+
<% else %>
16+
<%= sanitize @manifest["SupportingTexts"]["APIMethodUsed"] %>
17+
<% end %>
18+
19+
<% @example["LinksToAPIMethod"].each do |link| %>
20+
<a target='_blank' href="<%= link["Path"] %>"><%= link["PathName"] %></a>
21+
<% end %>
22+
<% end %>
23+
24+
<% if @example["LinkToHowTo"] %>
25+
<p>Prerequisite: See <a target='_blank' href="<%= @example["LinkToHowTo"][0]["Path"] %>"><%= @example["LinkToHowTo"][0]["PathName"] %></a></p>
26+
<% end %>
27+
28+
<p>
29+
<%= sanitize format_string(@manifest["SupportingTexts"]["ViewSourceFile"], "<a target='_blank' href='#{@source_url}'>#{@source_file}</a>" ) %>
3030
</p>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<button type="submit" class="btn btn-docu"><%= sanitize @manifest["SupportingTexts"]["SubmitButton"] %></button>
1+
<button type="submit" class="btn btn-docu"><%= sanitize @submit_button_text || @manifest["SupportingTexts"]["SubmitButton"] %></button>

config/routes.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@
231231

232232
get 'eeg044' => 'eeg044_focused_view#get'
233233
post 'eeg044' => 'eeg044_focused_view#create'
234+
235+
get 'eeg045' => 'eeg045_delete_restore_envelope#get_delete_envelope'
236+
post 'eeg045' => 'eeg045_delete_restore_envelope#delete_envelope'
237+
get 'eeg045restore' => 'eeg045_delete_restore_envelope#get_restore_envelope'
238+
post 'eeg045restore' => 'eeg045_delete_restore_envelope#restore_envelope'
234239
end
235240

236241
scope module: 'connect' do

0 commit comments

Comments
 (0)