import {
  DATA_URL,
  PROCEDURES,

} from 'config'
import { callApi } from 'helpers'

const proc = PROCEDURES.get_player_info

export type PlayerProfile = {
  c_gender: 1 | 2 | null,
  club_team: {
    id: number,
    name_eng: string,
    name_rus: string,
  } | null,
  country: {
    id: number,
    name_eng: string,
    name_rus: string,
  },
  firstname_eng: string,
  firstname_rus: string,
  height: number | null,
  id: number,
  is_favorite: boolean,
  is_gk: boolean | null,
  lastname_eng: string,
  lastname_rus: string,
  nickname_eng: string | null,
  nickname_rus: string | null,
  weight: number | null,
} | null

export const getPlayerInfo = (
  playerId: number,
  sportType: number,
): Promise<PlayerProfile> => {
  const config = {
    body: {
      params: {
        _p_player_id: playerId,
        _p_sport: sportType,
      },
      proc,
    },
  }

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