<commit_before>const request = require('request');
const accessToken = require('../secrets.json').access_token;
const apiUrl = 'https://bonus.ly/api/v1/';
const auth = `?access_token=${accessToken}`;

const api = {
    getHashtags() {
        return new Promise((resolve, reject) => {
            request.get({
                url: `${apiUrl}/companies/show${auth}`,
                json: true,
            }, (err, resp, body) => {
                if (err || !body.success) {
                    reject(new Error('Server failure'));
                } else {
                    resolve(body.result.company_hashtags);
                }
            });
        });
    },

    getOwnUserName() {
        return new Promise((resolve, reject) => {
            request.get({
                url: `${apiUrl}users/me${auth}`,
                json: true,
            }, (err, resp, body) => {
                if (err || !body.success) {
                    reject(new Error('server failure'));
                } else {
                    resolve(body.result.username);
                }
            });
        });
    },

    getUsers() {
        return new Promise((resolve, reject) => {
            request.get({
                url: `${apiUrl}users${auth}`,
                json: true,
            }, (err, resp, body) => {
                if (err || !body.success) {
                    reject(new Error('server failure'));
                } else {
                    const users = body.result.map(entry => entry.username);
                    resolve(users);
                }
            });
        });
    },

    postBonus(reason) {
        return new Promise((resolve, reject) => {
            request.post({
                url: `${apiUrl}bonuses${auth}`,
                json: {
                    reason,
                },
            }, (err, resp, body) => {
                if (err || !body.success) {
                    reject(new Error(body.message));
                } else {
                    resolve(body.result.giver.giving_balance);
                }
            });
        });
    },
};

module.exports = api;<commit_msg>Tidy up<commit_after>const request = require('request');
const accessToken = require('../secrets.json').access_token;
const apiUrl = 'https://bonus.ly/api/v1/';
const auth = `?access_token=${accessToken}`;

const api = {
    getHashtags() {
        return new Promise((resolve, reject) => {
            get(`${apiUrl}/companies/show${auth}`).then(result => {
                resolve(result.company_hashtags);
            }).catch(err => {
                reject(err);
            });
        });
    },

    getOwnUserName() {
        return new Promise((resolve, reject) => {
            get(`${apiUrl}users/me${auth}`).then(result => {
                resolve(result.username);
            }).catch(err => {
                reject(err);
            });
        });
    },

    getUsers() {
        return new Promise((resolve, reject) => {
            get(`${apiUrl}users${auth}`).then(result => {
                const users = result.map(entry => entry.username);
                resolve(users);
            }).catch(err => {
                reject(err);
            });
        });
    },

    postBonus(reason) {
        return new Promise((resolve, reject) => {
            request.post({
                url: `${apiUrl}bonuses${auth}`,
                json: {
                    reason,
                },
            }, (err, resp, body) => {
                if (err || !body.success) {
                    reject(new Error(body.message));
                } else {
                    resolve(body.result.giver.giving_balance);
                }
            });
        });
    },
};

function get(url) {
    return new Promise((resolve, reject) => {
        request.get({
            url,
            json: true,
        }, (err, resp, body) => {
            if (err || !body.success) {
                reject(body.message || new Error('Server failure'));
            } else {
                resolve(body.result);
            }
        });
    });
}

module.exports = api;
{'fraction_non_alphanumeric': 0.15423728813559323, 'fraction_numerical': 0.00048426150121065375, 'mean_word_length': 1.2710280373831775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, 'https://': 2, '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': '1307417', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1076, 'n_words': 192}