package api import ( "encoding/json" "fmt" "io" ) func (s *Session) GetAttachmentsForJob(jobID string) (map[string]interface{}, error) { resp, err := s.DoRequest("GET", fmt.Sprintf("/job/%s/paperwork", jobID), nil) if err != nil { return nil, err } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) if resp.StatusCode != 200 { return nil, fmt.Errorf("failed to get attachments: %s, response: %s", resp.Status, string(body)) } var result map[string]interface{} if err := json.Unmarshal(body, &result); err != nil { return nil, fmt.Errorf("error unmarshalling response: %v", err) } return result, nil } func (s *Session) DeleteAttachment(attachmentID string) error { resp, err := s.DoRequest("DELETE", fmt.Sprintf("/attachment/%s", attachmentID), nil) if err != nil { return err } defer resp.Body.Close() if resp.StatusCode != 200 && resp.StatusCode != 204 { body, _ := io.ReadAll(resp.Body) return fmt.Errorf("failed to delete attachment: %s, response: %s", resp.Status, string(body)) } return nil } func (s *Session) GetDeficiencyInfoForJob(jobID string) ([]map[string]interface{}, error) { resp, err := s.DoRequest("GET", fmt.Sprintf("/deficiency/%s", jobID), nil) if err != nil { return nil, err } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) if resp.StatusCode != 200 { return nil, fmt.Errorf("failed to get deficiency info: %s, response: %s", resp.Status, string(body)) } var result struct { Data []map[string]interface{} `json:"data"` } if err := json.Unmarshal(body, &result); err != nil { return nil, fmt.Errorf("error unmarshalling response: %v", err) } return result.Data, nil }