-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
49 lines (42 loc) · 1.39 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import {Turknet} from "../../Turknet";
import * as GlobalTypes from "../../dataTypes";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
dayjs.extend(utc);
export interface TelekomFaultObject {
outageStatus: string;
lastUpdated: Date;
province: string;
city: string;
popExchange: string;
}
export class TelekomSSGProblems {
/** @internal @ignore */
private __client: Turknet;
constructor(client: Turknet) {
this.__client = client;
}
private __stripASPDateString(datestr: string): number {
return parseInt(datestr.replace(/^\/Date\(|\+\d{4}\)\/$/, ""), 10);
}
async getAll(): Promise<TelekomFaultObject[]> {
try {
let raw = await this.__client.__request() as GlobalTypes.ResultObject;
let data = raw.TelecomSsgFaultInfoList;
let res = [];
for (const faultObj of data) {
let ob: TelekomFaultObject = {
outageStatus: faultObj.ArizaDurumu,
lastUpdated: dayjs(this.__stripASPDateString(faultObj.GuncellenmeTarihi)).utcOffset(3).toDate(),
province: faultObj.Il,
city: faultObj.Ilce,
popExchange: faultObj.POP
};
res.push(ob);
}
return res;
} catch (error) {
throw error;
}
}
}