@como/como-client 0.1.5 → 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/lib/como.js CHANGED
@@ -1,5 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ var _promise = require('babel-runtime/core-js/promise');
4
+
5
+ var _promise2 = _interopRequireDefault(_promise);
6
+
7
+ var _keys = require('babel-runtime/core-js/object/keys');
8
+
9
+ var _keys2 = _interopRequireDefault(_keys);
10
+
3
11
  var _extends2 = require('babel-runtime/helpers/extends');
4
12
 
5
13
  var _extends3 = _interopRequireDefault(_extends2);
@@ -12,15 +20,25 @@ var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
12
20
 
13
21
  var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
14
22
 
23
+ var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
24
+
25
+ var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
26
+
27
+ var _createClass2 = require('babel-runtime/helpers/createClass');
28
+
29
+ var _createClass3 = _interopRequireDefault(_createClass2);
30
+
15
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
32
 
17
33
  var moment = require('moment-timezone');
34
+ var axios = require('axios');
18
35
  var ramda = require('ramda');
19
36
  var environmentConfig = require('./config/env');
20
37
  var APIService = require('./services');
38
+ var comoExternalUrlTranslator = require('./utils/comoExternalUrlTranslator');
39
+ var resourceNames = require('./constants/resourceNames');
40
+ var urlsUtils = require('./utils/urls');
21
41
 
22
- var como = {};
23
- var comoData = void 0;
24
42
  var INITIAL_COMO_DATA = {
25
43
  env: environmentConfig,
26
44
  token: null,
@@ -29,602 +47,2215 @@ var INITIAL_COMO_DATA = {
29
47
  installationId: null,
30
48
  membership: null,
31
49
  assets: null,
32
- archivedAssets: null,
33
- redeemedAssets: null,
34
50
  mainResources: {}
35
51
  };
36
52
 
37
- var updateLocalCreds = function updateLocalCreds(credentials) {
38
- comoData.sessionId = credentials.sessionId;
39
- comoData.token = credentials.sessionId;
40
- comoData.refreshToken = credentials.refreshToken;
41
- };
53
+ var Como = function () {
54
+ function Como() {
55
+ (0, _classCallCheck3.default)(this, Como);
42
56
 
43
- /**
44
- * Sign the user and returns guest token & refresh token.
45
- * Requires init.
46
- */
47
- como.signon = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
48
- var _comoData, api, data;
57
+ this.comoData = {};
58
+ }
49
59
 
50
- return _regenerator2.default.wrap(function _callee$(_context) {
51
- while (1) {
52
- switch (_context.prev = _context.next) {
53
- case 0:
54
- _comoData = comoData, api = _comoData.api;
55
- _context.next = 3;
56
- return api.signOn(comoData.installationId, comoData.locationId);
60
+ (0, _createClass3.default)(Como, [{
61
+ key: 'refreshTokenIfNeeded',
62
+ value: function () {
63
+ var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
64
+ var _comoData, refresher, expiresIn;
65
+
66
+ return _regenerator2.default.wrap(function _callee$(_context) {
67
+ while (1) {
68
+ switch (_context.prev = _context.next) {
69
+ case 0:
70
+ _comoData = this.comoData, refresher = _comoData.refresher, expiresIn = _comoData.expiresIn;
71
+
72
+ if (!refresher) {
73
+ console.log('No refresh for %o', this.comoData);
74
+ }
75
+
76
+ if (!(refresher && expiresIn && moment(expiresIn).subtract(10, 'seconds').isBefore(moment()))) {
77
+ _context.next = 5;
78
+ break;
79
+ }
80
+
81
+ _context.next = 5;
82
+ return refresher();
83
+
84
+ case 5:
85
+ case 'end':
86
+ return _context.stop();
87
+ }
88
+ }
89
+ }, _callee, this);
90
+ }));
57
91
 
58
- case 3:
59
- data = _context.sent;
92
+ function refreshTokenIfNeeded() {
93
+ return _ref.apply(this, arguments);
94
+ }
60
95
 
61
- updateLocalCreds(data);
96
+ return refreshTokenIfNeeded;
97
+ }()
98
+
99
+ /**
100
+ * Sign the user and returns guest token & refresh token.
101
+ * Requires init.
102
+ */
103
+
104
+ }, {
105
+ key: 'signon',
106
+ value: function () {
107
+ var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(source) {
108
+ var api, data, _error$response$data, code, message;
109
+
110
+ return _regenerator2.default.wrap(function _callee2$(_context2) {
111
+ while (1) {
112
+ switch (_context2.prev = _context2.next) {
113
+ case 0:
114
+ api = this.comoData.api;
115
+ _context2.prev = 1;
116
+ _context2.next = 4;
117
+ return api.signOn(this.comoData.installationId, this.comoData.locationId, this.comoData.refreshToken, source);
118
+
119
+ case 4:
120
+ data = _context2.sent;
121
+
122
+ if (data && data.config && data.config.loyaltyCDN) {
123
+ this.comoData.env_params.services_root_cdn = data.config.loyaltyCDN;
124
+ }
125
+ return _context2.abrupt('return', data);
126
+
127
+ case 9:
128
+ _context2.prev = 9;
129
+ _context2.t0 = _context2['catch'](1);
130
+
131
+ if (!(_context2.t0.response && _context2.t0.response.data)) {
132
+ _context2.next = 14;
133
+ break;
134
+ }
135
+
136
+ _error$response$data = _context2.t0.response.data, code = _error$response$data.code, message = _error$response$data.message;
137
+ throw new Error(code || message);
138
+
139
+ case 14:
140
+ throw _context2.t0;
141
+
142
+ case 15:
143
+ case 'end':
144
+ return _context2.stop();
145
+ }
146
+ }
147
+ }, _callee2, this, [[1, 9]]);
148
+ }));
62
149
 
63
- return _context.abrupt('return', data);
150
+ function signon(_x) {
151
+ return _ref2.apply(this, arguments);
152
+ }
64
153
 
65
- case 6:
66
- case 'end':
67
- return _context.stop();
154
+ return signon;
155
+ }()
156
+
157
+ /**
158
+ *
159
+ * @param {Object} environment Environemnt object
160
+ * @param {string} environment.id Environment Id
161
+ * @param {string} environment.locationId Location Id
162
+ * @param {string} environment.installationId Unique installation id
163
+ * @param {Object} credentials Member credentials (Optional)
164
+ * @param {string} accessToken session id string (Optional)
165
+ * @param {string} refreshToken refresh token string (Optional)
166
+ * @param {string} expiresIn access token expiration date formatted (Optional)
167
+ * @param {function} refreshCallback an event callback which fires each time user's tokens gets refreshed
168
+ * @param {boolean} enableSignon if disabled signOn api call will not be fired. Enabled by default.
169
+ */
170
+
171
+ }, {
172
+ key: 'init',
173
+ value: function () {
174
+ var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(environment, credentials, refreshCallback) {
175
+ var _this = this;
176
+
177
+ var enableSignon = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
178
+
179
+ var isExists, environmentId, locationId, installationId, source, updateCredentials, getCredentials, gateway, _APIService$getServic, service, refresher, accessToken, refreshToken, expiresIn, credsNotExist, isExpired, refreshFailed;
180
+
181
+ return _regenerator2.default.wrap(function _callee3$(_context3) {
182
+ while (1) {
183
+ switch (_context3.prev = _context3.next) {
184
+ case 0:
185
+ isExists = function isExists(x) {
186
+ return !ramda.isNil(x) && !ramda.isEmpty(x);
187
+ };
188
+
189
+ environmentId = environment.id, locationId = environment.locationId, installationId = environment.installationId, source = environment.source;
190
+
191
+ if (!(!isExists(environmentId) || !isExists(locationId) || !isExists(installationId))) {
192
+ _context3.next = 4;
193
+ break;
194
+ }
195
+
196
+ throw new Error('missing parameters: ' + environment);
197
+
198
+ case 4:
199
+ this.comoData = (0, _extends3.default)({}, INITIAL_COMO_DATA, credentials, {
200
+ installationId: installationId,
201
+ locationId: locationId,
202
+ source: source,
203
+ env_params: (0, _extends3.default)({}, INITIAL_COMO_DATA.env[environmentId])
204
+ });
205
+
206
+ updateCredentials = function updateCredentials(creds) {
207
+ var isNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
208
+
209
+ _this.updateLocalCreds(creds);
210
+ if (refreshCallback && isNew) {
211
+ refreshCallback(creds);
212
+ }
213
+ };
214
+
215
+ getCredentials = this.getCredentials.bind(this);
216
+ gateway = this.comoData.env_params.gateway;
217
+ _APIService$getServic = APIService.getService(gateway, installationId, getCredentials, updateCredentials, source, locationId), service = _APIService$getServic.service, refresher = _APIService$getServic.refresher;
218
+
219
+ this.comoData.api = service;
220
+ this.comoData.refresher = refresher;
221
+
222
+ accessToken = credentials.accessToken, refreshToken = credentials.refreshToken, expiresIn = credentials.expiresIn;
223
+ credsNotExist = !isExists(accessToken) || !isExists(refreshToken);
224
+ isExpired = !credsNotExist && expiresIn && moment(expiresIn).isBefore(moment());
225
+
226
+ if (!credsNotExist) {
227
+ _context3.next = 24;
228
+ break;
229
+ }
230
+
231
+ _context3.prev = 15;
232
+ _context3.next = 18;
233
+ return this.signon(installationId, locationId, source);
234
+
235
+ case 18:
236
+ _context3.next = 24;
237
+ break;
238
+
239
+ case 20:
240
+ _context3.prev = 20;
241
+ _context3.t0 = _context3['catch'](15);
242
+
243
+ //TODO: need to parse error
244
+ console.log('Failed to signOn, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source);
245
+ isExpired = true; // user uid exist - do refresh
246
+
247
+ case 24:
248
+ refreshFailed = false;
249
+
250
+ if (!isExpired) {
251
+ _context3.next = 35;
252
+ break;
253
+ }
254
+
255
+ _context3.prev = 26;
256
+ _context3.next = 29;
257
+ return this.refreshTokenIfNeeded();
258
+
259
+ case 29:
260
+ _context3.next = 35;
261
+ break;
262
+
263
+ case 31:
264
+ _context3.prev = 31;
265
+ _context3.t1 = _context3['catch'](26);
266
+
267
+ console.log('Failed to refresh token, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source);
268
+ //TODO: need to parse error
269
+ //refresh failed - need to revoke and signOn again
270
+ refreshFailed = true;
271
+
272
+ case 35:
273
+ if (!refreshFailed) {
274
+ _context3.next = 38;
275
+ break;
276
+ }
277
+
278
+ _context3.next = 38;
279
+ return this.signon(installationId, locationId, source);
280
+
281
+ case 38:
282
+ return _context3.abrupt('return', this.getCredentials());
283
+
284
+ case 39:
285
+ case 'end':
286
+ return _context3.stop();
287
+ }
288
+ }
289
+ }, _callee3, this, [[15, 20], [26, 31]]);
290
+ }));
291
+
292
+ function init(_x2, _x3, _x4) {
293
+ return _ref3.apply(this, arguments);
68
294
  }
295
+
296
+ return init;
297
+ }()
298
+
299
+ /**
300
+ * Updates the como.js local credentials settings.
301
+ * Used when making api calls to janua.
302
+ *
303
+ * @param {Object} credentials credentials to update.
304
+ * @param {Object} accessToken access token to update.
305
+ * @param {Object} refreshToken refresh token to update.
306
+ * @param {Object} expiresIn access token expiry date to update.
307
+ */
308
+
309
+ }, {
310
+ key: 'updateLocalCreds',
311
+ value: function updateLocalCreds() {
312
+ var credentials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
313
+
314
+ this.comoData.accessToken = credentials.accessToken;
315
+ this.comoData.token = credentials.accessToken;
316
+ this.comoData.refreshToken = credentials.refreshToken;
317
+ this.comoData.expiresIn = credentials.expiresIn;
69
318
  }
70
- }, _callee, undefined);
71
- }));
319
+ }, {
320
+ key: 'getExternalUrlByID',
321
+ value: function getExternalUrlByID(itemID, gpsData, assetID, accessibilityData) {
322
+ var locationData = this.comoData.mainResources[resourceNames.LOCATION_DATA];
323
+ if (locationData && locationData.WebViews && locationData.WebViews[0].item) {
324
+ var possibleWebViews = locationData.WebViews[0].item.filter(function (u) {
325
+ return u.id === itemID;
326
+ });
327
+ var url = possibleWebViews && possibleWebViews[0] && possibleWebViews[0].url;
328
+ return this.translateExternalUrl(url, gpsData, assetID, accessibilityData);
329
+ }
330
+ return null;
331
+ }
332
+ }, {
333
+ key: 'translateExternalUrl',
334
+ value: function () {
335
+ var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(url, gpsData, assetID, accessibilityData) {
336
+ var legacyUrl, externalUrl, _comoData2, api, locationId, token, env, membership, assets, locationData, apiObjects, dataToUse;
337
+
338
+ return _regenerator2.default.wrap(function _callee4$(_context4) {
339
+ while (1) {
340
+ switch (_context4.prev = _context4.next) {
341
+ case 0:
342
+ _context4.next = 2;
343
+ return this.getAppModulesLegacyBaseUrl();
344
+
345
+ case 2:
346
+ legacyUrl = _context4.sent;
347
+ externalUrl = url;
348
+
349
+ if (externalUrl && externalUrl.startsWith(legacyUrl)) {
350
+ externalUrl = externalUrl.replace(legacyUrl, this.comoData.env_params.app_modules_root);
351
+ }
352
+ _comoData2 = this.comoData, api = _comoData2.api, locationId = _comoData2.locationId, token = _comoData2.token, env = _comoData2.env_params, membership = _comoData2.membership, assets = _comoData2.assets;
353
+ locationData = this.comoData.mainResources && this.comoData.mainResources[resourceNames.LOCATION_DATA];
354
+ apiObjects = { api: api, servicesRoot: env.services_root };
355
+ dataToUse = {
356
+ locationId: locationId, token: token, membership: membership, locationData: locationData, assets: assets, gpsData: gpsData, assetID: assetID, accessibilityData: accessibilityData
357
+ };
358
+ return _context4.abrupt('return', comoExternalUrlTranslator.translateUrl(externalUrl, apiObjects, dataToUse));
359
+
360
+ case 10:
361
+ case 'end':
362
+ return _context4.stop();
363
+ }
364
+ }
365
+ }, _callee4, this);
366
+ }));
72
367
 
