cowin-api-wrapper
Version:
API wrapper for COWIN's public API with TypeScript support.
43 lines • 1.75 kB
JavaScript
;
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapSessionResponse = exports.formatDate = void 0;
/**
* Formats the date from 23/5/2021 -> 23-5-2021
* @param date
* @returns
*/
const formatDate = (date) => date.toLocaleDateString("en-IN").replace(/\//g, "-");
exports.formatDate = formatDate;
/**
* Maps the plain session response to appointment object
* @param { SessionResponse } session
* @returns { Appointment }
*/
const mapSessionResponse = (_a) => {
var { session_id, date, available_capacity, available_capacity_dose1, available_capacity_dose2, slots, min_age_limit, vaccine } = _a, center = __rest(_a, ["session_id", "date", "available_capacity", "available_capacity_dose1", "available_capacity_dose2", "slots", "min_age_limit", "vaccine"]);
return (Object.assign(Object.assign({}, center), { sessions: [
{
session_id,
date,
slots,
min_age_limit,
vaccine,
available_capacity,
available_capacity_dose1,
available_capacity_dose2,
},
] }));
};
exports.mapSessionResponse = mapSessionResponse;
//# sourceMappingURL=format-response.js.map