node package manager

harvest-er

harvest-er: Harvest Automation Server

NPM version Dependency Status code-style License NPM downloads

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

  1. 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"
  2. 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)

  1. Require harvest and harvester
const Harvest = require('harvest');
const Harvester = require('./harvester');
  1. 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

  1. 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
  2. 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
  3. 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
});