paperless-gpt/types.go
Icereed abeab949a1
refactor(api): simplify response structures for GetDocuments and GetD… (#199)
* refactor(api): simplify response structures for GetDocuments and GetDocument endpoints

Closes #198

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-02-07 15:47:40 +00:00

108 lines
4.6 KiB
Go

package main
// GetDocumentsApiResponse is the response payload for /documents endpoint.
// But we are only interested in a subset of the fields.
type GetDocumentsApiResponse struct {
Count int `json:"count"`
// Next interface{} `json:"next"`
// Previous interface{} `json:"previous"`
All []int `json:"all"`
Results []GetDocumentApiResponseResult `json:"results"`
}
// GetDocumentApiResponseResult is a part of the response payload for /documents endpoint.
// But we are only interested in a subset of the fields.
type GetDocumentApiResponseResult struct {
ID int `json:"id"`
Correspondent int `json:"correspondent"`
// DocumentType interface{} `json:"document_type"`
// StoragePath interface{} `json:"storage_path"`
Title string `json:"title"`
Content string `json:"content"`
Tags []int `json:"tags"`
// Created time.Time `json:"created"`
// CreatedDate string `json:"created_date"`
// Modified time.Time `json:"modified"`
// Added time.Time `json:"added"`
// ArchiveSerialNumber interface{} `json:"archive_serial_number"`
// OriginalFileName string `json:"original_file_name"`
// ArchivedFileName string `json:"archived_file_name"`
// Owner int `json:"owner"`
// UserCanChange bool `json:"user_can_change"`
Notes []interface{} `json:"notes"`
// SearchHit struct {
// Score float64 `json:"score"`
// Highlights string `json:"highlights"`
// NoteHighlights string `json:"note_highlights"`
// Rank int `json:"rank"`
// } `json:"__search_hit__"`
}
// GetDocumentApiResponse is the response payload for /documents/{id} endpoint.
// But we are only interested in a subset of the fields.
type GetDocumentApiResponse struct {
ID int `json:"id"`
Correspondent int `json:"correspondent"`
// DocumentType interface{} `json:"document_type"`
// StoragePath interface{} `json:"storage_path"`
Title string `json:"title"`
Content string `json:"content"`
Tags []int `json:"tags"`
// Created time.Time `json:"created"`
// CreatedDate string `json:"created_date"`
// Modified time.Time `json:"modified"`
// Added time.Time `json:"added"`
// ArchiveSerialNumber interface{} `json:"archive_serial_number"`
// OriginalFileName string `json:"original_file_name"`
// ArchivedFileName string `json:"archived_file_name"`
// Owner int `json:"owner"`
// UserCanChange bool `json:"user_can_change"`
Notes []interface{} `json:"notes"`
}
// Document is a stripped down version of the document object from paperless-ngx.
// Response payload for /documents endpoint and part of request payload for /generate-suggestions endpoint
type Document struct {
ID int `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Tags []string `json:"tags"`
Correspondent string `json:"correspondent"`
}
// GenerateSuggestionsRequest is the request payload for generating suggestions for /generate-suggestions endpoint
type GenerateSuggestionsRequest struct {
Documents []Document `json:"documents"`
GenerateTitles bool `json:"generate_titles,omitempty"`
GenerateTags bool `json:"generate_tags,omitempty"`
GenerateCorrespondents bool `json:"generate_correspondents,omitempty"`
}
// DocumentSuggestion is the response payload for /generate-suggestions endpoint and the request payload for /update-documents endpoint (as an array)
type DocumentSuggestion struct {
ID int `json:"id"`
OriginalDocument Document `json:"original_document"`
SuggestedTitle string `json:"suggested_title,omitempty"`
SuggestedTags []string `json:"suggested_tags,omitempty"`
SuggestedContent string `json:"suggested_content,omitempty"`
SuggestedCorrespondent string `json:"suggested_correspondent,omitempty"`
RemoveTags []string `json:"remove_tags,omitempty"`
}
type Correspondent struct {
Name string `json:"name"`
MatchingAlgorithm int `json:"matching_algorithm"`
Match string `json:"match"`
IsInsensitive bool `json:"is_insensitive"`
Owner *int `json:"owner"`
SetPermissions struct {
View struct {
Users []int `json:"users"`
Groups []int `json:"groups"`
} `json:"view"`
Change struct {
Users []int `json:"users"`
Groups []int `json:"groups"`
} `json:"change"`
} `json:"set_permissions"`
}