Senior
How to handle closing a vacancy — should it be archived on all job sites?
sobes.tech AI
Answer from AI
When closing a vacancy, it is important to ensure that it is correctly removed or archived on all platforms where it is posted. Usually, the process looks like this:
- The status of the vacancy is changed to "closed" in the vacancy management system.
- API requests are sent or integrations with job sites are used to delete or archive the vacancy.
- The success of operations on each platform is checked, with error logging.
In Go, this can be implemented through sequential or parallel HTTP requests with response handling and retries in case of errors. It is important to consider that different sites may have different APIs and authentication requirements.
Here is a simplified example code for sending a request to archive a vacancy:
package main
import (
"bytes"
"fmt"
"net/http"
)
func archiveVacancyOnSite(vacancyID string, apiURL string, token string) error {
reqBody := []byte(fmt.Sprintf(`{"vacancy_id":"%s","action":"archive"}`, vacancyID))
req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(reqBody))
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to archive vacancy, status: %s", resp.Status)
}
return nil
}
Thus, closing a vacancy involves synchronizing the status across all platforms.