2018-01-29 11:37:54 +00:00
|
|
|
module.exports = function(Self) {
|
|
|
|
Self.remoteMethod('card', {
|
|
|
|
description: 'Get client basic data',
|
|
|
|
accepts: {
|
|
|
|
arg: 'id',
|
|
|
|
type: 'number',
|
|
|
|
required: true,
|
|
|
|
description: 'The client id',
|
|
|
|
http: {source: 'path'}
|
|
|
|
},
|
|
|
|
returns: {
|
|
|
|
type: 'Object',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
verb: 'GET',
|
|
|
|
path: '/:id/card'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-04-03 16:31:13 +00:00
|
|
|
Self.card = async function(id) {
|
|
|
|
return await Self.findOne({
|
2018-01-29 11:37:54 +00:00
|
|
|
where: {
|
|
|
|
id: id
|
|
|
|
},
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'salesPerson',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'firstName', 'name']
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'contactChannel',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'province',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'country',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'country']
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'payMethod',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'account',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name', 'active']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|