// Import types
import Occurrence from '../../../shared/types/Occurrence';
import VisitServerEndpoint from '../../../types/VisitServerEndpoint';

// Import constants
import TTM_PATH_PREFIX from '../../../shared/constants/TTM_PATH_PREFIX';

/**
 * Create a new occurrence document in the database.
 * @author Benedikt Arnarsson
 * @param occ the occurrence that is being placed in the DB
 */
const putNewOccurrence = async (
  visitServerEndpoint: VisitServerEndpoint,
  occ: Occurrence,
) => {
  // FIXME: error handling
  await visitServerEndpoint({
    path: `${TTM_PATH_PREFIX}/occurrence`,
    method: 'POST',
    params: {
      occurrence: JSON.stringify(occ),
    },
  });
};

export default putNewOccurrence;