73
- como.legacySignon = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
74
- var _comoData2, api, data;
368
+ function translateExternalUrl(_x8, _x9, _x10, _x11) {
369
+ return _ref4.apply(this, arguments);
370
+ }
75
371
 
76
- return _regenerator2.default.wrap(function _callee2$(_context2) {
77
- while (1) {
78
- switch (_context2.prev = _context2.next) {
79
- case 0:
80
- _comoData2 = comoData, api = _comoData2.api;
81
- _context2.next = 3;
82
- return api.legacySignOn(comoData.env_params.zapp_root, comoData.installationId);
372
+ return translateExternalUrl;
373
+ }()
374
+ }, {
375
+ key: 'getFeedbackFormData',
376
+ value: function () {
377
+ var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5() {
378
+ var _comoData3, locationId, token, env, api;
379
+
380
+ return _regenerator2.default.wrap(function _callee5$(_context5) {
381
+ while (1) {
382
+ switch (_context5.prev = _context5.next) {
383
+ case 0:
384
+ _comoData3 = this.comoData, locationId = _comoData3.locationId, token = _comoData3.token, env = _comoData3.env_params, api = _comoData3.api;
385
+ return _context5.abrupt('return', api.getFeedbackFormData(env.zapp_root, locationId, token));
386
+
387
+ case 2:
388
+ case 'end':
389
+ return _context5.stop();
390
+ }
391
+ }
392
+ }, _callee5, this);
393
+ }));
394
+
395
+ function getFeedbackFormData() {
396
+ return _ref5.apply(this, arguments);
397
+ }
83
398
 
84
- case 3:
85
- data = _context2.sent;
399
+ return getFeedbackFormData;
400
+ }()
401
+
402
+ /**
403
+ *
404
+ * @param {Object} form registration form values
405
+ * @param {Object} verification flow
406
+ * @param {strin} reCaptchaToken
407
+ * @param {Object} source(registration origin)
408
+ */
409
+
410
+ }, {
411
+ key: 'register',
412
+ value: function () {
413
+ var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(form, verification, reCaptchaToken, source) {
414
+ var api, data, _error$response$data2, code, message;
415
+
416
+ return _regenerator2.default.wrap(function _callee6$(_context6) {
417
+ while (1) {
418
+ switch (_context6.prev = _context6.next) {
419
+ case 0:
420
+ api = this.comoData.api;
421
+ _context6.prev = 1;
422
+ _context6.next = 4;
423
+ return api.register(form, verification, reCaptchaToken, source);
424
+
425
+ case 4:
426
+ data = _context6.sent;
427
+ return _context6.abrupt('return', data);
428
+
429
+ case 8:
430
+ _context6.prev = 8;
431
+ _context6.t0 = _context6['catch'](1);
432
+
433
+ if (!(_context6.t0.response && _context6.t0.response.data)) {
434
+ _context6.next = 13;
435
+ break;
436
+ }
437
+
438
+ _error$response$data2 = _context6.t0.response.data, code = _error$response$data2.code, message = _error$response$data2.message;
439
+ throw new Error(code || message);
440
+
441
+ case 13:
442
+ throw _context6.t0;
443
+
444
+ case 14:
445
+ case 'end':
446
+ return _context6.stop();
447
+ }
448
+ }
449
+ }, _callee6, this, [[1, 8]]);
450
+ }));
86
451
 
87
- comoData.token = data.Token;
452
+ function register(_x12, _x13, _x14, _x15) {
453
+ return _ref6.apply(this, arguments);
454
+ }
88
455
 
89
- return _context2.abrupt('return', data);
456
+ return register;
457
+ }()
458
+
459
+ /**
460
+ *
461
+ * @param {string} verification flow (code & verification step)
462
+ * @param {string} type verification type
463
+ * @param {Object} form registration form values
464
+ * @param {string} reCaptchaToken
465
+ */
466
+
467
+ }, {
468
+ key: 'registerVerify',
469
+ value: function () {
470
+ var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(verification, type, form, reCaptchaToken) {
471
+ var api, data, _error$response$data3, code, message;
472
+
473
+ return _regenerator2.default.wrap(function _callee7$(_context7) {
474
+ while (1) {
475
+ switch (_context7.prev = _context7.next) {
476
+ case 0:
477
+ api = this.comoData.api;
478
+ _context7.prev = 1;
479
+ _context7.next = 4;
480
+ return api.registerVerify(verification, type, form, reCaptchaToken);
481
+
482
+ case 4:
483
+ data = _context7.sent;
484
+ return _context7.abrupt('return', data);
485
+
486
+ case 8:
487
+ _context7.prev = 8;
488
+ _context7.t0 = _context7['catch'](1);
489
+
490
+ if (!(_context7.t0.response && _context7.t0.response.data)) {
491
+ _context7.next = 13;
492
+ break;
493
+ }
494
+
495
+ _error$response$data3 = _context7.t0.response.data, code = _error$response$data3.code, message = _error$response$data3.message;
496
+ throw new Error(code || message);
497
+
498
+ case 13:
499
+ throw _context7.t0;
500
+
501
+ case 14:
502
+ case 'end':
503
+ return _context7.stop();
504
+ }
505
+ }
506
+ }, _callee7, this, [[1, 8]]);
507
+ }));
90
508
 
91
- case 6:
92
- case 'end':
93
- return _context2.stop();
509
+ function registerVerify(_x16, _x17, _x18, _x19) {
510
+ return _ref7.apply(this, arguments);
94
511
  }
95
- }
96
- }, _callee2, undefined);
97
- }));
98
-
99
- /**
100
- *
101
- * @param {Object} environment Environemnt object
102
- * @param {string} environment.id Environment Id
103
- * @param {string} environment.locationId Location Id
104
- * @param {string} environment.installationId Unique installation id
105
- * @param {string} sessionId session id string (Optional)
106
- * @param {string} refresh refresh token string (Optional)
107
- */
108
- como.init = function () {
109
- var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(environment, sessionId, refreshToken, refresher) {
110
- var enableSignon = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
111
- var isExists, environmentId, locationId, installationId, updateCredentials, gateway;
112
- return _regenerator2.default.wrap(function _callee3$(_context3) {
113
- while (1) {
114
- switch (_context3.prev = _context3.next) {
115
- case 0:
116
- isExists = function isExists(x) {
117
- return !ramda.isNil(x) && !ramda.isEmpty(x);
118
- };
119
-
120
- environmentId = environment.id, locationId = environment.locationId, installationId = environment.installationId;
121
-
122
- if (!(!isExists(environmentId) || !isExists(locationId) || !isExists(installationId))) {
123
- _context3.next = 4;
124
- break;
125
- }
126
-
127
- throw new Error('missing parameters');
128
-
129
- case 4:
130
-
131
- comoData = (0, _extends3.default)({}, INITIAL_COMO_DATA, {
132
- installationId: installationId,
133
- locationId: locationId,
134
- sessionId: sessionId,
135
- refreshToken: refreshToken,
136
- env_params: (0, _extends3.default)({}, INITIAL_COMO_DATA.env[environmentId])
137
- });
138
-
139
- updateCredentials = function updateCredentials(creds) {
140
- var isNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
141
-
142
- updateLocalCreds(creds);
143
- if (refresher && isNew) {
144
- refresher(creds);
145
- }
146
- };
147
-
148
- gateway = comoData.env_params.gateway;
149
-
150
- comoData.api = APIService.getService(gateway, installationId, como.getCredentials, updateCredentials);
151
-
152
- if (!(enableSignon && (!isExists(sessionId) || !isExists(refreshToken)))) {
153
- _context3.next = 11;
154
- break;
155
- }
156
-
157
- _context3.next = 11;
158
- return como.signon();
159
-
160
- case 11:
161
- return _context3.abrupt('return', como.getCredentials());
162
-
163
- case 12:
164
- case 'end':
165
- return _context3.stop();
166
- }
167
- }
168
- }, _callee3, undefined);
169
- }));
170
-
171
- return function (_x, _x2, _x3, _x4) {
172
- return _ref3.apply(this, arguments);
173
- };
174
- }();
175
512
 
176
- como.login = function () {
177
- var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(identifier, type) {
178
- var _comoData3, api, response;
179
-
180
- return _regenerator2.default.wrap(function _callee4$(_context4) {
181
- while (1) {
182
- switch (_context4.prev = _context4.next) {
183
- case 0:
184
- _comoData3 = comoData, api = _comoData3.api;
185
- _context4.next = 3;
186
- return api.logIn(type, identifier);
187
-
188
- case 3:
189
- response = _context4.sent;
190
- return _context4.abrupt('return', response);
191
-
192
- case 5:
193
- case 'end':
194
- return _context4.stop();
195
- }
196
- }
197
- }, _callee4, undefined);
198
- }));
199
-
200
- return function (_x7, _x8) {
201
- return _ref4.apply(this, arguments);
202
- };
203
- }();
513
+ return registerVerify;
514
+ }()
515
+
516
+ /**
517
+ *
518
+ * @param {Object} form update form values
519
+ * @param {string} reCaptchaToken
520
+ * @param {string} source request source
521
+ */
522
+
523
+ }, {
524
+ key: 'updateProfile',
525
+ value: function () {
526
+ var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(form, reCaptchaToken, source) {
527
+ var api, data, _error$response$data4, code, message;
528
+
529
+ return _regenerator2.default.wrap(function _callee8$(_context8) {
530
+ while (1) {
531
+ switch (_context8.prev = _context8.next) {
532
+ case 0:
533
+ api = this.comoData.api;
534
+ _context8.prev = 1;
535
+ _context8.next = 4;
536
+ return api.updateProfile(form, reCaptchaToken, source);
537
+
538
+ case 4:
539
+ data = _context8.sent;
540
+ return _context8.abrupt('return', data);
541
+
542
+ case 8:
543
+ _context8.prev = 8;
544
+ _context8.t0 = _context8['catch'](1);
545
+
546
+ if (!(_context8.t0.response && _context8.t0.response.data)) {
547
+ _context8.next = 13;
548
+ break;
549
+ }
550
+
551
+ _error$response$data4 = _context8.t0.response.data, code = _error$response$data4.code, message = _error$response$data4.message;
552
+ throw new Error(code || message);
553
+
554
+ case 13:
555
+ throw _context8.t0;
556
+
557
+ case 14:
558
+ case 'end':
559
+ return _context8.stop();
560
+ }
561
+ }
562
+ }, _callee8, this, [[1, 8]]);
563
+ }));
204
564
 
