diff --git a/app/controllers/api_settings_controller.rb b/app/controllers/api_settings_controller.rb new file mode 100644 index 00000000..40e57ba2 --- /dev/null +++ b/app/controllers/api_settings_controller.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class ApiSettingsController < ApplicationController + def index; end +end diff --git a/app/views/api_settings/index.html.erb b/app/views/api_settings/index.html.erb new file mode 100644 index 00000000..4ef20920 --- /dev/null +++ b/app/views/api_settings/index.html.erb @@ -0,0 +1,68 @@ +
+ <%= render 'shared/settings_nav' %> +
+

API

+
+
+ +
+ + <%= render 'shared/clipboard_copy', text: jwt, class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %> +
+
+
+
+
+ +
+
+ Request signature, single submitter +
+
+
POST
+
<%= api_submissions_path %>
+
+
+
+
+
curl --location '<%= api_submissions_url %>' \
+       --header 'X-Auth-Token: <%= jwt %>' \
+       --data-raw '{
+           "template_id": <%= current_account.templates.last.id %>,
+           "emails":  "<%= current_user.email.sub('@', '+test@') %>, <%= current_user.email.sub('@', '+test2@') %>"
+       }'
+
+
+
+
+ +
+
+ Request signature, multiple submitters +
+
+
POST
+
<%= api_submissions_path %>
+
+
+
+
+
curl --location '<%= api_submissions_url %>' \
+       --header 'X-Auth-Token: <%= jwt %>' \
+       --data-raw '{
+         "template_id": <%= current_account.templates.last.id %>,
+         "submission": [
+           {
+             "submitters": [
+               { "name": "<%= current_account.templates.last.submitters.first['name'] %>", "email": "<%= current_user.email.sub('@', '+test@') %>" },
+               { "name": "Second Submitter", "email": "<%= current_user.email.sub('@', '+test2@') %>" }
+             ]
+           }
+         ]
+       }'
+
+
+
+
+
+
diff --git a/app/views/shared/_settings_nav.html.erb b/app/views/shared/_settings_nav.html.erb index 20f48c25..b264b750 100644 --- a/app/views/shared/_settings_nav.html.erb +++ b/app/views/shared/_settings_nav.html.erb @@ -23,6 +23,11 @@
  • <%= link_to 'Team', settings_users_path, class: 'text-base hover:bg-base-300' %>
  • + <% unless Docuseal.multitenant? %> +
  • + <%= link_to 'API', settings_api_index_path, class: 'text-base hover:bg-base-300' %> +
  • + <% end %>
  • <%= link_to 'Console', console_redirect_index_path, class: 'text-base hover:bg-base-300' %>
  • diff --git a/config/routes.rb b/config/routes.rb index 028a0dd8..a8b41aed 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,7 @@ Rails.application.routes.draw do end resources :esign, only: %i[index create], controller: 'esign_settings' resources :users, only: %i[index] + resources :api, only: %i[index], controller: 'api_settings' unless Docuseal.multitenant? resource :account, only: %i[show update] resources :profile, only: %i[index] do collection do diff --git a/lib/submissions.rb b/lib/submissions.rb index bdefe66d..043ba379 100644 --- a/lib/submissions.rb +++ b/lib/submissions.rb @@ -33,7 +33,9 @@ module Submissions template.submitters.find { |e| e['name'] == submitter_attrs[:name] }&.dig('uuid') || template.submitters[index]&.dig('uuid') - submission.submitters.new(**submitter_attrs, uuid:, sent_at: send_email ? Time.current : nil) + next if uuid.blank? + + submission.submitters.new(email: submitter_attrs[:email], uuid:, sent_at: send_email ? Time.current : nil) end submission.tap(&:save!)