Fix API for getMarkers and saveMarkers
This commit is contained in:
parent
703c3e847b
commit
3df39136aa
23
example/typescript/src/mastodon/marker.ts
Normal file
23
example/typescript/src/mastodon/marker.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import generator, { Entity, Response } from 'megalodon'
|
||||
|
||||
declare var process: {
|
||||
env: {
|
||||
MASTODON_ACCESS_TOKEN: string
|
||||
}
|
||||
}
|
||||
|
||||
const BASE_URL: string = 'https://fedibird.com'
|
||||
|
||||
const access_token: string = process.env.MASTODON_ACCESS_TOKEN
|
||||
|
||||
const client = generator('mastodon', BASE_URL, access_token)
|
||||
|
||||
client.getMarkers(['home', 'notifications']).then((res: Response<Entity.Marker | {}>) => {
|
||||
console.log(res.data)
|
||||
})
|
||||
|
||||
client
|
||||
.saveMarkers({ home: { last_read_id: '106347765980135935' }, notifications: { last_read_id: '105917259070666683' } })
|
||||
.then((res: Response<Entity.Marker>) => {
|
||||
console.log(res.data)
|
||||
})
|
|
@ -68,6 +68,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/core-js": "^2.5.0",
|
||||
"@types/form-data": "^2.5.0",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/object-assign-deep": "^0.4.0",
|
||||
"@types/uuid": "^8.0.0",
|
||||
|
|
|
@ -1784,13 +1784,13 @@ export default class Mastodon implements MegalodonInterface {
|
|||
// ======================================
|
||||
// timelines/markers
|
||||
// ======================================
|
||||
public async getMarker(timeline: Array<'home' | 'notifications'>): Promise<Response<Entity.Marker | {}>> {
|
||||
public async getMarkers(timeline: Array<string>): Promise<Response<Entity.Marker | {}>> {
|
||||
return this.client.get<MastodonAPI.Entity.Marker | {}>('/api/v1/markers', {
|
||||
timeline: timeline
|
||||
})
|
||||
}
|
||||
|
||||
public async saveMarker(options?: {
|
||||
public async saveMarkers(options?: {
|
||||
home?: { last_read_id: string }
|
||||
notifications?: { last_read_id: string }
|
||||
}): Promise<Response<Entity.Marker>> {
|
||||
|
|
|
@ -1024,7 +1024,7 @@ export interface MegalodonInterface {
|
|||
* @param timelines Array of timeline names, String enum anyOf home, notifications.
|
||||
* @return Marker or empty object.
|
||||
*/
|
||||
getMarker(timeline: Array<'home' | 'notifications'>): Promise<Response<Entity.Marker | {}>>
|
||||
getMarkers(timeline: Array<string>): Promise<Response<Entity.Marker | {}>>
|
||||
/**
|
||||
* POST /api/v1/markers
|
||||
*
|
||||
|
@ -1032,7 +1032,7 @@ export interface MegalodonInterface {
|
|||
* @param options.notifications Marker position of the last read notification ID in notifications.
|
||||
* @return Marker.
|
||||
*/
|
||||
saveMarker(options?: { home?: { last_read_id: string }; notifications?: { last_read_id: string } }): Promise<Response<Entity.Marker>>
|
||||
saveMarkers(options?: { home?: { last_read_id: string }; notifications?: { last_read_id: string } }): Promise<Response<Entity.Marker>>
|
||||
// ======================================
|
||||
// notifications
|
||||
// ======================================
|
||||
|
|
|
@ -1713,14 +1713,14 @@ export default class Misskey implements MegalodonInterface {
|
|||
// ======================================
|
||||
// timelines/markers
|
||||
// ======================================
|
||||
public async getMarker(_timeline: Array<'home' | 'notifications'>): Promise<Response<Entity.Marker | {}>> {
|
||||
public async getMarkers(_timeline: Array<string>): Promise<Response<Entity.Marker | {}>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
public async saveMarker(_options?: {
|
||||
public async saveMarkers(_options?: {
|
||||
home?: { last_read_id: string }
|
||||
notifications?: { last_read_id: string }
|
||||
}): Promise<Response<Entity.Marker>> {
|
||||
|
|
|
@ -1791,13 +1791,13 @@ export default class Pleroma implements MegalodonInterface {
|
|||
// ======================================
|
||||
// timelines/markers
|
||||
// ======================================
|
||||
public async getMarker(timeline: Array<'home' | 'notifications'>): Promise<Response<Entity.Marker | {}>> {
|
||||
public async getMarkers(timeline: Array<string>): Promise<Response<Entity.Marker | {}>> {
|
||||
return this.client.get<PleromaAPI.Entity.Marker | {}>('/api/v1/markers', {
|
||||
timeline: timeline
|
||||
})
|
||||
}
|
||||
|
||||
public async saveMarker(options?: {
|
||||
public async saveMarkers(options?: {
|
||||
home?: { last_read_id: string }
|
||||
notifications?: { last_read_id: string }
|
||||
}): Promise<Response<Entity.Marker>> {
|
||||
|
|
|
@ -642,6 +642,13 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
|
||||
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==
|
||||
|
||||
"@types/form-data@^2.5.0":
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-2.5.0.tgz#5025f7433016f923348434c40006d9a797c1b0e8"
|
||||
integrity sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==
|
||||
dependencies:
|
||||
form-data "*"
|
||||
|
||||
"@types/graceful-fs@^4.1.2":
|
||||
version "4.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.3.tgz#039af35fe26bec35003e8d86d2ee9c586354348f"
|
||||
|
@ -2031,7 +2038,7 @@ forever-agent@~0.6.1:
|
|||
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
|
||||
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=
|
||||
|
||||
form-data@^4.0.0:
|
||||
form-data@*, form-data@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||
|
|
Loading…
Reference in a new issue