@como/como-client 0.6.8 → 0.7.2

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
@@ -223,7 +223,7 @@ var Como = function () {
223
223
  interval = 0;
224
224
 
225
225
  if (!(refreshFailed || !credExist)) {
226
- _context2.next = 49;
226
+ _context2.next = 51;
227
227
  break;
228
228
  }
229
229
 
@@ -262,14 +262,38 @@ var Como = function () {
262
262
  break;
263
263
 
264
264
  case 49:
265
+ _context2.next = 60;
266
+ break;
267
+
268
+ case 51:
269
+ _context2.prev = 51;
270
+
271
+ console.error('signOn with, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken);
272
+ _context2.next = 55;
273
+ return this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
274
+
275
+ case 55:
276
+ _context2.next = 60;
277
+ break;
278
+
279
+ case 57:
280
+ _context2.prev = 57;
281
+ _context2.t2 = _context2['catch'](51);
282
+
283
+ console.log('Failed signOn with accessToken, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken + ', error:' + _context2.t2);
284
+
285
+ case 60:
286
+ if (!this.comoData.token) {
287
+ this.comoData.token = this.comoData.accessToken;
288
+ }
265
289
  return _context2.abrupt('return', this.getCredentials());
266
290
 
267
- case 50:
291
+ case 62:
268
292
  case 'end':
269
293
  return _context2.stop();
270
294
  }
271
295
  }
272
- }, _callee2, this, [[17, 24], [32, 40]]);
296
+ }, _callee2, this, [[17, 24], [32, 40], [51, 57]]);
273
297
  }));
274
298
 
275
299
  function init(_x, _x2, _x3) {
@@ -885,14 +909,21 @@ var Como = function () {
885
909
  switch (_context14.prev = _context14.next) {
886
910
  case 0:
887
911
  _comoData7 = this.comoData, api = _comoData7.api, locationId = _comoData7.locationId, token = _comoData7.token, env = _comoData7.env_params;
912
+ _context14.prev = 1;
888
913
  return _context14.abrupt('return', api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable));
889
914
 
890
- case 2:
915
+ case 5:
916
+ _context14.prev = 5;
917
+ _context14.t0 = _context14['catch'](1);
918
+
919
+ console.log('clientUpdateMembership failed, token:' + token + ', locationId:' + locationId + ', error: ' + _context14.t0);
920
+
921
+ case 8:
891
922
  case 'end':
892
923
  return _context14.stop();
893
924
  }
894
925
  }
895
- }, _callee14, this);
926
+ }, _callee14, this, [[1, 5]]);
896
927
  }));
897
928
 
898
929
  function clientUpdateMembership(_x35, _x36) {
@@ -2238,6 +2269,20 @@ var Como = function () {
2238
2269
 
2239
2270
  return getPurchaseHistory;
2240
2271
  }()
2272
+
2273
+ /**
2274
+ * Get app texts for multi languages - only for apps that has project set in translation service
2275
+ */
2276
+
2277
+ }, {
2278
+ key: 'getAppTextsV2',
2279
+ value: function getAppTextsV2() {
2280
+ var _comoData44 = this.comoData,
2281
+ api = _comoData44.api,
2282
+ locationId = _comoData44.locationId;
2283
+
2284
+ return api.getAllTranslations(locationId);
2285
+ }
2241
2286
  }]);
2242
2287
  return Como;
2243
2288
  }();
@@ -27,24 +27,31 @@ function getHashHeader(data) {
27
27
 
28
28
  exports.signOn = function (service) {
29
29
  return function () {
30
- var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(deviceId, locationId, source) {
30
+ var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(deviceId, locationId, source, accessToken) {
31
31
  var params, headers, _ref2, data;
32
32
 
33
33
  return _regenerator2.default.wrap(function _callee$(_context) {
34
34
  while (1) {
35
35
  switch (_context.prev = _context.next) {
36
36
  case 0:
37
- params = { deviceId: deviceId, locationId: locationId, source: source };
37
+ params = { deviceId: deviceId, locationId: locationId, source: source, accessToken: accessToken };
38
38
  headers = getHashHeader(params);
39
- _context.next = 4;
39
+
40
+ if (accessToken) {
41
+ headers['Authorization'] = "Bearer " + token;
42
+ }
43
+ console.error("signOn(auth) with deviceId:" + deviceId + ", locationId:" + locationId + ", source:" + source + ",accessToken:" + accessToken + ", headers: " + headers);
44
+ _context.next = 6;
40
45
  return service.post('/auth/v2/auth/signOn', params, { headers: headers });
41
46
 
42
- case 4:
47
+ case 6:
43
48
  _ref2 = _context.sent;
44
49
  data = _ref2.data;
50
+
51
+ console.error("signOn(auth) result with data:" + data);
45
52
  return _context.abrupt("return", data);
46
53
 
47
- case 7:
54
+ case 10:
48
55
  case "end":
49
56
  return _context.stop();
50
57
  }
@@ -52,7 +59,7 @@ exports.signOn = function (service) {
52
59
  }, _callee, undefined);
53
60
  }));
54
61
 
55
- return function (_x, _x2, _x3) {
62
+ return function (_x, _x2, _x3, _x4) {
56
63
  return _ref.apply(this, arguments);
57
64
  };
58
65
  }();
@@ -85,7 +92,7 @@ exports.register = function (service) {
85
92
  }, _callee2, undefined);
86
93
  }));
87
94
 
