<commit_before>import { get, post, ajax } from 'jquery'
import AppDispatcher from './AppDispatcher'
import ServerActions from './actions/ServerActions'
import RestaurantActions from './actions/RestaurantActions';
import ActivityActions from './actions/ActivityActions';


const API = {
  getAllClientData() {
    get('/api/clients/')
    .done(res => ServerActions.receivedClientData(res))
    .fail(err => ServerActions.receivedError(err));
  },
  deleteAllClients() {
    ajax({
      url: '/api/clients/',
      method: 'DELETE',
    })
    .done(res => ServerActions.receivedClientData(res))
    .fail(err => ServerActions.receivedError(err));
  },
  createClient() {
    post('/api/clients/')
    .done(res => ServerActions.receivedNewClient(res))
    .fail(err => ServerActions.receivedError(err));
  },
  getClientData(clientId) {
    get(`/api/clients/${clientId}`)
    .done(res => { ServerActions.receivedClientData(res) })
    .fail(err => ServerActions.receivedError(err));
  },
  addClientData(newClientData, clientId) {
    ajax({
      url: `/api/clients/${clientId}`,
      method: 'PUT',
      data: newClientData,
    })
    .done(res => ServerActions.receivedClientData(res[0]))
    .fail(err => ServerActions.receivedError(err));
  },
  deleteClient(clientId) {
    ajax({
      url: `/api/clients/${clientId}`,
      method: 'DELETE',
    })
    .done()
    .fail(err => ServerActions.receivedError(err));
  },

  getRestaurants(id, city) {
    get('/api/yelp', { city, id })
    .done(res => ServerActions.receivedClientData(res))
    .fail(err => ServerActions.receivedError(err));
  },

  // getLunch(id, city) {
  //   get(`/api/yelp/lunch/${city}`)
  //   .done(response => response.json())
  //   .done(data => {
  //     RestaurantActions.getLunch(data.businesses);
  //     API.addClientData({
  //       lunch: data.businesses
  //     }, `${id}`)
  //   })
  //   .fail(err => console.log('err:', err))
  // },
  //
  // getDinner(id, city) {
  //   get(`/api/yelp/dinner/${city}`)
  //   .done(response => response.json())
  //   .done(data => {
  //     RestaurantActions.getDinner(data.businesses);
  //     API.addClientData({
  //       dinner: data.businesses
  //     }, `${id}`)
  //   })
  //   .fail(err => console.log('err:', err))
  // },

  getActivities(id, city) {
    get(`/api/yelp/activities/${city}`)
    .done(response => response.json())
    .done(data => {
      ActivityActions.getActivities(data.businesses)
      API.addClientData({
        activities: data.businesses
      }, `${id}`)
    })
    .fail(err => console.log('err:', err))
  },<commit_msg>updated API with getRestaurants and getActivities<commit_after>import { get, post, ajax } from 'jquery'
import AppDispatcher from './AppDispatcher'
import ServerActions from './actions/ServerActions'
import RestaurantActions from './actions/RestaurantActions';
import ActivityActions from './actions/ActivityActions';


const API = {
  getAllClientData() {
    get('/api/clients/')
    .done(res => ServerActions.receivedClientData(res))
    .fail(err => ServerActions.receivedError(err));
  },
  deleteAllClients() {
    ajax({
      url: '/api/clients/',
      method: 'DELETE',
    })
    .done(res => ServerActions.receivedClientData(res))
    .fail(err => ServerActions.receivedError(err));
  },
  createClient() {
    post('/api/clients/')
    .done(res => ServerActions.receivedNewClient(res))
    .fail(err => ServerActions.receivedError(err));
  },
  getClientData(clientId) {
    get(`/api/clients/${clientId}`)
    .done(res => { ServerActions.receivedClientData(res) })
    .fail(err => ServerActions.receivedError(err));
  },
  addClientData(newClientData, clientId) {
    ajax({
      url: `/api/clients/${clientId}`,
      method: 'PUT',
      data: newClientData,
    })
    .done(res => ServerActions.receivedClientData(res[0]))
    .fail(err => ServerActions.receivedError(err));
  },
  deleteClient(clientId) {
    ajax({
      url: `/api/clients/${clientId}`,
      method: 'DELETE',
    })
    .done()
    .fail(err => ServerActions.receivedError(err));
  },
  getRestaurants(id, city) {
    get(`/api/yelp/restaurants/${id}`, city)
    .done(res => ServerActions.receivedClientData(res))
    .fail(err => ServerActions.receivedError(err));
  },
  getActivities(id, city) {
    get(`/api/yelp/activities/${id}`, city)
    .done(res => ServerActions.receivedClientData(res))
    .fail(err => ServerActions.receivedError(err));
  },
{'fraction_non_alphanumeric': 0.18295964125560538, 'fraction_numerical': 0.0004484304932735426, 'mean_word_length': 3.2005649717514126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 40, 'https://': 0, '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': '1011350', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1467, 'n_words': 220}