docbase

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseURL is the base URL of DocBase API
	BaseURL = "https://api.docbase.io"
	// APIVersion is the version of DocBase API
	APIVersion = "3"
	// DefaultTimeout is the default timeout for API requests
	DefaultTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Memo    *MemoService
	Group   *GroupService
	Tag     *TagService
	Comment *CommentService
	// contains filtered or unexported fields
}

API represents the DocBase API client

func NewAPI

func NewAPI(teamDomain, accessToken string) *API

NewAPI creates a new DocBase API client

func (*API) Delete

func (a *API) Delete(path string) (*resty.Response, error)

Delete sends a DELETE request to the API

func (*API) Get

func (a *API) Get(path string, params map[string]string) (*resty.Response, error)

Get sends a GET request to the API

func (*API) Post

func (a *API) Post(path string, body any) (*resty.Response, error)

Post sends a POST request to the API

func (*API) Put

func (a *API) Put(path string, body any) (*resty.Response, error)

Put sends a PUT request to the API

func (*API) SetBaseURL

func (a *API) SetBaseURL(baseURL string)

SetBaseURL sets the base URL of the API

func (*API) SetTimeout

func (a *API) SetTimeout(timeout int)

SetTimeout sets the timeout for API requests

type Attachment

type Attachment struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Size      int       `json:"size"`
	URL       string    `json:"url"`
	CreatedAt time.Time `json:"created_at"`
}

Attachment represents a file attachment

type Client

type Client struct {
	TeamDomain  string
	AccessToken string
	BaseURL     string
	// contains filtered or unexported fields
}

Client represents a DocBase API client

func NewClient

func NewClient(teamDomain, accessToken string) *Client

NewClient creates a new DocBase API client

func (*Client) Delete

func (c *Client) Delete(path string) (*resty.Response, error)

Delete sends a DELETE request to the API

func (*Client) Get

func (c *Client) Get(path string, params map[string]string) (*resty.Response, error)

Get sends a GET request to the API

func (*Client) Post

func (c *Client) Post(path string, body any) (*resty.Response, error)

Post sends a POST request to the API

func (*Client) Put

func (c *Client) Put(path string, body any) (*resty.Response, error)

Put sends a PUT request to the API

func (*Client) Request added in v0.0.8

func (c *Client) Request(method, path string, body any, result any, opts ...RequestOption) error

Request performs the API request and handles standard error checking and unmarshaling

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string)

SetBaseURL sets the base URL of the API

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for API requests

type Comment

type Comment struct {
	ID        int       `json:"id"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"created_at"`
	User      User      `json:"user"`
}

Comment represents a comment on a memo

type CommentListResponse

type CommentListResponse struct {
	Meta     Meta      `json:"meta"`
	Comments []Comment `json:"comments"`
}

CommentListResponse represents the response for listing comments

type CommentResponse

type CommentResponse struct {
	Comment Comment `json:"comment"`
}

CommentResponse represents the response for a single comment

type CommentService

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

CommentService handles communication with the comment related methods of the DocBase API

func NewCommentService

func NewCommentService(client *Client) *CommentService

NewCommentService creates a new comment service

func (*CommentService) Create

func (s *CommentService) Create(memoID int, req *CreateCommentRequest) (*Comment, error)

Create creates a new comment for a memo

func (*CommentService) Delete

func (s *CommentService) Delete(commentID int) error

Delete deletes a comment

func (*CommentService) List

func (s *CommentService) List(memoID, page, perPage int) (*CommentListResponse, error)

List returns a list of comments for a memo

type CreateCommentRequest

type CreateCommentRequest struct {
	Body   string `json:"body"`
	Notify bool   `json:"notice,omitempty"`
}

CreateCommentRequest represents the request for creating a comment

type CreateMemoRequest

type CreateMemoRequest struct {
	Title  string   `json:"title"`
	Body   string   `json:"body"`
	Draft  bool     `json:"draft,omitempty"`
	Tags   []string `json:"tags,omitempty"`
	Scope  string   `json:"scope,omitempty"`
	Groups []int    `json:"groups,omitempty"`
	Notify bool     `json:"notice,omitempty"`
}

CreateMemoRequest represents the request for creating a memo

type ErrorResponse

type ErrorResponse struct {
	Error    string   `json:"error"`
	Messages []string `json:"messages"`
}

ErrorResponse represents an error response from the API

type Group

type Group struct {
	ID             int        `json:"id"`
	Name           string     `json:"name"`
	CreatedAt      time.Time  `json:"created_at"`
	Description    string     `json:"description"`
	PostsCount     int        `json:"posts_count"`
	LastActivityAt *time.Time `json:"last_activity_at"`
	Users          []User     `json:"users,omitempty"`
}

Group represents a DocBase group

type GroupListResponse

