@itutoring/itutoring_application_js_api 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/apiController.js +14 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# iTutoring Application Javascript API
|
|
2
|
+
|
|
3
|
+
This package contains a javascript API for iTutoring Application.
|
|
4
|
+
In order to use this API you need to obtain an API key.
|
|
5
|
+
|
|
6
|
+
API Documentation for iTutoring Application can be found here: TO BE SOON
|
package/apiController.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import CookiesManager
|
|
2
|
-
import {R_KEYs} from "./objects/Enums";
|
|
1
|
+
import CookiesManager from "./CookiesManager";
|
|
2
|
+
import { R_KEYs } from "./objects/Enums";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Main class for comunicating with our backend REST api.
|
|
@@ -171,25 +171,23 @@ class APIController
|
|
|
171
171
|
resolve(APIController.#CLIENT_KEY);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
//
|
|
174
|
+
let keyPath = '/client_key.xml';
|
|
175
|
+
// For localhost use different xml file (to make suer we won't revwrite the server key when uploading websites)
|
|
176
176
|
if (location.hostname === "localhost")
|
|
177
177
|
{
|
|
178
|
-
|
|
179
|
-
resolve(APIController.#R_KEY);
|
|
178
|
+
keyPath = '/local_client_key.xml'
|
|
180
179
|
}
|
|
181
|
-
|
|
180
|
+
|
|
181
|
+
fetch(keyPath).then(response => response.text()).then((data) =>
|
|
182
182
|
{
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
var parser = new DOMParser();
|
|
184
|
+
var keyXML = parser.parseFromString(data, "text/xml");
|
|
185
|
+
var key = keyXML.getElementsByTagName("key")[0].childNodes[0].nodeValue;
|
|
186
|
+
|
|
187
|
+
APIController.#CLIENT_KEY = key;
|
|
188
|
+
resolve(APIController.#CLIENT_KEY);
|
|
189
|
+
});
|
|
188
190
|
|
|
189
|
-
APIController.#CLIENT_KEY = key;
|
|
190
|
-
resolve(APIController.#CLIENT_KEY);
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
191
|
});
|
|
194
192
|
}
|
|
195
193
|
|