Create API endpoint for archiving companies
gruz0 opened this issue · 0 comments
We need to create a new API endpoint for archiving companies in our system. The endpoint should be accessible at /api/companies/[id]
and should accept the DELETE
HTTP method. The purpose of this endpoint is to set a company as archived in our database.
Your task is to create the /api/companies/[id]
endpoint and implement the logic for archiving a company. If the company is already archived, the endpoint should not do anything (but return success response). The archived status of a company is stored as a timestamp in the archived_at
column in the companies
table.
If the company is not already archived (has a null in the column), the endpoint should update the archived_at
column in the companies
table to the current timestamp. If the company is already archived, the endpoint should not update the database.
The endpoint should return a HTTP 200 code, and a success message if the company is successfully archived, and an error message if there is an issue with the request (like company doesn't exist, for example).
Tests should be written to verify the functionality of the endpoint