in src/app/api/mock/onerep/config/config.ts [154:209]
export async function mockOnerepBrokers(
profileId: number,
page: string,
perPage: string,
email: string,
) {
let scanId = (await getLatestOnerepScan(profileId))?.onerep_scan_id;
if (!scanId) scanId = mockOnerepScanId(profileId);
const mockMeta = mockOnerepObjectMeta(page);
const mockLinks = mockOnerepObjectLinks(profileId, page, perPage);
const idStart = mockOnerepIdStart(profileId);
const idStartDataBroker = mockOnerepDatabrokerIdStart(profileId);
const emailHash = emailHashPrefix(email);
const brokersListMap = MockUser.BROKERS_LIST as BrokerMap;
const datasetKey = hashToEmailKeyMap[emailHash] || "default";
const brokersListLookup = brokersListMap[datasetKey];
const brokersList =
brokersListLookup === undefined
? brokersListMap["default"]
: brokersListLookup;
const res = brokersList.map(
(elem: BrokerOptionals, index: number) =>
({
id: idStart - index,
profile_id: profileId,
scan_id: elem["scan_id"] || scanId,
status: elem["status"] || "new",
first_name: elem["first_name"] || mockOnerepFirstName(),
middle_name: elem["middle_name"] || null,
last_name: elem["last_name"] || mockOnerepLastName(),
age: elem["age"] || null,
addresses: elem["addresses"] || mockOnerepAddresses(),
phones: elem["phones"] || mockOnerepPhones(),
emails: elem["emails"] || mockOnerepEmails(),
relatives: elem["relatives"] || mockOnerepRelatives(),
link:
elem["link"] || `https://mockexample.com/link-to-databroker${index}`,
data_broker: elem["data_broker"] || `mockexample${index}.com`,
data_broker_id: elem["data_broker_id"] || idStartDataBroker - index,
optout_attempts: elem["optout_attempts"] || 0,
last_optout_at: elem["last_optout_at"] || mockOnerepTime(),
created_at: elem["created_at"] || mockOnerepTime(),
updated_at: elem["updated_at"] || mockOnerepTime(),
}) as Broker,
);
const responseData = {
data: res,
meta: mockMeta,
links: mockLinks,
};
return responseData;
}