verimor-api-sdk
Version:
A NodeJS SDK for the Verimor API
57 lines • 2.58 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageApi = void 0;
const base_api_1 = require("./base-api");
const error_response_1 = require("../models/error-response");
/**
* MessageApi class provides methods to interact with message-related endpoints.
*/
class MessageApi extends base_api_1.BaseApi {
/**
* Creates an instance of MessageApi.
* @param username - The API username.
* @param password - The API password.
* @param proxyConfig - Optional proxy configuration.
*/
constructor(username, password, proxyConfig) {
super(username, password, proxyConfig);
}
/**
* Retrieves the status of messages.
* @param params - Parameters for fetching message status.
* @returns Promise resolving to an array of MessageStatusResponse.
* @throws ErrorResponse if the API call fails.
*/
getMessageStatus(params) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
// Include credentials in query parameters
const queryParams = this.withCredentialsParams({
id: params.id,
custom_id: params.custom_id,
dest: params.dest ? params.dest.join(',') : undefined,
greater_than: params.greater_than,
});
const response = yield this.apiClient.get('/status', {
params: queryParams,
});
return response.data;
}
catch (error) {
throw new error_response_1.ErrorResponse(((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
}
});
}
}
exports.MessageApi = MessageApi;
//# sourceMappingURL=message-api.js.map