import { callApi } from 'helpers'

import { API_ROOT } from 'config'

import type { Team, MatchTournament } from 'requests/getMatchInfo'

type Params = {
  profileId: number,
  sportType: number,
}

type Response = {
  match_date: string,
  match_date_utc: string,
  match_id: number,
  sport_id: number,
  team1: Team,
  team2: Team,
  tournament: MatchTournament,
}

export const getMatchScore = ({ profileId, sportType }: Params): Promise<Response> => {
  const url = `${API_ROOT}/v1/matches/${sportType}/${profileId}/scores`

  const config = {
    method: 'GET',
  }

  return callApi({
    config,
    url,
  })
}
