@como/como-client
Advanced tools
Comparing version
602
lib/como.js
@@ -389,7 +389,6 @@ 'use strict'; | ||
* | ||
* @param {Object} identifier an object which identifies the user by its credentials | ||
* @param {string} type login type i.e PhoneNumber/Email/etc | ||
* @param {Object} form update form values | ||
*/ | ||
como.login = function () { | ||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(identifier, type) { | ||
como.updateProfile = function () { | ||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(form) { | ||
var _comoData7, api, data, _error$response$data4, code, message; | ||
@@ -404,3 +403,3 @@ | ||
_context8.next = 4; | ||
return api.logIn(type, identifier); | ||
return api.updateProfile(form); | ||
@@ -434,3 +433,3 @@ case 4: | ||
return function (_x15, _x16) { | ||
return function (_x15) { | ||
return _ref8.apply(this, arguments); | ||
@@ -442,9 +441,9 @@ }; | ||
* | ||
* @param {Object} identifier key-value identifiers | ||
* @param {*} type login type i.e PhoneNumber/Email/etc | ||
* @param {*} code a 2-factor verification code sent to the client | ||
* @param {string} verificationCode code verification sent by 3rd party | ||
* @param {string} type verification type | ||
* @param {Object} form update form values | ||
*/ | ||
como.loginVerify = function () { | ||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(identifier, type, code) { | ||
var _comoData8, api, _ref10, consent, _error$response$data5, errCode, message; | ||
como.updateProfileVerify = function () { | ||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(verificationCode, type, form) { | ||
var _comoData8, api, data, _error$response$data5, code, message; | ||
@@ -458,25 +457,126 @@ return _regenerator2.default.wrap(function _callee9$(_context9) { | ||
_context9.next = 4; | ||
return api.updateProfileVerify(verificationCode, type, form); | ||
case 4: | ||
data = _context9.sent; | ||
return _context9.abrupt('return', data); | ||
case 8: | ||
_context9.prev = 8; | ||
_context9.t0 = _context9['catch'](1); | ||
if (!(_context9.t0.response && _context9.t0.response.data)) { | ||
_context9.next = 13; | ||
break; | ||
} | ||
_error$response$data5 = _context9.t0.response.data, code = _error$response$data5.code, message = _error$response$data5.message; | ||
throw new Error(code || message); | ||
case 13: | ||
throw _context9.t0; | ||
case 14: | ||
case 'end': | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee9, undefined, [[1, 8]]); | ||
})); | ||
return function (_x16, _x17, _x18) { | ||
return _ref9.apply(this, arguments); | ||
}; | ||
}(); | ||
/** | ||
* | ||
* @param {Object} identifier an object which identifies the user by its credentials | ||
* @param {string} type login type i.e PhoneNumber/Email/etc | ||
*/ | ||
como.login = function () { | ||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(identifier, type) { | ||
var _comoData9, api, data, _error$response$data6, code, message; | ||
return _regenerator2.default.wrap(function _callee10$(_context10) { | ||
while (1) { | ||
switch (_context10.prev = _context10.next) { | ||
case 0: | ||
_comoData9 = comoData, api = _comoData9.api; | ||
_context10.prev = 1; | ||
_context10.next = 4; | ||
return api.logIn(type, identifier); | ||
case 4: | ||
data = _context10.sent; | ||
return _context10.abrupt('return', data); | ||
case 8: | ||
_context10.prev = 8; | ||
_context10.t0 = _context10['catch'](1); | ||
if (!(_context10.t0.response && _context10.t0.response.data)) { | ||
_context10.next = 13; | ||
break; | ||
} | ||
_error$response$data6 = _context10.t0.response.data, code = _error$response$data6.code, message = _error$response$data6.message; | ||
throw new Error(code || message); | ||
case 13: | ||
throw _context10.t0; | ||
case 14: | ||
case 'end': | ||
return _context10.stop(); | ||
} | ||
} | ||
}, _callee10, undefined, [[1, 8]]); | ||
})); | ||
return function (_x19, _x20) { | ||
return _ref10.apply(this, arguments); | ||
}; | ||
}(); | ||
/** | ||
* | ||
* @param {Object} identifier key-value identifiers | ||
* @param {*} type login type i.e PhoneNumber/Email/etc | ||
* @param {*} code a 2-factor verification code sent to the client | ||
*/ | ||
como.loginVerify = function () { | ||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(identifier, type, code) { | ||
var _comoData10, api, _ref12, consent, _error$response$data7, errCode, message; | ||
return _regenerator2.default.wrap(function _callee11$(_context11) { | ||
while (1) { | ||
switch (_context11.prev = _context11.next) { | ||
case 0: | ||
_comoData10 = comoData, api = _comoData10.api; | ||
_context11.prev = 1; | ||
_context11.next = 4; | ||
return api.logInVerify(code, type, identifier); | ||
case 4: | ||
_ref10 = _context9.sent; | ||
consent = _ref10.consent; | ||
_ref12 = _context11.sent; | ||
consent = _ref12.consent; | ||
comoData.consent = consent; | ||
_context9.next = 17; | ||
_context11.next = 17; | ||
break; | ||
case 9: | ||
_context9.prev = 9; | ||
_context9.t0 = _context9['catch'](1); | ||
_context11.prev = 9; | ||
_context11.t0 = _context11['catch'](1); | ||
if (!(_context9.t0.response && _context9.t0.response.data)) { | ||
_context9.next = 16; | ||
if (!(_context11.t0.response && _context11.t0.response.data)) { | ||
_context11.next = 16; | ||
break; | ||
} | ||
_error$response$data5 = _context9.t0.response.data, errCode = _error$response$data5.code, message = _error$response$data5.message; | ||
_error$response$data7 = _context11.t0.response.data, errCode = _error$response$data7.code, message = _error$response$data7.message; | ||
if (!(message && message === 'Invalid verification Code')) { | ||
_context9.next = 15; | ||
_context11.next = 15; | ||
break; | ||
@@ -491,17 +591,17 @@ } | ||
case 16: | ||
throw _context9.t0; | ||
throw _context11.t0; | ||
case 17: | ||
return _context9.abrupt('return', como.getCredentials()); | ||
return _context11.abrupt('return', como.getCredentials()); | ||
case 18: | ||
case 'end': | ||
return _context9.stop(); | ||
return _context11.stop(); | ||
} | ||
} | ||
}, _callee9, undefined, [[1, 9]]); | ||
}, _callee11, undefined, [[1, 9]]); | ||
})); | ||
return function (_x17, _x18, _x19) { | ||
return _ref9.apply(this, arguments); | ||
return function (_x21, _x22, _x23) { | ||
return _ref11.apply(this, arguments); | ||
}; | ||
@@ -514,15 +614,15 @@ }(); | ||
*/ | ||
como.reloadMembership = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10() { | ||
var _comoData9, env, locationId, api, membership; | ||
como.reloadMembership = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12() { | ||
var _comoData11, env, locationId, api, membership; | ||
return _regenerator2.default.wrap(function _callee10$(_context10) { | ||
return _regenerator2.default.wrap(function _callee12$(_context12) { | ||
while (1) { | ||
switch (_context10.prev = _context10.next) { | ||
switch (_context12.prev = _context12.next) { | ||
case 0: | ||
_comoData9 = comoData, env = _comoData9.env_params, locationId = _comoData9.locationId, api = _comoData9.api; | ||
_context10.next = 3; | ||
_comoData11 = comoData, env = _comoData11.env_params, locationId = _comoData11.locationId, api = _comoData11.api; | ||
_context12.next = 3; | ||
return api.getUserAtLocation(env.zapp_root, locationId); | ||
case 3: | ||
membership = _context10.sent; | ||
membership = _context12.sent; | ||
@@ -533,6 +633,6 @@ comoData.membership = membership; | ||
case 'end': | ||
return _context10.stop(); | ||
return _context12.stop(); | ||
} | ||
} | ||
}, _callee10, undefined); | ||
}, _callee12, undefined); | ||
})); | ||
@@ -543,18 +643,18 @@ | ||
*/ | ||
como.openApp = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11() { | ||
var _comoData10, api, locationId, token, env; | ||
como.openApp = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13() { | ||
var _comoData12, api, locationId, token, env; | ||
return _regenerator2.default.wrap(function _callee11$(_context11) { | ||
return _regenerator2.default.wrap(function _callee13$(_context13) { | ||
while (1) { | ||
switch (_context11.prev = _context11.next) { | ||
switch (_context13.prev = _context13.next) { | ||
case 0: | ||
_comoData10 = comoData, api = _comoData10.api, locationId = _comoData10.locationId, token = _comoData10.token, env = _comoData10.env_params; | ||
return _context11.abrupt('return', api.openApp(env.zapp_root, token, locationId)); | ||
_comoData12 = comoData, api = _comoData12.api, locationId = _comoData12.locationId, token = _comoData12.token, env = _comoData12.env_params; | ||
return _context13.abrupt('return', api.openApp(env.zapp_root, token, locationId)); | ||
case 2: | ||
case 'end': | ||
return _context11.stop(); | ||
return _context13.stop(); | ||
} | ||
} | ||
}, _callee11, undefined); | ||
}, _callee13, undefined); | ||
})); | ||
@@ -568,22 +668,22 @@ | ||
como.clientUpdateMembership = function () { | ||
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(pushEnable, locationEnable) { | ||
var _comoData11, api, locationId, token, env; | ||
var _ref15 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14(pushEnable, locationEnable) { | ||
var _comoData13, api, locationId, token, env; | ||
return _regenerator2.default.wrap(function _callee12$(_context12) { | ||
return _regenerator2.default.wrap(function _callee14$(_context14) { | ||
while (1) { | ||
switch (_context12.prev = _context12.next) { | ||
switch (_context14.prev = _context14.next) { | ||
case 0: | ||
_comoData11 = comoData, api = _comoData11.api, locationId = _comoData11.locationId, token = _comoData11.token, env = _comoData11.env_params; | ||
return _context12.abrupt('return', api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable)); | ||
_comoData13 = comoData, api = _comoData13.api, locationId = _comoData13.locationId, token = _comoData13.token, env = _comoData13.env_params; | ||
return _context14.abrupt('return', api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable)); | ||
case 2: | ||
case 'end': | ||
return _context12.stop(); | ||
return _context14.stop(); | ||
} | ||
} | ||
}, _callee12, undefined); | ||
}, _callee14, undefined); | ||
})); | ||
return function (_x20, _x21) { | ||
return _ref13.apply(this, arguments); | ||
return function (_x24, _x25) { | ||
return _ref15.apply(this, arguments); | ||
}; | ||
@@ -598,8 +698,8 @@ }(); | ||
como.downloadMainResource = function () { | ||
var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(resourceId) { | ||
var resource, err, _comoData12, env, api, responseJson; | ||
var _ref16 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15(resourceId) { | ||
var resource, err, _comoData14, env, api, responseJson; | ||
return _regenerator2.default.wrap(function _callee13$(_context13) { | ||
return _regenerator2.default.wrap(function _callee15$(_context15) { | ||
while (1) { | ||
switch (_context13.prev = _context13.next) { | ||
switch (_context15.prev = _context15.next) { | ||
case 0: | ||
@@ -609,3 +709,3 @@ resource = comoData.mainResourcesMap[resourceId]; | ||
if (resource) { | ||
_context13.next = 4; | ||
_context15.next = 4; | ||
break; | ||
@@ -618,8 +718,8 @@ } | ||
case 4: | ||
_comoData12 = comoData, env = _comoData12.env_params, api = _comoData12.api; | ||
_context13.next = 7; | ||
_comoData14 = comoData, env = _comoData14.env_params, api = _comoData14.api; | ||
_context15.next = 7; | ||
return api.getLoyaltyResource(env.services_root_temp, resource.id, 'Namespace' in resource ? resource.Namespace : 'location_' + comoData.locationId, resource.Version); | ||
case 7: | ||
responseJson = _context13.sent; | ||
responseJson = _context15.sent; | ||
@@ -631,10 +731,10 @@ | ||
case 'end': | ||
return _context13.stop(); | ||
return _context15.stop(); | ||
} | ||
} | ||
}, _callee13, undefined); | ||
}, _callee15, undefined); | ||
})); | ||
return function (_x22) { | ||
return _ref14.apply(this, arguments); | ||
return function (_x26) { | ||
return _ref16.apply(this, arguments); | ||
}; | ||
@@ -647,15 +747,15 @@ }(); | ||
*/ | ||
como.reloadLocationState = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14() { | ||
var _comoData13, api, state, mainResources; | ||
como.reloadLocationState = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16() { | ||
var _comoData15, api, state, mainResources; | ||
return _regenerator2.default.wrap(function _callee14$(_context14) { | ||
return _regenerator2.default.wrap(function _callee16$(_context16) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
switch (_context16.prev = _context16.next) { | ||
case 0: | ||
_comoData13 = comoData, api = _comoData13.api; | ||
_context14.next = 3; | ||
_comoData15 = comoData, api = _comoData15.api; | ||
_context16.next = 3; | ||
return api.getLocationState(comoData.env_params.zapp_root, comoData.locationId); | ||
case 3: | ||
state = _context14.sent; | ||
state = _context16.sent; | ||
@@ -673,6 +773,6 @@ comoData.locationState = state; | ||
case 'end': | ||
return _context14.stop(); | ||
return _context16.stop(); | ||
} | ||
} | ||
}, _callee14, undefined); | ||
}, _callee16, undefined); | ||
})); | ||
@@ -683,23 +783,23 @@ | ||
*/ | ||
como.getAppClientID = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15() { | ||
var _comoData14, env, locationId, api, responseJson; | ||
como.getAppClientID = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17() { | ||
var _comoData16, env, locationId, api, responseJson; | ||
return _regenerator2.default.wrap(function _callee15$(_context15) { | ||
return _regenerator2.default.wrap(function _callee17$(_context17) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
switch (_context17.prev = _context17.next) { | ||
case 0: | ||
_comoData14 = comoData, env = _comoData14.env_params, locationId = _comoData14.locationId, api = _comoData14.api; | ||
_context15.next = 3; | ||
_comoData16 = comoData, env = _comoData16.env_params, locationId = _comoData16.locationId, api = _comoData16.api; | ||
_context17.next = 3; | ||
return api.getShortUserId(env.zapp_root, locationId); | ||
case 3: | ||
responseJson = _context15.sent; | ||
return _context15.abrupt('return', responseJson.ID); | ||
responseJson = _context17.sent; | ||
return _context17.abrupt('return', responseJson.ID); | ||
case 5: | ||
case 'end': | ||
return _context15.stop(); | ||
return _context17.stop(); | ||
} | ||
} | ||
}, _callee15, undefined); | ||
}, _callee17, undefined); | ||
})); | ||
@@ -710,23 +810,23 @@ | ||
*/ | ||
como.getPaymentCode = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16() { | ||
var _comoData15, env, locationId, api, responseJson; | ||
como.getPaymentCode = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee18() { | ||
var _comoData17, env, locationId, api, responseJson; | ||
return _regenerator2.default.wrap(function _callee16$(_context16) { | ||
return _regenerator2.default.wrap(function _callee18$(_context18) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
switch (_context18.prev = _context18.next) { | ||
case 0: | ||
_comoData15 = comoData, env = _comoData15.env_params, locationId = _comoData15.locationId, api = _comoData15.api; | ||
_context16.next = 3; | ||
_comoData17 = comoData, env = _comoData17.env_params, locationId = _comoData17.locationId, api = _comoData17.api; | ||
_context18.next = 3; | ||
return api.getPaymentCode(env.zapp_root, locationId); | ||
case 3: | ||
responseJson = _context16.sent; | ||
return _context16.abrupt('return', responseJson.VerificationCode); | ||
responseJson = _context18.sent; | ||
return _context18.abrupt('return', responseJson.VerificationCode); | ||
case 5: | ||
case 'end': | ||
return _context16.stop(); | ||
return _context18.stop(); | ||
} | ||
} | ||
}, _callee16, undefined); | ||
}, _callee18, undefined); | ||
})); | ||
@@ -737,39 +837,39 @@ | ||
*/ | ||
como.logout = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17() { | ||
var _comoData16, api, response, _error$response$data6, errCode, message; | ||
como.logout = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee19() { | ||
var _comoData18, api, response, _error$response$data8, errCode, message; | ||
return _regenerator2.default.wrap(function _callee17$(_context17) { | ||
return _regenerator2.default.wrap(function _callee19$(_context19) { | ||
while (1) { | ||
switch (_context17.prev = _context17.next) { | ||
switch (_context19.prev = _context19.next) { | ||
case 0: | ||
_comoData16 = comoData, api = _comoData16.api; | ||
_context17.prev = 1; | ||
_context17.next = 4; | ||
_comoData18 = comoData, api = _comoData18.api; | ||
_context19.prev = 1; | ||
_context19.next = 4; | ||
return api.logOut(); | ||
case 4: | ||
response = _context17.sent; | ||
return _context17.abrupt('return', response); | ||
response = _context19.sent; | ||
return _context19.abrupt('return', response); | ||
case 8: | ||
_context17.prev = 8; | ||
_context17.t0 = _context17['catch'](1); | ||
_context19.prev = 8; | ||
_context19.t0 = _context19['catch'](1); | ||
if (!(_context17.t0.response && _context17.t0.response.data)) { | ||
_context17.next = 13; | ||
if (!(_context19.t0.response && _context19.t0.response.data)) { | ||
_context19.next = 13; | ||
break; | ||
} | ||
_error$response$data6 = _context17.t0.response.data, errCode = _error$response$data6.code, message = _error$response$data6.message; | ||
_error$response$data8 = _context19.t0.response.data, errCode = _error$response$data8.code, message = _error$response$data8.message; | ||
throw new Error(errCode || message); | ||
case 13: | ||
throw _context17.t0; | ||
throw _context19.t0; | ||
case 14: | ||
case 'end': | ||
return _context17.stop(); | ||
return _context19.stop(); | ||
} | ||
} | ||
}, _callee17, undefined, [[1, 8]]); | ||
}, _callee19, undefined, [[1, 8]]); | ||
})); | ||
@@ -782,27 +882,27 @@ | ||
como.redeemAsset = function () { | ||
var _ref19 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee18(assetKey) { | ||
var _comoData17, env, locationId, api, responseJson; | ||
var _ref21 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee20(assetKey) { | ||
var _comoData19, env, locationId, api, responseJson; | ||
return _regenerator2.default.wrap(function _callee18$(_context18) { | ||
return _regenerator2.default.wrap(function _callee20$(_context20) { | ||
while (1) { | ||
switch (_context18.prev = _context18.next) { | ||
switch (_context20.prev = _context20.next) { | ||
case 0: | ||
_comoData17 = comoData, env = _comoData17.env_params, locationId = _comoData17.locationId, api = _comoData17.api; | ||
_context18.next = 3; | ||
_comoData19 = comoData, env = _comoData19.env_params, locationId = _comoData19.locationId, api = _comoData19.api; | ||
_context20.next = 3; | ||
return api.redeemAsset(env.zapp_root, locationId, assetKey); | ||
case 3: | ||
responseJson = _context18.sent; | ||
return _context18.abrupt('return', responseJson); | ||
responseJson = _context20.sent; | ||
return _context20.abrupt('return', responseJson); | ||
case 5: | ||
case 'end': | ||
return _context18.stop(); | ||
return _context20.stop(); | ||
} | ||
} | ||
}, _callee18, undefined); | ||
}, _callee20, undefined); | ||
})); | ||
return function (_x23) { | ||
return _ref19.apply(this, arguments); | ||
return function (_x27) { | ||
return _ref21.apply(this, arguments); | ||
}; | ||
@@ -816,27 +916,27 @@ }(); | ||
como.purchaseAsset = function () { | ||
var _ref20 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee19(itemId) { | ||
var _comoData18, env, token, locationId, api, responseJson; | ||
var _ref22 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee21(itemId) { | ||
var _comoData20, env, token, locationId, api, responseJson; | ||
return _regenerator2.default.wrap(function _callee19$(_context19) { | ||
return _regenerator2.default.wrap(function _callee21$(_context21) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
switch (_context21.prev = _context21.next) { | ||
case 0: | ||
_comoData18 = comoData, env = _comoData18.env_params, token = _comoData18.token, locationId = _comoData18.locationId, api = _comoData18.api; | ||
_context19.next = 3; | ||
_comoData20 = comoData, env = _comoData20.env_params, token = _comoData20.token, locationId = _comoData20.locationId, api = _comoData20.api; | ||
_context21.next = 3; | ||
return api.purchaseAsset(env.zapp_root, locationId, token, itemId); | ||
case 3: | ||
responseJson = _context19.sent; | ||
return _context19.abrupt('return', responseJson); | ||
responseJson = _context21.sent; | ||
return _context21.abrupt('return', responseJson); | ||
case 5: | ||
case 'end': | ||
return _context19.stop(); | ||
return _context21.stop(); | ||
} | ||
} | ||
}, _callee19, undefined); | ||
}, _callee21, undefined); | ||
})); | ||
return function (_x24) { | ||
return _ref20.apply(this, arguments); | ||
return function (_x28) { | ||
return _ref22.apply(this, arguments); | ||
}; | ||
@@ -849,15 +949,15 @@ }(); | ||
*/ | ||
como.reloadAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee20() { | ||
var _comoData19, env, locationId, api, responseJson, assets, archivedAssets, dateNow; | ||
como.reloadAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee22() { | ||
var _comoData21, env, locationId, api, responseJson, assets, archivedAssets, dateNow; | ||
return _regenerator2.default.wrap(function _callee20$(_context20) { | ||
return _regenerator2.default.wrap(function _callee22$(_context22) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
switch (_context22.prev = _context22.next) { | ||
case 0: | ||
_comoData19 = comoData, env = _comoData19.env_params, locationId = _comoData19.locationId, api = _comoData19.api; | ||
_context20.next = 3; | ||
_comoData21 = comoData, env = _comoData21.env_params, locationId = _comoData21.locationId, api = _comoData21.api; | ||
_context22.next = 3; | ||
return api.memberAssets(env.services_root, locationId); | ||
case 3: | ||
responseJson = _context20.sent; | ||
responseJson = _context22.sent; | ||
assets = []; | ||
@@ -897,6 +997,6 @@ archivedAssets = []; | ||
case 'end': | ||
return _context20.stop(); | ||
return _context22.stop(); | ||
} | ||
} | ||
}, _callee20, undefined); | ||
}, _callee22, undefined); | ||
})); | ||
@@ -908,15 +1008,15 @@ | ||
*/ | ||
como.reloadArchivedAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee21() { | ||
var _comoData20, env, locationId, api, responseJson; | ||
como.reloadArchivedAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee23() { | ||
var _comoData22, env, locationId, api, responseJson; | ||
return _regenerator2.default.wrap(function _callee21$(_context21) { | ||
return _regenerator2.default.wrap(function _callee23$(_context23) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
switch (_context23.prev = _context23.next) { | ||
case 0: | ||
_comoData20 = comoData, env = _comoData20.env_params, locationId = _comoData20.locationId, api = _comoData20.api; | ||
_context21.next = 3; | ||
_comoData22 = comoData, env = _comoData22.env_params, locationId = _comoData22.locationId, api = _comoData22.api; | ||
_context23.next = 3; | ||
return api.memberAssets(env.services_root, locationId, true); | ||
case 3: | ||
responseJson = _context21.sent; | ||
responseJson = _context23.sent; | ||
@@ -927,6 +1027,6 @@ comoData.redeemedAssets = responseJson; | ||
case 'end': | ||
return _context21.stop(); | ||
return _context23.stop(); | ||
} | ||
} | ||
}, _callee21, undefined); | ||
}, _callee23, undefined); | ||
})); | ||
@@ -964,11 +1064,11 @@ | ||
*/ | ||
como.downloadMainResources = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee22() { | ||
como.downloadMainResources = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee24() { | ||
var resources, downloads; | ||
return _regenerator2.default.wrap(function _callee22$(_context22) { | ||
return _regenerator2.default.wrap(function _callee24$(_context24) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
switch (_context24.prev = _context24.next) { | ||
case 0: | ||
resources = ['LocationData', 'Menu', 'Updates', 'TCAlts', 'AppTexts', 'DefaultAppTexts']; | ||
downloads = resources.map(como.downloadMainResource); | ||
_context22.next = 4; | ||
_context24.next = 4; | ||
return Promise.all(downloads); | ||
@@ -981,6 +1081,6 @@ | ||
case 'end': | ||
return _context22.stop(); | ||
return _context24.stop(); | ||
} | ||
} | ||
}, _callee22, undefined); | ||
}, _callee24, undefined); | ||
})); | ||
@@ -993,5 +1093,5 @@ | ||
como.loadForm = function (type) { | ||
var _comoData21 = comoData, | ||
api = _comoData21.api, | ||
locationId = _comoData21.locationId; | ||
var _comoData23 = comoData, | ||
api = _comoData23.api, | ||
locationId = _comoData23.locationId; | ||
@@ -1007,5 +1107,5 @@ | ||
como.getConfigration = function (type) { | ||
var _comoData22 = comoData, | ||
api = _comoData22.api, | ||
locationId = _comoData22.locationId; | ||
var _comoData24 = comoData, | ||
api = _comoData24.api, | ||
locationId = _comoData24.locationId; | ||
@@ -1023,5 +1123,5 @@ var _como$getLocationStat = como.getLocationState(), | ||
como.getResource = function (type) { | ||
var _comoData23 = comoData, | ||
api = _comoData23.api, | ||
locationId = _comoData23.locationId; | ||
var _comoData25 = comoData, | ||
api = _comoData25.api, | ||
locationId = _comoData25.locationId; | ||
@@ -1035,7 +1135,7 @@ return api.getResource(type, locationId); | ||
como.generateReferralCode = function () { | ||
var _comoData24 = comoData, | ||
api = _comoData24.api, | ||
locationId = _comoData24.locationId, | ||
token = _comoData24.token, | ||
env = _comoData24.env_params; | ||
var _comoData26 = comoData, | ||
api = _comoData26.api, | ||
locationId = _comoData26.locationId, | ||
token = _comoData26.token, | ||
env = _comoData26.env_params; | ||
@@ -1101,22 +1201,22 @@ | ||
*/ | ||
como.getRegistrationUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee23() { | ||
var _comoData25, token, locationId, env; | ||
como.getRegistrationUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee25() { | ||
var _comoData27, token, locationId, env; | ||
return _regenerator2.default.wrap(function _callee23$(_context23) { | ||
return _regenerator2.default.wrap(function _callee25$(_context25) { | ||
while (1) { | ||
switch (_context23.prev = _context23.next) { | ||
switch (_context25.prev = _context25.next) { | ||
case 0: | ||
_context23.next = 2; | ||
_context25.next = 2; | ||
return refreshTokenIfNeeded(); | ||
case 2: | ||
_comoData25 = comoData, token = _comoData25.token, locationId = _comoData25.locationId, env = _comoData25.env_params; | ||
return _context23.abrupt('return', env.app_modules_root + '/register?token=' + token + '&locationid=' + locationId); | ||
_comoData27 = comoData, token = _comoData27.token, locationId = _comoData27.locationId, env = _comoData27.env_params; | ||
return _context25.abrupt('return', env.app_modules_root + '/register?token=' + token + '&locationid=' + locationId); | ||
case 4: | ||
case 'end': | ||
return _context23.stop(); | ||
return _context25.stop(); | ||
} | ||
} | ||
}, _callee23, undefined); | ||
}, _callee25, undefined); | ||
})); | ||
@@ -1127,22 +1227,22 @@ | ||
*/ | ||
como.getProfileUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee24() { | ||
var _comoData26, token, locationId, env; | ||
como.getProfileUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee26() { | ||
var _comoData28, token, locationId, env; | ||
return _regenerator2.default.wrap(function _callee24$(_context24) { | ||
return _regenerator2.default.wrap(function _callee26$(_context26) { | ||
while (1) { | ||
switch (_context24.prev = _context24.next) { | ||
switch (_context26.prev = _context26.next) { | ||
case 0: | ||
_context24.next = 2; | ||
_context26.next = 2; | ||
return refreshTokenIfNeeded(); | ||
case 2: | ||
_comoData26 = comoData, token = _comoData26.token, locationId = _comoData26.locationId, env = _comoData26.env_params; | ||
return _context24.abrupt('return', env.app_modules_root + '/profile?token=' + token + '&locationid=' + locationId); | ||
_comoData28 = comoData, token = _comoData28.token, locationId = _comoData28.locationId, env = _comoData28.env_params; | ||
return _context26.abrupt('return', env.app_modules_root + '/profile?token=' + token + '&locationid=' + locationId); | ||
case 4: | ||
case 'end': | ||
return _context24.stop(); | ||
return _context26.stop(); | ||
} | ||
} | ||
}, _callee24, undefined); | ||
}, _callee26, undefined); | ||
})); | ||
@@ -1153,22 +1253,22 @@ | ||
*/ | ||
como.getLoginUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee25() { | ||
var _comoData27, token, locationId, env; | ||
como.getLoginUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee27() { | ||
var _comoData29, token, locationId, env; | ||
return _regenerator2.default.wrap(function _callee25$(_context25) { | ||
return _regenerator2.default.wrap(function _callee27$(_context27) { | ||
while (1) { | ||
switch (_context25.prev = _context25.next) { | ||
switch (_context27.prev = _context27.next) { | ||
case 0: | ||
_context25.next = 2; | ||
_context27.next = 2; | ||
return refreshTokenIfNeeded(); | ||
case 2: | ||
_comoData27 = comoData, token = _comoData27.token, locationId = _comoData27.locationId, env = _comoData27.env_params; | ||
return _context25.abrupt('return', env.app_modules_root + '/login?token=' + token + '&locationid=' + locationId); | ||
_comoData29 = comoData, token = _comoData29.token, locationId = _comoData29.locationId, env = _comoData29.env_params; | ||
return _context27.abrupt('return', env.app_modules_root + '/login?token=' + token + '&locationid=' + locationId); | ||
case 4: | ||
case 'end': | ||
return _context25.stop(); | ||
return _context27.stop(); | ||
} | ||
} | ||
}, _callee25, undefined); | ||
}, _callee27, undefined); | ||
})); | ||
@@ -1179,22 +1279,22 @@ | ||
*/ | ||
como.getAppModulesLegacyBaseUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee26() { | ||
var _comoData28, env; | ||
como.getAppModulesLegacyBaseUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee28() { | ||
var _comoData30, env; | ||
return _regenerator2.default.wrap(function _callee26$(_context26) { | ||
return _regenerator2.default.wrap(function _callee28$(_context28) { | ||
while (1) { | ||
switch (_context26.prev = _context26.next) { | ||
switch (_context28.prev = _context28.next) { | ||
case 0: | ||
_context26.next = 2; | ||
_context28.next = 2; | ||
return refreshTokenIfNeeded(); | ||
case 2: | ||
_comoData28 = comoData, env = _comoData28.env_params; | ||
return _context26.abrupt('return', '' + env.app_modules_legacy_root); | ||
_comoData30 = comoData, env = _comoData30.env_params; | ||
return _context28.abrupt('return', '' + env.app_modules_legacy_root); | ||
case 4: | ||
case 'end': | ||
return _context26.stop(); | ||
return _context28.stop(); | ||
} | ||
} | ||
}, _callee26, undefined); | ||
}, _callee28, undefined); | ||
})); | ||
@@ -1239,5 +1339,5 @@ | ||
como.getResourceUrl = function (resourceId, namespace, version) { | ||
var _comoData29 = comoData, | ||
api = _comoData29.api, | ||
env = _comoData29.env_params; | ||
var _comoData31 = comoData, | ||
api = _comoData31.api, | ||
env = _comoData31.env_params; | ||
@@ -1251,7 +1351,7 @@ return api.getResourceUrl(env.services_root_temp, resourceId, namespace, version); | ||
como.sendPushChannel = function (identifier) { | ||
var _comoData30 = comoData, | ||
api = _comoData30.api, | ||
locationId = _comoData30.locationId, | ||
token = _comoData30.token, | ||
env = _comoData30.env_params; | ||
var _comoData32 = comoData, | ||
api = _comoData32.api, | ||
locationId = _comoData32.locationId, | ||
token = _comoData32.token, | ||
env = _comoData32.env_params; | ||
@@ -1261,18 +1361,18 @@ return api.sendPushChannel(env.services_root, locationId, token, identifier); | ||
como.getRegionConfig = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee27() { | ||
var _comoData31, api, locationId, token, env; | ||
como.getRegionConfig = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee29() { | ||
var _comoData33, api, locationId, token, env; | ||
return _regenerator2.default.wrap(function _callee27$(_context27) { | ||
return _regenerator2.default.wrap(function _callee29$(_context29) { | ||
while (1) { | ||
switch (_context27.prev = _context27.next) { | ||
switch (_context29.prev = _context29.next) { | ||
case 0: | ||
_comoData31 = comoData, api = _comoData31.api, locationId = _comoData31.locationId, token = _comoData31.token, env = _comoData31.env_params; | ||
return _context27.abrupt('return', api.getClientBusinessBackend(env.zapp_root, token, locationId)); | ||
_comoData33 = comoData, api = _comoData33.api, locationId = _comoData33.locationId, token = _comoData33.token, env = _comoData33.env_params; | ||
return _context29.abrupt('return', api.getClientBusinessBackend(env.zapp_root, token, locationId)); | ||
case 2: | ||
case 'end': | ||
return _context27.stop(); | ||
return _context29.stop(); | ||
} | ||
} | ||
}, _callee27, undefined); | ||
}, _callee29, undefined); | ||
})); | ||
@@ -1284,7 +1384,7 @@ | ||
como.sendCouponCode = function (code) { | ||
var _comoData32 = comoData, | ||
api = _comoData32.api, | ||
locationId = _comoData32.locationId, | ||
token = _comoData32.token, | ||
env = _comoData32.env_params; | ||
var _comoData34 = comoData, | ||
api = _comoData34.api, | ||
locationId = _comoData34.locationId, | ||
token = _comoData34.token, | ||
env = _comoData34.env_params; | ||
@@ -1295,48 +1395,48 @@ return api.sendCouponCode(env.zapp_root, locationId, token, code); | ||
como.addPaymentMethod = function () { | ||
var _ref29 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee28(cardToken) { | ||
var _comoData33, api, locationId, token, env; | ||
var _ref31 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee30(cardToken) { | ||
var _comoData35, api, locationId, token, env; | ||
return _regenerator2.default.wrap(function _callee28$(_context28) { | ||
return _regenerator2.default.wrap(function _callee30$(_context30) { | ||
while (1) { | ||
switch (_context28.prev = _context28.next) { | ||
switch (_context30.prev = _context30.next) { | ||
case 0: | ||
_comoData33 = comoData, api = _comoData33.api, locationId = _comoData33.locationId, token = _comoData33.token, env = _comoData33.env_params; | ||
return _context28.abrupt('return', api.addPaymentMethod(env.services_root, locationId, token, cardToken)); | ||
_comoData35 = comoData, api = _comoData35.api, locationId = _comoData35.locationId, token = _comoData35.token, env = _comoData35.env_params; | ||
return _context30.abrupt('return', api.addPaymentMethod(env.services_root, locationId, token, cardToken)); | ||
case 2: | ||
case 'end': | ||
return _context28.stop(); | ||
return _context30.stop(); | ||
} | ||
} | ||
}, _callee28, undefined); | ||
}, _callee30, undefined); | ||
})); | ||
return function (_x25) { | ||
return _ref29.apply(this, arguments); | ||
return function (_x29) { | ||
return _ref31.apply(this, arguments); | ||
}; | ||
}(); | ||
como.getPaymentMethods = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee29() { | ||
var _comoData34, env, locationId, api, responseJson; | ||
como.getPaymentMethods = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee31() { | ||
var _comoData36, env, locationId, api, responseJson; | ||
return _regenerator2.default.wrap(function _callee29$(_context29) { | ||
return _regenerator2.default.wrap(function _callee31$(_context31) { | ||
while (1) { | ||
switch (_context29.prev = _context29.next) { | ||
switch (_context31.prev = _context31.next) { | ||
case 0: | ||
_comoData34 = comoData, env = _comoData34.env_params, locationId = _comoData34.locationId, api = _comoData34.api; | ||
_context29.next = 3; | ||
_comoData36 = comoData, env = _comoData36.env_params, locationId = _comoData36.locationId, api = _comoData36.api; | ||
_context31.next = 3; | ||
return api.getPaymentMethods(env.services_root, locationId); | ||
case 3: | ||
responseJson = _context29.sent; | ||
return _context29.abrupt('return', responseJson); | ||
responseJson = _context31.sent; | ||
return _context31.abrupt('return', responseJson); | ||
case 5: | ||
case 'end': | ||
return _context29.stop(); | ||
return _context31.stop(); | ||
} | ||
} | ||
}, _callee29, undefined); | ||
}, _callee31, undefined); | ||
})); | ||
module.exports = como; |
@@ -24,3 +24,3 @@ 'use strict'; | ||
_context.next = 3; | ||
return service.post('/v1/auth/signOn', params); | ||
return service.post('/auth/v1/auth/signOn', params); | ||
@@ -56,3 +56,3 @@ case 3: | ||
_context2.next = 2; | ||
return service.post('/v1/auth/register', { form: form }); | ||
return service.post('/auth/v1/registration', { form: form }); | ||
@@ -89,3 +89,3 @@ case 2: | ||
_context3.next = 3; | ||
return service.post('/v1/auth/register-verify', body); | ||
return service.post('/auth/v1/registration/verify', body); | ||
@@ -111,6 +111,6 @@ case 3: | ||
exports.logIn = function (service) { | ||
exports.updateProfile = function (service) { | ||
return function () { | ||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(type, identifier) { | ||
var params, _ref8, data; | ||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(form) { | ||
var _ref8, data; | ||
@@ -121,7 +121,6 @@ return _regenerator2.default.wrap(function _callee4$(_context4) { | ||
case 0: | ||
params = { type: type, identifier: identifier }; | ||
_context4.next = 3; | ||
return service.post('/v1/auth/logIn', params); | ||
_context4.next = 2; | ||
return service.post('/auth/v1/update-profile', { form: form }); | ||
case 3: | ||
case 2: | ||
_ref8 = _context4.sent; | ||
@@ -131,3 +130,3 @@ data = _ref8.data; | ||
case 6: | ||
case 5: | ||
case 'end': | ||
@@ -140,3 +139,3 @@ return _context4.stop(); | ||
return function (_x7, _x8) { | ||
return function (_x7) { | ||
return _ref7.apply(this, arguments); | ||
@@ -147,6 +146,6 @@ }; | ||
exports.logInVerify = function (service) { | ||
exports.updateProfileVerify = function (service) { | ||
return function () { | ||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(code, type, identifier) { | ||
var params, _ref10, data; | ||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(code, type, form) { | ||
var body, _ref10, data; | ||
@@ -157,9 +156,5 @@ return _regenerator2.default.wrap(function _callee5$(_context5) { | ||
case 0: | ||
params = { | ||
identifier: identifier, | ||
code: code, | ||
type: type | ||
}; | ||
body = { code: code, type: type, form: form }; | ||
_context5.next = 3; | ||
return service.post('/v1/auth/logInVerify', params); | ||
return service.post('/auth/v1/update-profile/verify', body); | ||
@@ -179,3 +174,3 @@ case 3: | ||
return function (_x9, _x10, _x11) { | ||
return function (_x8, _x9, _x10) { | ||
return _ref9.apply(this, arguments); | ||
@@ -186,30 +181,37 @@ }; | ||
exports.logOut = function (service) { | ||
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6() { | ||
var _ref12, data; | ||
exports.logIn = function (service) { | ||
return function () { | ||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(type, identifier) { | ||
var params, _ref12, data; | ||
return _regenerator2.default.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
_context6.next = 2; | ||
return service.post('/v1/auth/logOut'); | ||
return _regenerator2.default.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
params = { type: type, identifier: identifier }; | ||
_context6.next = 3; | ||
return service.post('/auth/v1/auth/logIn', params); | ||
case 2: | ||
_ref12 = _context6.sent; | ||
data = _ref12.data; | ||
return _context6.abrupt('return', data); | ||
case 3: | ||
_ref12 = _context6.sent; | ||
data = _ref12.data; | ||
return _context6.abrupt('return', data); | ||
case 5: | ||
case 'end': | ||
return _context6.stop(); | ||
case 6: | ||
case 'end': | ||
return _context6.stop(); | ||
} | ||
} | ||
} | ||
}, _callee6, undefined); | ||
})); | ||
}, _callee6, undefined); | ||
})); | ||
return function (_x11, _x12) { | ||
return _ref11.apply(this, arguments); | ||
}; | ||
}(); | ||
}; | ||
exports.refreshToken = function (service) { | ||
exports.logInVerify = function (service) { | ||
return function () { | ||
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(uid, token) { | ||
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(code, type, identifier) { | ||
var params, _ref14, data; | ||
@@ -221,5 +223,9 @@ | ||
case 0: | ||
params = { uid: uid, refreshToken: token }; | ||
params = { | ||
identifier: identifier, | ||
code: code, | ||
type: type | ||
}; | ||
_context7.next = 3; | ||
return service.post('/v1/auth/refresh-token', params); | ||
return service.post('/auth/v1/auth/logInVerify', params); | ||
@@ -239,6 +245,63 @@ case 3: | ||
return function (_x12, _x13) { | ||
return function (_x13, _x14, _x15) { | ||
return _ref13.apply(this, arguments); | ||
}; | ||
}(); | ||
}; | ||
exports.logOut = function (service) { | ||
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8() { | ||
var _ref16, data; | ||
return _regenerator2.default.wrap(function _callee8$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
_context8.next = 2; | ||
return service.post('/auth/v1/auth/logOut'); | ||
case 2: | ||
_ref16 = _context8.sent; | ||
data = _ref16.data; | ||
return _context8.abrupt('return', data); | ||
case 5: | ||
case 'end': | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee8, undefined); | ||
})); | ||
}; | ||
exports.refreshToken = function (service) { | ||
return function () { | ||
var _ref17 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(uid, token) { | ||
var params, _ref18, data; | ||
return _regenerator2.default.wrap(function _callee9$(_context9) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
params = { uid: uid, refreshToken: token }; | ||
_context9.next = 3; | ||
return service.post('/auth/v1/auth/refresh-token', params); | ||
case 3: | ||
_ref18 = _context9.sent; | ||
data = _ref18.data; | ||
return _context9.abrupt('return', data); | ||
case 6: | ||
case 'end': | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee9, undefined); | ||
})); | ||
return function (_x16, _x17) { | ||
return _ref17.apply(this, arguments); | ||
}; | ||
}(); | ||
}; |
{ | ||
"name": "@como/como-client", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "Client module for Como's loaylty API", | ||
@@ -5,0 +5,0 @@ "main": "src/como.js", |
@@ -189,5 +189,42 @@ const moment = require('moment-timezone'); | ||
/** | ||
* | ||
* @param {Object} form update form values | ||
*/ | ||
como.updateProfile = async form => { | ||
const { api } = comoData; | ||
try { | ||
const data = await api.updateProfile(form); | ||
return data; | ||
} catch (error) { | ||
if (error.response && error.response.data) { | ||
const { code, message } = error.response.data; | ||
throw new Error(code || message); | ||
} | ||
throw error; | ||
} | ||
}; | ||
/** | ||
* | ||
* @param {string} verificationCode code verification sent by 3rd party | ||
* @param {string} type verification type | ||
* @param {Object} form update form values | ||
*/ | ||
como.updateProfileVerify = async (verificationCode, type, form) => { | ||
const { api } = comoData; | ||
try { | ||
const data = await api.updateProfileVerify(verificationCode, type, form); | ||
return data; | ||
} catch (error) { | ||
if (error.response && error.response.data) { | ||
const { code, message } = error.response.data; | ||
throw new Error(code || message); | ||
} | ||
throw error; | ||
} | ||
}; | ||
/** | ||
* | ||
* @param {Object} identifier an object which identifies the user by its credentials | ||
@@ -194,0 +231,0 @@ * @param {string} type login type i.e PhoneNumber/Email/etc |
exports.signOn = service => async (deviceId, locationId) => { | ||
const params = { deviceId, locationId }; | ||
const { data } = await service.post('/v1/auth/signOn', params); | ||
const { data } = await service.post('/auth/v1/auth/signOn', params); | ||
return data; | ||
@@ -8,3 +8,3 @@ }; | ||
exports.register = service => async form => { | ||
const { data } = await service.post('/v1/auth/register', { form }); | ||
const { data } = await service.post('/auth/v1/registration', { form }); | ||
return data; | ||
@@ -15,9 +15,20 @@ }; | ||
const body = { code, type, form }; | ||
const { data } = await service.post('/v1/auth/register-verify', body); | ||
const { data } = await service.post('/auth/v1/registration/verify', body); | ||
return data; | ||
}; | ||
exports.updateProfile = service => async form => { | ||
const { data } = await service.post('/auth/v1/update-profile', { form }); | ||
return data; | ||
}; | ||
exports.updateProfileVerify = service => async (code, type, form) => { | ||
const body = { code, type, form }; | ||
const { data } = await service.post('/auth/v1/update-profile/verify', body); | ||
return data; | ||
}; | ||
exports.logIn = service => async (type, identifier) => { | ||
const params = { type, identifier }; | ||
const { data } = await service.post('/v1/auth/logIn', params); | ||
const { data } = await service.post('/auth/v1/auth/logIn', params); | ||
return data; | ||
@@ -32,3 +43,3 @@ }; | ||
}; | ||
const { data } = await service.post('/v1/auth/logInVerify', params); | ||
const { data } = await service.post('/auth/v1/auth/logInVerify', params); | ||
return data; | ||
@@ -38,3 +49,3 @@ }; | ||
exports.logOut = service => async () => { | ||
const { data } = await service.post('/v1/auth/logOut'); | ||
const { data } = await service.post('/auth/v1/auth/logOut'); | ||
return data; | ||
@@ -45,4 +56,4 @@ }; | ||
const params = { uid, refreshToken: token }; | ||
const { data } = await service.post('/v1/auth/refresh-token', params); | ||
const { data } = await service.post('/auth/v1/auth/refresh-token', params); | ||
return data; | ||
}; |
@@ -14,5 +14,5 @@ exports.getForm = service => async (type, locationId) => { | ||
exports.getResource = service => async (type, locationId, token) => { | ||
const url = `/v1/resource/${type}/?tags=${locationId},v1.0,GA`; | ||
const { data } = await service.get(url); | ||
return data; | ||
const url = `/v1/resource/${type}/?tags=${locationId},v1.0,GA`; | ||
const { data } = await service.get(url); | ||
return data; | ||
}; |
338899
2.24%3667
5.16%