@docbrasil/api-systemmanager 1.0.66 → 1.0.67

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.
@@ -1,13 +1,12 @@
1
1
  import _ from 'lodash';
2
2
  import Boom from '@hapi/boom';
3
3
  import Joi from 'joi';
4
- import Cypher from '../utils/cypher';
5
4
 
6
5
  /**
7
6
  * Class for user registration in a user
8
7
  * @class
9
8
  */
10
- class Register {
9
+ class Notification {
11
10
 
12
11
  constructor(options) {
13
12
  Joi.assert(options, Joi.object().required());
@@ -48,6 +47,16 @@ class Register {
48
47
  };
49
48
  }
50
49
 
50
+ /**
51
+ * Notification token types
52
+ * @return {{FCM_CAPACITOR: string, FCM_WEB: string}}
53
+ */
54
+ get tokenTypes () {
55
+ return {
56
+ FCM_WEB: 'FCM_WEB',
57
+ FCM_CAPACITOR: 'FCM_CAPACITOR'
58
+ };
59
+ }
51
60
 
52
61
  /**
53
62
  * @author CloudBrasil <abernardo.br@gmail.com>
@@ -85,89 +94,6 @@ class Register {
85
94
  throw ex;
86
95
  }
87
96
  }
88
-
89
- /**
90
- * @author CloudBrasil <abernardo.br@gmail.com>
91
- * @description Method to register a user
92
- * @param {object} params Params to get task
93
- * @param {string} params.registerId The registerId that comes with the registration page context
94
- * @param {string} params.type=sign The type of the registration. By defailt,
95
- * @param {boolean} params.login=false If we want to login the user directly after registering the user successfully. If you have a redirect, the best option is to login automatically.
96
- * @param {object} params.emailInfo The information for the email validation
97
- * @param {string} params.emailInfo.email The email validation information
98
- * @param {string} params.emailInfo.code The 4 digit code to validate the email
99
- * @param {object} params.registerData The registration data
100
- * @param {string} params.registerData.name The name if the user
101
- * @param {string} params.registerData.registerEmail The email of the user
102
- * @param {string} params.registerData.phone The phone of the user
103
- * @param {string} params.registerData.idcard The ID card of the user
104
- * @param {string} params.registerData.registerPassword The user password in open text
105
- * @param {string} params.registerData.emailValidationCode The code used to validate the email
106
- * @param {string} params.registerData.phoneValidationCode The code used to validate the phone
107
- * @param {string} params.registerData.language The defaulf navigator language (i.e.: navigator.language)
108
- * @param {string} params.registerData.timezone The defaulf navigator timezone (i.e.: Intl.DateTimeFormat().resolvedOptions().timeZone)
109
- * @returns {promise<object>} data
110
- * @returns {boolean} data.success If the operation was successfully done (true|false)
111
- * @returns {boolean} data.userAlreadyExists If the user already exists (true|false), if true, then the other information is not returned
112
- * @returns {object} auth The full authentication data with session, if login is true.
113
- * @returns {string} auth.redirectUrl The url to redirect.
114
- * @public
115
- * @example
116
- *
117
- * const API = require('@docbrasil/api-systemmanager');
118
- * const api = new API();
119
- * const params ={
120
- * "registerId": 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
121
- * "type": 'sign',
122
- * "login": false,
123
- * "emailInfo": {
124
- * "code": "5974",
125
- * "email": "cbtoto_1@mailinator.com"
126
- * },
127
- * "registerData": {
128
- * "name": "Augusto Totlo",
129
- * "registerEmail": "cbtoto_1@mailinator.com",
130
- * "phone": "",
131
- * "idcard": "",
132
- * "dob": "1978-01-12T03:00:00.000Z",
133
- * "registerPassword": "123456",
134
- * "emailValidationCode": "5974",
135
- * "phoneValidationCode": "",
136
- * "language": "en-US",
137
- * "timezone": "Europe/Dublin"
138
- * }
139
- * };
140
- * const retData = await api.user.register.execute(params);
141
- */
142
- async execute(params = {}) {
143
- const self = this;
144
-
145
- try {
146
- Joi.assert(params, Joi.object().required(), 'Params to get task');
147
- Joi.assert(params.registerId, Joi.string().required(), ' RegisterId for registration');
148
- Joi.assert(params.emailInfo, Joi.object().required(), ' The email info');
149
- Joi.assert(params.registerData, Joi.object().required(), ' The registerData');
150
-
151
- const {
152
- type = 'sign',
153
- registerId = '',
154
- emailInfo = {},
155
- registerData = {},
156
- login = false
157
- } = params;
158
- const registerInfo = Cypher.get(registerId) || {};
159
- const payload = { ...registerInfo, type, login, emailInfo, registerData };
160
- const payloadInfo = { info: Cypher.set(payload) };
161
- const apiCall = self._client
162
- .put(`/users/register`, payloadInfo);
163
-
164
- const { success = false, userAlreadyExists = false, auth } = self._returnData(await apiCall);
165
- const retData = { success, userAlreadyExists, auth };
166
- return retData;
167
- } catch (ex) {
168
- throw ex;
169
- }
170
- }
171
97
  }
172
98
 
173
- export default Register;
99
+ export default Notification;
package/dist/bundle.cjs CHANGED
@@ -8675,7 +8675,7 @@ const cypher = new Cypher();
8675
8675
  * Class for user registration in a user
8676
8676
  * @class
8677
8677
  */
8678
- class Register$1 {
8678
+ class Register {
8679
8679
 
8680
8680
  constructor(options) {
8681
8681
  Joi__default["default"].assert(options, Joi__default["default"].object().required());
@@ -8874,7 +8874,7 @@ class Register$1 {
8874
8874
  * Class for user registration in a user
8875
8875
  * @class
8876
8876
  */
8877
- class Register {
8877
+ class Notification {
8878
8878
 
8879
8879
  constructor(options) {
8880
8880
  Joi__default["default"].assert(options, Joi__default["default"].object().required());
@@ -8915,6 +8915,16 @@ class Register {
8915
8915
  };
8916
8916
  }
8917
8917
 
8918
+ /**
8919
+ * Notification token types
8920
+ * @return {{FCM_CAPACITOR: string, FCM_WEB: string}}
8921
+ */
8922
+ get tokenTypes () {
8923
+ return {
8924
+ FCM_WEB: 'FCM_WEB',
8925
+ FCM_CAPACITOR: 'FCM_CAPACITOR'
8926
+ };
8927
+ }
8918
8928
 
8919
8929
  /**
8920
8930
  * @author CloudBrasil <abernardo.br@gmail.com>
@@ -8952,89 +8962,6 @@ class Register {
8952
8962
  throw ex;
8953
8963
  }
8954
8964
  }
8955
-
8956
- /**
8957
- * @author CloudBrasil <abernardo.br@gmail.com>
8958
- * @description Method to register a user
8959
- * @param {object} params Params to get task
8960
- * @param {string} params.registerId The registerId that comes with the registration page context
8961
- * @param {string} params.type=sign The type of the registration. By defailt,
8962
- * @param {boolean} params.login=false If we want to login the user directly after registering the user successfully. If you have a redirect, the best option is to login automatically.
8963
- * @param {object} params.emailInfo The information for the email validation
8964
- * @param {string} params.emailInfo.email The email validation information
8965
- * @param {string} params.emailInfo.code The 4 digit code to validate the email
8966
- * @param {object} params.registerData The registration data
8967
- * @param {string} params.registerData.name The name if the user
8968
- * @param {string} params.registerData.registerEmail The email of the user
8969
- * @param {string} params.registerData.phone The phone of the user
8970
- * @param {string} params.registerData.idcard The ID card of the user
8971
- * @param {string} params.registerData.registerPassword The user password in open text
8972
- * @param {string} params.registerData.emailValidationCode The code used to validate the email
8973
- * @param {string} params.registerData.phoneValidationCode The code used to validate the phone
8974
- * @param {string} params.registerData.language The defaulf navigator language (i.e.: navigator.language)
8975
- * @param {string} params.registerData.timezone The defaulf navigator timezone (i.e.: Intl.DateTimeFormat().resolvedOptions().timeZone)
8976
- * @returns {promise<object>} data
8977
- * @returns {boolean} data.success If the operation was successfully done (true|false)
8978
- * @returns {boolean} data.userAlreadyExists If the user already exists (true|false), if true, then the other information is not returned
8979
- * @returns {object} auth The full authentication data with session, if login is true.
8980
- * @returns {string} auth.redirectUrl The url to redirect.
8981
- * @public
8982
- * @example
8983
- *
8984
- * const API = require('@docbrasil/api-systemmanager');
8985
- * const api = new API();
8986
- * const params ={
8987
- * "registerId": 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
8988
- * "type": 'sign',
8989
- * "login": false,
8990
- * "emailInfo": {
8991
- * "code": "5974",
8992
- * "email": "cbtoto_1@mailinator.com"
8993
- * },
8994
- * "registerData": {
8995
- * "name": "Augusto Totlo",
8996
- * "registerEmail": "cbtoto_1@mailinator.com",
8997
- * "phone": "",
8998
- * "idcard": "",
8999
- * "dob": "1978-01-12T03:00:00.000Z",
9000
- * "registerPassword": "123456",
9001
- * "emailValidationCode": "5974",
9002
- * "phoneValidationCode": "",
9003
- * "language": "en-US",
9004
- * "timezone": "Europe/Dublin"
9005
- * }
9006
- * };
9007
- * const retData = await api.user.register.execute(params);
9008
- */
9009
- async execute(params = {}) {
9010
- const self = this;
9011
-
9012
- try {
9013
- Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
9014
- Joi__default["default"].assert(params.registerId, Joi__default["default"].string().required(), ' RegisterId for registration');
9015
- Joi__default["default"].assert(params.emailInfo, Joi__default["default"].object().required(), ' The email info');
9016
- Joi__default["default"].assert(params.registerData, Joi__default["default"].object().required(), ' The registerData');
9017
-
9018
- const {
9019
- type = 'sign',
9020
- registerId = '',
9021
- emailInfo = {},
9022
- registerData = {},
9023
- login = false
9024
- } = params;
9025
- const registerInfo = cypher.get(registerId) || {};
9026
- const payload = { ...registerInfo, type, login, emailInfo, registerData };
9027
- const payloadInfo = { info: cypher.set(payload) };
9028
- const apiCall = self._client
9029
- .put(`/users/register`, payloadInfo);
9030
-
9031
- const { success = false, userAlreadyExists = false, auth } = self._returnData(await apiCall);
9032
- const retData = { success, userAlreadyExists, auth };
9033
- return retData;
9034
- } catch (ex) {
9035
- throw ex;
9036
- }
9037
- }
9038
8965
  }
9039
8966
 
9040
8967
  /**
@@ -9057,8 +8984,8 @@ class Users {
9057
8984
  self.process = new Process(options);
9058
8985
  self.task = new Task(options);
9059
8986
  self.user = self.profile = new User(options);
9060
- self.register = new Register$1(options);
9061
- self.notification = new Register(options);
8987
+ self.register = new Register(options);
8988
+ self.notification = new Notification(options);
9062
8989
  }
9063
8990
  }
9064
8991