import {
  DATA_URL,
  PROCEDURES,
} from 'config'
import { callApi } from 'helpers'

const proc = PROCEDURES.get_team_players

export type Player = {
  birthday: string | null,
  c_gender: number,
  firstname_eng: string,
  firstname_rus: string,
  height: string | number,
  id: number,
  lastname_eng: string,
  lastname_rus: string,
  nickname_eng: string | number| null,
  nickname_rus: string | number | null,
  sport_id: number,
  weight: string | number | null,
}

export const getTeamPlayers = (_p_sport_id: number,
  _p_team_id: number)
: Promise<Array<Player>> => {
  const config = {
    body: {
      params: {
        _p_sport_id,
        _p_team_id,
      },
      proc,
    },
  }

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