treeno

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 12 Imported by: 0

README

Treengo

A go library for interacting with Treeno

Few things are tested, some might work.

https://api.treenosoftware.com/api/documentation/

https://api.treenosoftware.com/api/walkthrough

Documentation

Index

Constants

View Source
const DateFormat = "01/02/2006"

DateFormat format used by treeno

Variables

View Source
var ErrNotImplemented = fmt.Errorf("not implemented")

ErrNotImplemented this method isn't implemented yet

View Source
var ErrNotOK = fmt.Errorf("Status Not OK")

Functions

func ResponseBodyIfOK added in v0.0.8

func ResponseBodyIfOK(resp *http.Response, err error) ([]byte, error)

Types

type AuthResp

type AuthResp struct {
	Authentication Authentication `json:"authentication"`
	HasError       bool           `json:"hasError"`
	ErrorMessage   string         `json:"errorMessage"`
}

AuthResp authentication response

type Authentication

type Authentication struct {
	User         User       `json:"user"`
	Token        string     `json:"token"`
	RefreshToken string     `json:"refreshToken"`
	Expiration   treenoTime `json:"expiration"`
}

Authentication authentication info

type Bool added in v0.0.9

type Bool bool

Bool Treeno representation of a bool, like "True", "Yes", etc.

func (*Bool) MarshalJSON added in v0.0.9

func (b *Bool) MarshalJSON() ([]byte, error)

MarshalJSON Marshall to valid Treeno date

func (*Bool) UnmarshalJSON added in v0.0.9

