Package Exports
- harvest-er
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (harvest-er) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
harvest-er: Harvest Automation Server
Getting Started
Harvester requires Node.js and npm, which can both be installed by following the instructions on https://nodejs.org/. Installing Node.js also installs npm.
Installing with npm
npm install harvest-er
Installing from source
git clone https://github.com/sbolel/harvest-er
- clone the source code
npm install
- install node dependencies
npm run debug
- start the application using Supervisor with debug messages enabled
Usage
Start the application using Supervisor with npm run debug
. The Harvest data will be downloaded and saved to Dropbox each time the server runs. To re-run this download, execute rs
in Supervisor.
Setting up Harvest
Add the admin users email/password to your environment
export HARVESTER_SUBDOMAIN="thinkcrazy" export HARVESTER_ADMIN_EMAIL="admin@thinkcrazy.co" export HARVESTER_ADMIN_TOKEN="abc-def-123-456"
Set your Harvest subdomain in
server/harvester.js
and the email/password for the admin user:var harvester = new Harvest({ subdomain: process.env.HARVESTER_SUBDOMAIN, // your harvest subdomain email: process.env.HARVESTER_ADMIN_EMAIL, password: process.env.HARVESTER_ADMIN_TOKEN }),
Getting Today's Expense and Time Entries data from Harvest (see app.js
)
- Require
harvest
andharvester
const Harvest = require('harvest');
const Harvester = require('./harvester');
- Initialize Harvester and download the data using a promise array
function getTodaysData(){
const harvest = new Harvest({
subdomain: process.env.HARVESTER_SUBDOMAIN,
email: process.env.HARVEST_ADMIN_EMAIL,
password: process.env.HARVEST_ADMIN_TOKEN
});
const harvester = new Harvester(harvest);
const tasks = [];
harvester.loaded().then(function(teamData){
tasks.push(harvester.getExpenses());
tasks.push(harvester.getTimesheets());
Q.all(tasks).then(function(results){
debug(harvester.val());
});
});
}
Future work
Setting up Dropbox
Create a new Dropbox app at https://www.dropbox.com/developers/apps/create
- Go to the settings for your new Dropbox app
- Take note of the App key and App secret
- Click "Generate" to get a Generated access token
Add the admin users email/password to your environment
export HARVESTER_DROPBOX_KEY=2abcdef1234t53e export HARVESTER_DROPBOX_SECRET=vn5aaf3bb5dd3qt export HARVESTER_DROPBOX_TOKEN=rUY9dxaAABBCCDDeeXJctUSUA_c8SuvABfzNwDAdFmTACAa6mUrpAAmcc7Gg7Qch
Set your Dropbox credentials in
server/dropboxer.js
:
const client = new Dropbox.Client({
key: process.env.HARVESTER_DROPBOX_KEY,
secret: process.env.HARVESTER_DROPBOX_SECRET,
token: process.env.HARVESTER_DROPBOX_TOKEN
});