@como/como-client 0.1.8 → 0.1.9-1.1

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/.babelrc DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "presets": [
3
- "es2015",
4
- "stage-2"
5
- ],
6
- "plugins": [
7
- [
8
- "transform-runtime",
9
- {
10
- "polyfill": false,
11
- "regenerator": true
12
- }
13
- ]
14
- ]
15
- }
package/.eslintignore DELETED
@@ -1 +0,0 @@
1
- lib
package/.eslintrc DELETED
@@ -1,46 +0,0 @@
1
- {
2
- "rules": {
3
- "no-console": 0,
4
- "no-underscore-dangle": 0,
5
- "no-unused-vars": [
6
- "error",
7
- {
8
- "argsIgnorePattern": "next"
9
- }
10
- ],
11
- "no-use-before-define": [
12
- "error",
13
- {
14
- "variables": false
15
- }
16
- ],
17
- "no-multi-str": 0,
18
- "no-mixed-spaces-and-tabs": "warn",
19
- "indent": [
20
- "warn",
21
- 4
22
- ],
23
- "max-len": [
24
- "warn",
25
- 120
26
- ],
27
- "arrow-parens": [
28
- "warn",
29
- "as-needed"
30
- ],
31
- "semi": [
32
- "warn",
33
- "always"
34
- ]
35
- },
36
- "env": {
37
- "node": true,
38
- "mocha": true
39
- },
40
- "parserOptions": {
41
- "ecmaVersion": 8
42
- },
43
- "extends": [
44
- "airbnb-base"
45
- ]
46
- }
@@ -1,14 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "program": "${workspaceFolder}/test.js"
12
- }
13
- ]
14
- }
package/como.js DELETED
@@ -1,413 +0,0 @@
1
- import moment from 'moment-timezone';
2
- import * as ramda from "ramda";
3
-
4
- // THIS IS NOT FOR REAL!
5
- export const como = {};
6
- const comoData = {
7
- env:{
8
- hotfix:{
9
- zapp_root: "https://app-dot-como-hotfix.appspot.com",
10
- services_root: "https://services-dot-como-hotfix.appspot.com",
11
- app_modules_root: "https://appmodules-hotfix.como.com",
12
- demo_locationId:"hotfix_7301"
13
- },
14
- qa:{
15
- zapp_root: "https://app-dot-comoqa.appspot.com",
16
- services_root: "https://services-dot-comoqa.appspot.com",
17
- app_modules_root: "https://appmodules-qa.como.com",
18
- demo_locationId:"qa_5200"
19
- },
20
- prod:{
21
- zapp_root: "https://app-dot-zipory-alpha.appspot.com",
22
- services_root: "https://services-dot-zipory-alpha.appspot.com",
23
- app_modules_root: "https://appmodules-prod.como.com",
24
- demo_locationId:"3973"
25
- }
26
- },
27
- token: null,
28
- locationId: null,
29
- locationState: null,
30
- installationId: null,
31
- membership: null,
32
- assets: null,
33
- archivedAssets: null,
34
- redeemedAssets: null,
35
- mainResources: {}
36
- }
37
-
38
- como.buildPath = function(domain, path, paramsMap) {
39
- var queryString = Object.keys(paramsMap)
40
- .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(paramsMap[k]))
41
- .join('&');
42
- return domain + "/" + path + "?" + queryString;
43
- }
44
-
45
- como.reloadMembership = function(afterDone) {
46
- console.log("reloadMembership");
47
- var path = como.buildPath(
48
- comoData.env_params.zapp_root,
49
- 'alpha/api/GetUserAtLocation',
50
- {"InputType":"json","MimeType":"application/json"}
51
- );
52
- fetch(path, {
53
- method: 'POST',
54
- body: JSON.stringify({
55
- LocationID: comoData.locationId,
56
- Token:comoData.token
57
- })
58
- })
59
- .then((response) => response.json())
60
- .then((responseJson) => {
61
- console.log("reloadMembership - Done!");
62
- console.log(responseJson);
63
- comoData.membership = responseJson;
64
- afterDone();
65
- })
66
- }
67
-
68
- ///GetResource?namespace=location_6671&resourceId=%25%24Resource%2Fid%25&version=%25%24Res
69
- como.downloadMainResource = function(resource_id, afterDoneCallback) {
70
- //debugger;
71
- var resource = comoData.mainResourcesMap[resource_id];
72
-
73
- if (!resource) {
74
- console.log("resource " + resource_id + " not found!");
75
- return;
76
- }
77
-
78
- // NOTE: this version is correct, but temporarily disabled because:
79
- // como.env_params.services_root does not support CORS
80
- //
81
- // var path = como.buildPath(
82
- // como.env_params.services_root,
83
- // "GetResource",
84
- // {
85
- // "namespace": ("namespace" in resource)?resource["namespace"]:"location_" + como.locationId,
86
- // "resourceId":resource.id,
87
- // "version":resource.Version
88
- // }
89
- // );
90
-
91
- var path = como.buildPath(
92
- comoData.env_params.zapp_root,
93
- "alpha/api/GetResource",
94
- {
95
- "Namespace": ("Namespace" in resource)?resource["Namespace"]:"location_" + comoData.locationId,
96
- "ResourceID":resource.id,
97
- "Version":resource.Version,
98
- "MimeType":"application/json"
99
- }
100
- );
101
-
102
- console.log("GET: " + path);
103
- fetch(path, {
104
- method: 'GET',
105
- }).then(
106
- function(response) {
107
- if (response.status !== 200) {
108
- console.log('Looks like there was a problem. Status Code: ' +
109
- response.status);
110
- return;
111
- }
112
-
113
- // Examine the text in the response
114
- response.json().then(function(responseJson) {
115
- comoData.mainResources[resource_id] = responseJson;
116
- afterDoneCallback();
117
- });
118
- }
119
- )
120
- .catch(function(err) {
121
- console.log('Fetch Error :-S', err);
122
- });
123
- }
124
-
125
-
126
- como.reloadLocationState = function(afterDone) {
127
- console.log("reloadLocationState");
128
- fetch(comoData.env_params.zapp_root + '/alpha/api/GetLocationState?InputType=json&MimeType=application/json', {
129
- method: 'POST',
130
- body: JSON.stringify({
131
- LocationID: comoData.locationId,
132
- })
133
- })
134
- .then((response) => response.json())
135
- .then((responseJson) => {
136
- console.log("reloadLocationState - Done!");
137
- comoData.locationState = responseJson;
138
- var mainResources = responseJson["MainResources"]["Resource"];
139
-
140
- comoData.mainResourcesMap = mainResources.reduce(function(map, obj) {
141
- map[obj.id] = obj;
142
- return map;
143
- }, {});
144
-
145
- afterDone();
146
- })
147
- }
148
-
149
- como.getAppClientID = function(returnedAppClientID) {
150
- console.log("getAppClientID");
151
- fetch(comoData.env_params.zapp_root + '/alpha/api/GetShortUserID?InputType=json&MimeType=application/json', {
152
- method: 'POST',
153
- body: JSON.stringify({
154
- Token:comoData.token,
155
- Namespace:comoData.locationId
156
- })
157
- })
158
- .then((response) => response.json())
159
- .then((responseJson) => {
160
- console.log("getAppClientID - Done!");
161
- returnedAppClientID(responseJson.ID);
162
- })
163
- }
164
-
165
- como.getPaymentCode = function(returnedPaymentCode) {
166
- console.log("getPaymentCode");
167
- fetch(comoData.env_params.zapp_root + '/alpha/api/GetClientVerificationCode?InputType=json&MimeType=application/json', {
168
- method: 'POST',
169
- body: JSON.stringify({
170
- Token:comoData.token,
171
- LocationID: comoData.locationId
172
- })
173
- })
174
- .then((response) => response.json())
175
- .then((responseJson) => {
176
- console.log("getPaymentCode - Done!");
177
- returnedPaymentCode(responseJson.VerificationCode);
178
- })
179
- }
180
-
181
- como.logout = function(returnedlogout) {
182
- console.log("logout");
183
- fetch(comoData.env_params.zapp_root + '/alpha/api/DisconnectUserFromMembership?InputType=json&MimeType=application/json', {
184
- method: 'POST',
185
- body: JSON.stringify({
186
- Token:comoData.token,
187
- LocationID: comoData.locationId
188
- })
189
- })
190
- .then((response) => response.json())
191
- .then((responseJson) => {
192
- console.log("logout - Done!");
193
- returnedlogout(responseJson);
194
- })
195
- }
196
-
197
- como.redeemAsset = function(AssetKey,returnedAssetRedeemCode) {
198
- console.log("redeemAsset");
199
- fetch(comoData.env_params.zapp_root + '/alpha/api/RedeemAsset?InputType=json&MimeType=application/json', {
200
- method: 'POST',
201
- body: JSON.stringify({
202
- Token:comoData.token,
203
- LocationID: comoData.locationId,
204
- AssetKey: AssetKey
205
-
206
- })
207
- })
208
- .then((response) => response.json())
209
- .then((responseJson) => {
210
- console.log("redeemAsset - Done!");
211
- returnedAssetRedeemCode(responseJson);
212
- })
213
- }
214
-
215
- como.purchaseAsset = function(itemId,afterDone) {
216
- console.log("purchaseAsset");
217
-
218
- var path = comoData.buildPath(
219
- comoData.env_params.zapp_root,
220
- 'alpha/api/PurchaseAsset',
221
- {"InputType":"json","MimeType":"application/json"}
222
- );
223
-
224
- fetch(path, {
225
- method: 'POST',
226
- body: JSON.stringify({
227
- Token:comoData.token,
228
- LocationID: comoData.locationId,
229
- ItemID: itemId
230
- })
231
- })
232
- .then((response) => response.json())
233
- .then((responseJson) => {
234
- console.log("redeemAsset - Done!");
235
- afterDone(responseJson);
236
- })
237
- }
238
-
239
- como.reloadAssets = function(afterDone) {
240
- console.log("reloadAssets");
241
-
242
- fetch(comoData.env_params.services_root + '/memberAssets?requestKind=OnlyUnarchived&token=' + comoData.token + '&locationId=' + comoData.locationId, {
243
- method: 'GET'
244
- })
245
- .then((response) => response.json())
246
- .then((responseJson) => {
247
- console.log("reloadAssets - Done!");
248
-
249
- const assets = [];
250
- const archivedAssets = [];
251
- const dateNow = moment();
252
-
253
- responseJson.forEach((asset) => {
254
- const validUntil = ramda.pathOr(null, ['Data', 'ValidUntil'], asset);
255
- const validUntilDate = moment(validUntil, 'DD/MM/YYYY HH:mm:ss'); // 31/05/2018 20:59:59
256
- if (validUntilDate.isBefore(dateNow) || asset.Archived) {
257
- archivedAssets.push(asset);
258
- } else {
259
- assets.push(asset);
260
- }
261
- });
262
-
263
- comoData.assets = assets; // saperate assest from archivedAssets
264
- comoData.archivedAssets = archivedAssets; // saperate assest from archivedAssets
265
- afterDone();
266
- })
267
- }
268
-
269
- como.reloadArchivedAssets = function(afterDone) {
270
- console.log("reloadAssets");
271
-
272
- fetch(comoData.env_params.services_root + '/memberAssets?requestKind=OnlyArchived&token=' + comoData.token + '&locationId=' + comoData.locationId, {
273
- method: 'GET'
274
- })
275
- .then((response) => response.json())
276
- .then((responseJson) => {
277
- console.log("reloadAssets - Done!");
278
- comoData.redeemedAssets = responseJson; // concat with existing archivedAssets
279
- afterDone();
280
- })
281
- }
282
-
283
- como.checkInitEnded = function(afterInit) {
284
- console.log("como.checkInitEnded");
285
- if (comoData.locationState != null && comoData.membership != null) {
286
- console.log("como.checkInitEnded - True!");
287
- afterInit();
288
- }
289
- }
290
-
291
- como.signon = function (afterInit) {
292
- var afterDoneCallback = function() {como.checkInitEnded(afterInit)};
293
-
294
- como.reloadLocationState(afterDoneCallback);
295
-
296
- fetch(comoData.env_params.zapp_root + '/alpha/api/SignOn?InputType=json&MimeType=application/json', {
297
- method: 'POST',
298
- body: JSON.stringify({
299
- DeviceID: comoData.installationId,
300
- InstallationID: comoData.installationId,
301
- })
302
- })
303
- .then((response) => response.json())
304
- .then((responseJson) => {
305
- var cleanResponse = responseJson;
306
- cleanResponse.UserData.PreviousVersions = "...";
307
- comoData.token = cleanResponse.Token;
308
- como.reloadMembership(afterDoneCallback);
309
- como.reloadAssets(function(){});
310
- })
311
- }
312
-
313
- como.init = function(environmentId, locationId, installationId, afterInit) {
314
- console.log("init LocationId and installationID");
315
-
316
- comoData.installationId = installationId;
317
- comoData.env_params = comoData.env[environmentId];
318
-
319
- if (locationId && locationId != "") {
320
- comoData.locationId = locationId;
321
- } else {
322
- comoData.locationId = comoData.env_params.demo_locationId;
323
- }
324
-
325
- como.signon(afterInit);
326
- }
327
-
328
- como.mergeTexts = function () {
329
- if (comoData.mainResources["AppTexts"] && comoData.mainResources["DefaultAppTexts"]) {
330
- comoData.app_texts = comoData.mainResources["DefaultAppTexts"];
331
- Object.keys(comoData.mainResources["AppTexts"]).forEach(function(key) {
332
- comoData.app_texts[key]=comoData.mainResources["AppTexts"][key];
333
- });
334
- }
335
- }
336
-
337
- como.getTextForKey = function(key) {
338
- return comoData.app_texts[key];
339
- }
340
-
341
- como.downloadMainResources = function (){
342
- como.downloadMainResource("LocationData", function (){
343
- console.log(comoData.mainResources["LocationData"]);
344
- });
345
-
346
- como.downloadMainResource("Menu", function (){
347
- console.log(comoData.mainResources["Menu"]);
348
- });
349
-
350
- como.downloadMainResource("Updates", function (){
351
- console.log(comoData.mainResources["Updates"]);
352
- });
353
-
354
- como.downloadMainResource("TCAlts", function (){
355
- console.log(comoData.mainResources["TCAlts"]);
356
- });
357
-
358
- como.downloadMainResource("AppTexts", function (){
359
- console.log(comoData.mainResources["AppTexts"]);
360
- como.mergeTexts();
361
- });
362
-
363
- como.downloadMainResource("DefaultAppTexts", function (){
364
- console.log(comoData.mainResources["DefaultAppTexts"]);
365
- como.mergeTexts();
366
- });
367
- }
368
-
369
-
370
-
371
- como.getToken = function () {
372
- return comoData.token;
373
- }
374
-
375
- como.getInstallationId = function () {
376
- return comoData.installationId;
377
- }
378
-
379
- como.getMembership = function () {
380
- return comoData.membership;
381
- }
382
-
383
- como.getAssets = function () {
384
- return comoData.assets;
385
- }
386
-
387
- como.getArchivedAssets = function () {
388
- return comoData.archivedAssets.concat(comoData.redeemedAssets);
389
- }
390
-
391
- como.getRegistrationUrl = function() {
392
- return comoData.env_params.app_modules_root + "/register?token=" + comoData.token + "&locationid=" + comoData.locationId;
393
- }
394
-
395
- como.getProfileUrl = function() {
396
- return como.env_params.app_modules_root + "/profile?token=" + comoData.token + "&locationid=" + comoData.locationId;
397
- }
398
-
399
- como.getLoginUrl = function() {
400
- return comoData.env_params.app_modules_root + "/login?token=" + comoData.token + "&locationid=" + comoData.locationId;
401
- }
402
-
403
- como.getLocationState = function() {
404
- return comoData.locationState;
405
- }
406
-
407
- como.getPointShopItems = function() {
408
- return comoData.mainResources.menu.gifts_shop_item;
409
- }
410
-
411
- como.getMainResource = function (resourceName) {
412
- return comoData.mainResources[resourceName];
413
- }
package/webpack.config.js DELETED
@@ -1,13 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = {
4
- entry: './src/v2/como.js',
5
- output: {
6
- path: path.resolve(__dirname, 'build'),
7
- filename: 'como.js',
8
- },
9
- stats: {
10
- colors: true,
11
- },
12
- devtool: 'source-map',
13
- };