205
- como.loginVerify = function () {
206
- var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(identifier, type, code) {
207
- var _comoData4, api, _ref6, data;
565
+ function updateProfile(_x20, _x21, _x22) {
566
+ return _ref8.apply(this, arguments);
567
+ }
208
568
 
209
- return _regenerator2.default.wrap(function _callee5$(_context5) {
210
- while (1) {
211
- switch (_context5.prev = _context5.next) {
212
- case 0:
213
- _comoData4 = comoData, api = _comoData4.api;
214
- _context5.next = 3;
215
- return api.logInVerify(code, type, identifier);
569
+ return updateProfile;
570
+ }()
571
+
572
+ /**
573
+ *
574
+ * @param {string} verificationCode code verification sent by 3rd party
575
+ * @param {string} type verification type
576
+ * @param {Object} form update form values
577
+ * @param {string} reCaptchaToken
578
+ * @param {string} source request source
579
+ */
580
+
581
+ }, {
582
+ key: 'updateProfileVerify',
583
+ value: function () {
584
+ var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(verificationCode, type, form, reCaptchaToken, source) {
585
+ var api, data, _error$response$data5, code, message;
586
+
587
+ return _regenerator2.default.wrap(function _callee9$(_context9) {
588
+ while (1) {
589
+ switch (_context9.prev = _context9.next) {
590
+ case 0:
591
+ api = this.comoData.api;
592
+ _context9.prev = 1;
593
+ _context9.next = 4;
594
+ return api.updateProfileVerify(verificationCode, type, form, reCaptchaToken, source);
595
+
596
+ case 4:
597
+ data = _context9.sent;
598
+ return _context9.abrupt('return', data);
599
+
600
+ case 8:
601
+ _context9.prev = 8;
602
+ _context9.t0 = _context9['catch'](1);
603
+
604
+ if (!(_context9.t0.response && _context9.t0.response.data)) {
605
+ _context9.next = 13;
606
+ break;
607
+ }
608
+
609
+ _error$response$data5 = _context9.t0.response.data, code = _error$response$data5.code, message = _error$response$data5.message;
610
+ throw new Error(code || message);
611
+
612
+ case 13:
613
+ throw _context9.t0;
614
+
615
+ case 14:
616
+ case 'end':
617
+ return _context9.stop();
618
+ }
619
+ }
620
+ }, _callee9, this, [[1, 8]]);
621
+ }));
216
622
 
217
- case 3:
218
- _ref6 = _context5.sent;
219
- data = _ref6.data;
623
+ function updateProfileVerify(_x23, _x24, _x25, _x26, _x27) {
624
+ return _ref9.apply(this, arguments);
625
+ }
220
626
 
221
- updateLocalCreds(data);
627
+ return updateProfileVerify;
628
+ }()
629
+
630
+ /**
631
+ *
632
+ * @param {string} unsubscribeSms unsubscribe user at location
633
+ * @param {string} PhoneNumber phone number to identify user
634
+ */
635
+
636
+ }, {
637
+ key: 'unsubscribeSms',
638
+ value: function () {
639
+ var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(PhoneNumber) {
640
+ var _comoData4, api, locationId, identifier, data, _error$response$data6, code, message;
641
+
642
+ return _regenerator2.default.wrap(function _callee10$(_context10) {
643
+ while (1) {
644
+ switch (_context10.prev = _context10.next) {
645
+ case 0:
646
+ _comoData4 = this.comoData, api = _comoData4.api, locationId = _comoData4.locationId;
647
+ _context10.prev = 1;
648
+ identifier = { PhoneNumber: PhoneNumber };
649
+ _context10.next = 5;
650
+ return api.unsubscribeSms(locationId, identifier);
651
+
652
+ case 5:
653
+ data = _context10.sent;
654
+ return _context10.abrupt('return', data);
655
+
656
+ case 9:
657
+ _context10.prev = 9;
658
+ _context10.t0 = _context10['catch'](1);
659
+
660
+ if (!(_context10.t0.response && _context10.t0.response.data)) {
661
+ _context10.next = 14;
662
+ break;
663
+ }
664
+
665
+ _error$response$data6 = _context10.t0.response.data, code = _error$response$data6.code, message = _error$response$data6.message;
666
+ throw new Error(code || message);
667
+
668
+ case 14:
669
+ throw _context10.t0;
670
+
671
+ case 15:
672
+ case 'end':
673
+ return _context10.stop();
674
+ }
675
+ }
676
+ }, _callee10, this, [[1, 9]]);
677
+ }));
678
+
679
+ function unsubscribeSms(_x28) {
680
+ return _ref10.apply(this, arguments);
681
+ }
222
682
 
223
- return _context5.abrupt('return', como.getCredentials());
683
+ return unsubscribeSms;
684
+ }()
685
+
686
+ /**
687
+ *
688
+ * @param {Object} identifier an object which identifies the user by its credentials
689
+ * @param {string} type login type i.e PhoneNumber/Email/etc
690
+ */
691
+
692
+ }, {
693
+ key: 'login',
694
+ value: function () {
695
+ var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(identifier, type) {
696
+ var api, data, _error$response$data7, code, message;
697
+
698
+ return _regenerator2.default.wrap(function _callee11$(_context11) {
699
+ while (1) {
700
+ switch (_context11.prev = _context11.next) {
701
+ case 0:
702
+ api = this.comoData.api;
703
+ _context11.prev = 1;
704
+ _context11.next = 4;
705
+ return api.logIn(type, identifier);
706
+
707
+ case 4:
708
+ data = _context11.sent;
709
+ return _context11.abrupt('return', data);
710
+
711
+ case 8:
712
+ _context11.prev = 8;
713
+ _context11.t0 = _context11['catch'](1);
714
+
715
+ if (!(_context11.t0.response && _context11.t0.response.data)) {
716
+ _context11.next = 13;
717
+ break;
718
+ }
719
+
720
+ _error$response$data7 = _context11.t0.response.data, code = _error$response$data7.code, message = _error$response$data7.message;
721
+ throw new Error(code || message);
722
+
723
+ case 13:
724
+ throw _context11.t0;
725
+
726
+ case 14:
727
+ case 'end':
728
+ return _context11.stop();
729
+ }
730
+ }
731
+ }, _callee11, this, [[1, 8]]);
732
+ }));
224
733
 
225
- case 7:
226
- case 'end':
227
- return _context5.stop();
228
- }
734
+ function login(_x29, _x30) {
735
+ return _ref11.apply(this, arguments);
229
736
  }
230
- }, _callee5, undefined);
231
- }));
232
737
 
233
- return function (_x9, _x10, _x11) {
234
- return _ref5.apply(this, arguments);
235
- };
236
- }();
738
+ return login;
739
+ }()
740
+
741
+ /**
742
+ *
743
+ * @param {Object} identifier key-value identifiers
744
+ * @param {*} type login type i.e PhoneNumber/Email/etc
745
+ * @param {*} code a 2-factor verification code sent to the client
746
+ */
747
+
748
+ }, {
749
+ key: 'loginVerify',
750
+ value: function () {
751
+ var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(identifier, type, code) {
752
+ var api, _ref13, consent, _error$response$data8, errCode, message;
753
+
754
+ return _regenerator2.default.wrap(function _callee12$(_context12) {
755
+ while (1) {
756
+ switch (_context12.prev = _context12.next) {
757
+ case 0:
758
+ api = this.comoData.api;
759
+ _context12.prev = 1;
760
+ _context12.next = 4;
761
+ return api.logInVerify(code, type, identifier);
762
+
763
+ case 4:
764
+ _ref13 = _context12.sent;
765
+ consent = _ref13.consent;
766
+
767
+ this.comoData.consent = consent;
768
+ _context12.next = 17;
769
+ break;
770
+
771
+ case 9:
772
+ _context12.prev = 9;
773
+ _context12.t0 = _context12['catch'](1);
774
+
775
+ if (!(_context12.t0.response && _context12.t0.response.data)) {
776
+ _context12.next = 16;
777
+ break;
778
+ }
779
+
780
+ _error$response$data8 = _context12.t0.response.data, errCode = _error$response$data8.code, message = _error$response$data8.message;
781
+
782
+ if (!(message && message === 'Invalid verification Code')) {
783
+ _context12.next = 15;
784
+ break;
785
+ }
786
+
787
+ throw new Error(message);
788
+
789
+ case 15:
790
+ throw new Error(errCode || message);
791
+
792
+ case 16:
793
+ throw _context12.t0;
794
+
795
+ case 17:
796
+ return _context12.abrupt('return', this.getCredentials());
797
+
798
+ case 18:
799
+ case 'end':
800
+ return _context12.stop();
801
+ }
802
+ }
803
+ }, _callee12, this, [[1, 9]]);
804
+ }));
237
805
 
238
- como.reloadMembership = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
239
- var _comoData5, env, locationId, api, membership;
806
+ function loginVerify(_x31, _x32, _x33) {
807
+ return _ref12.apply(this, arguments);
808
+ }
809
+
810
+ return loginVerify;
811
+ }()
812
+
813
+ /**
814
+ * Reload and sets the internal membership state.
815
+ * To get the reloaded membership make sure to call getMembership();
816
+ * @param onlyAssetKeys - include assets list full data or only the asset keys
817
+ * @returns {Promise<void>}
818
+ */
819
+
820
+ }, {
821
+ key: 'reloadMembership',
822
+ value: function () {
823
+ var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13() {
824
+ var onlyAssetKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
240
825
 
241
- return _regenerator2.default.wrap(function _callee6$(_context6) {
242
- while (1) {
243
- switch (_context6.prev = _context6.next) {
244
- case 0:
245
- _comoData5 = comoData, env = _comoData5.env_params, locationId = _comoData5.locationId, api = _comoData5.api;
246
- _context6.next = 3;
247
- return api.getUserAtLocation(env.zapp_root, locationId);
826
+ var _comoData5, env, locationId, api, membership;
248
827
 
249
- case 3:
250
- membership = _context6.sent;
828
+ return _regenerator2.default.wrap(function _callee13$(_context13) {
829
+ while (1) {
830
+ switch (_context13.prev = _context13.next) {
831
+ case 0:
832
+ _comoData5 = this.comoData, env = _comoData5.env_params, locationId = _comoData5.locationId, api = _comoData5.api;
833
+ _context13.next = 3;
834
+ return api.getUserAtLocation(env.zapp_root, locationId, onlyAssetKeys);
251
835
 
252
- comoData.membership = membership;
836
+ case 3:
837
+ membership = _context13.sent;
838
+
839
+ this.comoData.membership = membership;
840
+
841
+ case 5:
842
+ case 'end':
843
+ return _context13.stop();
844
+ }
845
+ }
846
+ }, _callee13, this);
847
+ }));
253
848
 
254
- case 5:
255
- case 'end':
256
- return _context6.stop();
849
+ function reloadMembership() {
850
+ return _ref14.apply(this, arguments);
257
851
  }
258
- }
259
- }, _callee6, undefined);
260
- }));
261
852
 
