package io.delphi.qa.auto.awsmfrw.tests.api;

import io.delphi.qa.auto.awsmfrw.models.api.rest.v3.EnDelphiApiV3_PlaylistTypeItems;
import io.delphi.qa.auto.awsmfrw.models.api.rest.v3.EnDelphiApiV3_StreamsItems;
import io.delphi.qa.auto.awsmfrw.models.api.rest.v3.track_positions.EnTrackPositionsPlaylistsInclude;

import java.util.Arrays;
import java.util.stream.Collectors;

public abstract class BsAudioTest extends BsApiRestMagicTest{

  private final String DSP = fetchChartDsp();
  private final String DSPS = String.join(",", fetchChartDsps());
  protected final String COUNTRY_CODE = fetchCountryCode(true);
  protected final String CHART_ID = fetchChartId(true, DSP, COUNTRY_CODE);
  protected final String CHART_IDS = String.join(",", fetchChartIds(true, DSP));

  protected final String SORT_BY_STREAMS = "streams";
  protected final String SORT_BY_ISRC = "isrc";
  protected final String SORT_BY_DSP = "dsp";
  protected final String SORT_BY_LYRICS_VERSION = "lyrics_version";
  protected final String SORT_BY_NAME = "name";
  protected final String SORT_BY_RELEASE_DATE = "release_date";
  protected final String SORT_BY_TRACK_ID = "track_id";
  protected final String SORT_BY_TRACK_NAME_SUPPL = "track_name_suppl";
  protected final String SORT_BY_TRACK_TYPE_NAME = "track_type_name";
  protected final String SORT_BY_REP_OWNER_KEY = "rep_owner_key";
  protected final String SORT_BY_COUNTRY_CODE = "country_code";
  protected final String SORT_BY_DATE = "date";
  protected final String SORT_BY_TOP = "top";
  protected final String SORT_BY_CURRENT = "current";
  protected final String SORT_BY_PREVIOUS = "previous";
  protected final String SORT_BY_NUM_WEEKS_ON = "num_weeks_on";
  protected final String SORT_BY_PLAYLIST_ID = "playlist_id";
  protected final String SORT_BY_TOTAL_PLAYLISTS = "total_playlists";
  protected final String SORT_BY_ARTIST_ID = "artist_id";
  protected final String SORT_BY_PROJECT_ID = "project_id";
  protected final String SORT_BY_PRODUCT_FAMILY_ID = "product_family_id";

  protected final String GROUP_BY_DATE = "date";
  protected final String GROUP_BY_SUB_DSP = "sub_dsp";

  protected final String PLAYLIST_TYPE_USER_SHARED = "user-shared";
  protected final String PLAYLIST_TYPE_SONY_OWNED = "sony-owned";
  protected final String PLAYLIST_TYPE_EDITORIAL = "editorial";

  protected final String INCLUDE_CHARTS = "charts";
  protected final String INCLUDE_PLAYLISTS = EnTrackPositionsPlaylistsInclude.PLAYLISTS.get();
  protected final String INCLUDE_STREAMS = EnTrackPositionsPlaylistsInclude.STREAMS.get();
  protected final String INCLUDES =
      Arrays.stream(EnTrackPositionsPlaylistsInclude.values())
          .map(EnTrackPositionsPlaylistsInclude::get)
          .collect(Collectors.joining(","));
  protected static final String INCLUDE_DEMOGRAPHICS_SAVES_SKIPS =
      String.format(
          "%s,%s,%s",
          EnDelphiApiV3_StreamsItems.DEMOGRAPHICS.get(),
          EnDelphiApiV3_StreamsItems.SAVES.get(),
          EnDelphiApiV3_StreamsItems.SKIPS.get());
  protected static final String INCLUDE_ALL = EnDelphiApiV3_StreamsItems.ALL.get();
  protected static final String INCLUDE_DEMOGRAPHICS = EnDelphiApiV3_StreamsItems.DEMOGRAPHICS.get();

  protected final String PLAYLIST_TYPES =
      Arrays.stream(EnDelphiApiV3_PlaylistTypeItems.values())
          .map(EnDelphiApiV3_PlaylistTypeItems::get)
          .collect(Collectors.joining(","));
  protected final String PLAYLIST_TYPE =
      EnDelphiApiV3_PlaylistTypeItems.values()[
          random.nextInt(EnDelphiApiV3_PlaylistTypeItems.values().length)]
          .get();
}
