/ApartmentHub

Hub for the Apartment

Primary LanguageJavaScript

ApartmentHub

Hub for the Apartment

##Brief explanation as of 11/6/19

I have many more plans for this little web application I have made. In the future, this will be run off of a Raspberry Pi that will act as a server for connections outside of my home IP. Eventually, the connection will use Google's OAuth2 service to login to the RPI and from there a user could access my expense sheet and maybe adjust the thermostat in the future (with a bunch of programming to go).

Currently, all it does is take command line arguments as rows of data and submit them to the Google Sheet as a new row of data

###Installation of necessary libraries Run the following commands sudo apt-get update sudo apt-get upgrade sudo apt install nodejs npm install googleapis destroyer

###To Run program node main.js google_sheet_id date store_name item_type amount purchaser

Command line args: google_sheet_id => unique google sheet ID (use 1Vii37qL4NF1NYZJ5dNCBL4Ya2bHdeghVMYkPyH7y2H4 for my demo)
date => date of purchase store_name => name of store item_type => grocery, utility, etc amount => dollar amount up to 2 decimals purchaser => who bought the item

Note: at this time, there is little input validation for the arguments, and the rows may be off in the google sheet dude to background errors from other projects

##Program Flow main.js calls addTransaction with arguments sheetId and updateArray. Immediately when this function is called, a new OAuth2 instance is created which allows a user to use Google's APIs. If a user has never used this application a refresh_token will be stored, otherwise the user will be taken to a login screen. Once login is complete, the authentication code sent from Google is used in the addTransaction function as the authentication needed to use Google Sheets.

With valid authentication, the function accesses the the specific google_sheet supplied to the api via sheetId, and then adds the data from the command line to the last row of the google sheet.

Documentation is currently not very good. I am working to fix that soon.