26 lines
940 B
TypeScript
26 lines
940 B
TypeScript
import { createRoute } from "../../../../../modules/api-utils/createRoute";
|
|
import { opportunities } from "../../../../../managers/opportunities";
|
|
import { apiResponse } from "../../../../../modules/api-utils/apiResponse";
|
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
|
import { authMiddleware } from "../../../../middleware/authorization";
|
|
|
|
/* GET /v1/sales/opportunities/opportunity/:identifier/notes */
|
|
export default createRoute(
|
|
"get",
|
|
["/opportunities/opportunity/:identifier/notes"],
|
|
async (c) => {
|
|
const identifier = c.req.param("identifier");
|
|
const item = await opportunities.fetchRecord(identifier);
|
|
|
|
const data = await item.fetchNotes();
|
|
|
|
const response = apiResponse.successful(
|
|
"Opportunity notes fetched successfully!",
|
|
data,
|
|
);
|
|
|
|
return c.json(response, response.status as ContentfulStatusCode);
|
|
},
|
|
authMiddleware({ permissions: ["sales.opportunity.fetch"] }),
|
|
);
|