paperless

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToDocumentIDs

func MapToDocumentIDs(docs []Document) []int

func MapToDocumentMap

func MapToDocumentMap(docs []Document) map[int]Document

Types

type BulkDownloadContent

type BulkDownloadContent string
const (
	BulkDownloadBoth     BulkDownloadContent = "both"
	BulkDownloadArchives BulkDownloadContent = "archive"
	BulkDownloadOriginal BulkDownloadContent = "originals"
)

func (BulkDownloadContent) String

func (c BulkDownloadContent) String() string

String implements fmt.Stringer.

type BulkDownloadParams

type BulkDownloadParams struct {
	DocumentIDs      []int
	FollowFormatting bool
	Content          BulkDownloadContent
}

type Client

type Client struct {
	URL        string
	HttpClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url, username, passwordOrToken string) *Client

NewClient creates a new PaperlessClient using the given URL and credentials. If using token auth, `username` parameter can be left empty.

func (*Client) BulkDownload

func (clt *Client) BulkDownload(ctx context.Context, targetFile *os.File, params BulkDownloadParams) error

BulkDownload downloads the documents identified by BulkDownloadParams.DocumentIDs and saves to the given targetPath. If targetPath is empty, it will use the suggested file name from Paperless in the current working dir.

func (*Client) QueryDocuments

func (clt *Client) QueryDocuments(ctx context.Context, params QueryParams) ([]Document, error)

func (*Client) Upload

func (clt *Client) Upload(ctx context.Context, filePath string, params UploadParams) error

type Document

type Document struct {
	// ID of the document, read-only.
	ID int `json:"id"`
	// OriginalFileName of the original document, read-only.
	OriginalFileName string `json:"original_file_name,omitempty"`
	// ArchivedFileName of the archived document, read-only.
	// May be empty if no archived document is available.
	ArchivedFileName string `json:"archived_file_name,omitempty"`
}

type QueryParams

type QueryParams struct {
	TruncateContent bool   `param:"truncate_content"`
	Ordering        string `param:"ordering"`
	PageSize        int64  `param:"page_size"`
	// contains filtered or unexported fields
}

type QueryResult

type QueryResult struct {
	Results []Document `json:"results,omitempty"`
	Next    string     `json:"next,omitempty"`
}

func (QueryResult) NextPage

func (r QueryResult) NextPage() int64

NextPage returns the next page number for pagination. It returns 1 if QueryResult.Next is empty (first page), or 0 if there's an error parsing QueryResult.Next.

type UploadParams

type UploadParams struct {
	Title         string
	Created       time.Time
	Correspondent string
	DocumentType  string
	Tags          []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL