import config from "config";

const API_URL = config.api.url || "";
const API_ANALYTICS_URL = config.analytics.url || "";
const API_SPOTIFY_URL = config.spotify.url || "";
const API_BANDSINTOWN_URL = config.bandsintown.url || "";
const API_SHOP_MY_SHELF_URL = config.shopMyShelf.url || "";
const API_RYE_GRAPHQL_URL = config.ryeShopify.graphqlApiUrl || "";
const API_SALES_URL = config.sales.url || "";
const API_AUTH_URL = config.auth.url || "";
const API_GOOGLE_URL = config.google.url || "";

/**
 * The options used to configure the API.
 */
export interface ApiConfig {
  /**
   * The URL of the api.
   */
  url: string;

  /**
   * Milliseconds before we timeout the request.
   */
  timeout: number;
}

/**
 * The default configuration for the app.
 */
export const DEFAULT_API_CONFIG: ApiConfig = {
  url: API_URL,
  timeout: 20000,
};

export const DEFAULT_ANALYTICS_API_CONFIG: ApiConfig = {
  url: API_ANALYTICS_URL,
  timeout: 20000,
};

export const DEFAULT_AUTH_API_CONFIG: ApiConfig = {
  url: API_AUTH_URL,
  timeout: 10000,
};

export const DEFAULT_SPOTIFY_API_CONFIG: ApiConfig = {
  url: API_SPOTIFY_URL,
  timeout: 10000,
};

export const DEFAULT_BANDSINTOWN_API_CONFIG: ApiConfig = {
  url: API_BANDSINTOWN_URL,
  timeout: 10000,
};
export const DEFAULT_SHOP_MY_SHELF_API_CONFIG: ApiConfig = {
  url: API_SHOP_MY_SHELF_URL,
  timeout: 10000,
};

export const DEFAULT_RYE_GRAPHQL_API_CONFIG: ApiConfig = {
  url: API_RYE_GRAPHQL_URL,
  timeout: 10000,
};

export const DEFAULT_SALES_API_CONFIG: ApiConfig = {
  url: API_SALES_URL,
  timeout: 20000,
};

export const DEFAULT_GOOGLE_API_CONFIG: ApiConfig = {
  url: API_GOOGLE_URL,
  timeout: 10000,
};
