import {
  DATA_URL,
  PROCEDURES,
} from 'config'

import { callApi } from 'helpers'

const proc = PROCEDURES.get_view_user_match

type ResponseType = {
  duration?: number,
  error?: string,
  status: 1 | 2,
}

type ViewMatchDurationType = {
  matchId: number,
  sportType: number,
  userId: number,
}

export const getViewMatchDuration = ({
  matchId,
  sportType,
  userId,
}: ViewMatchDurationType): Promise<ResponseType> => {
  const config = {
    body: {
      params: {
        _p_match_id: matchId,
        _p_sport_id: sportType,
        _p_user_id: userId,
      },
      proc,
    },
  }

  return callApi({
    config,
    url: DATA_URL,
  })
}
