-
Notifications
You must be signed in to change notification settings - Fork 10
/
clientRetriever.js
42 lines (40 loc) · 1.06 KB
/
clientRetriever.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var clientRetriever = (function() {
"use strict";
var getContacts = function() {
var clientObjects = dataProvider.getClients();
return _.map(clientObjects, function(clientObject) {
if (!clientObject.isActive) {
return new Contact(
clientObject.id,
clientObject.name,
clientObject.gender,
clientObject.company,
clientObject.email,
clientObject.phone,
clientObject.address);
}
return new Client(
clientObject.id,
clientObject.name,
clientObject.gender,
clientObject.company,
clientObject.email,
clientObject.phone,
clientObject.address,
new Date(clientObject.registered),
clientObject.preferredBike,
clientObject.bikePoints,
clientObject.notes
);
});
};
return {
getContacts: getContacts,
getClients: function() {
var contacts = getContacts();
return _.filter(contacts, function(contact) {
return contact instanceof Client;
});
}
};
}());