const BASE = 'https://www.twstats.com';

export type BuildURLParams =
  | {
      entity: 'player';
      id: number;
      server: string;
    }
  | {
      entity: 'tribe';
      id: number;
      server: string;
    };

export const buildURL = (params: BuildURLParams) => {
  switch (params.entity) {
    case 'player':
      return `${BASE}/in/${params.server}/player/${params.id}`;
    case 'tribe':
      return `${BASE}/in/${params.server}/tribe/${params.id}`;
    default:
      throw new Error(`Incorrect params.entity`);
  }
};
