import { VIEWS_API } from 'config'

import { callApi } from 'helpers'

type Props = {
  matchId: number,
  matchSecond: number,
  sportType: number,
}

export const VIEW_INTERVAL_MS = 5000

export const saveMatchStats = ({
  matchId,
  matchSecond,
  sportType,
}: Props) => {
  const url = `${VIEWS_API}/user/view`

  const config = {
    body: {
      interval: VIEW_INTERVAL_MS / 1000,
      match_id: matchId,
      second: matchSecond,
      sport_id: sportType,
    },
  }

  return callApi({ config, url })
}
