Documentation ¶
Index ¶
Constants ¶
const ( // ResponseReadError occues when error happened while we tried to // read the response. ResponseReadError = "Error reading body" // ResponseReadBodyError occues when error happened while we tried to // read the body of the response. ResponseReadBodyError = "Error reading body" // ErrorResponseParseError occues when the response was an error, // but something went wrong with parsing it as an Error. ErrorResponseParseError = "Error response parse error" )
const RequestTimout = 10
RequestTimout is the timeout of a request in seconds.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseRequest ¶
BaseRequest is the base request.
func (*BaseRequest) SetAPIToken ¶
func (r *BaseRequest) SetAPIToken(token string)
SetAPIToken stores the API key for a Misskey User.
func (BaseRequest) ToJSON ¶
func (r BaseRequest) ToJSON() ([]byte, error)
ToJSON returns with the JSON []byte representation of the request.
type Client ¶
type Client struct { BaseURL string Token string HTTPClient HTTPClient }
Client is the main Misskey client struct.
func (*Client) CreateFile ¶ added in v1.2.0
func (c *Client) CreateFile(content []byte, name string) (*FileCreateResponse, error)
CreateFile sends a request to the Misskey server to create a file.
func (*Client) CreateFileFromURL ¶ added in v1.2.0
func (c *Client) CreateFileFromURL(url, name string) (*FileCreateResponse, error)
CreateFileFromURL sends a request to the Misskey server to create a file from a URL.
func (*Client) CreateNote ¶
func (c *Client) CreateNote(content string, file *FileCreateResponse) error
CreateNote sends a request to the Misskey server to create a note.
type ClientInterface ¶
type ClientInterface interface { CreateNote(content string, file *FileCreateResponse) error CreateFile(content []byte, name string) (*FileCreateResponse, error) CreateFileFromURL(url, name string) (*FileCreateResponse, error) }
ClientInterface is an interface to describe how a Client looks like. Mostly for Mocking. Or later if Misskey gets multiple API versions.
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message"` Code string `json:"code"` ID string `json:"id"` Kind string `json:"kind"` Info struct { Param string `json:"param"` Reason string `json:"reason"` } `json:"info"` }
ErrorResponse represents any kind of Error responses from Misskey.
type FileCreateRequest ¶ added in v1.2.0
type FileCreateRequest struct { *BaseRequest FolderID string Name string Sensitive bool Force bool Content []byte }
FileCreateRequest represents a CreateNote request.
type FileCreateResponse ¶ added in v1.2.0
type FileCreateResponse struct { ID string `json:"id"` CreatedAt string `json:"createdAt"` Name string `json:"name"` Type string `json:"type"` MD5 string `json:"md5"` Size uint `json:"size"` URL string `json:"url"` FolderID string `json:"folderId"` Sensitive bool `json:"isSensitive"` }
FileCreateResponse is the response structure of a file creation request.
type HTTPClient ¶
HTTPClient is a simple intreface for http.Client.
type MultipartRequest ¶ added in v1.2.0
MultipartRequest is an interface for multipart form requests.
type NoteCreateRequest ¶
type NoteCreateRequest struct { *BaseRequest Visibility string `json:"visibility"` VisibleUserIDs []string `json:"visibleUserIds,omitempty"` Text string `json:"text,omitempty"` CW string `json:"cw,omitempty"` ViaMobile bool `json:"viaMobile"` LocalOnly bool `json:"localOnly"` NoExtractMentions bool `json:"noExtractMentions"` NoExtractEmojis bool `json:"noExtractEmojis"` FileIDs []string `json:"fileIds,omitempty"` ReplyID string `json:"replyId,omitempty"` RenoteID string `json:"renoteId,omitempty"` Poll *Poll `json:"poll,omitempty"` }
NoteCreateRequest represents a CreateNote request.
type Poll ¶
type Poll struct { Choices []string `json:"choices,omitempty"` Multiple bool `json:"multiple,omitempty"` ExpiresAt uint `json:"expiresAt,omitempty"` ExpiredAfter uint `json:"expiredAfter,omitempty"` }
Poll represents a Poll data structure for Misskey.
type RequestError ¶
RequestError happens when something went wrong with the request.
func (RequestError) Error ¶
func (e RequestError) Error() string
type UnknownError ¶
type UnknownError struct {
Response ErrorResponse
}
UnknownError occues when we coudn't determine the source of the error.
func (UnknownError) Error ¶
func (e UnknownError) Error() string