mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-23 16:12:34 +02:00
Merge pull request #374 from OpenSignLabs/api-v1-beta
This commit is contained in:
@@ -50,10 +50,10 @@ app.delete('/contact/:contact_id', deleteContact);
|
||||
app.get('/contactlist', getContactList);
|
||||
|
||||
// create Document
|
||||
app.post('/createdocumentwithbinary', upload.array('file', 1), createDocument);
|
||||
app.post('/createdocumentwithbinary', upload.array('file', 1), createDocumentwithCoordinate);
|
||||
|
||||
// create Document with co-ordinate
|
||||
app.post('/createdocument', upload.array('file', 1), createDocumentwithCoordinate);
|
||||
app.post('/createdocument', createDocumentwithCoordinate);
|
||||
|
||||
// create Document with base64 without placeholder
|
||||
app.post('/draftdocument', createDocument);
|
||||
@@ -74,13 +74,13 @@ app.delete('/document/:document_id', deleteDocument);
|
||||
app.get('/documentlist/:doctype', getDocumentList);
|
||||
|
||||
// create Template with co-ordinate
|
||||
app.post('/createtemplate', upload.array('file', 1), createTemplatewithCoordinate);
|
||||
app.post('/createtemplate', createTemplatewithCoordinate);
|
||||
|
||||
// create Template
|
||||
app.post('/drafttemplate', createTemplate);
|
||||
|
||||
// create Template with binary
|
||||
app.post('/createtemplatewithbinary', upload.array('file', 1), createTemplate);
|
||||
app.post('/createtemplatewithbinary', upload.array('file', 1), createTemplatewithCoordinate);
|
||||
|
||||
// get template on the basis of id
|
||||
app.get('/template/:template_id', getTemplate);
|
||||
|
||||
@@ -108,35 +108,48 @@ export default async function createDocumentwithCoordinate(request, response) {
|
||||
'Signers',
|
||||
contact?.map(x => x.contactPtr)
|
||||
);
|
||||
let updatePlaceholders = contact.map(x => {
|
||||
let updatePlaceholders = contact.map((signer, index) => {
|
||||
const placeHolder = [];
|
||||
|
||||
for (const widget of signer.widgets) {
|
||||
const pageNumber = widget.page;
|
||||
const page = placeHolder.find(page => page.pageNumber === pageNumber);
|
||||
|
||||
const widgetData = {
|
||||
xPosition: widget.x,
|
||||
yPosition: widget.y,
|
||||
isStamp: widget.type === 'stamp',
|
||||
key: randomId(),
|
||||
isDrag: false,
|
||||
firstXPos: widget.x,
|
||||
firstYPos: widget.y,
|
||||
yBottom: 0,
|
||||
scale: 1,
|
||||
isMobile: false,
|
||||
zIndex: 1,
|
||||
type: widget.type,
|
||||
widgetValue: '',
|
||||
Width: widget.w,
|
||||
Height: widget.h,
|
||||
};
|
||||
|
||||
if (page) {
|
||||
page.pos.push(widgetData);
|
||||
} else {
|
||||
placeHolder.push({
|
||||
pageNumber,
|
||||
pos: [widgetData],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
signerObjId: x?.contactPtr?.objectId,
|
||||
signerPtr: x?.contactPtr,
|
||||
Role: x.role,
|
||||
signerObjId: signer?.contactPtr?.objectId,
|
||||
signerPtr: signer?.contactPtr,
|
||||
Role: signer.role,
|
||||
Id: randomId(),
|
||||
blockColor: color[x?.index],
|
||||
placeHolder: x.widgets.map((widget, i) => ({
|
||||
pageNumber: widget.page,
|
||||
pos: [
|
||||
{
|
||||
xPosition: widget.x,
|
||||
yPosition: widget.y,
|
||||
isStamp: widget.type === 'stamp' || widget.type === 'image' ? true : false,
|
||||
key: randomId(),
|
||||
isDrag: false,
|
||||
firstXPos: widget.x,
|
||||
firstYPos: widget.y,
|
||||
yBottom: 0,
|
||||
scale: 1,
|
||||
isMobile: false,
|
||||
zIndex: i + 1,
|
||||
type: widget.type,
|
||||
widgetValue: '',
|
||||
Width: widget.w,
|
||||
Height: widget.h,
|
||||
},
|
||||
],
|
||||
})),
|
||||
blockColor: color[signer?.index],
|
||||
placeHolder,
|
||||
};
|
||||
});
|
||||
object.set('Placeholders', updatePlaceholders);
|
||||
@@ -220,19 +233,14 @@ export default async function createDocumentwithCoordinate(request, response) {
|
||||
}
|
||||
|
||||
if (sendMail.data.result.status === 'success') {
|
||||
const user = contact.find(x => x.email === parseExtUser.Email);
|
||||
if (user && user.email) {
|
||||
return response.json({
|
||||
objectId: res.id,
|
||||
url: `${baseUrl.origin}/loadmf/signmicroapp/login/${res.id}/${user.email}/${user.contactPtr.objectId}/${serverParams}`,
|
||||
message: 'Document sent successfully!',
|
||||
});
|
||||
} else {
|
||||
return response.json({
|
||||
objectId: res.id,
|
||||
message: 'Document sent successfully!',
|
||||
});
|
||||
}
|
||||
return response.json({
|
||||
objectId: res.id,
|
||||
signurl: contact.map(x => ({
|
||||
email: x.email,
|
||||
url: `${baseUrl.origin}/loadmf/signmicroapp/login/${res.id}/${x.email}/${x.contactPtr.objectId}/${serverParams}`,
|
||||
})),
|
||||
message: 'Document sent successfully!',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return response.status(400).json({ error: 'Please provide signers!' });
|
||||
|
||||
@@ -113,39 +113,50 @@ export default async function createTemplatewithCoordinate(request, response) {
|
||||
updatedSigners?.map(x => x.contactPtr)
|
||||
);
|
||||
}
|
||||
let updatePlaceholders = contact.map(x => {
|
||||
let updatePlaceholders = contact.map((signer, index) => {
|
||||
const placeHolder = [];
|
||||
|
||||
for (const widget of signer.widgets) {
|
||||
const pageNumber = widget.page;
|
||||
const page = placeHolder.find(page => page.pageNumber === pageNumber);
|
||||
|
||||
const widgetData = {
|
||||
xPosition: widget.x,
|
||||
yPosition: widget.y,
|
||||
isStamp: widget.type === 'stamp',
|
||||
key: randomId(),
|
||||
isDrag: false,
|
||||
firstXPos: widget.x,
|
||||
firstYPos: widget.y,
|
||||
yBottom: 0,
|
||||
scale: 1,
|
||||
isMobile: false,
|
||||
zIndex: 1,
|
||||
type: widget.type,
|
||||
widgetValue: '',
|
||||
Width: widget.w,
|
||||
Height: widget.h,
|
||||
};
|
||||
|
||||
if (page) {
|
||||
page.pos.push(widgetData);
|
||||
} else {
|
||||
placeHolder.push({
|
||||
pageNumber,
|
||||
pos: [widgetData],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
signerObjId: x?.contactPtr?.objectId || '',
|
||||
signerPtr: x?.contactPtr || {},
|
||||
Role: x.role,
|
||||
signerObjId: signer?.contactPtr?.objectId,
|
||||
signerPtr: signer?.contactPtr,
|
||||
Role: signer.role,
|
||||
Id: randomId(),
|
||||
blockColor: color[x?.index],
|
||||
placeHolder: x.widgets.map((widget, i) => ({
|
||||
pageNumber: widget.page,
|
||||
pos: [
|
||||
{
|
||||
xPosition: widget.x,
|
||||
yPosition: widget.y,
|
||||
isStamp: widget.type === 'stamp' || widget.type === 'image' ? true : false,
|
||||
key: randomId(),
|
||||
isDrag: false,
|
||||
firstXPos: widget.x,
|
||||
firstYPos: widget.y,
|
||||
yBottom: 0,
|
||||
scale: 1,
|
||||
isMobile: false,
|
||||
zIndex: i + 1,
|
||||
type: widget.type,
|
||||
widgetValue: '',
|
||||
Width: widget.w,
|
||||
Height: widget.h,
|
||||
},
|
||||
],
|
||||
})),
|
||||
blockColor: color[signer?.index],
|
||||
placeHolder,
|
||||
};
|
||||
});
|
||||
// console.log('updatePLacholders', updatePlaceholders);
|
||||
|
||||
object.set('Placeholders', updatePlaceholders);
|
||||
}
|
||||
if (folderId) {
|
||||
|
||||
Reference in New Issue
Block a user