squeeze_go_client

package module
v0.0.0-...-bb2e6f6 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

Squeeze Go Client

This project implements an HTTP client for the Squeeze API.

Maturity: Experimental. We have already created multiple HTTP clients internally but never a fully featured client which supported all API endpoints of Squeeze. We will try to generate an API client based on the OpenAPI specification once the OpenAPI generator is able to generate a fully working client.

Support: Currently, we will not officially support this client. Still, if you want to use the client and have problems or questions, feel free to open an issue. We would love to encourage usage of this client and the HTTP api of our products in general.

Versioning

Squeeze has multiple APIs (and will probably receive more APIs in the future). This client is versioned to match the versions of the API.

  • The v1 API /api/v1 will not be supported
  • The v2 API /api/v2 will be supported by this client. The main branch is used for this.
  • Git tags will be used to mark client releases matching to the Squeeze API. If you use Squeeze 2.3.1, you must also use the client version 2.3.1.

Usage

Add client as dependency:

go get github.com/dexpro-solutions-gmbh/squeeze-go-client
Authentication

Currently, only authentication via API key is supported. We will support for JWT based authentication in the future.

client := squeeze_go_client.NewClient("https://your.squeeze.one/api/v2")
client.ApiKey = "..."

Tests

To run tests on this project, use these ENV variables to configure the Squeeze API to be used when testing:

  • SQZ_BASE_PATH: The base path of the Squeeze API. Example: https://your.squeeze.one/api/v2
  • SQZ_KEY: API key to authenticate with

Documentation

Overview

Package squeeze_go_client implements an HTTP client for Squeeze

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundingBox

type BoundingBox struct {
	Page int `json:"page"`
	X0   int `json:"x0"`
	Y0   int `json:"y0"`
	X1   int `json:"x1"`
	Y1   int `json:"y1"`
}

type Client

type Client struct {

	// ApiKey is used to authenticate with Squeeze
	ApiKey string

	Document      *DocumentApi
	DocumentClass *DocumentClassApi
	Jobs          *JobsApi
	Public        *PublicApi
	Queue         *QueueApi
	ScriptingApi  *ScriptingApi
	// contains filtered or unexported fields
}

func NewClient

func NewClient(basePath string) *Client

type CreatedIntDto

type CreatedIntDto struct {
	Id int `json:"id"`
}

type Document

type Document struct {
	Id              int                   `json:"id"`
	Name            string                `json:"name"`
	RepoPath        string                `json:"repoPath"`
	BatchClassId    int                   `json:"batchClassId"`
	DocumentClassId int                   `json:"documentClassId"`
	ExternalId      string                `json:"externalId"`
	CreatedBy       int                   `json:"createdBy"`
	CreatedAt       time.Time             `json:"createdAt"`
	ModifiedBy      int                   `json:"modifiedBy"`
	ModifiedAt      time.Time             `json:"modifiedAt"`
	DeletedBy       int                   `json:"deletedBy"`
	DeletedTs       time.Time             `json:"deletedTs"`
	WorkflowContext *WorkflowContext      `json:"workflowContext"`
	FieldGroups     []*DocumentFieldGroup `json:"fieldGroups"`
	Fields          []*DocumentField      `json:"fields"`
	Tables          []*DocumentTable      `json:"tables"`
}

type DocumentApi

type DocumentApi struct {
	// contains filtered or unexported fields
}

func (*DocumentApi) GetDocumentById

func (api *DocumentApi) GetDocumentById(id int) (*Document, *Error)

func (*DocumentApi) ProcessDocument

func (api *DocumentApi) ProcessDocument(batchClassId, documentClassId int, externalId string, fields map[string]string, file io.Reader, filename string) (*CreatedIntDto, *Error)

type DocumentClass

type DocumentClass = DocumentClassDto

type DocumentClassApi

type DocumentClassApi struct {
	// contains filtered or unexported fields
}

func (*DocumentClassApi) GetAllDocumentClassFields

func (api *DocumentClassApi) GetAllDocumentClassFields(documentClassId int) ([]*DocumentField, *Error)

func (*DocumentClassApi) GetAllDocumentClassTableColumns

func (api *DocumentClassApi) GetAllDocumentClassTableColumns(documentClassId int, tableId int) ([]*DocumentTableColumn, *Error)

func (*DocumentClassApi) GetAllDocumentClassTables

func (api *DocumentClassApi) GetAllDocumentClassTables(documentClassId int) ([]*DocumentTable, *Error)

func (*DocumentClassApi) GetAllFieldGroups

func (api *DocumentClassApi) GetAllFieldGroups(documentClassId int) ([]*DocumentFieldGroup, *Error)

func (*DocumentClassApi) GetDocumentClasses

func (api *DocumentClassApi) GetDocumentClasses() ([]*DocumentClassDto, *Error)

type DocumentClassDto

type DocumentClassDto struct {
	Id                    int    `json:"id"`
	Name                  string `json:"name"`
	Description           string `json:"description"`
	MaySeeDocuments       bool   `json:"maySeeDocuments"`
	TranslationKey        string `json:"translationKey"`
	TranslatedDescription string `json:"translatedDescription"`
}