88
- return function (_x4, _x5, _x6) {
95
+ return function (_x5, _x6, _x7) {
89
96
  return _ref3.apply(this, arguments);
90
97
  };
91
98
  }();
@@ -117,7 +124,7 @@ exports.registerVerify = function (service) {
117
124
  }, _callee3, undefined);
118
125
  }));
119
126
 
120
- return function (_x8, _x9, _x10, _x11) {
127
+ return function (_x9, _x10, _x11, _x12) {
121
128
  return _ref5.apply(this, arguments);
122
129
  };
123
130
  }();
@@ -150,7 +157,7 @@ exports.updateProfile = function (service) {
150
157
  }, _callee4, undefined);
151
158
  }));
152
159
 
153
- return function (_x12, _x13) {
160
+ return function (_x13, _x14) {
154
161
  return _ref7.apply(this, arguments);
155
162
  };
156
163
  }();
@@ -184,7 +191,7 @@ exports.updateProfileVerify = function (service) {
184
191
  }, _callee5, undefined);
185
192
  }));
186
193
 
187
- return function (_x15, _x16, _x17, _x18) {
194
+ return function (_x16, _x17, _x18, _x19) {
188
195
  return _ref9.apply(this, arguments);
189
196
  };
190
197
  }();
@@ -216,7 +223,7 @@ exports.unsubscribeSms = function (service) {
216
223
  }, _callee6, undefined);
217
224
  }));
218
225
 
219
- return function (_x20, _x21) {
226
+ return function (_x21, _x22) {
220
227
  return _ref11.apply(this, arguments);
221
228
  };
222
229
  }();
@@ -249,7 +256,7 @@ exports.logIn = function (service) {
249
256
  }, _callee7, undefined);
250
257
  }));
251
258
 
252
- return function (_x22, _x23) {
259
+ return function (_x23, _x24) {
253
260
  return _ref13.apply(this, arguments);
254
261
  };
255
262
  }();
@@ -286,7 +293,7 @@ exports.logInVerify = function (service) {
286
293
  }, _callee8, undefined);
287
294
  }));
288
295
 
289
- return function (_x24, _x25, _x26) {
296
+ return function (_x25, _x26, _x27) {
290
297
  return _ref15.apply(this, arguments);
291
298
  };
292
299
  }();
@@ -344,7 +351,7 @@ exports.refreshToken = function (service) {
344
351
  }, _callee10, undefined);
345
352
  }));
346
353
 
347
- return function (_x27, _x28, _x29, _x30) {
354
+ return function (_x28, _x29, _x30, _x31) {
348
355
  return _ref19.apply(this, arguments);
349
356
  };
350
357
  }();
@@ -136,4 +136,36 @@ exports.getZappResource = function (service) {
136
136
  return _ref7.apply(this, arguments);
137
137
  };
138
138
  }();
139
+ };
140
+
141
+ exports.getAllTranslations = function (service) {
142
+ return function () {
143
+ var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(locationId) {
144
+ var url, _ref10, data;
145
+
146
+ return _regenerator2.default.wrap(function _callee5$(_context5) {
147
+ while (1) {
148
+ switch (_context5.prev = _context5.next) {
149
+ case 0:
150
+ url = "/v1/translation/" + locationId;
151
+ _context5.next = 3;
152
+ return service.get(url);
153
+
154
+ case 3:
155
+ _ref10 = _context5.sent;
156
+ data = _ref10.data;
157
+ return _context5.abrupt("return", data);
158
+
159
+ case 6:
160
+ case "end":
161
+ return _context5.stop();
162
+ }
163
+ }
164
+ }, _callee5, undefined);
165
+ }));
166
+
167
+ return function (_x9) {
168
+ return _ref9.apply(this, arguments);
169
+ };
170
+ }();
139
171
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@como/como-client",
3
- "version": "0.6.8",
3
+ "version": "0.7.2",
4
4
  "description": "Client module for Como's loaylty API",
5
5
  "main": "src/como.js",
6
6
  "scripts": {
package/src/como.js CHANGED
@@ -130,7 +130,18 @@ class Como {
130
130
  }
131
131
  }
132
132
  }
133
+ else{
134
+ try{
135
+ console.error(`signOn with, installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}`);
136
+ await this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
137
+ }catch(e){
138
+ console.log(`Failed signOn with accessToken, installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}, error:${e}`);
139
+ }
133
140
 
141
+ }
142
+ if(!this.comoData.token){
143
+ this.comoData.token = this.comoData.accessToken;
144
+ }
134
145
  return this.getCredentials();
135
146
  }
136
147
 
@@ -366,8 +377,13 @@ class Como {
366
377
  const {
367
378
  api, locationId, token, env_params: env,
368
379
  } = this.comoData;
380
+ try{
381
+ return api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable);
382
+ }
383
+ catch(e){
384
+ console.log(`clientUpdateMembership failed, token:${token}, locationId:${locationId}, error: ${e}`);
369
385
 
370
- return api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable);
386
+ }
371
387
  }
372
388
 
373
389
  /**
@@ -931,6 +947,14 @@ class Como {
931
947
  } = this.comoData;
932
948
  return api.getPurchaseHistory(locationId, membership.Key, limit, offset);
933
949
  }
950
+
951
+ /**
952
+ * Get app texts for multi languages - only for apps that has project set in translation service
953
+ */
954
+ getAppTextsV2() {
955
+ const { api, locationId } = this.comoData;
956
+ return api.getAllTranslations(locationId);
957
+ }
934
958
  }
935
959
 
936
960
  module.exports = Como;