26 lines
916 B
TypeScript
26 lines
916 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/:identifier/contacts */
|
|
export default createRoute(
|
|
"get",
|
|
["/opportunities/:identifier/contacts"],
|
|
async (c) => {
|
|
const identifier = c.req.param("identifier");
|
|
const item = await opportunities.fetchRecord(identifier);
|
|
|
|
const data = await item.fetchContacts();
|
|
|
|
const response = apiResponse.successful(
|
|
"Opportunity contacts fetched successfully!",
|
|
data,
|
|
);
|
|
|
|
return c.json(response, response.status as ContentfulStatusCode);
|
|
},
|
|
authMiddleware({ permissions: ["sales.opportunity.fetch"] }),
|
|
);
|