|
72 | 72 | return dimension + unixTimestamp + dimensions.length; |
73 | 73 | }, |
74 | 74 |
|
75 | | - //TODO --> when signature algorithm is defined! |
76 | | - generateTemporalDataMessage: function (amount, unixTimestamp, type) { |
77 | | - return type + unixTimestamp + amount; |
78 | | - }, |
| 75 | + generateTemporalDataMessage: function (localDateTime, timezone, unixTimestamp) { |
| 76 | + var paraLocalDateTime = typeof localDateTime === 'undefined' || localDateTime === null ? "" : localDateTime; |
| 77 | + var paraTimezone = typeof timezone === 'undefined' || timezone === null ? "" : timezone; |
| 78 | + |
| 79 | + return unixTimestamp + "-" + paraLocalDateTime + "-" + paraTimezone; |
| 80 | + } |
79 | 81 | }; |
80 | 82 |
|
81 | 83 | /** |
|
216 | 218 | }; |
217 | 219 |
|
218 | 220 | /** |
219 | | - * Sends an temporalData request to the Breinify server. |
| 221 | + * Sends an temporalData request to the Breinify backend. |
220 | 222 | * |
221 | 223 | * @param user {object} the user-information |
222 | 224 | * @param timezone {string|null} contains the timezone (e.g. xxx) |
223 | 225 | * @param localDateTime {string|null} contains the localDateTime |
224 | 226 | * @param sign {boolean|null} true if a signature should be added (needs the secret to be configured - not recommended in open systems), otherwise false (can be null or undefined) |
225 | | - * @param onReady {function|null} function to be executed after triggering the activity |
| 227 | + * @param onReady {function|null} function to be executed after triggering the temporalData request |
226 | 228 | */ |
227 | 229 | Breinify.temporalData = function (user, timezone, localDateTime, sign, onReady) { |
228 | 230 | Breinify.temporalDataUser(user, timezone, localDateTime, sign, function (data) { |
229 | 231 | var url = _config.get(ATTR_CONFIG.URL) + _config.get(ATTR_CONFIG.TEMPORALDATA_ENDPOINT); |
230 | | - _privates.ajax(url, data, onLookUp, onLookUp); |
| 232 | + _privates.ajax(url, data, onReady, onReady); |
231 | 233 | }); |
232 | 234 | }; |
233 | 235 |
|
|
261 | 263 | localDateTime = typeof localDateTime === 'undefined' || localDateTime === null ? null : localDateTime; |
262 | 264 | sign = typeof sign === 'boolean' ? sign : false; |
263 | 265 |
|
| 266 | + if (timzone === null) { |
| 267 | + // get timezone from moment.js |
| 268 | + // moment().tz(moment.tz.guess()).format('z'); |
| 269 | + } |
| 270 | + |
| 271 | + if (localDateTime === null) { |
| 272 | + // get localDateTime from moment.js |
| 273 | + } |
| 274 | + |
264 | 275 | // get the other values needed |
265 | 276 | var unixTimestamp = Breinify.unixTimestamp(); |
266 | 277 | var signature = null; |
267 | 278 | if (sign) { |
268 | 279 | // might be a different secret |
269 | 280 | var secret = _config.get(ATTR_CONFIG.SECRET); |
270 | 281 | if (typeof secret === 'string') { |
271 | | - var message = _privates.generateTemporalDataMessage(1, unixTimestamp, type); |
| 282 | + var message = _privates.generateTemporalDataMessage(unixTimestamp, localDateTime, timezone); |
272 | 283 | signature = _privates.determineSignature(message, _config.get(ATTR_CONFIG.SECRET)) |
273 | 284 | } else { |
274 | 285 | _onReady(null); |
|
0 commit comments