go-e-api-ts
Version:
GoE-Charger Typescript API
97 lines (96 loc) • 3.8 kB
JavaScript
"use strict";
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.User = void 0;
class User {
setData(url, cardNo) {
return __awaiter(this, void 0, void 0, function* () {
this.cardNumber = cardNo;
yield fetch(url)
.then(r => r.json())
.then(status => {
switch (cardNo) {
case 1:
{
this.rfid = status.rca;
this.kWhCharged = parseInt(status.eca);
}
;
break;
case 2:
{
this.rfid = status.rcr;
this.kWhCharged = parseInt(status.ecr);
}
;
break;
case 3:
{
this.rfid = status.rcd;
this.kWhCharged = parseInt(status.ecd);
}
;
break;
case 4:
{
this.rfid = status.rc4;
this.kWhCharged = parseInt(status.ec4);
}
;
break;
case 5:
{
this.rfid = status.rc5;
this.kWhCharged = parseInt(status.ec5);
}
;
break;
case 6:
{
this.rfid = status.rc6;
this.kWhCharged = parseInt(status.ec6);
}
;
break;
case 7:
{
this.rfid = status.rc7;
this.kWhCharged = parseInt(status.ec7);
}
;
break;
case 8:
{
this.rfid = status.rc8;
this.kWhCharged = parseInt(status.ec8);
}
;
break;
case 9:
{
this.rfid = status.rc9;
this.kWhCharged = parseInt(status.ec9);
}
;
break;
case 10:
{
this.rfid = status.rc1;
this.kWhCharged = parseInt(status.ec1);
}
;
break;
}
});
});
}
}
exports.User = User;