type GroupListResponse struct {
	Meta   Meta    `json:"meta"`
	Groups []Group `json:"groups"`
}

GroupListResponse represents the response for listing groups

type GroupResponse

type GroupResponse struct {
	Group Group `json:"group"`
}

GroupResponse represents the response for a single group

type GroupService

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

GroupService handles communication with the group related methods of the DocBase API

func NewGroupService

func NewGroupService(client *Client) *GroupService

NewGroupService creates a new group service

func (*GroupService) Get

func (s *GroupService) Get(id int) (*Group, error)

Get returns a group by ID

func (*GroupService) GetMembers

func (s *GroupService) GetMembers(id int) ([]User, error)

GetMembers returns the members of a group

func (*GroupService) List

func (s *GroupService) List(page, perPage int) (*GroupListResponse, error)

List returns a list of groups

type Memo

type Memo struct {
	ID          int          `json:"id"`
	Title       string       `json:"title"`
	Body        string       `json:"body"`
	Draft       bool         `json:"draft"`
	Archived    bool         `json:"archived"`
	URL         string       `json:"url"`
	CreatedAt   time.Time    `json:"created_at"`
	UpdatedAt   time.Time    `json:"updated_at"`
	Scope       string       `json:"scope"`
	SharingURL  string       `json:"sharing_url"`
	Tags        []Tag        `json:"tags"`
	User        User         `json:"user"`
	Groups      []Group      `json:"groups"`
	Comments    []Comment    `json:"comments"`
	Attachments []Attachment `json:"attachments"`
	LikedUsers  []User       `json:"liked_users"`
	Stars       int          `json:"stars"`
}

Memo represents a DocBase memo

type MemoListResponse

type MemoListResponse struct {
	Meta  Meta   `json:"meta"`
	Memos []Memo `json:"posts"`
}

MemoListResponse represents the response for listing memos

type MemoResponse

type MemoResponse struct {
	Memo Memo `json:"post"`
}

MemoResponse represents the response for a single memo

type MemoService

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

MemoService handles communication with the memo related methods of the DocBase API

func NewMemoService

func NewMemoService(client *Client) *MemoService

NewMemoService creates a new memo service

func (*MemoService) Archive

func (s *MemoService) Archive(id int) error

Archive archives a memo

func (*MemoService) Create

func (s *MemoService) Create(req *CreateMemoRequest) (*Memo, error)

Create creates a new memo

func (*MemoService) Delete

func (s *MemoService) Delete(id int) error

Delete deletes a memo

func (*MemoService) Get

func (s *MemoService) Get(id int) (*Memo, error)

Get returns a memo by ID

func (*MemoService) List

func (s *MemoService) List(page, perPage int, query string) (*MemoListResponse, error)

List returns a list of memos

func (*MemoService) Unarchive

func (s *MemoService) Unarchive(id int) error

Unarchive unarchives a memo

func (*MemoService) Update

func (s *MemoService) Update(id int, req *UpdateMemoRequest) (*Memo, error)

Update updates a memo

type Meta

type Meta struct {
	PreviousPage *string `json:"previous_page"`
	NextPage     *string `json:"next_page"`
	Total        int     `json:"total"`
}

Meta represents metadata in API responses

type RequestOption added in v0.0.8

type RequestOption func(*resty.Request)

RequestOption allows setting custom options for requests

type Tag

type Tag struct {
	Name string `json:"name"`
}

Tag represents a DocBase tag

type TagListResponse

type TagListResponse struct {
	Meta Meta  `json:"meta"`
	Tags []Tag `json:"tags"`
}

TagListResponse represents the response for listing tags

type TagService

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

TagService handles communication with the tag related methods of the DocBase API

func NewTagService

func NewTagService(client *Client) *TagService

NewTagService creates a new tag service

func (*TagService) List

func (s *TagService) List(page, perPage int) (*TagListResponse, error)

List returns a list of tags

func (*TagService) Search

func (s *TagService) Search(query string, page, perPage int) (*TagListResponse, error)

Search searches for tags by name

type UpdateMemoRequest

type UpdateMemoRequest struct {
	Title  string   `json:"title,omitempty"`
	Body   string   `json:"body,omitempty"`
	Draft  *bool    `json:"draft,omitempty"`
	Tags   []string `json:"tags,omitempty"`
	Scope  string   `json:"scope,omitempty"`
	Groups []int    `json:"groups,omitempty"`
	Notify *bool    `json:"notice,omitempty"`
}

UpdateMemoRequest represents the request for updating a memo

type User

type User struct {
	ID              int       `json:"id"`
	Name            string    `json:"name"`
	Username        string    `json:"username"`
	ProfileImageURL string    `json:"profile_image_url"`
	CreatedAt       time.Time `json:"created_at"`
	Admin           bool      `json:"admin"`
}

User represents a DocBase user

Jump to

Keyboard shortcuts

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