262
- como.downloadMainResource = function () {
263
- var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(resourceId) {
264
- var resource, err, _comoData6, env, api, responseJson;
853
+ return reloadMembership;
854
+ }()
855
+
856
+ /**
857
+ * Send an Open app request to update server.
858
+ */
859
+
860
+ }, {
861
+ key: 'openApp',
862
+ value: function () {
863
+ var _ref15 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14(data) {
864
+ var _comoData6, api, locationId, token, env;
865
+
866
+ return _regenerator2.default.wrap(function _callee14$(_context14) {
867
+ while (1) {
868
+ switch (_context14.prev = _context14.next) {
869
+ case 0:
870
+ _comoData6 = this.comoData, api = _comoData6.api, locationId = _comoData6.locationId, token = _comoData6.token, env = _comoData6.env_params;
871
+ return _context14.abrupt('return', api.openApp(env.zapp_root, token, locationId, data));
872
+
873
+ case 2:
874
+ case 'end':
875
+ return _context14.stop();
876
+ }
877
+ }
878
+ }, _callee14, this);
879
+ }));
880
+
881
+ function openApp(_x35) {
882
+ return _ref15.apply(this, arguments);
883
+ }
884
+
885
+ return openApp;
886
+ }()
887
+
888
+ /**
889
+ * Update membership status (permissions).
890
+ * @param {boolean} pushEnable
891
+ * @param {boolean} locationEnable
892
+ */
893
+
894
+ }, {
895
+ key: 'clientUpdateMembership',
896
+ value: function () {
897
+ var _ref16 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15(pushEnable, locationEnable) {
898
+ var _comoData7, api, locationId, token, env;
899
+
900
+ return _regenerator2.default.wrap(function _callee15$(_context15) {
901
+ while (1) {
902
+ switch (_context15.prev = _context15.next) {
903
+ case 0:
904
+ _comoData7 = this.comoData, api = _comoData7.api, locationId = _comoData7.locationId, token = _comoData7.token, env = _comoData7.env_params;
905
+ return _context15.abrupt('return', api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable));
906
+
907
+ case 2:
908
+ case 'end':
909
+ return _context15.stop();
910
+ }
911
+ }
912
+ }, _callee15, this);
913
+ }));
914
+
915
+ function clientUpdateMembership(_x36, _x37) {
916
+ return _ref16.apply(this, arguments);
917
+ }
918
+
919
+ return clientUpdateMembership;
920
+ }()
921
+
922
+ /**
923
+ * Downloads the main resource by its id and sets the resource in the main resource's map.
924
+ * @param {string} resourceId Main resource id
925
+ */
926
+
927
+ }, {
928
+ key: 'downloadMainResource',
929
+ value: function () {
930
+ var _ref17 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16(resourceId) {
931
+ var resource, err, _comoData8, env, api, responseJson;
932
+
933
+ return _regenerator2.default.wrap(function _callee16$(_context16) {
934
+ while (1) {
935
+ switch (_context16.prev = _context16.next) {
936
+ case 0:
937
+ resource = this.comoData.mainResourcesMap[resourceId];
938
+
939
+ if (resource) {
940
+ _context16.next = 4;
941
+ break;
942
+ }
265
943
 
266
- return _regenerator2.default.wrap(function _callee7$(_context7) {
267
- while (1) {
268
- switch (_context7.prev = _context7.next) {
269
- case 0:
270
- resource = comoData.mainResourcesMap[resourceId];
944
+ err = 'resource ' + resourceId + ' not found!';
945
+ throw new Error(err);
271
946
 
272
- if (resource) {
273
- _context7.next = 4;
274
- break;
947
+ case 4:
948
+ _comoData8 = this.comoData, env = _comoData8.env_params, api = _comoData8.api;
949
+ _context16.next = 7;
950
+ return api.getLoyaltyResource(env.services_root_cdn, resource.id, 'Namespace' in resource ? resource.Namespace : 'location_' + this.comoData.locationId, resource.Version);
951
+
952
+ case 7:
953
+ responseJson = _context16.sent;
954
+
955
+
956
+ this.comoData.mainResources[resourceId] = responseJson;
957
+
958
+ case 9:
959
+ case 'end':
960
+ return _context16.stop();
275
961
  }
962
+ }
963
+ }, _callee16, this);
964
+ }));
276
965
 
277
- err = 'resource ' + resourceId + ' not found!';
278
- throw new Error(err);
966
+ function downloadMainResource(_x38) {
967
+ return _ref17.apply(this, arguments);
968
+ }
279
969
 
280
- case 4:
281
- _comoData6 = comoData, env = _comoData6.env_params, api = _comoData6.api;
282
- _context7.next = 7;
283
- return api.getResource(env.services_root, resource.id, 'Namespace' in resource ? resource.Namespace : 'location_' + comoData.locationId, resource.Version);
970
+ return downloadMainResource;
971
+ }()
972
+
973
+ /**
974
+ * Reload and sets the internal location state.
975
+ * To get the reloaded location state make sure to call getLocationState();
976
+ */
977
+
978
+ }, {
979
+ key: 'reloadLocationState',
980
+ value: function () {
981
+ var _ref18 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17() {
982
+ var api, state, mainResources;
983
+ return _regenerator2.default.wrap(function _callee17$(_context17) {
984
+ while (1) {
985
+ switch (_context17.prev = _context17.next) {
986
+ case 0:
987
+ api = this.comoData.api;
988
+ _context17.next = 3;
989
+ return api.getLocationState(this.comoData.env_params.zapp_root, this.comoData.locationId);
990
+
991
+ case 3:
992
+ state = _context17.sent;
993
+
994
+ this.comoData.locationState = state;
995
+ mainResources = state.MainResources.Resource;
996
+
997
+
998
+ this.comoData.mainResourcesMap = mainResources.reduce(function (total, obj) {
999
+ total[obj.id] = obj; // eslint-disable-line no-param-reassign
1000
+ return total;
1001
+ }, {});
1002
+
1003
+ case 7:
1004
+ case 'end':
1005
+ return _context17.stop();
1006
+ }
1007
+ }
1008
+ }, _callee17, this);
1009
+ }));
284
1010
 
285
- case 7:
286
- responseJson = _context7.sent;
1011
+ function reloadLocationState() {
1012
+ return _ref18.apply(this, arguments);
1013
+ }
287
1014
 
1015
+ return reloadLocationState;
1016
+ }()
1017
+
1018
+ /**
1019
+ * Requests an app client id by the user's location id.
1020
+ */
1021
+
1022
+ }, {
1023
+ key: 'getAppClientID',
1024
+ value: function () {
1025
+ var _ref19 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee18() {
1026
+ var _comoData9, env, locationId, api, responseJson;
1027
+
1028
+ return _regenerator2.default.wrap(function _callee18$(_context18) {
1029
+ while (1) {
1030
+ switch (_context18.prev = _context18.next) {
1031
+ case 0:
1032
+ _comoData9 = this.comoData, env = _comoData9.env_params, locationId = _comoData9.locationId, api = _comoData9.api;
1033
+ _context18.next = 3;
1034
+ return api.getShortUserId(env.zapp_root, locationId);
1035
+
1036
+ case 3:
1037
+ responseJson = _context18.sent;
1038
+ return _context18.abrupt('return', responseJson.ID);
1039
+
1040
+ case 5:
1041
+ case 'end':
1042
+ return _context18.stop();
1043
+ }
1044
+ }
1045
+ }, _callee18, this);
1046
+ }));
1047
+
1048
+ function getAppClientID() {
1049
+ return _ref19.apply(this, arguments);
1050
+ }
288
1051
 
289
- comoData.mainResources[resourceId] = responseJson;
1052
+ return getAppClientID;
1053
+ }()
1054
+
1055
+ /**
1056
+ * Requests a generated payment code from the loyalty server
1057
+ */
1058
+
1059
+ }, {
1060
+ key: 'getPaymentCode',
1061
+ value: function () {
1062
+ var _ref20 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee19() {
1063
+ var _comoData10, env, locationId, api, responseJson;
1064
+
1065
+ return _regenerator2.default.wrap(function _callee19$(_context19) {
1066
+ while (1) {
1067
+ switch (_context19.prev = _context19.next) {
1068
+ case 0:
1069
+ _comoData10 = this.comoData, env = _comoData10.env_params, locationId = _comoData10.locationId, api = _comoData10.api;
1070
+ _context19.next = 3;
1071
+ return api.getPaymentCode(env.zapp_root, locationId);
1072
+
1073
+ case 3:
1074
+ responseJson = _context19.sent;
1075
+ return _context19.abrupt('return', responseJson.VerificationCode);
1076
+
1077
+ case 5:
1078
+ case 'end':
1079
+ return _context19.stop();
1080
+ }
1081
+ }
1082
+ }, _callee19, this);
1083
+ }));
290
1084
 
291
- case 9:
292
- case 'end':
293
- return _context7.stop();
294
- }
1085
+ function getPaymentCode() {
1086
+ return _ref20.apply(this, arguments);
295
1087
  }
296
- }, _callee7, undefined);
297
- }));
298
1088
 
299
- return function (_x12) {
300
- return _ref8.apply(this, arguments);
301
- };
302
- }();
1089
+ return getPaymentCode;
1090
+ }()
1091
+
1092
+ /**
1093
+ * Logout the user identified by its accessToken
1094
+ */
1095
+
1096
+ }, {
1097
+ key: 'logout',
1098
+ value: function () {
1099
+ var _ref21 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee20() {
1100
+ var api, response, _error$response$data9, errCode, message;
1101
+
1102
+ return _regenerator2.default.wrap(function _callee20$(_context20) {
1103
+ while (1) {
1104
+ switch (_context20.prev = _context20.next) {
1105
+ case 0:
1106
+ api = this.comoData.api;
1107
+ _context20.prev = 1;
1108
+ _context20.next = 4;
1109
+ return api.logOut();
1110
+
1111
+ case 4:
1112
+ response = _context20.sent;
1113
+ return _context20.abrupt('return', response);
1114
+
1115
+ case 8:
1116
+ _context20.prev = 8;
1117
+ _context20.t0 = _context20['catch'](1);
1118
+
1119
+ if (!(_context20.t0.response && _context20.t0.response.data)) {
1120
+ _context20.next = 13;
1121
+ break;
1122
+ }
1123
+
1124
+ _error$response$data9 = _context20.t0.response.data, errCode = _error$response$data9.code, message = _error$response$data9.message;
1125
+ throw new Error(errCode || message);
1126
+
1127
+ case 13:
1128
+ throw _context20.t0;
1129
+
1130
+ case 14:
1131
+ case 'end':
1132
+ return _context20.stop();
1133
+ }
1134
+ }
1135
+ }, _callee20, this, [[1, 8]]);
1136
+ }));
303
1137
 
