fivesim-api
Version:
Node.js wrapper for the 5sim.net API - SMS verification service with TypeScript support
114 lines (113 loc) • 3.53 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GuestService = void 0;
const axios_1 = __importDefault(require("axios"));
const error_1 = require("../utils/error");
class GuestService {
/**
* Get available products for a specific country and operator
*/
static async getProducts(country, operator) {
try {
const response = await axios_1.default.get(`${this.baseURL}/guest/products/${country}/${operator}`, {
headers: { Accept: "application/json" },
});
return response.data;
}
catch (error) {
throw (0, error_1.createError)(error);
}
}
/**
* Get all prices
*/
static async getPrices() {
try {
const response = await axios_1.default.get(`${this.baseURL}/guest/prices`, {
headers: { Accept: "application/json" },
});
return response.data;
}
catch (error) {
throw (0, error_1.createError)(error);
}
}
/**
* Get prices for a specific country
*/
static async getPricesByCountry(country) {
try {
const response = await axios_1.default.get(`${this.baseURL}/guest/prices`, {
headers: { Accept: "application/json" },
params: { country },
});
return response.data;
}
catch (error) {
throw (0, error_1.createError)(error);
}
}
/**
* Get prices for a specific product
*/
static async getPricesByProduct(product) {
try {
const response = await axios_1.default.get(`${this.baseURL}/guest/prices`, {
headers: { Accept: "application/json" },
params: { product },
});
return response.data;
}
catch (error) {
throw (0, error_1.createError)(error);
}
}
/**
* Get prices for a specific country and product combination
*/
static async getPricesByCountryAndProduct(country, product) {
try {
const response = await axios_1.default.get(`${this.baseURL}/guest/prices`, {
headers: { Accept: "application/json" },
params: { country, product },
});
return response.data;
}
catch (error) {
throw (0, error_1.createError)(error);
}
}
/**
* Get notifications in specified language
*/
static async getNotifications(lang) {
try {
const response = await axios_1.default.get(`${this.baseURL}/guest/flash/${lang}`, {
headers: { Accept: "application/json" },
});
return response.data;
}
catch (error) {
throw (0, error_1.createError)(error);
}
}
/**
* Get list of available countries
*/
static async getCountries() {
try {
const response = await axios_1.default.get(`${this.baseURL}/guest/countries`, {
headers: { Accept: "application/json" },
});
return response.data;
}
catch (error) {
throw (0, error_1.createError)(error);
}
}
}
exports.GuestService = GuestService;
GuestService.baseURL = "https://5sim.net/v1";