@elucidatainc/pollycli
Version:
pollycli lets users access the functionalities of Polly over a command line interface
55 lines (50 loc) • 1.26 kB
JavaScript
const pollymsg = require("./message");
const axios = require("axios");
const pollyHeader = require("./pollyheaders.js");
const dateFormat = (EpocTimeInSec) => {
const options = {
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: true,
};
return new Date(parseInt(EpocTimeInSec)).toLocaleString("en-US", options);
};
const onlyDayYearFormat = (EpocTimeInSec) => {
const options = { year: "numeric", month: "long", day: "numeric" };
return new Date(parseInt(EpocTimeInSec)).toLocaleString("en-US", options);
};
const checkName = (name) => {
if (!name ) {
pollymsg.pollyError("Workspace name not given");
}
};
async function projectDataPostCall(projectUrl, payload, headers) {
try {
const response = await axios.post(projectUrl, payload, headers);
return response;
} catch (e) {
throw e;
};
}
async function apiDataGetCall(pollyEnv, projectUrl, headers) {
try {
const response = await axios.get(
`${pollyEnv.baseV2Api}${projectUrl}`,
headers
);
return response;
} catch (e) {
throw e;
}
}
module.exports = {
checkName,
onlyDayYearFormat,
dateFormat,
projectDataPostCall,
apiDataGetCall,
};