Introduce HTTP API for plugins (#5383)
This commit is contained in:
Vendored
+32
@@ -32,6 +32,8 @@ declare module c2 {
|
||||
is_valid(): boolean;
|
||||
}
|
||||
|
||||
interface ISharedResource {}
|
||||
|
||||
class RoomModes {
|
||||
unique_chat: boolean;
|
||||
subscriber_only: boolean;
|
||||
@@ -69,6 +71,36 @@ declare module c2 {
|
||||
static by_twitch_id(id: string): null | Channel;
|
||||
}
|
||||
|
||||
enum HTTPMethod {
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Patch,
|
||||
}
|
||||
|
||||
class HTTPResponse implements ISharedResource {
|
||||
data(): string;
|
||||
status(): number | null;
|
||||
error(): string;
|
||||
}
|
||||
|
||||
type HTTPCallback = (res: HTTPResponse) => void;
|
||||
class HTTPRequest implements ISharedResource {
|
||||
on_success(callback: HTTPCallback): void;
|
||||
on_error(callback: HTTPCallback): void;
|
||||
finally(callback: () => void): void;
|
||||
|
||||
set_timeout(millis: number): void;
|
||||
set_payload(data: string): void;
|
||||
set_header(name: string, value: string): void;
|
||||
|
||||
execute(): void;
|
||||
|
||||
// might error
|
||||
static create(method: HTTPMethod, url: string): HTTPRequest;
|
||||
}
|
||||
|
||||
function log(level: LogLevel, ...data: any[]): void;
|
||||
function register_command(
|
||||
name: String,
|
||||
|
||||
Reference in New Issue
Block a user