const faker = require('faker')
const moment = require('moment')
var express = require("@runkit/runkit/express-endpoint/1.0.0");
var app = express(exports);
app.get("/", (req, res) => {
const firstName = faker.name.firstName();
const lastName = faker.name.lastName();
const legalName = `${firstName} ${lastName}`;
const dateFormat = 'YYYY-MM-DD';
const trueBirth = moment(faker.date.past(20), dateFormat, true);
const yearBirth = moment(trueBirth, dateFormat).format('YYYY');
const monthBirth = moment(trueBirth, dateFormat).format('MM');
const dayBirth = moment(trueBirth, dateFormat).format('DD');
const dateOfBirth = `${yearBirth}-${monthBirth}-${dayBirth}`;
const trueAnniversary = moment(faker.date.past(15), dateFormat, true);
const yearAnniversary = moment(trueAnniversary, dateFormat).format('YYYY');
const monthAnniversary = moment(trueAnniversary, dateFormat).format('MM');
const dayAnniversary = moment(trueAnniversary, dateFormat).format('DD');
const dateOfAnniversary = `${yearAnniversary}-${monthAnniversary}-${dayAnniversary}`;
const data = {
eventId: faker.datatype.uuid(),
payload: {
owner: {
type: 'AGENT',
id: '556397'
},
name: {
preferred: faker.name.firstName(),
prefix: 'Dr.',
first: firstName,
middle: faker.name.firstName(),
last: lastName,
suffix: faker.name.suffix(),
legal: legalName
},
contactTypes: {
mark: ['LEAD'],
},
emails: {
primary: {
email: faker.internet.email(),
label: 'PERSONAL',
},
others: [
{
email: faker.internet.email(),
label: 'WORK',
},
]
},
phones: {
primary: {
ISOPhoneNumber: faker.phone.phoneNumber('+12525550###'),
label: 'PERSONAL'
},
others: [
{
ISOPhoneNumber: faker.phone.phoneNumber('+12525550###'),
label: 'WORK'
},
]
},
addresses: {
primaryAddress: {
addressLine1: faker.address.streetAddress(),
addressLine2: faker.address.secondaryAddress(),
city: faker.address.city(),
county: faker.address.state(),
state: faker.address.stateAbbr(),
country: faker.address.country(),
zipCode: faker.address.zipCode(),
neighborhoodName: faker.address.cityPrefix(),
label: 'WORK',
lat: faker.address.latitude,
lng: faker.address.longitude
}
},
personalInfo: {
dateOfBirth: {
full: dateOfBirth,
year: yearBirth,
month: monthBirth,
day: dayBirth
},
homeAnniversary: {
full: dateOfAnniversary,
year: yearAnniversary,
month: monthAnniversary,
day: dayAnniversary
}
},
tags: [
{
color: faker.commerce.color(),
label: faker.lorem.word(),
}
],
customFields: {
add: [
{
customFieldId: faker.lorem.words(),
value: faker.lorem.words(),
}
]
}
},
info: {
productId: 'syncx',
domain: 'contacts',
method: 'POST',
time: faker.date.past(10),
kwuid: '556397',
owner: {
type: 'AGENT',
id: '556397'
}
}
};
// console.log('Click below arrow, copy and paste the string to apigee-contact topics')
// console.log(JSON.stringify(data));
// return data;
res.send(data)
})