dynalist

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

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

Go to latest
Published: Jul 3, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

README

dynalist-go

GoDoc Go Report Card

Set an env before using:

export DYNALIST_TOKEN=your_secret_token

example

Get file list:

api, err := dynalist.New()
if err != nil {
	panic(err)
}

res, err := api.FileList()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", res)

Documentation

Overview

Package dynalist implements dynalist.io API for Go

Set an env before using: export DYNALIST_TOKEN=your_secret_token

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Token      string    `json:"token"`
	RateLimit  time.Time `json:"-"`
	BurstLimit int       `json:"-"`
	// contains filtered or unexported fields
}

func New

func New() (*API, error)

func (*API) DocEdit

func (api *API) DocEdit(fileID string, changes []*Change) (*Response, error)

func (*API) DocRead

func (api *API) DocRead(fileID string) (*Response, error)

func (*API) FileEdit

func (api *API) FileEdit(changes []*Change) (*Response, error)

func (*API) FileList

func (api *API) FileList() (*Response, error)

func (*API) InboxAdd

func (api *API) InboxAdd(change *Change) (*Response, error)

func (*API) LimitChange

func (api *API) LimitChange() *Limit

func (*API) LimitDocEdit

func (api *API) LimitDocEdit() *Limit

func (*API) LimitDocRead

func (api *API) LimitDocRead() *Limit

func (*API) LimitFileEdit

func (api *API) LimitFileEdit() *Limit

func (*API) LimitFileList

func (api *API) LimitFileList() *Limit

func (*API) LimitInboxAdd

func (api *API) LimitInboxAdd() *Limit

type Action

type Action string
const (
	ActionInsert Action = "action"
	ActionEdit   Action = "edit"
	ActionMove   Action = "move"
	ActionDelete Action = "delete"
)

type Change

type Change struct {
	Action   Action `json:"action"`
	Index    int    `json:"index,omitempty"`
	NodeID   string `json:"node_id,omitempty"`
	ParentID string `json:"parent_id,omitempty"`
	Content  string `json:"content,omitempty"`
	Type     Type   `json:"type,omitempty"`
	FileID   string `json:"file_id,omitempty"`
	Title    string `json:"title,omitempty"`
	Note     string `json:"note,omitempty"`
	Checked  bool   `json:"checked,omitempty"`
}

func NewChange

func NewChange(action Action) *Change

type Code

type Code string
const (
	CodeOK Code = "Ok"
	//Your request is not valid JSON.
	CodeInvalid Code = "Invalid"
	//You've hit the limit on how many requests you can send.
	CodeTooManyRequests Code = "TooManyRequests"
	//Your secret token is invalid.
	CodeInvalidToken Code = "InvalidToken"
	//Server unable to handle the request.
	CodeLockFail Code = "LockFail"
	//You don't have permission to access this document.
	CodeUnauthorized Code = "Unauthorized"
	//The document you're requesting is not found.
	CodeNotFound Code = "NotFound"
	//The node (item) you're requesting is not found.
	CodeNodeNotFound Code = "NodeNotFound"
	//Inbox location is not configured, or invalid.
	CodeNoInbox Code = "NoInbox"
)

type File

type File struct {
	ID         string     `json:"id"`
	Title      string     `json:"title"`
	Type       Type       `json:"type"`
	Permission Permission `json:"permission"`
	Collapsed  bool       `json:"collapsed,omitempty"`
	Children   []string   `json:"children,omitempty"`
}

type Limit

type Limit struct {
	Rate  time.Duration
	Burst int
}

type Node

type Node struct {
	ID        string   `json:"id"`
	Content   string   `json:"content"`
	Note      string   `json:"note,omitempty"`
	Checked   bool     `json:"checked,omitempty"`
	Collapsed bool     `json:"collapsed,omitempty"`
	Parent    string   `json:"parent,omitempty"`
	Children  []string `json:"children,omitempty"`
}

type Permission

type Permission int
const (
	PermissionNoAccess Permission = iota
	PermissionReadOnly
	PermissionEditRights
	PermissionManage
	PermissionOwner
)

type Response

type Response struct {
	Code       Code   `json:"_code"`
	Msg        string `json:"_msg"`
	RootFileID string `json:"root_file_id,omitempty"`
	Files      []File `json:"files,omitempty"`
	Results    []bool `json:"results,omitempty"`
	Title      string `json:"title,omitempty"`
	Nodes      []Node `json:"nodes,omitempty"`
}

type Type

type Type string
const (
	TypeDocument Type = "document"
	TypeFolder   Type = "folder"
)

Jump to

Keyboard shortcuts

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