type DocumentField

type DocumentField struct {
	Id                      int                   `json:"id"`
	DocumentClassId         int                   `json:"documentClassId"`
	SortOrder               int                   `json:"sortOrder"`
	FieldGroupId            int                   `json:"fieldGroupId"`
	LocatorId               int                   `json:"locatorId"`
	Name                    string                `json:"name"`
	Description             string                `json:"description"`
	DataType                string                `json:"dataType"`
	TranslationKey          string                `json:"translationKey"`
	TranslatedDescription   string                `json:"translatedDescription"`
	Value                   *DocumentFieldValue   `json:"value"`
	DefaultValue            string                `json:"defaultValue"`
	SameLineAsPreviousField bool                  `json:"sameLineAsPreviousField"`
	Alternatives            []*DocumentFieldValue `json:"alternatives"`
	SubFieldName            string                `json:"subFieldName"`
	Mandatory               bool                  `json:"mandatory"`
	Readonly                bool                  `json:"readonly"`
	Hidden                  bool                  `json:"hidden"`
	ForceValidation         bool                  `json:"forceValidation"`
	State                   string                `json:"state"`
	ExternalName            string                `json:"externalName"`
	Lookup                  *LookupDefinition     `json:"lookup"`
}

type DocumentFieldGroup

type DocumentFieldGroup struct {
	Id              int    `json:"id"`
	DocumentClassId int    `json:"documentClassId"`
	Name            string `json:"name"`
	Description     string `json:"description"`
	// removed because these are not actively being used.
	// Type                  int    `json:"type"`
	// TableField            string `json:"tableField"`
	SortOrder             int    `json:"sortOrder"`
	TranslationKey        string `json:"translationKey"`
	TranslatedDescription string `json:"translatedDescription"`
}

type DocumentFieldValue

type DocumentFieldValue struct {
	Id           int          `json:"id"`
	Value        string       `json:"value"`
	BoundingBox  *BoundingBox `json:"boundingBox"`
	Alternative  bool         `json:"alternative"`
	FieldId      int          `json:"fieldId"`
	Confidence   int          `json:"confidence"`
	SubFieldName string       `json:"subFieldName"`
	State        string       `json:"state"`
	ErrorText    string       `json:"errorText"`
	Subfields    []string     `json:"subfields"`
}

type DocumentTable

type DocumentTable struct {
	Id              int `json:"id"`
	DocumentClassId int `json:"documentClassId"`
	// removed because not actively being used
	// FieldGroupId    int    `json:"fieldGroupId"`
	LocatorId             int                    `json:"locatorId"`
	Name                  string                 `json:"name"`
	Description           string                 `json:"description"`
	Mandatory             bool                   `json:"mandatory"`
	Readonly              bool                   `json:"readonly"`
	Hidden                bool                   `json:"hidden"`
	ForceValidation       bool                   `json:"forceValidation"`
	ExternalName          string                 `json:"externalName"`
	Columns               []*DocumentTableColumn `json:"columns"`
	Rows                  []*DocumentTableRow    `json:"rows"`
	State                 string                 `json:"state"`
	ErrorText             string                 `json:"errorText"`
	ErrorCode             int                    `json:"errorCode"`
	TableBehaviour        string                 `json:"tableBehaviour"`
	TranslationKey        string                 `json:"translationKey"`
	TranslatedDescription string                 `json:"translatedDescription"`
}

type DocumentTableCell

type DocumentTableCell struct {
	Id          int          `json:"id"`
	ColumnId    int          `json:"columnId"`
	ColumnName  string       `json:"columnName"`
	Value       string       `json:"value"`
	RowId       int          `json:"rowId"`
	BoundingBox *BoundingBox `json:"boundingBox"`
	Confidence  int          `json:"confidence"`
	State       string       `json:"state"`
	ErrorText   string       `json:"errorText"`
	ErrorCode   int          `json:"errorCode"`
}

type DocumentTableColumn

type DocumentTableColumn struct {
	Id                    int               `json:"id"`
	SortOrder             int               `json:"sortOrder"`
	TableId               int               `json:"tableId"`
	HeaderLocatorId       int               `json:"headerLocatorId"`
	ValueLocatorId        int               `json:"valueLocatorId"`
	Name                  string            `json:"name"`
	Description           string            `json:"description"`
	DataType              string            `json:"dataType"`
	Mandatory             bool              `json:"mandatory"`
	Readonly              bool              `json:"readonly"`
	Hidden                bool              `json:"hidden"`
	ForceValidation       bool              `json:"forceValidation"`
	ExternalName          string            `json:"externalName"`
	Lookup                *LookupDefinition `json:"lookup"`
	TranslationKey        string            `json:"translationKey"`
	TranslatedDescription string            `json:"translatedDescription"`
}

type DocumentTableRow

type DocumentTableRow struct {
	Value     *DocumentFieldValue  `json:"value"`
	Cells     []*DocumentTableCell `json:"cells"`
	State     string               `json:"state"`
	ErrorText string               `json:"errorText"`
	ErrorCode int                  `json:"errorCode"`
}

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

