1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const xml2js = require("xml2js");
|
4 | class RootDescription {
|
5 | constructor(remoteAddress, rootDescription) {
|
6 | this.remoteAddress = remoteAddress;
|
7 | this.rootDescription = rootDescription;
|
8 | }
|
9 | static parse(remoteAddress, xml) {
|
10 | return new Promise((resolve, reject) => {
|
11 | xml2js.parseString(xml, (error, result) => {
|
12 | if (error) {
|
13 | reject(error);
|
14 | }
|
15 | else {
|
16 | resolve(new RootDescription(remoteAddress, result));
|
17 | }
|
18 | });
|
19 | });
|
20 | }
|
21 | get friendlyName() {
|
22 | return this.rootDescription['root']['device'][0]['friendlyName'][0];
|
23 | }
|
24 | get modelDescription() {
|
25 | if (!this.rootDescription['root']['device'][0]['modelDescription']) {
|
26 | return undefined;
|
27 | }
|
28 | return this.rootDescription['root']['device'][0]['modelDescription'][0];
|
29 | }
|
30 | get modelName() {
|
31 | return this.rootDescription['root']['device'][0]['modelName'][0];
|
32 | }
|
33 | get modelNumber() {
|
34 | if (!this.rootDescription['root']['device'][0]['modelNumber']) {
|
35 | return undefined;
|
36 | }
|
37 | return this.rootDescription['root']['device'][0]['modelNumber'][0];
|
38 | }
|
39 | get macAddress() {
|
40 |
|
41 |
|
42 |
|
43 | if (!this.rootDescription['root']['device'][0]['serialNumber']) {
|
44 | return undefined;
|
45 | }
|
46 | return this.rootDescription['root']['device'][0]['serialNumber'][0].toUpperCase();
|
47 | }
|
48 | get presentationUrl() {
|
49 | if (!this.rootDescription['root']['device'][0]['presentationURL']) {
|
50 | return undefined;
|
51 | }
|
52 | return this.rootDescription['root']['device'][0]['presentationURL'][0];
|
53 | }
|
54 | }
|
55 | exports.RootDescription = RootDescription;
|
56 |
|
\ | No newline at end of file |