304
- como.reloadLocationState = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8() {
305
- var _comoData7, api, state, mainResources;
1138
+ function logout() {
1139
+ return _ref21.apply(this, arguments);
1140
+ }
306
1141
 
307
- return _regenerator2.default.wrap(function _callee8$(_context8) {
308
- while (1) {
309
- switch (_context8.prev = _context8.next) {
310
- case 0:
311
- _comoData7 = comoData, api = _comoData7.api;
312
- _context8.next = 3;
313
- return api.getLocationState(comoData.env_params.zapp_root, comoData.locationId);
1142
+ return logout;
1143
+ }()
1144
+
1145
+ /**
1146
+ *
1147
+ * @param {string} assetKey asset's id
1148
+ */
1149
+
1150
+ }, {
1151
+ key: 'redeemAsset',
1152
+ value: function () {
1153
+ var _ref22 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee21(assetKey) {
1154
+ var _comoData11, env, locationId, api, responseJson;
1155
+
1156
+ return _regenerator2.default.wrap(function _callee21$(_context21) {
1157
+ while (1) {
1158
+ switch (_context21.prev = _context21.next) {
1159
+ case 0:
1160
+ _comoData11 = this.comoData, env = _comoData11.env_params, locationId = _comoData11.locationId, api = _comoData11.api;
1161
+ _context21.next = 3;
1162
+ return api.redeemAsset(env.zapp_root, locationId, assetKey);
1163
+
1164
+ case 3:
1165
+ responseJson = _context21.sent;
1166
+ return _context21.abrupt('return', responseJson);
1167
+
1168
+ case 5:
1169
+ case 'end':
1170
+ return _context21.stop();
1171
+ }
1172
+ }
1173
+ }, _callee21, this);
1174
+ }));
314
1175
 
315
- case 3:
316
- state = _context8.sent;
1176
+ function redeemAsset(_x39) {
1177
+ return _ref22.apply(this, arguments);
1178
+ }
317
1179
 
318
- comoData.locationState = state;
319
- mainResources = state.MainResources.Resource;
1180
+ return redeemAsset;
1181
+ }()
1182
+
1183
+ /**
1184
+ *
1185
+ * @param {string} itemId item's id
1186
+ */
1187
+
1188
+ }, {
1189
+ key: 'purchaseAsset',
1190
+ value: function () {
1191
+ var _ref23 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee22(itemId) {
1192
+ var _comoData12, env, token, locationId, api, responseJson;
1193
+
1194
+ return _regenerator2.default.wrap(function _callee22$(_context22) {
1195
+ while (1) {
1196
+ switch (_context22.prev = _context22.next) {
1197
+ case 0:
1198
+ _comoData12 = this.comoData, env = _comoData12.env_params, token = _comoData12.token, locationId = _comoData12.locationId, api = _comoData12.api;
1199
+ _context22.next = 3;
1200
+ return api.purchaseAsset(env.zapp_root, locationId, token, itemId);
1201
+
1202
+ case 3:
1203
+ responseJson = _context22.sent;
1204
+ return _context22.abrupt('return', responseJson);
1205
+
1206
+ case 5:
1207
+ case 'end':
1208
+ return _context22.stop();
1209
+ }
1210
+ }
1211
+ }, _callee22, this);
1212
+ }));
320
1213
 
1214
+ function purchaseAsset(_x40) {
1215
+ return _ref23.apply(this, arguments);
1216
+ }
321
1217
 
322
- comoData.mainResourcesMap = mainResources.reduce(function (total, obj) {
323
- total[obj.id] = obj; // eslint-disable-line no-param-reassign
324
- return total;
325
- }, {});
1218
+ return purchaseAsset;
1219
+ }()
1220
+ }, {
1221
+ key: 'getUserPointShopDataAPI2',
1222
+ value: function () {
1223
+ var _ref24 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee23() {
1224
+ var _comoData13, env, locationId, api, responseJson;
1225
+
1226
+ return _regenerator2.default.wrap(function _callee23$(_context23) {
1227
+ while (1) {
1228
+ switch (_context23.prev = _context23.next) {
1229
+ case 0:
1230
+ _comoData13 = this.comoData, env = _comoData13.env_params, locationId = _comoData13.locationId, api = _comoData13.api;
1231
+ _context23.next = 3;
1232
+ return api.getUserPointShopDataAPI2(env.zapp_root, locationId);
1233
+
1234
+ case 3:
1235
+ responseJson = _context23.sent;
1236
+ return _context23.abrupt('return', responseJson);
1237
+
1238
+ case 5:
1239
+ case 'end':
1240
+ return _context23.stop();
1241
+ }
1242
+ }
1243
+ }, _callee23, this);
1244
+ }));
326
1245
 
327
- case 7:
328
- case 'end':
329
- return _context8.stop();
1246
+ function getUserPointShopDataAPI2() {
1247
+ return _ref24.apply(this, arguments);
330
1248
  }
331
- }
332
- }, _callee8, undefined);
333
- }));
334
1249
 
335
- como.getAppClientID = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9() {
336
- var _comoData8, env, locationId, api, responseJson;
1250
+ return getUserPointShopDataAPI2;
1251
+ }()
1252
+ }, {
1253
+ key: 'purchaseAssetAPI2',
1254
+ value: function () {
1255
+ var _ref25 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee24(assetID) {
1256
+ var _comoData14, env, locationId, api, responseJson;
1257
+
1258
+ return _regenerator2.default.wrap(function _callee24$(_context24) {
1259
+ while (1) {
1260
+ switch (_context24.prev = _context24.next) {
1261
+ case 0:
1262
+ _comoData14 = this.comoData, env = _comoData14.env_params, locationId = _comoData14.locationId, api = _comoData14.api;
1263
+ _context24.next = 3;
1264
+ return api.purchaseAssetAPI2(env.zapp_root, locationId, assetID);
1265
+
1266
+ case 3:
1267
+ responseJson = _context24.sent;
1268
+ return _context24.abrupt('return', responseJson);
1269
+
1270
+ case 5:
1271
+ case 'end':
1272
+ return _context24.stop();
1273
+ }
1274
+ }
1275
+ }, _callee24, this);
1276
+ }));
1277
+
1278
+ function purchaseAssetAPI2(_x41) {
1279
+ return _ref25.apply(this, arguments);
1280
+ }
1281
+
1282
+ return purchaseAssetAPI2;
1283
+ }()
1284
+
1285
+ /**
1286
+ * Reload and sets the internal assets (expired and valid) state.
1287
+ * To get the reloaded assets make sure to call como.getAssets();
1288
+ */
1289
+
1290
+ }, {
1291
+ key: 'reloadAssets',
1292
+ value: function () {
1293
+ var _ref26 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee25() {
1294
+ var _comoData15, env, locationId, api, responseJson;
1295
+
1296
+ return _regenerator2.default.wrap(function _callee25$(_context25) {
1297
+ while (1) {
1298
+ switch (_context25.prev = _context25.next) {
1299
+ case 0:
1300
+ _comoData15 = this.comoData, env = _comoData15.env_params, locationId = _comoData15.locationId, api = _comoData15.api;
1301
+ _context25.next = 3;
1302
+ return api.memberAssets(env.services_root, locationId);
337
1303
 
338
- return _regenerator2.default.wrap(function _callee9$(_context9) {
339
- while (1) {
340
- switch (_context9.prev = _context9.next) {
341
- case 0:
342
- _comoData8 = comoData, env = _comoData8.env_params, locationId = _comoData8.locationId, api = _comoData8.api;
343
- _context9.next = 3;
344
- return api.getShortUserId(env.zapp_root, locationId);
1304
+ case 3:
1305
+ responseJson = _context25.sent;
345
1306
 
346
- case 3:
347
- responseJson = _context9.sent;
348
- return _context9.abrupt('return', responseJson.ID);
1307
+ this.comoData.assets = responseJson;
349
1308
 
350
- case 5:
351
- case 'end':
352
- return _context9.stop();
1309
+ case 5:
1310
+ case 'end':
1311
+ return _context25.stop();
1312
+ }
1313
+ }
1314
+ }, _callee25, this);
1315
+ }));
1316
+
1317
+ function reloadAssets() {
1318
+ return _ref26.apply(this, arguments);
353
1319
  }
354
- }
355
- }, _callee9, undefined);
356
- }));
357
1320
 
358
- como.getPaymentCode = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10() {
359
- var _comoData9, env, locationId, api, responseJson;
1321
+ return reloadAssets;
1322
+ }()
360
1323
 
361
- return _regenerator2.default.wrap(function _callee10$(_context10) {
362
- while (1) {
363
- switch (_context10.prev = _context10.next) {
364
- case 0:
365
- _comoData9 = comoData, env = _comoData9.env_params, locationId = _comoData9.locationId, api = _comoData9.api;
366
- _context10.next = 3;
367
- return api.getPaymentCode(env.zapp_root, locationId);
1324
+ /**
1325
+ * Merge the default app text with the location specific app texts
1326
+ * Both DefaultAppTexts and AppTexts are a MainResource that needs to be downloaded before merge
1327
+ */
368
1328
 
369
- case 3:
370
- responseJson = _context10.sent;
371
- return _context10.abrupt('return', responseJson.VerificationCode);
1329
+ }, {
1330
+ key: 'mergeTexts',
1331
+ value: function mergeTexts() {
1332
+ var _this2 = this;
372
1333
 
373
- case 5:
374
- case 'end':
375
- return _context10.stop();
1334
+ if (this.comoData.mainResources.AppTexts && this.comoData.mainResources.DefaultAppTexts) {
1335
+ this.comoData.app_texts = this.comoData.mainResources.DefaultAppTexts;
1336
+ (0, _keys2.default)(this.comoData.mainResources.AppTexts).forEach(function (key) {
1337
+ _this2.comoData.app_texts[key] = _this2.comoData.mainResources.AppTexts[key];
1338
+ });
376
1339
  }
377
1340
  }
378
- }, _callee10, undefined);
379
- }));
380
1341
 
381
- como.logout = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11() {
382
- var _comoData10, api, response;
1342
+ /**
1343
+ *
1344
+ * @param {string} key app text key
1345
+ */
1346
+
1347
+ }, {
1348
+ key: 'getTextForKey',
1349
+ value: function getTextForKey(key) {
1350
+ return this.comoData.app_texts[key];
1351
+ }
1352
+
1353
+ /**
1354
+ * Downloads the main resources:
1355
+ * - LocationData
1356
+ * - Menu
1357
+ * - Updates
1358
+ * - TCAlts
1359
+ * - AppTexts
1360
+ * - DefaultAppTexts
1361
+ */
1362
+
1363
+ }, {
1364
+ key: 'downloadMainResources',
1365
+ value: function () {
1366
+ var _ref27 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee26() {
1367
+ var resources, downloadMainResource, downloads;
1368
+ return _regenerator2.default.wrap(function _callee26$(_context26) {
1369
+ while (1) {
1370
+ switch (_context26.prev = _context26.next) {
1371
+ case 0:
1372
+ resources = ['LocationData', 'Menu', 'Updates', 'TCAlts', 'AppTexts', 'DefaultAppTexts'];
1373
+ downloadMainResource = this.downloadMainResource.bind(this);
1374
+ downloads = resources.map(downloadMainResource);
1375
+ _context26.next = 5;
1376
+ return _promise2.default.all(downloads);
1377
+
1378
+ case 5:
1379
+ this.mergeTexts();
1380
+
1381
+ case 6:
1382
+ case 'end':
1383
+ return _context26.stop();
1384
+ }
1385
+ }
1386
+ }, _callee26, this);
1387
+ }));
1388
+
1389
+ function downloadMainResources() {
1390
+ return _ref27.apply(this, arguments);
1391
+ }
1392
+
1393
+ return downloadMainResources;
1394
+ }()
383
1395
 
384
- return _regenerator2.default.wrap(function _callee11$(_context11) {
385
- while (1) {
386
- switch (_context11.prev = _context11.next) {
387
- case 0:
388
- _comoData10 = comoData, api = _comoData10.api;
389
- _context11.next = 3;
390
- return api.logOut();
1396
+ /**
1397
+ *
1398
+ * @param {string} type form type
1399
+ */
391
1400
 
392
- case 3:
393
- response = _context11.sent;
394
- return _context11.abrupt('return', response);
1401
+ }, {
1402
+ key: 'loadForm',
1403
+ value: function loadForm(type) {
1404
+ var _comoData16 = this.comoData,
1405
+ api = _comoData16.api,
1406
+ locationId = _comoData16.locationId;
1407
+
1408
+
1409
+ return api.getForm(type, locationId);
1410
+ }
395
1411
 
396
- case 5:
397
- case 'end':
398
- return _context11.stop();
1412
+ /**
1413
+ *
1414
+ * @param {string} type configuration type
1415
+ */
1416
+
1417
+ }, {
1418
+ key: 'getConfigration',
1419
+ value: function getConfigration(type) {
1420
+ var _comoData17 = this.comoData,
1421
+ api = _comoData17.api,
1422
+ locationId = _comoData17.locationId;
1423
+
1424
+ var locationState = this.getLocationState();
1425
+ var version = null;
1426
+ if (locationState) {
1427
+ version = locationState.PublishVersion;
399
1428
  }
1429
+
1430
+ return api.getConfiguration(type, locationId, version);
400
1431
  }
401
- }, _callee11, undefined);
402
- }));
403
-
404
- como.redeemAsset = function () {
405
- var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(assetKey) {
406
- var _comoData11, env, locationId, api, responseJson;
407
-
408
- return _regenerator2.default.wrap(function _callee12$(_context12) {
409
- while (1) {
410
- switch (_context12.prev = _context12.next) {
411
- case 0:
412
- _comoData11 = comoData, env = _comoData11.env_params, locationId = _comoData11.locationId, api = _comoData11.api;
413
- _context12.next = 3;
414
- return api.redeemAsset(env.zapp_root, locationId, assetKey);
415
-
416
- case 3:
417
- responseJson = _context12.sent;
418
- return _context12.abrupt('return', responseJson);
419
-
420
- case 5:
421
- case 'end':
422
- return _context12.stop();
423
- }
424
- }
425
- }, _callee12, undefined);
426
- }));
427
-
428
- return function (_x13) {
429
- return _ref13.apply(this, arguments);
430
- };
431
- }();
432
1432
 
