<commit_before>const _send = require('@tonybadguy/call-me-maybe');
const setup = require('./setup');
const cache = require('memory-cache');

const { getAccessToken, BASE_V3_URL } = setup;

// getAccessToken().then(data => console.log('works', data));
const Yelp = (function() {
    const businessSearch = `${BASE_V3_URL}/businesses/search`;
    const tempAccessToken =
        '<KEY>';
    const accessTokenKey = 'accessToken';
    let accessTokenCache = new cache.Cache();
    let businessesCache = new cache.Cache();

    function init() {
        return new Promise((resolve, reject) => {
            if (!accessTokenCache.get('accessToken')) {
                getAccessToken()
                    .then(tokenStruct => {
                        // TODO: Uncoment code below for production
                        // const { access_token } = tokenStruct;
                        accessTokenCache.put(accessTokenKey, businessesCache);
                        resolve();
                    })
                    .catch(err => reject(err));
            }
        });
    }

    function searchBusiness(params) {
        return _send({
            url: businessSearch,
            query: params,
            bearerToken: accessTokenCache.get(accessTokenKey)
        }).then(response => response.jsonBody);
    }

    return {
        init,<commit_msg>Made test use a temporary key manually<commit_after>const _send = require('@tonybadguy/call-me-maybe');
const setup = require('./setup');
const cache = require('memory-cache');

const { getAccessToken, BASE_V3_URL } = setup;

// getAccessToken().then(data => console.log('works', data));
const Yelp = (function() {
    const businessSearch = `${BASE_V3_URL}/businesses/search`;
    const tempAccessToken =
        '<KEY>';
    const accessTokenKey = 'accessToken';
    let accessTokenCache = new cache.Cache();
    let businessesCache = new cache.Cache();

    function init() {
        return new Promise((resolve, reject) => {
            if (!accessTokenCache.get('accessToken')) {
                // getAccessToken()
                //     .then(tokenStruct => {
                //         const { access_token } = tokenStruct;
                //         accessTokenCache.put(accessTokenKey, access_token);
                //         resolve();
                //     })
                //     .catch(err => reject(err));
                accessTokenCache.put(accessTokenKey, tempAccessToken);
            }
            resolve();
        });
    }

    function searchBusiness(params) {
        return _send({
            url: businessSearch,
            query: params,
            bearerToken: accessTokenCache.get(accessTokenKey)
        }).then(response => response.jsonBody);
    }

    return {
        init,
{'fraction_non_alphanumeric': 0.12608381502890173, 'fraction_numerical': 0.001445086705202312, 'mean_word_length': 1.945744680851064, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '618453', 'n_tokens_mistral': 733, 'n_tokens_neox': 707, 'n_words': 150}