func (b *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON Unmarshall from treeno some kind of positive representation to go bool

type CabinetSearchFoldersResponse added in v0.0.8

type CabinetSearchFoldersResponse struct {
	CabinetSearchInfo CabinetSearchInfo `json:"CabinetSearchInfo"`
	HasError          bool              `json:"HasError"`
	ErrorMessage      string            `json:"errorMessage"`
}

type CabinetSearchInfo added in v0.0.8

type CabinetSearchInfo struct {
	Department        string `json:"Department"`
	CabinetId         int    `json:"CabinetId"`
	ResultId          string `json:"ResultId"`
	ResultCount       int    `json:"ResultCount"`
	AuditStr          string `json:"AuditStr"`
	MatchingFolderIDs []int  `json:"MatchingFolderIDs"`
}

type CabinetSearchResponse

type CabinetSearchResponse struct {
	Results      []CabinetSearchResult `json:"results"`
	HasError     bool                  `json:"hasError"`
	ErrorMessage string                `json:"errorMessage"`
}

CabinetSearchResponse contains results from a search, and errors if there was errors

type CabinetSearchResult

type CabinetSearchResult struct {
	DocId   int     `json:"docId"`
	Indices Indices `json:"cabinetIndices"`
}

CabinetSearchResult is the contents of a Cabinet Search

type Cabinets

type Cabinets []struct {
	IsAutoComplete        bool     `json:"isAutoComplete"`
	SavedTabs             []string `json:"savedTabs"`
	DataTypeDefinitions   struct{} `json:"dataTypeDefinitions"`
	Indices               []string `json:"indices"`
	DepartmentRealName    string   `json:"departmentRealName"`
	DepartmentDisplayName string   `json:"departmentDisplayName"`
	IsDocumentView        bool     `json:"isDocumentView"`
	CabinetID             int      `json:"cabinetId"`
	RealName              string   `json:"realName"`
	DisplayName           string   `json:"displayName"`
}

Cabinets slice of cabinets for the department

type CabinetsResponse

type CabinetsResponse struct {
	Cabinets     Cabinets `json:"cabinets"`
	HasError     bool     `json:"hasError"`
	ErrorMessage string   `json:"errorMessage"`
}

CabinetsResponse response containing any errors and the Cabinets

type Client

type Client struct {
	Authentication Authentication

	DefaultDepartment string
	// contains filtered or unexported fields
}

Client treeno client containing an http.Client that makes requests

func NewService

func NewService(conf *Config, deptDefault string) (client *Client, err error)

NewService Create a new service with the config, and set a default department

func (*Client) AddFolder

func (client *Client) AddFolder(f Folder) (folder Folder, err error)

AddFolder Add a folder

func (*Client) DeleteFolder added in v0.0.7

func (client *Client) DeleteFolder(folderToDelete FolderDeleteRequest) (response FolderDeleteResponse, err error)

DeleteFolder delete a folder from a cabinet

func (Client) Do

func (client Client) Do(req *http.Request) (*http.Response, error)

Do Make the request with the client

func (*Client) EditFolder added in v0.0.8

func (client *Client) EditFolder(request FolderEditRequest) (response FolderEditResponse, err error)

EditFolder edits a folder in the thing

func (*Client) FilesAdd

func (client *Client) FilesAdd(file FilesAddRequest) (err error)

FilesAdd Adds a selected file to specific subfolder/tab TODO NOT IMPLEMENTED and also not needed maybe?

func (*Client) FilesDownload

func (client *Client) FilesDownload(filesDownload FilesDownloadRequest) (file FilesDownloadResponse, err error)

FilesDownload download a file TODO NOT TESTED

func (*Client) FilesGetFilesInFolder

func (client *Client) FilesGetFilesInFolder(department string, cabinet string, folderId int) (files FilesInFolder, err error)

FilesGetFilesInFolder TODO NOT TESTED department real name cabinet real name

func (*Client) FilesUploadToFolder

func (client *Client) FilesUploadToFolder(file FilesUploadToFolderRequest) (fileId int, err error)

FilesUploadToFolder Upload a file to a folder

func (*Client) GetDepartments

func (client *Client) GetDepartments() (deps Departments, err error)

GetDepartments get departments

func (*Client) GetDocumentTypes

func (client *Client) GetDocumentTypes(department, cabinet string) (dTypes DocumentTypes, err error)

GetDocumentTypes Get a list of document types for a cabinet in a department TODO UNTESTED

func (*Client) GetFolders

func (client *Client) GetFolders(department string, cabinet string) (f Folders, err error)

GetFolders return list of folders in a cabinet

func (*Client) GetPersonalInboxInfo added in v0.0.6

func (client *Client) GetPersonalInboxInfo() (result PersonalInboxInfoResponse, err error)

func (*Client) GetSavedTabs

func (client *Client) GetSavedTabs(department string, cabinet string) (f TabInfoList, err error)

GetSavedTabs Gets list of saved tabs name for a cabinet

func (Client) GetServerResponse

func (client Client) GetServerResponse(url string, method string, body io.Reader) (resp *http.Response, err error)

GetServerResponse by doing an auth request

func (*Client) GetTabInfo

func (client *Client) GetTabInfo(department string, cabinet string, folder string) (f TabInfoList, err error)

GetTabInfo UNTESTED, im not sure what this is for. I just noticed that it's a post not a get returns list of tabs for a folder in a cabinet.

func (*Client) GetWorkflowDefinitions added in v0.0.5

func (client *Client) GetWorkflowDefinitions() (result WorkflowDefinitionsResponse, err error)

GetWorkflowDefinitions gets a list of available workflow ids and names

func (*Client) ListCabinets

func (client *Client) ListCabinets() (cabinets Cabinets, err error)

ListCabinets Returns a list of cabinets in a department

func (Client) NewAuthRequest

func (client Client) NewAuthRequest(path string, method string, body io.Reader) (req *http.Request, err error)

NewAuthRequest with auth header and body

func (*Client) SearchCabinet

func (client *Client) SearchCabinet(cabinet string, query ...IndexQuery) (results []CabinetSearchResult, err error)

SearchCabinet Searches cabinet for folders by index value Gotcha: Cabinet index names are all lower case for some reason

func (*Client) SearchCabinetFolders added in v0.0.8

func (client *Client) SearchCabinetFolders(cabinet string, query ...IndexQuery) (results CabinetSearchInfo, err error)

SearchCabinetFolders Searches cabinet for folders by index value. Returns only Folder IDs Gotcha: Cabinet index names are all lower case for some reason

func (*Client) StartWorkflow added in v0.0.3

func (client *Client) StartWorkflow(w Workflow) (result StartWorkflowResponse, err error)

StartWorkflow from a workflow request

type Config

type Config struct {
	Host     string
	Username string
	Email    string
	Password string
}

Config Configs required to create a client

func (*Config) Authenticate

func (conf *Config) Authenticate() (*Authentication, error)

Authenticate authenticates to the treeno API

func (*Config) Token

func (conf *Config) Token() (*oauth2.Token, error)

Token Authenticates and creates a new oauth token

type Date added in v0.0.9

type Date struct {
	time.Time
}

Date Valid Treeno date

func (*Date) MarshalJSON added in v0.0.9

func (d *Date) MarshalJSON() ([]byte, error)

MarshalJSON Marshall to valid Treeno date

func (*Date) UnmarshalJSON added in v0.0.9

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON Unmarshall from treeno time to go time

type DepartmentResponse

type DepartmentResponse struct {
	Departments  Departments `json:"departments"`
	HasError     bool        `json:"hasError"`
	ErrorMessage string      `json:"errorMessage"`
}

DepartmentResponse response for GetDepartments

type Departments

type Departments []struct {
	RealName string `json:"realName"`
	ArbName  string `json:"arbName"`
}

Departments slice of departments in treeno

type DocumentTypes

type DocumentTypes []struct {
	DocumentTypeID      int    `json:"documentTypeID"`
	DocumentTypeEnabled int    `json:"documentTypeEnabled"`
	InternalName        string `json:"internalName"`
	DisplayName         string `json:"displayName"`
	Indices             []struct {
		ID    int    `json:"id"`
		Index string `json:"index"`
		Value string `json:"value"`
	} `json:"indices"`
	DocTypeIndexDefs []struct {
		IndexName      string   `json:"indexName"`
		DefinitionList []string `json:"definitionList"`
	} `json:"docTypeIndexDefs"`
}

DocumentTypes in a given department and cabinet

type DocumentTypesResponse

type DocumentTypesResponse struct {
	DocumentTypes DocumentTypes `json:"documentTypes"`
	HasError      bool          `json:"hasError"`
	ErrorMessage  string        `json:"errorMessage"`
}

DocumentTypesResponse Response containing any errors and the DocumentTypes

type File

type File struct {
	FileID       int    `json:"fileId"`
	FileFullName string `json:"fileFullName"`
	Department   string `json:"department"`
	Cabinet      string `json:"cabinet"`
	FolderID     int    `json:"folderId"`
	TabID        int    `json:"tabId"`
}

File represents a file in treeno

type FilesAddRequest

type FilesAddRequest struct {
}

FilesAddRequest TODO seems like it's not finished

type FilesAddResponse

type FilesAddResponse struct {
	File         File   `json:"file"`
	HasError     bool   `json:"hasError"`
	ErrorMessage string `json:"errorMessage"`
}

FilesAddResponse Response containing any errors and the file that was added

type FilesDownloadRequest

type FilesDownloadRequest struct {
	Department string `json:"department"`
	Cabinet    string `json:"cabinet"`
	FileIds    []int  `json:"fileIds"`
	Format     string `json:"format"`   // optional
	Filename   string `json:"filename"` // optional
}

FilesDownloadRequest request for file download

type FilesDownloadResponse

type FilesDownloadResponse struct {
	DownloadFile FilesDownloadRequest `json:"downloadFile"`
	FileContent  []byte               `json:"fileContent"`
	HasError     bool                 `json:"hasError"`
	ErrorMessage string               `json:"errorMessage"`
}

FilesDownloadResponse Response containing any errors, the file contents and the request

type FilesGetFilesInFolderResponse

type FilesGetFilesInFolderResponse struct {
	Files        FilesInFolder `json:"files"`
	HasError     bool          `json:"hasError"`
	ErrorMessage string        `json:"errorMessage"`
}

FilesGetFilesInFolderResponse Response containing any errors and the files in the folder

type FilesInFolder

type FilesInFolder []struct {
	FileID    int    `json:"fileId"`
	Filename  string `json:"filename"`
	Subfolder string `json:"subfolder"`
}

FilesInFolder slice of filenames and ids

type FilesUploadToFolderRequest

type FilesUploadToFolderRequest struct {
	Department  string `json:"department"`
	CabinetID   int    `json:"cabinetId"`
	DocID       int    `json:"docId"`
	TabID       int    `json:"tabId,omitempty"`
	Filename    string `json:"filename"`
	FileContent []byte `json:"fileContent"`
}

FilesUploadToFolderRequest request for file upload

type FilesUploadToFolderResponse

type FilesUploadToFolderResponse struct {
	Upload       FilesUploadToFolderRequest `json:"upload"`
	FileID       int                        `json:"fileId"`
	HasError     bool                       `json:"hasError"`
	ErrorMessage string                     `json:"errorMessage"`
}

FilesUploadToFolderResponse Response containing any errors and the initial request

type Folder

type Folder struct {
	FolderID   int     `json:"folderId"`  // optional
	CabinetID  int     `json:"cabinetId"` // optional, this or cabinet might be required
	Department string  `json:"department"`
	Cabinet    string  `json:"cabinet"` // optional, this or cabinetId might be required
	Indices    Indices `json:"indices"`
}

Folder represents a folder in Treeno

func (*Folder) IndexValue

func (f *Folder) IndexValue(index string) (value string)

IndexValue Find the value for a given index, or empty string

type FolderAddResponse

type FolderAddResponse struct {
	Folder       Folder `json:"folder"`
	HasError     bool   `json:"hasError"`
	ErrorMessage string `json:"errorMessage"`
}

FolderAddResponse Response to add folder to cabinet

type FolderDeleteRequest added in v0.0.7

type FolderDeleteRequest struct {
	FolderID   int    `json:"folderId"` // optional
	Department string `json:"department"`
	Cabinet    string `json:"cabinet"` // optional, this or cabinetId might be required
	Force      bool   `json:"force,omitempty"`
}

type FolderDeleteResponse added in v0.0.7

type FolderDeleteResponse struct {
	Folder       FolderDeleteRequest `json:"folder"`
	HasError     bool                `json:"hasError"`
	ErrorMessage string              `json:"errorMessage"`
}

type FolderEditRequest added in v0.0.8

type FolderEditRequest struct {
	DocId      int     `json:"DocId"`
	Department string  `json:"Department"`
	Cabinet    string  `json:"Cabinet"`
	Indices    Indices `json:"Indices"`
}

type FolderEditResponse added in v0.0.8

type FolderEditResponse struct {
	HasError     bool   `json:"HasError"`
	ErrorMessage string `json:"ErrorMessage"`
	IsSuccess    bool   `json:"IsSuccess"`
	Folder       struct {
		DocId      int    `json:"DocId"`
		Department string `json:"Department"`
		Cabinet    string `json:"Cabinet"`
		Indices    []struct {
			Index string `json:"Index"`
			Value string `json:"Value"`
		} `json:"Indices"`
	} `json:"Folder"`
}

type Folders

type Folders []Folder

Folders slice of folders

type FoldersResponse

type FoldersResponse struct {
	Folders      Folders `json:"folders"`
	HasError     bool    `json:"hasError"`
	ErrorMessage string  `json:"errorMessage"`
}

FoldersResponse GetFolders response

type Index added in v0.0.3

type Index struct {
	Index string `json:"index"`
	Value string `json:"value"` // optional?
}

Index for many things

type IndexQuery

type IndexQuery struct {
	Id       int    `json:"id,omitempty"`
	Index    string `json:"index"`
	Value    string `json:"value,omitempty"`
	Operator string `json:"operator,omitempty"`
}

IndexQuery for querying cabinets Available operators contains endswith startswith isblank < <= > >= equalto

type Indices

type Indices []Index

Indices slice of indexes

func (Indices) ToJSON added in v0.0.9

func (wrs Indices) ToJSON() ([]byte, error)

ToJSON marshall indexes to json for the purpose of unmarshalling

func (Indices) ToMap

func (wrs Indices) ToMap() (m map[string]string)

ToMap slice of Indices to map of indexes with values

func (Indices) Unmarshal added in v0.0.9

func (wrs Indices) Unmarshal(v interface{}) error

Unmarshal recently marshalled json to a thing

type PersonalInboxInfo added in v0.0.6

type PersonalInboxInfo struct {
	Username string `json:"username"`
	Value    string `json:"value"`
}

type PersonalInboxInfoResponse added in v0.0.6

type PersonalInboxInfoResponse struct {
	Info         []PersonalInboxInfo `json:"info"`
	HasError     bool                `json:"hasError"`
	ErrorMessage string              `json:"errorMessage"`
}

type StartWorkflowResponse added in v0.0.3

type StartWorkflowResponse struct {
	IsSuccess    bool                `json:"isSuccess"`
	Result       StartWorkflowResult `json:"result"`
	HasError     bool                `json:"hasError"`
	ErrorMessage string              `json:"errorMessage"`
}

StartWorkflowResponse server response for starting a workflow

type StartWorkflowResult added in v0.0.3

type StartWorkflowResult struct {
	Success   bool     `json:"success"`
	ToDoUsers []string `json:"toDoUsers"`
	WfDocId   int      `json:"wfDocId"`
	NodeId    int      `json:"nodeId"`
}

StartWorkflowResult results of starting a workflow

type TabInfoList

type TabInfoList []struct {
	TabName    string `json:"tabName"`
	FileName   string `json:"fileName"`
	FileID     int    `json:"fileId"`
	DocID      int    `json:"docId"`
	FileSize   int    `json:"fileSize"`
	Department string `json:"department"`
	CabinetID  int    `json:"cabinetId"`
}

TabInfoList slice of tabs

type TabInfoResponse

type TabInfoResponse struct {
	TabInfoList  TabInfoList `json:"tabInfoList"`
	HasError     bool        `json:"hasError"`
	ErrorMessage string      `json:"errorMessage"`
}

TabInfoResponse response of getSavedTabs

type TabRequest

type TabRequest struct {
	TabName    string `json:"tabName,"`
	FileName   string `json:"fileName,"`
	FileID     int    `json:"fileId,"`
	DocID      int    `json:"docId,"`
	FileSize   int    `json:"fileSize,"`
	Department string `json:"department,"`
	CabinetID  int    `json:"cabinetId,"`
}

TabRequest Request for list of tabs

type User

type User struct {
	ID       int    `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
	LdapID   int    `json:"ldapId"`
	Email    string `json:"email"`
}

User login acting user

type Workflow added in v0.0.3

type Workflow struct {
	Department string `json:"department"`
	Cabinet    string `json:"cabinet"`
	DocId      int    `json:"docId"`
	FileId     int    `json:"fileId"`
	OwnerName  string `json:"ownerName"`
	WfId       int    `json:"wfId"`
	Subfolder  string `json:"subfolder,omitempty"`
}

Workflow represents a treeno workflow

type WorkflowDefinition added in v0.0.5

type WorkflowDefinition struct {
	WorkflowId   int    `json:"workflowId"`
	WorkflowName string `json:"workflowName"`
}

WorkflowDefinition Workflow id and description

type WorkflowDefinitionsResponse added in v0.0.5

type WorkflowDefinitionsResponse struct {
	WorkflowDefinitions []WorkflowDefinition `json:"workflowDefinitions"`
	HasError            bool                 `json:"hasError"`
	ErrorMessage        string               `json:"errorMessage"`
}

WorkflowDefinitionsResponse Response from getting definitions of workflows

Jump to

Keyboard shortcuts

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