433
- como.purchaseAsset = function () {
434
- var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(itemId) {
435
- var _comoData12, env, locationId, api, responseJson;
436
-
437
- return _regenerator2.default.wrap(function _callee13$(_context13) {
438
- while (1) {
439
- switch (_context13.prev = _context13.next) {
440
- case 0:
441
- _comoData12 = comoData, env = _comoData12.env_params, locationId = _comoData12.locationId, api = _comoData12.api;
442
- _context13.next = 3;
443
- return api.purchaseAsset(env.zapp_root, locationId, itemId);
444
-
445
- case 3:
446
- responseJson = _context13.sent;
447
- return _context13.abrupt('return', responseJson);
448
-
449
- case 5:
450
- case 'end':
451
- return _context13.stop();
452
- }
453
- }
454
- }, _callee13, undefined);
455
- }));
456
-
457
- return function (_x14) {
458
- return _ref14.apply(this, arguments);
459
- };
460
- }();
1433
+ /**
1434
+ *
1435
+ * @param {string} type resource type
1436
+ */
1437
+
1438
+ }, {
1439
+ key: 'getResource',
1440
+ value: function getResource(type) {
1441
+ var _comoData18 = this.comoData,
1442
+ api = _comoData18.api,
1443
+ locationId = _comoData18.locationId;
1444
+
1445
+ return api.getResource(type, locationId);
1446
+ }
461
1447
 
462
- como.reloadAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14() {
463
- var _comoData13, env, locationId, api, responseJson, assets, archivedAssets, dateNow;
1448
+ /**
1449
+ *
1450
+ * Get all legacy resources (Zapp)
1451
+ */
464
1452
 
465
- return _regenerator2.default.wrap(function _callee14$(_context14) {
466
- while (1) {
467
- switch (_context14.prev = _context14.next) {
468
- case 0:
469
- _comoData13 = comoData, env = _comoData13.env_params, locationId = _comoData13.locationId, api = _comoData13.api;
470
- _context14.next = 3;
471
- return api.memberAssets(env.services_root, locationId);
1453
+ }, {
1454
+ key: 'getLegacyResources',
1455
+ value: function getLegacyResources() {
1456
+ var _comoData19 = this.comoData,
1457
+ api = _comoData19.api,
1458
+ locationId = _comoData19.locationId;
472
1459
 
473
- case 3:
474
- responseJson = _context14.sent;
475
- assets = [];
476
- archivedAssets = [];
477
- dateNow = moment();
1460
+ return api.getZappResource(locationId);
1461
+ }
1462
+
1463
+ /**
1464
+ * Generates a new referral code for friend-referral
1465
+ */
1466
+
1467
+ }, {
1468
+ key: 'generateReferralCode',
1469
+ value: function generateReferralCode() {
1470
+ var _comoData20 = this.comoData,
1471
+ api = _comoData20.api,
1472
+ locationId = _comoData20.locationId,
1473
+ token = _comoData20.token,
1474
+ env = _comoData20.env_params;
1475
+
1476
+
1477
+ return api.generateReferralCode(env.services_root, token, locationId);
1478
+ }
1479
+
1480
+ /**
1481
+ * Check that referral code is valid
1482
+ */
478
1483
 
1484
+ }, {
1485
+ key: 'verifyReferralCode',
1486
+ value: function verifyReferralCode(code) {
1487
+ var _comoData21 = this.comoData,
1488
+ api = _comoData21.api,
1489
+ locationId = _comoData21.locationId,
1490
+ token = _comoData21.token,
1491
+ env = _comoData21.env_params;
479
1492
 
480
- responseJson.forEach(function (asset) {
481
- var validUntil = ramda.pathOr(null, ['Data', 'ValidUntil'], asset);
482
- var validUntilDate = moment(validUntil, 'DD/MM/YYYY HH:mm:ss'); // 31/05/2018 20:59:59
483
- if (validUntilDate.isBefore(dateNow) || asset.Archived) {
484
- archivedAssets.push(asset);
485
- } else {
486
- assets.push(asset);
1493
+
1494
+ return api.verifyReferralCode(env.services_root, token, locationId, code);
1495
+ }
1496
+
1497
+ /**
1498
+ * Returns current accessToken and refreshToken
1499
+ * Caution: make sure to pass refresh callback to init to get the latest credentials
1500
+ */
1501
+
1502
+ }, {
1503
+ key: 'getCredentials',
1504
+ value: function getCredentials() {
1505
+ var _comoData22 = this.comoData,
1506
+ accessToken = _comoData22.accessToken,
1507
+ refreshToken = _comoData22.refreshToken,
1508
+ expiresIn = _comoData22.expiresIn,
1509
+ consent = _comoData22.consent;
1510
+
1511
+ return {
1512
+ accessToken: accessToken, refreshToken: refreshToken, expiresIn: expiresIn, consent: consent
1513
+ };
1514
+ }
1515
+
1516
+ /**
1517
+ * Returns the current accessToken
1518
+ * Caution: make sure to pass refresh callback to como.init to get the latest credentials
1519
+ */
1520
+
1521
+ }, {
1522
+ key: 'getToken',
1523
+ value: function getToken() {
1524
+ return this.comoData.token;
1525
+ }
1526
+
1527
+ /**
1528
+ * Returns the como.js initialized installation id
1529
+ */
1530
+
1531
+ }, {
1532
+ key: 'getInstallationId',
1533
+ value: function getInstallationId() {
1534
+ return this.comoData.installationId;
1535
+ }
1536
+
1537
+ /**
1538
+ * Return the user membership object
1539
+ * Make sure to call reloadMembership() to reload the membership object.
1540
+ */
1541
+
1542
+ }, {
1543
+ key: 'getMembership',
1544
+ value: function getMembership() {
1545
+ return this.comoData.membership;
1546
+ }
1547
+
1548
+ /**
1549
+ * Return the user assets object
1550
+ * Make sure to call reloadAssets() to reload the assets object.
1551
+ */
1552
+
1553
+ }, {
1554
+ key: 'getAssets',
1555
+ value: function getAssets() {
1556
+ return this.comoData.assets;
1557
+ }
1558
+
1559
+ /**
1560
+ * Returns the location specific registration web url
1561
+ */
1562
+
1563
+ }, {
1564
+ key: 'getRegistrationUrl',
1565
+ value: function () {
1566
+ var _ref28 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee27(overrides) {
1567
+ var _comoData23, token, installationId, locationId, env;
1568
+
1569
+ return _regenerator2.default.wrap(function _callee27$(_context27) {
1570
+ while (1) {
1571
+ switch (_context27.prev = _context27.next) {
1572
+ case 0:
1573
+ _context27.next = 2;
1574
+ return this.refreshTokenIfNeeded();
1575
+
1576
+ case 2:
1577
+ _comoData23 = this.comoData, token = _comoData23.token, installationId = _comoData23.installationId, locationId = _comoData23.locationId, env = _comoData23.env_params;
1578
+ return _context27.abrupt('return', urlsUtils.appendQuery(env.app_modules_root + '/register?token=' + token + '&locationid=' + locationId, (0, _extends3.default)({}, this.getCredentials(), {
1579
+ installationId: installationId,
1580
+ disableSuccessScreen: 'true'
1581
+ }, overrides)));
1582
+
1583
+ case 4:
1584
+ case 'end':
1585
+ return _context27.stop();
487
1586
  }
488
- });
1587
+ }
1588
+ }, _callee27, this);
1589
+ }));
489
1590
 
490
- comoData.assets = assets; // saperate assest from archivedAssets
1591
+ function getRegistrationUrl(_x42) {
1592
+ return _ref28.apply(this, arguments);
1593
+ }
1594
+
1595
+ return getRegistrationUrl;
1596
+ }()
1597
+
1598
+ /**
1599
+ * Returns the location specific profile web url
1600
+ */
1601
+
1602
+ }, {
1603
+ key: 'getProfileUrl',
1604
+ value: function () {
1605
+ var _ref29 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee28(overrides) {
1606
+ var _comoData24, token, installationId, locationId, env;
1607
+
1608
+ return _regenerator2.default.wrap(function _callee28$(_context28) {
1609
+ while (1) {
1610
+ switch (_context28.prev = _context28.next) {
1611
+ case 0:
1612
+ _context28.next = 2;
1613
+ return this.refreshTokenIfNeeded();
1614
+
1615
+ case 2:
1616
+ _comoData24 = this.comoData, token = _comoData24.token, installationId = _comoData24.installationId, locationId = _comoData24.locationId, env = _comoData24.env_params;
1617
+ return _context28.abrupt('return', urlsUtils.appendQuery(env.app_modules_root + '/profile?token=' + token + '&locationid=' + locationId, (0, _extends3.default)({}, this.getCredentials(), {
1618
+ installationId: installationId,
1619
+ disableSuccessScreen: 'true'
1620
+ }, overrides)));
1621
+
1622
+ case 4:
1623
+ case 'end':
1624
+ return _context28.stop();
1625
+ }
1626
+ }
1627
+ }, _callee28, this);
1628
+ }));
491
1629
 
492
- case 9:
493
- case 'end':
494
- return _context14.stop();
1630
+ function getProfileUrl(_x43) {
1631
+ return _ref29.apply(this, arguments);
495
1632
  }
496
- }
497
- }, _callee14, undefined);
498
- }));
499
1633
 
500
- como.reloadArchivedAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15() {
501
- var _comoData14, env, locationId, api, responseJson;
1634
+ return getProfileUrl;
1635
+ }()
1636
+
1637
+ /**
1638
+ * Returns the location specific login web url
1639
+ */
1640
+
1641
+ }, {
1642
+ key: 'getLoginUrl',
1643
+ value: function () {
1644
+ var _ref30 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee29() {
1645
+ var _comoData25, token, locationId, env;
1646
+
1647
+ return _regenerator2.default.wrap(function _callee29$(_context29) {
1648
+ while (1) {
1649
+ switch (_context29.prev = _context29.next) {
1650
+ case 0:
1651
+ _context29.next = 2;
1652
+ return this.refreshTokenIfNeeded();
1653
+
1654
+ case 2:
1655
+ _comoData25 = this.comoData, token = _comoData25.token, locationId = _comoData25.locationId, env = _comoData25.env_params;
1656
+ return _context29.abrupt('return', env.app_modules_root + '/login?token=' + token + '&locationid=' + locationId);
1657
+
1658
+ case 4:
1659
+ case 'end':
1660
+ return _context29.stop();
1661
+ }
1662
+ }
1663
+ }, _callee29, this);
1664
+ }));
502
1665
 
503
- return _regenerator2.default.wrap(function _callee15$(_context15) {
504
- while (1) {
505
- switch (_context15.prev = _context15.next) {
506
- case 0:
507
- _comoData14 = comoData, env = _comoData14.env_params, locationId = _comoData14.locationId, api = _comoData14.api;
508
- _context15.next = 3;
509
- return api.memberAssets(env.services_root, locationId, true);
1666
+ function getLoginUrl() {
1667
+ return _ref30.apply(this, arguments);
1668
+ }
510
1669
 
511
- case 3:
512
- responseJson = _context15.sent;
1670
+ return getLoginUrl;
1671
+ }()
1672
+
1673
+ /**
1674
+ * Returns the location data Portability url
1675
+ */
1676
+
1677
+ }, {
1678
+ key: 'getDataPortabilityUrl',
1679
+ value: function () {
1680
+ var _ref31 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee30(url, overrides) {
1681
+ var installationId;
1682
+ return _regenerator2.default.wrap(function _callee30$(_context30) {
1683
+ while (1) {
1684
+ switch (_context30.prev = _context30.next) {
1685
+ case 0:
1686
+ _context30.next = 2;
1687
+ return this.refreshTokenIfNeeded();
1688
+
1689
+ case 2:
1690
+ installationId = this.comoData.installationId;
1691
+ return _context30.abrupt('return', urlsUtils.appendQuery('' + url, (0, _extends3.default)({
1692
+ installationId: installationId
1693
+ }, overrides)));
1694
+
1695
+ case 4:
1696
+ case 'end':
1697
+ return _context30.stop();
1698
+ }
1699
+ }
1700
+ }, _callee30, this);
1701
+ }));
513
1702
 
514
- comoData.redeemedAssets = responseJson; // concat with existing archivedAssets
1703
+ function getDataPortabilityUrl(_x44, _x45) {
1704
+ return _ref31.apply(this, arguments);
1705
+ }
1706
+
1707
+ return getDataPortabilityUrl;
1708
+ }()
1709
+
1710
+ /**
1711
+ * Returns app-modules legacy root url
1712
+ */
1713
+
1714
+ }, {
1715
+ key: 'getAppModulesLegacyBaseUrl',
1716
+ value: function () {
1717
+ var _ref32 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee31() {
1718
+ var env;
1719
+ return _regenerator2.default.wrap(function _callee31$(_context31) {
1720
+ while (1) {
1721
+ switch (_context31.prev = _context31.next) {
1722
+ case 0:
1723
+ _context31.next = 2;
1724
+ return this.refreshTokenIfNeeded();
1725
+
1726
+ case 2:
1727
+ env = this.comoData.env_params;
1728
+ return _context31.abrupt('return', '' + env.app_modules_legacy_root);
1729
+
1730
+ case 4:
1731
+ case 'end':
1732
+ return _context31.stop();
1733
+ }
1734
+ }
1735
+ }, _callee31, this);
1736
+ }));
515
1737
 
