import {
  call, put, takeLatest, all,
} from 'redux-saga/effects';
import * as Api from '../../services/api';
import * as types from './constants';

// Individual exports for testing
export function* getFTPServers() {
  try {
    const result = yield call(Api.getFTPServers);
    yield put({ type: types.GET_FTP_SERVERS_SUCCESS, data: result.response });
  } catch (error) {
    yield put({ type: types.GET_FTP_SERVERS_FAILURE, error });
  }
}


function* watchGetFTPServers() {
  yield takeLatest(types.GET_FTP_SERVERS_REQUEST, getFTPServers);
  
  
}

// All sagas to be loaded
export default [
  watchGetFTPServers,
];

export function* v2FTPSagas() {
  yield all([
    watchGetFTPServers(),
  ]);
}
