<commit_before>// npm modules
import request from 'request';
// our modules
import {config} from './';

function endpoint(task, id) {
  const base = 'https://review-api.udacity.com/api/v1';
  return {
    certifications: [`${base}/me/certifications/`, 'GET'],
    assigned: [`${base}/me/submissions/assigned/`, 'GET'],
    count: [`${base}/me/submissions/assigned_count/`, 'GET'],
    submissions: [`${base}/me/submissions/`, 'GET'],
    feedbacks: [`${base}/me/student_feedbacks/`, 'GET'],
    stats: [`${base}/me/student_feedbacks/stats/`, 'GET'],
    completed: [`${base}/me/submissions/completed/`, 'GET'],
    assign: [`${base}/projects/${id}/submissions/assign`, 'POST'],
    unassign: [`${base}/submissions/${id}/unassign`, 'PUT'],
    // submission_request endpoints
    get: [`${base}/me/submission_requests/`, 'GET'],
    getById: [`${base}/submission_requests/${id}`, 'GET'],
    create: [`${base}/submission_requests/`, 'POST'],
    delete: [`${base}/submission_requests/${id}`, 'DELETE'],
    update: [`${base}/submission_requests/${id}`, 'PUT'],
    refresh: [`${base}/submission_requests/${id}/refresh/`, 'PUT'],
    position: [`${base}/submission_requests/${id}/waits`, 'GET'],
  }[task];
}

export function api({task, id = '', body = ''}) {
  const [url, method] = endpoint(task, id);
  const headers = {Authorization: config.token};
  const json = true;
  const requestOptions = {url, method, headers, json, body};
  return new Promise((resolve, reject) => {
    request(requestOptions, (error, res) => {
      if (error) {
        reject({error, requestOptions, res});
      } else {
        if (res.body.error) {
          reject({error: res.body.error, requestOptions, res})
        } else {
          console.log(res.body)
          resolve(res);
        }
      }
    });
  });
}<commit_msg>Refactor and remove logging to the console<commit_after>// npm modules
import request from 'request';
// our modules
import {config} from './';

function endpoint(task, id) {
  const base = 'https://review-api.udacity.com/api/v1';
  return {
    certifications: [`${base}/me/certifications/`, 'GET'],
    assigned: [`${base}/me/submissions/assigned/`, 'GET'],
    count: [`${base}/me/submissions/assigned_count/`, 'GET'],
    submissions: [`${base}/me/submissions/`, 'GET'],
    feedbacks: [`${base}/me/student_feedbacks/`, 'GET'],
    stats: [`${base}/me/student_feedbacks/stats/`, 'GET'],
    completed: [`${base}/me/submissions/completed/`, 'GET'],
    assign: [`${base}/projects/${id}/submissions/assign`, 'POST'],
    unassign: [`${base}/submissions/${id}/unassign`, 'PUT'],
    // submission_request endpoints
    get: [`${base}/me/submission_requests/`, 'GET'],
    getById: [`${base}/submission_requests/${id}`, 'GET'],
    create: [`${base}/submission_requests/`, 'POST'],
    delete: [`${base}/submission_requests/${id}`, 'DELETE'],
    update: [`${base}/submission_requests/${id}`, 'PUT'],
    refresh: [`${base}/submission_requests/${id}/refresh/`, 'PUT'],
    position: [`${base}/submission_requests/${id}/waits`, 'GET'],
  }[task];
}

export function api({task, id = '', body = ''}) {
  const [url, method] = endpoint(task, id);
  const headers = {Authorization: config.token};
  const json = true;
  const requestOptions = {url, method, headers, json, body};
  return new Promise((resolve, reject) => {
    request(requestOptions, (error, res) => {
      if (error) {
        reject({error, requestOptions, res});
      } else if (res.body.error) {
        reject({error: res.body.error, requestOptions, res});
      } else {
        resolve(res);
      }
    });
  });
}
{'fraction_non_alphanumeric': 0.22083333333333333, 'fraction_numerical': 0.0005555555555555556, 'mean_word_length': 3.7506596306068603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3693801', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1154, 'n_words': 237}