516
- case 5:
517
- case 'end':
518
- return _context15.stop();
1738
+ function getAppModulesLegacyBaseUrl() {
1739
+ return _ref32.apply(this, arguments);
519
1740
  }
1741
+
1742
+ return getAppModulesLegacyBaseUrl;
1743
+ }()
1744
+
1745
+ /**
1746
+ * Returns the location specific friend referral web url
1747
+ */
1748
+
1749
+ }, {
1750
+ key: 'getFriendReferralInviteLink',
1751
+ value: function getFriendReferralInviteLink(referral) {
1752
+ return this.comoData.env_params.gateway + '/ssr-modules/friend-referral/' + this.comoData.locationId + '?referral=' + referral;
520
1753
  }
521
- }, _callee15, undefined);
522
- }));
523
-
524
- como.mergeTexts = function () {
525
- if (comoData.mainResources.AppTexts && comoData.mainResources.DefaultAppTexts) {
526
- comoData.app_texts = comoData.mainResources.DefaultAppTexts;
527
- Object.keys(comoData.mainResources.AppTexts).forEach(function (key) {
528
- comoData.app_texts[key] = comoData.mainResources.AppTexts[key];
529
- });
530
- }
531
- };
532
1754
 
533
- como.getTextForKey = function (key) {
534
- return comoData.app_texts[key];
535
- };
1755
+ /**
1756
+ * Return the location state
1757
+ * Make sure to call reloadLocationState() to reload the location state object.
1758
+ */
536
1759
 
537
- como.downloadMainResources = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16() {
538
- var resources, downloads;
539
- return _regenerator2.default.wrap(function _callee16$(_context16) {
540
- while (1) {
541
- switch (_context16.prev = _context16.next) {
542
- case 0:
543
- resources = ['LocationData', 'Menu', 'Updates', 'TCAlts', 'AppTexts', 'DefaultAppTexts'];
544
- downloads = resources.map(como.downloadMainResource);
545
- _context16.next = 4;
546
- return Promise.all(downloads);
1760
+ }, {
1761
+ key: 'getLocationState',
1762
+ value: function getLocationState() {
1763
+ return this.comoData.locationState;
1764
+ }
1765
+
1766
+ /**
1767
+ * Returns the location point shop items
1768
+ */
1769
+
1770
+ }, {
1771
+ key: 'getPointShopItems',
1772
+ value: function getPointShopItems() {
1773
+ return this.comoData.mainResources.menu.gifts_shop_item;
1774
+ }
547
1775
 
548
- case 4:
549
- como.mergeTexts();
1776
+ /**
1777
+ *
1778
+ * @param {string} resourceName resource name
1779
+ */
550
1780
 
551
- case 5:
552
- case 'end':
553
- return _context16.stop();
1781
+ }, {
1782
+ key: 'getMainResource',
1783
+ value: function getMainResource(resourceName) {
1784
+ return this.comoData.mainResources[resourceName];
1785
+ }
1786
+
1787
+ /**
1788
+ *
1789
+ * @param {string} resourceId resource id
1790
+ * @param {string} namespace resource namespace
1791
+ * @param {string|number} version resource version
1792
+ */
1793
+
1794
+ }, {
1795
+ key: 'getResourceUrl',
1796
+ value: function getResourceUrl(resourceId, namespace, version) {
1797
+ var _comoData26 = this.comoData,
1798
+ api = _comoData26.api,
1799
+ env = _comoData26.env_params;
1800
+
1801
+ return api.getResourceUrl(env.services_root_cdn, resourceId, namespace, version);
1802
+ }
1803
+ }, {
1804
+ key: 'getCdnUrl',
1805
+ value: function getCdnUrl() {
1806
+ return this.comoData.env_params.services_root_cdn;
1807
+ }
1808
+
1809
+ /**
1810
+ * @param {string} identifier fcm token created by firebase
1811
+ * @param {boolean} isFirebaseProjectMigrated is migrated to new firebase project
1812
+ */
1813
+
1814
+ }, {
1815
+ key: 'sendPushChannel',
1816
+ value: function sendPushChannel(identifier) {
1817
+ var isFirebaseProjectMigrated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1818
+ var _comoData27 = this.comoData,
1819
+ api = _comoData27.api,
1820
+ locationId = _comoData27.locationId,
1821
+ token = _comoData27.token,
1822
+ env = _comoData27.env_params;
1823
+
1824
+ return api.sendPushChannel(env.services_root, locationId, token, identifier, isFirebaseProjectMigrated);
1825
+ }
1826
+ }, {
1827
+ key: 'getRegionConfig',
1828
+ value: function () {
1829
+ var _ref33 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee32() {
1830
+ var _comoData28, api, locationId, token, env;
1831
+
1832
+ return _regenerator2.default.wrap(function _callee32$(_context32) {
1833
+ while (1) {
1834
+ switch (_context32.prev = _context32.next) {
1835
+ case 0:
1836
+ _comoData28 = this.comoData, api = _comoData28.api, locationId = _comoData28.locationId, token = _comoData28.token, env = _comoData28.env_params;
1837
+ return _context32.abrupt('return', api.getClientBusinessBackend(env.zapp_root, token, locationId));
1838
+
1839
+ case 2:
1840
+ case 'end':
1841
+ return _context32.stop();
1842
+ }
1843
+ }
1844
+ }, _callee32, this);
1845
+ }));
1846
+
1847
+ function getRegionConfig() {
1848
+ return _ref33.apply(this, arguments);
554
1849
  }
1850
+
1851
+ return getRegionConfig;
1852
+ }()
1853
+
1854
+ /**
1855
+ * @param {string} code coupon code entered by user on App
1856
+ */
1857
+
1858
+ }, {
1859
+ key: 'sendCouponCode',
1860
+ value: function sendCouponCode(code) {
1861
+ var _comoData29 = this.comoData,
1862
+ api = _comoData29.api,
1863
+ locationId = _comoData29.locationId,
1864
+ token = _comoData29.token,
1865
+ env = _comoData29.env_params;
1866
+
1867
+ return api.sendCouponCode(env.zapp_root, locationId, token, code);
555
1868
  }
556
- }, _callee16, undefined);
557
- }));
1869
+ }, {
1870
+ key: 'addPaymentMethod',
1871
+ value: function () {
1872
+ var _ref34 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee33(cardToken) {
1873
+ var _comoData30, api, locationId, token, env;
1874
+
1875
+ return _regenerator2.default.wrap(function _callee33$(_context33) {
1876
+ while (1) {
1877
+ switch (_context33.prev = _context33.next) {
1878
+ case 0:
1879
+ _comoData30 = this.comoData, api = _comoData30.api, locationId = _comoData30.locationId, token = _comoData30.token, env = _comoData30.env_params;
1880
+ return _context33.abrupt('return', api.addPaymentMethod(env.services_root, locationId, token, cardToken));
1881
+
1882
+ case 2:
1883
+ case 'end':
1884
+ return _context33.stop();
1885
+ }
1886
+ }
1887
+ }, _callee33, this);
1888
+ }));
558
1889
 
559
- como.loadForm = function (type) {
560
- var _comoData15 = comoData,
561
- api = _comoData15.api,
562
- locationId = _comoData15.locationId;
1890
+ function addPaymentMethod(_x47) {
1891
+ return _ref34.apply(this, arguments);
1892
+ }
563
1893
 
1894
+ return addPaymentMethod;
1895
+ }()
1896
+ }, {
1897
+ key: 'knowYourData',
1898
+ value: function () {
1899
+ var _ref35 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee34(email) {
1900
+ var _comoData31, api, locationId, token, env;
1901
+
1902
+ return _regenerator2.default.wrap(function _callee34$(_context34) {
1903
+ while (1) {
1904
+ switch (_context34.prev = _context34.next) {
1905
+ case 0:
1906
+ _comoData31 = this.comoData, api = _comoData31.api, locationId = _comoData31.locationId, token = _comoData31.token, env = _comoData31.env_params;
1907
+ return _context34.abrupt('return', api.knowYourData(env.services_root, locationId, token, email));
1908
+
1909
+ case 2:
1910
+ case 'end':
1911
+ return _context34.stop();
1912
+ }
1913
+ }
1914
+ }, _callee34, this);
1915
+ }));
564
1916
 
565
- return api.getForm(type, locationId);
566
- };
1917
+ function knowYourData(_x48) {
1918
+ return _ref35.apply(this, arguments);
1919
+ }
567
1920
 
568
- como.generateReferralCode = function () {
569
- var _comoData16 = comoData,
570
- api = _comoData16.api,
571
- locationId = _comoData16.locationId,
572
- token = _comoData16.token,
573
- env = _comoData16.env_params;
1921
+ return knowYourData;
1922
+ }()
1923
+ }, {
1924
+ key: 'consentWithdraw',
1925
+ value: function () {
1926
+ var _ref36 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee35(consentData) {
1927
+ var _comoData32, api, locationId, token, env;
1928
+
1929
+ return _regenerator2.default.wrap(function _callee35$(_context35) {
1930
+ while (1) {
1931
+ switch (_context35.prev = _context35.next) {
1932
+ case 0:
1933
+ _comoData32 = this.comoData, api = _comoData32.api, locationId = _comoData32.locationId, token = _comoData32.token, env = _comoData32.env_params;
1934
+ return _context35.abrupt('return', api.consentWithdraw(env.services_root, locationId, token, consentData));
1935
+
1936
+ case 2:
1937
+ case 'end':
1938
+ return _context35.stop();
1939
+ }
1940
+ }
1941
+ }, _callee35, this);
1942
+ }));
574
1943
 
1944
+ function consentWithdraw(_x49) {
1945
+ return _ref36.apply(this, arguments);
1946
+ }
575
1947
 
576
- return api.generateReferralCode(env.services_root, token, locationId);
577
- };
1948
+ return consentWithdraw;
1949
+ }()
1950
+ }, {
1951
+ key: 'getPaymentMethods',
1952
+ value: function () {
1953
+ var _ref37 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee36() {
1954
+ var _comoData33, env, locationId, api, responseJson;
1955
+
1956
+ return _regenerator2.default.wrap(function _callee36$(_context36) {
1957
+ while (1) {
1958
+ switch (_context36.prev = _context36.next) {
1959
+ case 0:
1960
+ _comoData33 = this.comoData, env = _comoData33.env_params, locationId = _comoData33.locationId, api = _comoData33.api;
1961
+ _context36.next = 3;
1962
+ return api.getPaymentMethods(env.services_root, locationId);
1963
+
1964
+ case 3:
1965
+ responseJson = _context36.sent;
1966
+ return _context36.abrupt('return', responseJson);
1967
+
1968
+ case 5:
1969
+ case 'end':
1970
+ return _context36.stop();
1971
+ }
1972
+ }
1973
+ }, _callee36, this);
1974
+ }));
578
1975
 
