mirror of
https://github.com/versia-pub/api.git
synced 2026-03-13 12:19:15 +01:00
feat(client): ✨ Add role API, expose more HTTP internals
This commit is contained in:
parent
d54a7462ce
commit
24c5f3effd
3 changed files with 113 additions and 9 deletions
|
|
@ -134,7 +134,7 @@ export class BaseClient {
|
|||
});
|
||||
}
|
||||
|
||||
protected async get<ReturnType>(
|
||||
public async get<ReturnType>(
|
||||
path: string,
|
||||
extra?: RequestInit,
|
||||
): Promise<Output<ReturnType>> {
|
||||
|
|
@ -143,7 +143,7 @@ export class BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
protected async post<ReturnType>(
|
||||
public async post<ReturnType>(
|
||||
path: string,
|
||||
body?: object,
|
||||
extra?: RequestInit,
|
||||
|
|
@ -153,7 +153,7 @@ export class BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
protected async postForm<ReturnType>(
|
||||
public async postForm<ReturnType>(
|
||||
path: string,
|
||||
body: FormData | ConvertibleObject,
|
||||
extra?: RequestInit,
|
||||
|
|
@ -168,7 +168,7 @@ export class BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
protected async put<ReturnType>(
|
||||
public async put<ReturnType>(
|
||||
path: string,
|
||||
body?: object,
|
||||
extra?: RequestInit,
|
||||
|
|
@ -178,7 +178,7 @@ export class BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
protected async putForm<ReturnType>(
|
||||
public async putForm<ReturnType>(
|
||||
path: string,
|
||||
body: FormData | ConvertibleObject,
|
||||
extra?: RequestInit,
|
||||
|
|
@ -193,7 +193,7 @@ export class BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
protected async patch<ReturnType>(
|
||||
public async patch<ReturnType>(
|
||||
path: string,
|
||||
body?: object,
|
||||
extra?: RequestInit,
|
||||
|
|
@ -203,7 +203,7 @@ export class BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
protected async patchForm<ReturnType>(
|
||||
public async patchForm<ReturnType>(
|
||||
path: string,
|
||||
body: FormData | ConvertibleObject,
|
||||
extra?: RequestInit,
|
||||
|
|
@ -218,7 +218,7 @@ export class BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
protected async delete<ReturnType>(
|
||||
public async delete<ReturnType>(
|
||||
path: string,
|
||||
body?: object,
|
||||
extra?: RequestInit,
|
||||
|
|
@ -228,7 +228,7 @@ export class BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
protected async deleteForm<ReturnType>(
|
||||
public async deleteForm<ReturnType>(
|
||||
path: string,
|
||||
body: FormData | ConvertibleObject,
|
||||
extra?: RequestInit,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import type { Emoji } from "../types/emoji";
|
|||
import type { FeaturedTag } from "../types/featured_tag";
|
||||
import type { ExtendedDescription, Instance } from "../types/instance";
|
||||
import type { List } from "../types/list";
|
||||
import type { LysandRole } from "../types/lysand";
|
||||
import type { Marker } from "../types/marker";
|
||||
import type { Notification } from "../types/notification";
|
||||
import type { Poll } from "../types/poll";
|
||||
|
|
@ -98,6 +99,16 @@ export class LysandClient extends BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/v1/roles/:roleId
|
||||
*
|
||||
* Lysand API only.
|
||||
* @param roleId ID of the role to add to the requesting account.
|
||||
*/
|
||||
public addRole(roleId: string, extra?: RequestInit): Promise<Output<void>> {
|
||||
return this.post<void>(`/api/v1/roles/${roleId}`, undefined, extra);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/v1/accounts/:id/block
|
||||
*
|
||||
|
|
@ -1359,6 +1370,29 @@ export class LysandClient extends BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/roles/:id
|
||||
*
|
||||
* @param id Target role ID.
|
||||
* @return Role.
|
||||
*/
|
||||
public getRole(
|
||||
id: string,
|
||||
extra?: RequestInit,
|
||||
): Promise<Output<LysandRole>> {
|
||||
return this.get<LysandRole>(`/api/v1/roles/${id}`, extra);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/roles
|
||||
*
|
||||
* Lysand API only.
|
||||
* @returns Array of roles.
|
||||
*/
|
||||
public getRoles(extra?: RequestInit): Promise<Output<LysandRole[]>> {
|
||||
return this.get<LysandRole[]>("/api/v1/roles", extra);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/scheduled_statuses/:id
|
||||
*
|
||||
|
|
@ -1889,6 +1923,20 @@ export class LysandClient extends BaseClient {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE /api/v1/roles/:roleId
|
||||
*
|
||||
* Lysand API only.
|
||||
* @param roleId Role ID to remove from requesting account.
|
||||
* @returns
|
||||
*/
|
||||
public removeRole(
|
||||
roleId: string,
|
||||
extra?: RequestInit,
|
||||
): Promise<Output<void>> {
|
||||
return this.delete<void>(`/api/v1/roles/${roleId}`, undefined, extra);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/v1/reports
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue