import calls from './calls';
import candidateMetadata from './candidateMetadata';
import metadata from './metadata';
const callFeed = function callFeed(data) {
  if (!data) return data;
  const {
    id,
    calls: callList
  } = data;
  const newCalls = callList.map(entry => {
    const {
      call,
      contestMetadata,
      candidateMetadata: candMeta
    } = entry;
    return {
      ...entry,
      call: call && calls([call])[0],
      contestMetadata: contestMetadata && metadata(contestMetadata),
      candidateMetadata: candMeta && candidateMetadata(candMeta)
    };
  });
  return {
    ...data,
    id: `collection:${id}`,
    calls: newCalls
  };
};
export default callFeed;