579
- como.getCredentials = function () {
580
- return {
581
- sessionId: comoData.sessionId,
582
- refreshToken: comoData.refreshToken
583
- };
584
- };
1976
+ function getPaymentMethods() {
1977
+ return _ref37.apply(this, arguments);
1978
+ }
585
1979
 
586
- como.getToken = function () {
587
- return comoData.token;
588
- };
1980
+ return getPaymentMethods;
1981
+ }()
1982
+
1983
+ /**
1984
+ * @param {Integer} amount to charge
1985
+ * @param {String} creditCardToken to charge from
1986
+ * @param {String} itemName for submit purchase
1987
+ * @param {String} itemNumber for submit purchase
1988
+ * @param {String} membershipKey for user identification
1989
+ */
1990
+
1991
+ }, {
1992
+ key: 'payInApp',
1993
+ value: function () {
1994
+ var _ref38 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee37(amount, creditCardToken, itemName, itemNumber, membershipKey) {
1995
+ var _comoData34, env, token, locationId, api, responseJson;
1996
+
1997
+ return _regenerator2.default.wrap(function _callee37$(_context37) {
1998
+ while (1) {
1999
+ switch (_context37.prev = _context37.next) {
2000
+ case 0:
2001
+ _comoData34 = this.comoData, env = _comoData34.env_params, token = _comoData34.token, locationId = _comoData34.locationId, api = _comoData34.api;
2002
+ _context37.next = 3;
2003
+ return api.payInApp(env.services_root, locationId, token, amount, creditCardToken, itemName, itemNumber, membershipKey);
2004
+
2005
+ case 3:
2006
+ responseJson = _context37.sent;
2007
+ return _context37.abrupt('return', responseJson);
2008
+
2009
+ case 5:
2010
+ case 'end':
2011
+ return _context37.stop();
2012
+ }
2013
+ }
2014
+ }, _callee37, this);
2015
+ }));
589
2016
 
590
- como.getInstallationId = function () {
591
- return comoData.installationId;
592
- };
2017
+ function payInApp(_x50, _x51, _x52, _x53, _x54) {
2018
+ return _ref38.apply(this, arguments);
2019
+ }
593
2020
 
594
- como.getMembership = function () {
595
- return comoData.membership;
596
- };
2021
+ return payInApp;
2022
+ }()
2023
+
2024
+ /**
2025
+ * @param {string} creditCardToken which card to delete
2026
+ */
2027
+
2028
+ }, {
2029
+ key: 'deletePayment',
2030
+ value: function () {
2031
+ var _ref39 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee38(creditCardToken) {
2032
+ var _comoData35, env, token, locationId, api, responseJson;
2033
+
2034
+ return _regenerator2.default.wrap(function _callee38$(_context38) {
2035
+ while (1) {
2036
+ switch (_context38.prev = _context38.next) {
2037
+ case 0:
2038
+ _comoData35 = this.comoData, env = _comoData35.env_params, token = _comoData35.token, locationId = _comoData35.locationId, api = _comoData35.api;
2039
+ _context38.next = 3;
2040
+ return api.deletePayment(env.services_root, locationId, token, creditCardToken);
2041
+
2042
+ case 3:
2043
+ responseJson = _context38.sent;
2044
+ return _context38.abrupt('return', responseJson);
2045
+
2046
+ case 5:
2047
+ case 'end':
2048
+ return _context38.stop();
2049
+ }
2050
+ }
2051
+ }, _callee38, this);
2052
+ }));
597
2053
 
598
- como.getAssets = function () {
599
- return comoData.assets;
600
- };
2054
+ function deletePayment(_x55) {
2055
+ return _ref39.apply(this, arguments);
2056
+ }
601
2057
 
602
- como.getArchivedAssets = function () {
603
- return (comoData.archivedAssets || []).concat(comoData.redeemedAssets);
604
- };
2058
+ return deletePayment;
2059
+ }()
2060
+ /**
2061
+ * @param {string} tag for Pop-up Message Trigger (Optional param)
2062
+ */
2063
+
2064
+ }, {
2065
+ key: 'getMemberMessages',
2066
+ value: function getMemberMessages(tag, limit, offset) {
2067
+ var _comoData36 = this.comoData,
2068
+ api = _comoData36.api,
2069
+ locationId = _comoData36.locationId,
2070
+ env = _comoData36.env_params;
2071
+
2072
+ return api.getMemberMessages(env.services_root, locationId, tag, limit, offset);
2073
+ }
605
2074
 
606
- como.getRegistrationUrl = function () {
607
- return comoData.env_params.app_modules_root + '/register?token=' + comoData.token + '&locationid=' + comoData.locationId;
608
- };
2075
+ /**
2076
+ * @param {string} keysList keys of the messages to mark as read
2077
+ */
609
2078
 
610
- como.getProfileUrl = function () {
611
- return como.env_params.app_modules_root + '/profile?token=' + comoData.token + '&locationid=' + comoData.locationId;
612
- };
2079
+ }, {
2080
+ key: 'markAsReadMemberMessages',
2081
+ value: function markAsReadMemberMessages(keysList) {
2082
+ var _comoData37 = this.comoData,
2083
+ api = _comoData37.api,
2084
+ locationId = _comoData37.locationId,
2085
+ env = _comoData37.env_params;
613
2086
 
614
- como.getLoginUrl = function () {
615
- return comoData.env_params.app_modules_root + '/login?token=' + comoData.token + '&locationid=' + comoData.locationId;
616
- };
2087
+ return api.markAsReadMemberMessages(env.services_root, locationId, keysList);
2088
+ }
617
2089
 
618
- como.getLocationState = function () {
619
- return comoData.locationState;
620
- };
2090
+ /**
2091
+ * @param {String} receiver to share with
2092
+ * @param {String} sender name
2093
+ * @param {Integer} amount to share
2094
+ * @param {String} type of wallet
2095
+ */
2096
+
2097
+ }, {
2098
+ key: 'budgetTransfer',
2099
+ value: function () {
2100
+ var _ref40 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee39(receiver, sender, amount, wallet) {
2101
+ var _comoData38, api, locationId, env;
2102
+
2103
+ return _regenerator2.default.wrap(function _callee39$(_context39) {
2104
+ while (1) {
2105
+ switch (_context39.prev = _context39.next) {
2106
+ case 0:
2107
+ _comoData38 = this.comoData, api = _comoData38.api, locationId = _comoData38.locationId, env = _comoData38.env_params;
2108
+ return _context39.abrupt('return', api.budgetTransfer(env.services_root, locationId, receiver, sender, amount, wallet));
2109
+
2110
+ case 2:
2111
+ case 'end':
2112
+ return _context39.stop();
2113
+ }
2114
+ }
2115
+ }, _callee39, this);
2116
+ }));
621
2117
 
622
- como.getPointShopItems = function () {
623
- return comoData.mainResources.menu.gifts_shop_item;
624
- };
2118
+ function budgetTransfer(_x56, _x57, _x58, _x59) {
2119
+ return _ref40.apply(this, arguments);
2120
+ }
625
2121
 
626
- como.getMainResource = function (resourceName) {
627
- return comoData.mainResources[resourceName];
628
- };
2122
+ return budgetTransfer;
2123
+ }()
2124
+
2125
+ /**
2126
+ * @param {string} claimId key of the credit claim to read the data for
2127
+ */
2128
+
2129
+ }, {
2130
+ key: 'getCreditClaimData',
2131
+ value: function getCreditClaimData(claimId) {
2132
+ var _comoData39 = this.comoData,
2133
+ api = _comoData39.api,
2134
+ env = _comoData39.env_params;
2135
+
2136
+ return api.getCreditClaimData(env.services_root, claimId);
2137
+ }
2138
+
2139
+ /**
2140
+ * @param {String} claimCode to use for budget transfer claim
2141
+ */
2142
+
2143
+ }, {
2144
+ key: 'budgetTransferClaim',
2145
+ value: function () {
2146
+ var _ref41 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee40(claimCode) {
2147
+ var _comoData40, api, locationId, env;
2148
+
2149
+ return _regenerator2.default.wrap(function _callee40$(_context40) {
2150
+ while (1) {
2151
+ switch (_context40.prev = _context40.next) {
2152
+ case 0:
2153
+ _comoData40 = this.comoData, api = _comoData40.api, locationId = _comoData40.locationId, env = _comoData40.env_params;
2154
+ return _context40.abrupt('return', api.budgetTransferClaim(env.services_root, locationId, claimCode));
2155
+
2156
+ case 2:
2157
+ case 'end':
2158
+ return _context40.stop();
2159
+ }
2160
+ }
2161
+ }, _callee40, this);
2162
+ }));
2163
+
2164
+ function budgetTransferClaim(_x60) {
2165
+ return _ref41.apply(this, arguments);
2166
+ }
2167
+
2168
+ return budgetTransferClaim;
2169
+ }()
2170
+
2171
+ /**
2172
+ * API call for claim generic action. To specify your trigger button, you need to associate it with a particular item, asset or tag.
2173
+ * @param {string} assetKey - asset to claim
2174
+ * @param {string} itemId - item id to claim
2175
+ * @param {string} tag - claim all with tag
2176
+ */
2177
+
2178
+ }, {
2179
+ key: 'claim',
2180
+ value: function claim(assetKey, itemId, tag) {
2181
+ var _comoData41 = this.comoData,
2182
+ env = _comoData41.env_params,
2183
+ locationId = _comoData41.locationId,
2184
+ api = _comoData41.api,
2185
+ token = _comoData41.token;
2186
+
2187
+ return api.claim(env.zapp_root, locationId, token, assetKey, itemId, tag);
2188
+ }
2189
+
2190
+ /**
2191
+ * Log user action
2192
+ * @param {string} action
2193
+ * @param {string} logData - log information
2194
+ */
2195
+
2196
+ }, {
2197
+ key: 'logUserAction',
2198
+ value: function () {
2199
+ var _ref42 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee41(action, logData) {
2200
+ var _comoData42, env, locationId, api, token;
2201
+
2202
+ return _regenerator2.default.wrap(function _callee41$(_context41) {
2203
+ while (1) {
2204
+ switch (_context41.prev = _context41.next) {
2205
+ case 0:
2206
+ _comoData42 = this.comoData, env = _comoData42.env_params, locationId = _comoData42.locationId, api = _comoData42.api, token = _comoData42.token;
2207
+ return _context41.abrupt('return', api.logUserAction(env.zapp_root, locationId, token, action, logData));
2208
+
2209
+ case 2:
2210
+ case 'end':
2211
+ return _context41.stop();
2212
+ }
2213
+ }
2214
+ }, _callee41, this);
2215
+ }));
2216
+
2217
+ function logUserAction(_x61, _x62) {
2218
+ return _ref42.apply(this, arguments);
2219
+ }
2220
+
2221
+ return logUserAction;
2222
+ }()
2223
+
2224
+ /**
2225
+ * Member purchase history
2226
+ * @param {string} limit - how manay items to return (if exists) - default value is 25
2227
+ * @param {string} offset - default value is 0(next offset would be 25)
2228
+ */
2229
+
2230
+ }, {
2231
+ key: 'getPurchaseHistory',
2232
+ value: function () {
2233
+ var _ref43 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee42(limit, offset) {
2234
+ var _comoData43, locationId, api, membership;
2235
+
2236
+ return _regenerator2.default.wrap(function _callee42$(_context42) {
2237
+ while (1) {
2238
+ switch (_context42.prev = _context42.next) {
2239
+ case 0:
2240
+ _comoData43 = this.comoData, locationId = _comoData43.locationId, api = _comoData43.api, membership = _comoData43.membership;
2241
+ return _context42.abrupt('return', api.getPurchaseHistory(locationId, membership.Key, limit, offset));
2242
+
2243
+ case 2:
2244
+ case 'end':
2245
+ return _context42.stop();
2246
+ }
2247
+ }
2248
+ }, _callee42, this);
2249
+ }));
2250
+
2251
+ function getPurchaseHistory(_x63, _x64) {
2252
+ return _ref43.apply(this, arguments);
2253
+ }
2254
+
2255
+ return getPurchaseHistory;
2256
+ }()
2257
+ }]);
2258
+ return Como;
2259
+ }();
629
2260
 
630
- module.exports = como;
2261
+ module.exports = Como;