(projectId string, documentId string)
| 71 | } |
| 72 | |
| 73 | func (c DuClient) GetDigitizationResult(projectId string, documentId string) (string, error) { |
| 74 | request := c.createDigitizeStatusRequest(projectId, documentId) |
| 75 | client := network.NewHttpClient(c.logger, c.httpClientSettings()) |
| 76 | response, err := client.Send(request) |
| 77 | if err != nil { |
| 78 | return "", err |
| 79 | } |
| 80 | defer func() { _ = response.Body.Close() }() |
| 81 | body, err := io.ReadAll(response.Body) |
| 82 | if err != nil { |
| 83 | return "", fmt.Errorf("Error reading response: %w", err) |
| 84 | } |
| 85 | if response.StatusCode != http.StatusOK { |
| 86 | return "", fmt.Errorf("Digitizer returned status code '%v' and body '%v'", response.StatusCode, string(body)) |
| 87 | } |
| 88 | var result digitizeResultResponse |
| 89 | err = json.Unmarshal(body, &result) |
| 90 | if err != nil { |
| 91 | return "", fmt.Errorf("Error parsing json response: %w", err) |
| 92 | } |
| 93 | if result.Status == "NotStarted" || result.Status == "Running" { |
| 94 | return "", nil |
| 95 | } |
| 96 | return string(body), err |
| 97 | } |
| 98 | |
| 99 | func (c DuClient) createDigitizeStatusRequest(projectId string, documentId string) *network.HttpRequest { |
| 100 | uri := c.newUriBuilder("/api/framework/projects/{projectId}/digitization/result/{documentId}"). |
no test coverage detected