Fix comments in mastodon
This commit is contained in:
parent
4190587dc1
commit
48c79204aa
|
@ -9,9 +9,9 @@ const DEFAULT_URL = 'https://mastodon.social'
|
|||
const DEFAULT_SCOPE = 'read write follow'
|
||||
|
||||
/**
|
||||
* for Mastodon API
|
||||
* Mastodon API client.
|
||||
*
|
||||
* using superagent for request, you will handle promises
|
||||
* Using axios for request, you will handle promises.
|
||||
*/
|
||||
export default class Mastodon {
|
||||
static DEFAULT_SCOPE = DEFAULT_SCOPE
|
||||
|
@ -31,8 +31,8 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* unauthorized GET request to mastodon REST API
|
||||
* @param path relative path from ${baseUrl}/api/v1/ or absolute path
|
||||
* Unauthorized GET request to mastodon REST API.
|
||||
* @param path relative path from baseUrl
|
||||
* @param params Query parameters
|
||||
* @param baseUrl base URL of the target
|
||||
*/
|
||||
|
@ -53,12 +53,8 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* Wrapper for personal OAuth Application (createApp and generateAuthUrl)
|
||||
*
|
||||
* First, [POST /api/v1/apps](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#apps)
|
||||
* only client_name is required, so others are optional.
|
||||
* Secound, generate an authorization url.
|
||||
* finally, return promise of OAuth.AppData instance, which has client_id, client_secret, url, and so on.
|
||||
* First, call createApp to get client_id and client_secret.
|
||||
* Next, call generateAuthUrl to get authorization url.
|
||||
* @param client_name Form Data, which is sent to /api/v1/apps
|
||||
* @param options Form Data, which is sent to /api/v1/apps. and properties should be **snake_case**
|
||||
* @param baseUrl base URL of the target
|
||||
|
@ -88,7 +84,7 @@ export default class Mastodon {
|
|||
/**
|
||||
* Create an application
|
||||
*
|
||||
* First, [POST /api/v1/apps](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#apps)
|
||||
* First, POST /api/v1/apps.
|
||||
* @param client_name your application's name
|
||||
* @param options Form Data
|
||||
* @param baseUrl target of base URL
|
||||
|
@ -121,7 +117,7 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* generate authorization url
|
||||
* Generate authorization url using OAuth2.
|
||||
*
|
||||
* @param clientId your OAuth app's client ID
|
||||
* @param clientSecret your OAuth app's client Secret
|
||||
|
@ -150,7 +146,9 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* Fetch OAuth access token
|
||||
* Fetch OAuth access token.
|
||||
* Get an access token based client_id and client_secret and authorization code.
|
||||
*
|
||||
* @param client_id will be generated by #createApp or #registerApp
|
||||
* @param client_secret will be generated by #createApp or #registerApp
|
||||
* @param code will be generated by the link of #generateAuthUrl or #registerApp
|
||||
|
@ -174,8 +172,8 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* GET request to mastodon REST API
|
||||
* @param path relative path from ${baseUrl}/api/v1/ or absolute path
|
||||
* GET request to mastodon REST API.
|
||||
* @param path relative path from baseUrl
|
||||
* @param params Query parameters
|
||||
*/
|
||||
public get<T>(path: string, params = {}): Promise<T> {
|
||||
|
@ -190,9 +188,9 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* PATCH request to mastodon REST API
|
||||
* @param path relative path from ${baseUrl}/api/v1/ or absolute path
|
||||
* @param params Form data
|
||||
* PATCH request to mastodon REST API.
|
||||
* @param path relative path from baseUrl
|
||||
* @param params Form data. If you want to post file, please use FormData()
|
||||
*/
|
||||
public patch<T>(path: string, params = {}): Promise<T> {
|
||||
return axios
|
||||
|
@ -205,8 +203,8 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* POST request to mastodon REST API
|
||||
* @param path relative path from ${baseUrl}/api/v1/ or absolute path
|
||||
* POST request to mastodon REST API.
|
||||
* @param path relative path from baseUrl
|
||||
* @param params Form data
|
||||
*/
|
||||
public post<T>(path: string, params = {}): Promise<T> {
|
||||
|
@ -220,8 +218,8 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* DELETE request to mastodon REST API
|
||||
* @param path relative path from ${baseUrl}/api/v1/ or absolute path
|
||||
* DELETE request to mastodon REST API.
|
||||
* @param path relative path from baseUrl
|
||||
*/
|
||||
public del(path: string): Promise<{}> {
|
||||
return axios
|
||||
|
@ -234,11 +232,12 @@ export default class Mastodon {
|
|||
}
|
||||
|
||||
/**
|
||||
* receive Server-sent Events from Mastodon Streaming API
|
||||
* @param path relative path from ${baseUrl}/api/v1/streaming/ or absolute path
|
||||
* 'public', 'public/local', 'user' and 'hashtag?tag=${tag}' are available.
|
||||
* Receive Server-sent Events from Mastodon Streaming API.
|
||||
* Create streaming connection, and start streamin.
|
||||
*
|
||||
* @param path relative path from baseUrl
|
||||
* @param reconnectInterval interval of reconnect
|
||||
* @returns streamListener, which inherits from EventEmitter and has event, 'update', 'notification', 'delete', and so on.
|
||||
* @returns streamListener, which inherits from EventEmitter
|
||||
*/
|
||||
public stream(path: string, reconnectInterval = 1000): StreamListener {
|
||||
const headers = {
|
||||
|
|
Loading…
Reference in a new issue