feat: add get field endpoints (#1599)

This commit is contained in:
David Nguyen
2025-01-20 15:53:12 +11:00
committed by GitHub
parent 80dfbeb16f
commit a28cdf437b
2 changed files with 64 additions and 10 deletions

View File

@ -47,15 +47,15 @@ export const recipientRouter = router({
/**
* @public
*/
getRecipient: authenticatedProcedure
getDocumentRecipient: authenticatedProcedure
.meta({
openapi: {
method: 'GET',
path: '/recipient/{recipientId}',
summary: 'Get recipient',
path: '/document/recipient/{recipientId}',
summary: 'Get document recipient',
description:
'Returns a single recipient. If you want to retrieve all the recipients for a document or template, use the "Get Document" or "Get Template" request.',
tags: ['Document Recipients', 'Template Recipients'],
'Returns a single recipient. If you want to retrieve all the recipients for a document, use the "Get Document" endpoint.',
tags: ['Document Recipients'],
},
})
.input(ZGetRecipientRequestSchema)
@ -239,6 +239,33 @@ export const recipientRouter = router({
});
}),
/**
* @public
*/
getTemplateRecipient: authenticatedProcedure
.meta({
openapi: {
method: 'GET',
path: '/template/recipient/{recipientId}',
summary: 'Get template recipient',
description:
'Returns a single recipient. If you want to retrieve all the recipients for a template, use the "Get Template" endpoint.',
tags: ['Template Recipients'],
},
})
.input(ZGetRecipientRequestSchema)
.output(ZGetRecipientResponseSchema)
.query(async ({ input, ctx }) => {
const { teamId } = ctx;
const { recipientId } = input;
return await getRecipientById({
userId: ctx.user.id,
teamId,
recipientId,
});
}),
/**
* @public
*/