import { A, buildContract } from '@jig-software/trest-core';
import { FullReportInput, FullEventInput } from '../constants';

export const readingReportContract = buildContract((c) =>
  c
    .prefix('/reports')
    .parse((p) => p.error.text(400).error.text(401))
    .endpoints({
      generateReadingsReport: (e) =>
        e
          .method('POST')
          .path('/reading-report')
          .prepare((p) => p.body.json(FullReportInput).annotate<[query: A]>())
          .parse((p) => p.success.file(200)),
      generateEventsReport: (e) =>
        e
          .method('POST')
          .path('/event-report')
          .prepare((p) => p.body.json(FullEventInput).annotate<[query: A]>())
          .parse((p) => p.success.file(200)),
    }),
);
