File: //home/arjun/projects/buyercall/buyercall/assets/vue/service/leadsContactsService.js
import BuyerGatewayMock from '../gateway/mockGateway';
import BuyerGateway from '../gateway/gateway';
export default {
createLead: postData => BuyerGateway.post(`/contacts/add`, postData),
getLeadsById:id => BuyerGateway.get(`/contacts/details/${id}/`),
updateLead: (id,data) => BuyerGateway.post(`/contacts/edit/${id}/`, data),
uploadcsv:data => BuyerGateway.post(`/contacts/bulk`, data),
addCampaign:data => BuyerGateway.post(`/contacts/campaigns`, data),
getCreditById:id => BuyerGateway.get(`/contacts/credit/${id}/`),
getLeads: (value) => {
// Serialize the parameters in the required format
const serializedParams = Object.entries(value)
.map(([key, val]) => {
if (val instanceof Array) {
return val
.map((v, i) => Object.entries(v).map(([k, v]) => `${key}[${i}][${k}]=${v}`).join('&'))
.join('&');
}
return `${key}=${val}`;
})
.join('&').trim();
return BuyerGateway.get(`/contacts/list?${serializedParams}`);
},
getFilters: () => BuyerGateway.get(`/contacts/filters`),
}