summaryrefslogtreecommitdiff
path: root/scraper/client/actions.js
blob: 2723deed5860e5ba8808aca16a56a0cfde98152d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { get, post } from './util'
import * as types from './types'

export const api = (dispatch, method, tag, url, params) => {
  dispatch({ type: types.api.loading, tag })
  get(url, params).then(data => {
    dispatch({ type: types.api.loaded, tag, data })
  }).catch(err => {
    dispatch({ type: types.api.error, tag, err })
  })
}

export const getInstitutions = () => dispatch => {
  api(dispatch, get, 'institutions', '/api/institutions', {})
}

export const getPapers = () => dispatch => {
  api(dispatch, get, 'papers', '/api/papers', {})
}

export const getPaperInfo = (key) => dispatch => {
  api(dispatch, get, 'paperInfo', '/reports/datasets/final/' + key + '.json', {})
  api(dispatch, get, 'unknownCitations', '/reports/datasets/unknown/' + key + '.json', {})
}

export const getAddress = sha256 => dispatch => {
  api(dispatch, get, 'address', '/api/address/' + sha256, {})
}

export const postAddress = data => dispatch => {
  api(dispatch, post, 'address', '/api/address/add', data)
}