{"size": 923, "ext": "js", "max_stars_repo_path": "src/APIFunctions/GoogleSheets.js", "max_stars_repo_name": "SCE-Development/Core-v4", "max_stars_repo_stars_event_min_datetime": "2020-01-29T03:59:10.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-19T08:56:43.000Z", "max_issues_repo_path": "src/APIFunctions/GoogleSheets.js", "max_issues_repo_name": "SCE-Development/Core-v4", "max_issues_repo_issues_event_min_datetime": "2019-11-01T22:46:15.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T22:21:44.000Z", "max_forks_repo_path": "src/APIFunctions/GoogleSheets.js", "max_forks_repo_name": "SCE-Development/Core-v4", "max_forks_repo_forks_event_min_datetime": "2020-02-20T17:44:02.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T19:26:38.000Z"}
{"max_stars_count": 27, "max_issues_count": 675, "max_forks_count": 11, "avg_line_length": 30.7666666667, "max_line_length": 80, "alphanum_fraction": 0.6901408451}
import axios from 'axios';
import { ApiResponse } from './ApiResponses';

let config = require('../config/config.json');
let MAILER_API_URL = process.env.NODE_ENV === 'production' ?
  config.MAILER_API_URL_PROD : config.MAILER_API_URL;

/**
 * Invokes the google spreadsheet API to add officer application form data to it
 * @param {object} row - the data from the officer application form
 * @param {String} sheetsId - ID of the google sheet getting updated
 * @returns {ApiResponse} Containing any error information related to the
 * request
 */
export async function addToSpreadsheet(row, sheetsId){
  let status = new ApiResponse();
  await axios
    .post(MAILER_API_URL + '/sheets/addToSpreadsheet',
      {row, sheetsId})
    .then((res)=>{
      status.responseData = res;
      status.error = false;
    })
    .catch(err => {
      status.responseData = err;
      status.error = true;
    });
  return status;
}
