import { router } from '../trpc';
import { createAttachmentRoute } from './attachment/create-attachment';
import { deleteAttachmentRoute } from './attachment/delete-attachment';
import { findAttachmentsRoute } from './attachment/find-attachments';
import { updateAttachmentRoute } from './attachment/update-attachment';
import { bulkCancelEnvelopesRoute } from './bulk-cancel-envelopes';
import { bulkDeleteEnvelopesRoute } from './bulk-delete-envelopes';
import { bulkMoveEnvelopesRoute } from './bulk-move-envelopes';
import { cancelEnvelopeRoute } from './cancel-envelope';
import { createEnvelopeRoute } from './create-envelope';
import { createEnvelopeItemsRoute } from './create-envelope-items';
import { deleteEnvelopeRoute } from './delete-envelope';
import { deleteEnvelopeItemRoute } from './delete-envelope-item';
import { distributeEnvelopeRoute } from './distribute-envelope';
import { downloadEnvelopeAuditLogPdfRoute } from './download-envelope-audit-log-pdf';
import { downloadEnvelopeCertificatePdfRoute } from './download-envelope-certificate-pdf';
import { downloadEnvelopeItemRoute } from './download-envelope-item';
import { duplicateEnvelopeRoute } from './duplicate-envelope';
import { createEnvelopeFieldsRoute } from './envelope-fields/create-envelope-fields';
import { deleteEnvelopeFieldRoute } from './envelope-fields/delete-envelope-field';
import { getEnvelopeFieldRoute } from './envelope-fields/get-envelope-field';
import { getEnvelopeFieldSignaturesRoute } from './envelope-fields/get-envelope-field-signatures';
import { updateEnvelopeFieldsRoute } from './envelope-fields/update-envelope-fields';
import { createEnvelopeRecipientsRoute } from './envelope-recipients/create-envelope-recipients';
import { deleteEnvelopeRecipientRoute } from './envelope-recipients/delete-envelope-recipient';
import { getEnvelopeRecipientRoute } from './envelope-recipients/get-envelope-recipient';
import { rejectEnvelopeRecipientOnBehalfOfRoute } from './envelope-recipients/reject-envelope-recipient-on-behalf-of';
import { reportRecipientRoute } from './envelope-recipients/report-recipient';
import { updateEnvelopeRecipientsRoute } from './envelope-recipients/update-envelope-recipients';
import { findEnvelopeAuditLogsRoute } from './find-envelope-audit-logs';
import { findEnvelopesRoute } from './find-envelopes';
import { getEditorEnvelopeRoute } from './get-editor-envelope';
import { getEnvelopeRoute } from './get-envelope';
import { getEnvelopeItemsRoute } from './get-envelope-items';
import { getEnvelopeItemsByTokenRoute } from './get-envelope-items-by-token';
import { getEnvelopesByIdsRoute } from './get-envelopes-by-ids';
import { redistributeEnvelopeRoute } from './redistribute-envelope';
import { replaceEnvelopeItemPdfRoute } from './replace-envelope-item-pdf';
import { saveAsTemplateRoute } from './save-as-template';
import { setEnvelopeFieldsRoute } from './set-envelope-fields';
import { setEnvelopeRecipientsRoute } from './set-envelope-recipients';
import { signEnvelopeFieldRoute } from './sign-envelope-field';
import { signingStatusEnvelopeRoute } from './signing-status-envelope';
import { updateEnvelopeRoute } from './update-envelope';
import { updateEnvelopeItemsRoute } from './update-envelope-items';
import { useEnvelopeRoute } from './use-envelope';

/**
 * Note: The order of the routes is important for public API routes.
 *
 * Example: GET /envelope/attachment must appear before GET /envelope/:id
 */
export const envelopeRouter = router({
  attachment: {
    find: findAttachmentsRoute,
    create: createAttachmentRoute,
    update: updateAttachmentRoute,
    delete: deleteAttachmentRoute,
  },
  item: {
    getMany: getEnvelopeItemsRoute,
    getManyByToken: getEnvelopeItemsByTokenRoute,
    createMany: createEnvelopeItemsRoute,
    updateMany: updateEnvelopeItemsRoute,
    delete: deleteEnvelopeItemRoute,
    download: downloadEnvelopeItemRoute,
    replacePdf: replaceEnvelopeItemPdfRoute,
  },
  recipient: {
    get: getEnvelopeRecipientRoute,
    createMany: createEnvelopeRecipientsRoute,
    updateMany: updateEnvelopeRecipientsRoute,
    delete: deleteEnvelopeRecipientRoute,
    set: setEnvelopeRecipientsRoute,
    report: reportRecipientRoute,
    rejectOnBehalfOf: rejectEnvelopeRecipientOnBehalfOfRoute,
  },
  field: {
    get: getEnvelopeFieldRoute,
    getSignatures: getEnvelopeFieldSignaturesRoute,
    createMany: createEnvelopeFieldsRoute,
    updateMany: updateEnvelopeFieldsRoute,
    delete: deleteEnvelopeFieldRoute,
    set: setEnvelopeFieldsRoute,
    sign: signEnvelopeFieldRoute,
  },
  find: findEnvelopesRoute,
  auditLog: {
    find: findEnvelopeAuditLogsRoute,
    downloadPdf: downloadEnvelopeAuditLogPdfRoute,
  },
  certificate: {
    downloadPdf: downloadEnvelopeCertificatePdfRoute,
  },
  bulk: {
    move: bulkMoveEnvelopesRoute,
    delete: bulkDeleteEnvelopesRoute,
    cancel: bulkCancelEnvelopesRoute,
  },
  editor: {
    get: getEditorEnvelopeRoute,
  },
  get: getEnvelopeRoute,
  getMany: getEnvelopesByIdsRoute,
  create: createEnvelopeRoute,
  use: useEnvelopeRoute,
  update: updateEnvelopeRoute,
  delete: deleteEnvelopeRoute,
  cancel: cancelEnvelopeRoute,
  duplicate: duplicateEnvelopeRoute,
  saveAsTemplate: saveAsTemplateRoute,
  distribute: distributeEnvelopeRoute,
  redistribute: redistributeEnvelopeRoute,
  signingStatus: signingStatusEnvelopeRoute,
});
