import {
  BaseHandler,
  Disabled,
  Handler,
  Operation,
  ScheduledOperation,
} from '@stock-bot/handlers';
import { fetchExchanges } from './actions';

@Disabled()
@Handler('tradingview')
export class TradingViewHandler extends BaseHandler {
  constructor(services: any) {
    super(services);
  }

  @Operation('fetch-exchanges')
  async fetchExchanges(): Promise<unknown[] | null> {
    return fetchExchanges(this);
  }

  @ScheduledOperation('tradingview-exchanges', '0 0 * * 0', {
    priority: 5,
    description: 'Fetch and update TradingView exchanges data',
    immediately: false,
  })
  @Disabled()
  async scheduledFetchExchanges(): Promise<unknown> {
    return this.fetchExchanges();
  }
}