@piarre/ts-freebox
Version:
59 lines (56 loc) • 1.93 kB
JavaScript
import {
submodule_default
} from "./chunk-3GGSTR2F.mjs";
import {
fetch_default
} from "./chunk-4JVQES7H.mjs";
// src/lib/port.ts
var PortForwarding = class extends submodule_default {
constructor(freebox) {
super(freebox);
}
/**
* Retrieves the status of a port or all ports.
* @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#getting-the-list-of-port-forwarding
* @param id - The ID of the port to retrieve the status for. If not provided, retrieves the status of all ports.
* @returns {Promise<Response<T>>}
*/
async status(id) {
return await fetch_default(id == void 0 ? `${this.baseUrl}/fw/redir/` : `${this.baseUrl}/fw/redir/${id}`, this.token);
}
/**
* Updating a port forwarding
* @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#updating-a-port-forwarding
* @param id The id of the port to update
* @param data The data to update
* @returns {Promise<Response<T>>}
*/
async update(id, data) {
return await fetch_default(`${this.baseUrl}/fw/redir/${id}`, this.token, {
body: data
}, "PUT");
}
/**
* Add a port forwarding
* @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#add-a-port-forwarding
* @param data Add a port forwarding
* @returns {Promise<Response<T>>}
*/
async add(data) {
return await fetch_default(`${this.baseUrl}/fw/redir/`, this.token, {
body: data
}, "POST");
}
/**
* Delete a port forwarding
* @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#delete-a-port-forwarding
* @param id The id of the port to delete
* @returns {Promise<VoidResponse>}
*/
async delete(id) {
return await fetch_default(`${this.baseUrl}/fw/redir/${id}`, this.token, {}, "DELETE");
}
};
export {
PortForwarding
};