<commit_before>import {encode} from 'base-64'
import merge from './util/merge'

const BASE_URL = 'http://claymaa6.miniserver.com:8080/bristol-pound/'
const USER = 'test1'
const PASS = '<PASSWORD>'

const headers = new Headers()
headers.append('Authorization', 'Basic ' + encode(USER + ':' + PASS))
headers.append('Content-Type', 'application/json')

const querystring = params =>
  Object.keys(params).map(key => key + '=' + params[key]).join('&')

const get = (url, params) =>
  fetch(BASE_URL + url + (params ? '?' + querystring(params) : ''), {headers})
    .then(response => response.text())
    .then(JSON.parse)
    .catch(console.error)

const post = (url, params) =>
  fetch(BASE_URL + url, merge({headers}, {method: 'POST', body: JSON.stringify(params)}))
    .then(response => response.text())
    .then(JSON.parse)

export const getBusinesses = () =>
  get('business')

export const getAccount = () =>
  get('account')

export const getTransactions = (pageNumber = 1) =>
  get('transaction', {
    pageNumber,
    pageSize: 20
  })

export const putTransaction = (transaction) =>
  post('transaction', transaction)
<commit_msg>getBusinesses from cyclos API. new_get for getting from cyclos API<commit_after>import {encode} from 'base-64'
import merge from './util/merge'

const BASE_URL = 'http://claymaa6.miniserver.com:8080/bristol-pound/'
const NEW_BASE_URL = 'https://bristol.cyclos.org/bristolpoundsandbox03/api/'
const USER = 'test1'
const PASS = '<PASSWORD>'

const headers = new Headers()
headers.append('Authorization', 'Basic ' + encode(USER + ':' + PASS))
headers.append('Content-Type', 'application/json')

const querystring = params =>
  Object.keys(params).map(key => key + '=' + params[key]).join('&')

const get = (url, params) =>
  fetch(BASE_URL + url + (params ? '?' + querystring(params) : ''), {headers})
    .then(response => response.text())
    .then(JSON.parse)
    .catch(console.error)

const new_get = (url, params) =>
  fetch(NEW_BASE_URL + url + (params ? '?' + querystring(params) : ''), {headers})
    .then(response => response.text())
    .then(JSON.parse)

const post = (url, params) =>
  fetch(BASE_URL + url, merge({headers}, {method: 'POST', body: JSON.stringify(params)}))
    .then(response => response.text())
    .then(JSON.parse)

export const getBusinesses = () => {
  let params = {
    fields: [
      "email",
      "id",
      "username",
      "name",
      "address.addressLine1",
      "address.addressLine2",
      "address.zip",
      "address.location",
      "image.url",
      "phone",
      "display",
      "shortDisplay"
    ]
  }
  let businesses = new_get('users', params)
  businesses = businesses.map((business) => {
    let res = {..business, location: business.address.location};
    delete res.address.location;
    return res;
  })
  return businesses;
}


export const getAccount = () =>
  get('accounts')

export const getTransactions = (pageNumber = 1) =>
  get('transaction', {
    pageNumber,
    pageSize: 20
  })

export const putTransaction = (transaction) =>
  post('transaction', transaction)

{'fraction_non_alphanumeric': 0.17461863031483285, 'fraction_numerical': 0.008438818565400843, 'mean_word_length': 3.8765822784810124, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3147742', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1000, 'n_words': 221}