Create API endpoint for unarchiving companies
gruz0 opened this issue · 0 comments
We need to create a new API endpoint for unarchiving companies in our system. The endpoint should be accessible at /api/companies/[id]/unarchive
and should accept the POST
HTTP method. The purpose of this endpoint is to set a company as active in our database.
Your task is to create the /api/companies/[id]/unarchive
endpoint and implement the logic for unarchiving a company. If the company is already active, the endpoint should not do anything. The archived status of a company is stored as a timestamp in the archived_at
column in the companies
table.
If the company is archived (archived_at
is not null), the endpoint should update the archived_at
column in the companies
table to the null
.
The endpoint should return a HTTP 200 code, and a success message if the company is successfully unarchived, 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