-
Notifications
You must be signed in to change notification settings - Fork 0
/
sponsor.js
27 lines (23 loc) · 931 Bytes
/
sponsor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* jshint node:true */
const moment = require('moment');
module.exports = (user, token) =>{
function formatPhone(phone) {
return [{ ddd: phone.areaCode, numero: phone.number }];
}
function sponsor(_user, _token) {
let responder = {};
console.log(_user);
responder.id = _user.userID;
responder.nome = _user.name;
responder.email = _user.email;
responder.telefones = _user.phones.length === 1 ?
formatPhone(_user.phones[0]) : _user.phones.map(
(phone) => { return formatPhone(phone); });
responder.data_criacao = moment(_user.created).format('DD/MM/YYYY');
responder.data_atualizacao = moment(_user.updated).format('DD/MM/YYYY');
responder.ultimo_login = moment(_user.lastLogin).format('DD/MM/YYYY HH:mm');
responder.token = _token;
return responder;
}
return sponsor(user, token);
};