Documentation
¶
Index ¶
- Constants
- type API
- func (a *API) Delete(path string) (*resty.Response, error)
- func (a *API) Get(path string, params map[string]string) (*resty.Response, error)
- func (a *API) Post(path string, body any) (*resty.Response, error)
- func (a *API) Put(path string, body any) (*resty.Response, error)
- func (a *API) SetBaseURL(baseURL string)
- func (a *API) SetTimeout(timeout int)
- type Attachment
- type Client
- func (c *Client) Delete(path string) (*resty.Response, error)
- func (c *Client) Get(path string, params map[string]string) (*resty.Response, error)
- func (c *Client) Post(path string, body any) (*resty.Response, error)
- func (c *Client) Put(path string, body any) (*resty.Response, error)
- func (c *Client) Request(method, path string, body any, result any, opts ...RequestOption) error
- func (c *Client) SetBaseURL(baseURL string)
- func (c *Client) SetTimeout(timeout time.Duration)
- type Comment
- type CommentListResponse
- type CommentResponse
- type CommentService
- type CreateCommentRequest
- type CreateMemoRequest
- type ErrorResponse
- type Group
- type GroupListResponse
- type GroupResponse
- type GroupService
- type Memo
- type MemoListResponse
- type MemoResponse
- type MemoService
- func (s *MemoService) Archive(id int) error
- func (s *MemoService) Create(req *CreateMemoRequest) (*Memo, error)
- func (s *MemoService) Delete(id int) error
- func (s *MemoService) Get(id int) (*Memo, error)
- func (s *MemoService) List(page, perPage int, query string) (*MemoListResponse, error)
- func (s *MemoService) Unarchive(id int) error
- func (s *MemoService) Update(id int, req *UpdateMemoRequest) (*Memo, error)
- type Meta
- type RequestOption
- type Tag
- type TagListResponse
- type TagService
- type UpdateMemoRequest
- type User
Constants ¶
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 (*API) SetBaseURL ¶
SetBaseURL sets the base URL of the API
func (*API) SetTimeout ¶
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 (*Client) Request ¶ added in v0.0.8
Request performs the API request and handles standard error checking and unmarshaling
func (*Client) SetBaseURL ¶
SetBaseURL sets the base URL of the API
func (*Client) SetTimeout ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) Create ¶
func (s *MemoService) Create(req *CreateMemoRequest) (*Memo, error)
Create creates a new memo
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
RequestOption allows setting custom options for requests
type TagListResponse ¶
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