type Job

type Job struct {
	Id             int    `json:"id"`
	Name           string `json:"name"`
	CronExpression string `json:"cronExpression"`
	ScriptId       string `json:"scriptId"`
	Active         bool   `json:"active"`
}

type JobsApi

type JobsApi struct {
	// contains filtered or unexported fields
}

func (*JobsApi) GetAllJobs

func (api *JobsApi) GetAllJobs() ([]*Job, *Error)

type LookupDefinition

type LookupDefinition struct {
	Active               bool  `json:"active"`
	AllowCustomValues    bool  `json:"allowCustomValues"`
	TableId              int   `json:"tableId"`
	ResultKeyColumnId    int   `json:"resultKeyColumnId"`
	SearchColumnIds      []int `json:"searchColumnIds"`
	ResultValueColumnIds []int `json:"resultValueColumnIds"`
	LookupFieldFilters   []struct {
		Id                 int    `json:"id"`
		DocumentFieldId    int    `json:"documentFieldId"`
		MasterDataColumnId int    `json:"masterDataColumnId"`
		Operand            string `json:"operand"`
		ValueFieldId       int    `json:"valueFieldId"`
		RowBasedFilter     bool   `json:"rowBasedFilter"`
	} `json:"lookupFieldFilters"`
	MinInputLength        int  `json:"minInputLength"`
	IgnoreInputValue      bool `json:"ignoreInputValue"`
	MaxLookupResultValues int  `json:"maxLookupResultValues"`
}

type PaginationDto

type PaginationDto struct {
	PageSize int `json:"pageSize"`
	Page     int `json:"page"`
	Total    int `json:"total"`
}

type PaginationResponse

type PaginationResponse[T any] struct {
	Pagination *PaginationDto `json:"pagination"`
	Elements   []T            `json:"elements"`
}

type PublicApi

type PublicApi struct {
	// contains filtered or unexported fields
}

func (*PublicApi) GetHealth

func (api *PublicApi) GetHealth() *Error

type QueueApi

type QueueApi struct {
	// contains filtered or unexported fields
}

func (*QueueApi) GetQueueStep

func (api *QueueApi) GetQueueStep(stepName string) (*QueueStepDto, *Error)

func (*QueueApi) GetQueueStepEntriesSimple

func (api *QueueApi) GetQueueStepEntriesSimple(stepName string, status string, documentClassId int, batchClassId int, page int, pageSize int) (*PaginationResponse[*QueueEntryDto], *Error)

GetQueueStepEntriesSimple is a simple implementation of a GET /queue/steps/{stepName}/entries request with support only for the most common parameters.

func (*QueueApi) GetQueueSteps

func (api *QueueApi) GetQueueSteps() (map[string]*QueueStepDto, *Error)

func (*QueueApi) RequeueDocument

func (api *QueueApi) RequeueDocument(documentId int, documentClassId int, newStepName string) *Error

type QueueEntryDto

type QueueEntryDto struct {
	Id              int              `json:"id"`
	DocumentId      int              `json:"documentId"`
	WorkflowContext *WorkflowContext `json:"workflowContext"`
}

type QueueStepDetailsDto

type QueueStepDetailsDto struct {
	DocumentClass *DocumentClass `json:"documentClass"`
	Count         int            `json:"count"`
	ErrorCount    int            `json:"errorCount"`
}

type QueueStepDto

type QueueStepDto struct {
	Name        string                 `json:"name"`
	Count       int                    `json:"count"`
	ErrorCount  int                    `json:"errorCount"`
	StepDetails []*QueueStepDetailsDto `json:"stepDetails"`
}

type ScriptDto

type ScriptDto struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Internal    bool   `json:"internal"`
}

type ScriptingApi

type ScriptingApi struct {
	// contains filtered or unexported fields
}

func (*ScriptingApi) ExecuteScript

func (api *ScriptingApi) ExecuteScript(scriptId string, async bool) *Error

func (*ScriptingApi) GetScripts

func (api *ScriptingApi) GetScripts() ([]*ScriptDto, *Error)

type WorkflowContext

type WorkflowContext struct {
	Status      string    `json:"status"`
	Step        string    `json:"step"`
	CreatedTs   time.Time `json:"createdTs"`
	ModifiedTs  time.Time `json:"modifiedTs"`
	Priority    int       `json:"priority"`
	Creator     string    `json:"creator"`
	Receiver    string    `json:"receiver"`
	ErrorText   string    `json:"errorText"`
	LockedBy    int       `json:"lockedBy"`
	LockedTs    time.Time `json:"lockedTs"`
	ValidatedBy int       `json:"validatedBy"`
	ValidatedTs time.Time `json:"validatedTs"`
	SuspendedBy int       `json:"suspendedBy"`
	SuspendedTs time.Time `json:"suspendedTs"`
	ExportedBy  int       `json:"exportedBy"`
	ExportedTs  time.Time `json:"exportedTs"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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