import axios from 'axios';

const YELP = {
    businessId: 'medihand-acupuncture-clinic-pico-rivera-2',
    apiKey: 'TKZgETJ1yg3sruR1QOzrbtP31RbSmRWe7nCQnzadI-UFgG2lTiYxSLGCmDedFIYhrFMI6hSquCnx8ClTAhAiX1c5iK4fNxjtrDpoUTgeaAKI8HTqyz4g9HAQYyZ7YnYx',
}

const reviews = function() {
    return axios
                .get('/api/home/yelp/' + YELP.businessId + '/' + YELP.apiKey)
                .then(response => {
                  let reviewsItems = [];
                  for (var i = 0; i < response.data.reviews.length; i++) {
                    var reviewItem = {
                        social : 1,
                        profile_photo_url : response.data.reviews[i].user.image_url,
                        author_name : response.data.reviews[i].user.name,
                        date : response.data.reviews[i].time_created,
                        rating : response.data.reviews[i].rating,
                        text : response.data.reviews[i].text
                    }
                    reviewItem.time = Date.parse(response.data.reviews[i].time_created);
                    reviewsItems.push(reviewItem);
                  }
                  return reviewsItems;
                });
}

export default {
    reviews,
    // the other functions
}
