geonet
Version:
A Node.js API wrapper for GeoNet — Aotearoa's geological hazard monitoring system.
43 lines (42 loc) • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VolcanoService = void 0;
const base_1 = require("../../@types/base");
const volcano_1 = require("../../@types/volcano");
const BaseService_1 = require("./BaseService");
/**
* VolcanoService class for volcanic alert level information and volcano earthquakes from the GeoNet API.
* @extends BaseService
* @since 1.0.0
*/
class VolcanoService extends BaseService_1.BaseService {
/**
* Fetches the volcanic alert level data for every volcano.
*
* @returns {Promise<VolcanoAlertLevelResponse>} - A promise that resolves to the volcanic alert level data.
* @since 1.0.0
*/
async getVolcanoAlertLevel() {
return await this.GET({
endpoint: "/volcano/val",
format: base_1.JSONFormatTypes.APPLICATION_VND_GEO_JSON_VERSION_2
});
}
/**
* Fetches quakes in the vicinity of the volcano within a pre-defined region by GeoNet over the past 60 days.
*
* @param {VolcanoID} volcanoID - The request object containing the volcano ID.
* @returns {Promise<VolcanoQuakeResponse>} - A promise that resolves to the volcano quake data.
* @throws {Error} - Throws an error if the volcano ID is not provided or is not a valid volcano ID.
* @since 1.0.0
*/
async getVolcanoQuakes(volcanoID) {
if (!volcanoID || !Object.values(volcano_1.VolcanoID).includes(volcanoID))
throw new Error("Volcano ID not provided, or was invalid.");
return await this.GET({
endpoint: `/volcano/quake/${volcanoID}`,
format: base_1.JSONFormatTypes.APPLICATION_VND_GEO_JSON_VERSION_2
});
}
}
exports.VolcanoService = VolcanoService;