import { PROCEDURES, SportTypes } from 'config'

import type { MatchesBySection } from './types'
import { requestMatches } from './request'

const proc = PROCEDURES.get_player_matches

type Args = {
  limit: number,
  offset: number,
  playerId: number,
  sportType: SportTypes,
}

export const getPlayerMatches = async ({
  limit,
  offset,
  playerId,
  sportType,
}: Args): Promise<MatchesBySection> => {
  const config = {
    body: {
      params: {
        _p_limit: limit,
        _p_offset: offset,
        _p_player_id: playerId,
        _p_sport: sportType,
      },
      proc,
    },
  }

  return requestMatches(config)
}
