{"size": 982, "ext": "js", "max_stars_repo_path": "kibana-extra/conveyor/public/sagas/workers/source.js", "max_stars_repo_name": "NurFaizin/conveyor", "max_stars_repo_stars_event_min_datetime": "2017-11-03T03:35:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-27T12:03:41.000Z", "max_issues_repo_path": "kibana-extra/conveyor/public/sagas/workers/source.js", "max_issues_repo_name": "NurFaizin/conveyor", "max_issues_repo_issues_event_min_datetime": "2017-10-05T05:32:26.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-15T17:41:16.000Z", "max_forks_repo_path": "kibana-extra/conveyor/public/sagas/workers/source.js", "max_forks_repo_name": "NurFaizin/conveyor", "max_forks_repo_forks_event_min_datetime": "2017-12-19T03:29:58.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-02T12:45:45.000Z"}
{"max_stars_count": 90, "max_issues_count": 115, "max_forks_count": 19, "avg_line_length": 33.8620689655, "max_line_length": 115, "alphanum_fraction": 0.6894093686}
import {
  call,
  put
} from 'redux-saga/effects';
import { MessageTypes } from '../../../server/constants';
import * as global from '../../actions/global';
import generateMessage from '../../components/Messages';
import fetch from '../../lib/fetch';

export function* getAllSources(payload) {
  const { size, page } = payload;
  try {
    const response = yield call(fetch.get, `/flowTemplate`, { params: { size, page } });

    yield put(global.loadAllSourcesSuccess(response.data));
  } catch (error) {
    yield put(global.loadAllSourcesFail(generateMessage({ type: MessageTypes.RESPONSE_ERROR, message: error })));
  }
}

export function* getSourceByName(payload) {
  try {
    const { name } = payload;
    const response = yield call(fetch.get, `/flowTemplate/${name}`);
    yield put(global.loadSourceByNameSuccess(response.data));
  } catch (error) {
    yield put(global.loadSourceByNameFail(generateMessage({ type: MessageTypes.RESPONSE_ERROR, message: error })));
  }
}