docuphase

package module
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 12 Imported by: 0

README

Docuphase Golang

A go library for interacting with Docuphase

Use with caution, some methods have not been tested

Documentation

Index

Constants

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

DateFormat format used by docuphase

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

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   docuphaseTime `json:"expiration"`
}

Authentication Auth info

type Bool

type Bool bool

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

func (*Bool) MarshalJSON

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

MarshalJSON Marshall to valid docuphase date

func (*Bool) ToString added in v0.0.13

func (b *Bool) ToString() string

ToString Marshall to valid docuphase date

func (*Bool) UnmarshalJSON

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

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

type CabinetSearchFoldersResponse

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

type CabinetSearchInfo

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 CheckIn added in v0.0.12

type CheckIn struct {
	Department  string `json:"Department"`
	Cabinet     string `json:"Cabinet"`
	FileId      int    `json:"FileId"`
	FileName    string `json:"FileName"`
	EncFileData []byte `json:"EncFileData"`
}

type CheckInRequest added in v0.0.12

type CheckInRequest CheckIn

CheckInRequest request for file upload

type CheckInResponse added in v0.0.12

type CheckInResponse struct {
	HasError     bool    `json:"HasError"`
	ErrorMessage string  `json:"ErrorMessage"`
	Data         string  `json:"Data"`
	CheckIn      CheckIn `json:"CheckIn"`
}

CheckInResponse Response containing any errors and the initial request

type CheckOutFile added in v0.0.12

type CheckOutFile struct {
	Department string `json:"Department"`
	Cabinet    string `json:"Cabinet"`
	FileId     int    `json:"FileId"`
}

type Client

type Client struct {
	Authentication Authentication

	DefaultDepartment string
	// contains filtered or unexported fields
}

Client docuphase 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

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

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

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) GetUserToDo added in v0.0.14

func (client *Client) GetUserToDo(username string) (result GetToDoResponse, err error)

GetUserToDo gets the to do items for a username

func (*Client) GetUserToDoWithContext added in v0.0.15

func (client *Client) GetUserToDoWithContext(ctx context.Context, username string) (result GetToDoResponse, err error)

GetUserToDoWithContext gets the to do items for a username

func (*Client) GetWorkflowDefinitions

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) NewAuthRequestWithContext added in v0.0.15

func (client *Client) NewAuthRequestWithContext(ctx context.Context, path string, method string, body io.Reader) (req *http.Request, err error)

NewAuthRequestWithContext with auth header and body and context

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

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) SearchCabinetWithContext added in v0.0.15

func (client *Client) SearchCabinetWithContext(ctx context.Context, cabinet string, query ...IndexQuery) (results []CabinetSearchResult, err error)

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

func (*Client) StartWorkflow

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

StartWorkflow from a workflow request

func (*Client) VersionsFileCheckIn added in v0.0.12

func (client *Client) VersionsFileCheckIn(request CheckInRequest) (response CheckInResponse, err error)

VersionsFileCheckIn Check In a file I guess

func (Client) VersionsFileCheckOut added in v0.0.12

func (client Client) VersionsFileCheckOut(request VersionFileCheckOutRequest) (response VersionFileCheckOutResponse, err error)

VersionsFileCheckOut check out a file

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 docuphase API

func (*Config) Token

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

Token Authenticates and creates a new oauth token

type Date

type Date struct {
	time.Time
}

Date Valid docuphase date

func (*Date) MarshalJSON

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

MarshalJSON Marshall to valid docuphase date

func (*Date) UnmarshalJSON

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

UnmarshalJSON Unmarshall from docuphase 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 docuphase

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 docuphase

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 docuphase

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

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

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

type FolderEditRequest

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

type FolderEditResponse

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 GetToDoResponse added in v0.0.14

type GetToDoResponse struct {
	ToDoList     ToDoList `json:"toDoList"`
	HasError     bool     `json:"hasError"`
	ErrorMessage string   `json:"errorMessage"`
}

GetToDoResponse response from server for to do items for user

type Index

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

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

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

Unmarshal recently marshalled json to a thing

type PersonalInboxInfo

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

type PersonalInboxInfoResponse

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

type StartWorkflowResponse

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

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 ToDoItem added in v0.0.14

type ToDoItem struct {
	Id                 int    `json:"id"`
	Department         string `json:"department"`
	Cabinet            string `json:"cabinet"`
	DocId              int    `json:"docId"`
	FileId             int    `json:"fileId"`
	WorkflowNodeId     int    `json:"workflowNodeId"`
	Username           string `json:"username"`
	WorkflowDefId      int    `json:"workflowDefId"`
	WorkflowDocumentId int    `json:"workflowDocumentId"`
	Priority           int    `json:"priority"`
	Notes              string `json:"notes,omitempty"`
	Date               string `json:"date"`
	DelegatedFrom      string `json:"delegatedFrom,omitempty"`
}

ToDoItem an individual to do item

type ToDoList added in v0.0.14

type ToDoList []ToDoItem

ToDoList slice of ToDoItem

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 VersionFileCheckOutRequest added in v0.0.12

type VersionFileCheckOutRequest CheckOutFile

type VersionFileCheckOutResponse added in v0.0.12

type VersionFileCheckOutResponse struct {
	HasError     bool         `json:"HasError"`
	ErrorMessage string       `json:"ErrorMessage"`
	Content      []byte       `json:"Content"`
	CheckOutFile CheckOutFile `json:"CheckOutFile"`
}

type Workflow

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 docuphase workflow

type WorkflowDefinition

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

WorkflowDefinition Workflow id and description

type WorkflowDefinitionsResponse

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