-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdocument-service.go
More file actions
36 lines (31 loc) · 1.17 KB
/
document-service.go
File metadata and controls
36 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"encoding/json"
"fmt"
)
// GetDocumentQuestionResponse retrieves question responses for a document
func (app *App) GetDocumentQuestionResponse(documentId string) string {
responses, err := GetDocumentQuestionResponse(app.appArgs, documentId)
if err != nil {
ctx := DocumentQueryErrorCtx
ctx.TechnicalMsg = fmt.Sprintf("Failed to get document question response for documentId: %s", documentId)
return HandleError(app.log, ctx, err)
}
jsonOutput, err := json.Marshal(responses)
if err != nil {
ctx := JSONMarshalErrorCtx
ctx.TechnicalMsg = fmt.Sprintf("Failed to marshal document responses for documentId: %s, response type: %T", documentId, responses)
return HandleError(app.log, ctx, err)
}
return string(jsonOutput)
}
// SaveDocumentQuestionResponse saves a document question response
func (app *App) SaveDocumentQuestionResponse(payload DocumentQuestionResponse) string {
result, err := SaveDocumentQuestionResponse(app.appArgs, payload)
if err != nil {
ctx := DocumentSaveErrorCtx
ctx.TechnicalMsg = fmt.Sprintf("Failed to save document question response, payload: %+v", payload)
return HandleError(app.log, ctx, err)
}
return result
}