feat: Utilisation d'une clef API Docuseal par établissement

This commit is contained in:
N3WT DE COMPET
2025-05-30 14:19:01 +02:00
parent 8cf22905e5
commit 23ab7d04ef
21 changed files with 256 additions and 134 deletions

View File

@ -3,18 +3,19 @@ import { BE_DOCUSEAL_CLONE_TEMPLATE } from '@/utils/Url';
export default function handler(req, res) {
if (req.method === 'POST') {
const { templateId, email, is_required } = req.body;
const { templateId, email, is_required, establishment_id, apiDocuseal } = req.body;
fetch(BE_DOCUSEAL_CLONE_TEMPLATE, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Auth-Token': process.env.DOCUSEAL_API_KEY,
'X-Auth-Token': apiDocuseal,
},
body: JSON.stringify({
templateId,
email,
is_required,
establishment_id,
}),
})
.then((response) => {

View File

@ -3,13 +3,13 @@ import { BE_DOCUSEAL_DOWNLOAD_TEMPLATE } from '@/utils/Url';
export default function handler(req, res) {
if (req.method === 'GET') {
const { slug } = req.query;
const { slug, establishment_id, apiDocuseal } = req.query;
logger.debug('slug : ', slug);
fetch(`${BE_DOCUSEAL_DOWNLOAD_TEMPLATE}/${slug}`, {
fetch(`${BE_DOCUSEAL_DOWNLOAD_TEMPLATE}/${slug}?establishment_id=${establishment_id}`, {
method: 'GET',
headers: {
'X-Auth-Token': process.env.DOCUSEAL_API_KEY,
'X-Auth-Token': apiDocuseal,
},
})
.then((response) => {

View File

@ -3,13 +3,15 @@ import { BE_DOCUSEAL_GET_JWT } from '@/utils/Url';
export default function handler(req, res) {
if (req.method === 'POST') {
const { apiDocuseal, ...rest } = req.body;
fetch(BE_DOCUSEAL_GET_JWT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Auth-Token': process.env.DOCUSEAL_API_KEY,
'X-Auth-Token': apiDocuseal,
},
body: JSON.stringify(req.body),
body: JSON.stringify(rest),
})
.then((response) => {
logger.debug('Response status:', response.status);

View File

@ -3,12 +3,12 @@ import { BE_DOCUSEAL_REMOVE_TEMPLATE } from '@/utils/Url';
export default function handler(req, res) {
if (req.method === 'DELETE') {
const { templateId } = req.body;
const { templateId, establishment_id, apiDocuseal } = req.body;
fetch(`${BE_DOCUSEAL_REMOVE_TEMPLATE}/${templateId}`, {
fetch(`${BE_DOCUSEAL_REMOVE_TEMPLATE}/${templateId}?establishment_id=${establishment_id}`, {
method: 'DELETE',
headers: {
'X-Auth-Token': process.env.DOCUSEAL_API_KEY,
'X-Auth-Token': apiDocuseal,
},
})
.then((response) => {