Skip to content

Commit

Permalink
ci(Completed Build): Finished the rebuild of the CI process.
Browse files Browse the repository at this point in the history
  • Loading branch information
simplyspoke committed Apr 9, 2018
1 parent 5080fef commit 73c3310
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 178 deletions.
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ cache:
directories:
- node_modules
notifications:
email: false
slack:
rooms:
- $SLACK_ACCOUNT:$SLACK_TOKEN#node-harvest
on_success: change # default: always
on_failure: always # default: always
node_js:
- '8.10.0'
script:
Expand All @@ -19,10 +23,4 @@ script:
after_success:
- npm run report-coverage
- npm run deploy-docs
# - npm run semantic-release
notifications:
slack:
rooms:
- $SLACK_ACCOUNT:$SLACK_TOKEN#node-harvest
on_success: change # default: always
on_failure: always # default: always
- npm run semantic-release
215 changes: 51 additions & 164 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,219 +5,106 @@
[![Coverage Status](https://coveralls.io/repos/github/simplyspoke/node-harvest/badge.svg)](https://coveralls.io/github/simplyspoke/node-harvest)
[![Dev Dependencies](https://david-dm.org/simplyspoke/node-harvest/dev-status.svg)](https://david-dm.org/simplyspoke/node-harvest?type=dev)
[![npm version](https://badge.fury.io/js/harvest.svg)](http://badge.fury.io/js/harvest)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Harvest is a tool that enables businesses to track time, track projects, manage clients, and invoice. This is a full client API built using node.js and the [Harvest API](http://help.getharvest.com/api/).
**Version 1.x - Will be depreciated in the days to come, once enough testing of Version 2.x has been completed.**

**Version 2.x - This is a substantial update to the prior versions adding functionality compatible with the Harvest API v2. This version is not backwards compatible**

Harvest is a tool that enables businesses to track time, track projects, manage clients, and invoice. This is a full client API built using node.js and the [Harvest API](http://help.getharvest.com/api/). This node module provides an easy to use wrapper for the API returning promises.

# Install

npm install harvest
`npm install harvest`

# Usage

## Basic Authentication

```js
let Harvest = require('harvest'),
harvest = new Harvest({
subdomain: config.harvest.subdomain,
email: config.harvest.email,
password: config.harvest.password
}),
TimeTracking = harvest.timeTracking;

TimeTracking.daily({}, function(err, tasks) {
if (err) throw new Error(err);

// work with tasks
});
```

## OAuth Authentication

### When you already have an access token

```js
const Harvest = require('harvest');
import Harvest from '../src/index';

const harvest = new Harvest({
subdomain: 'your-shop-name',
accessToken: 'your-oauth-token'
subdomain: 'SUBDOMAIN',
userAgent: 'MyApp (yourname@example.com)',
concurrency: 1,
auth: {
accessToken: process.env.ACCESS_TOKEN,
accountId: process.env.ACCOUNT_ID
}
});
```

### To get an access token which can then be stored and used in future

```js
// See https://platform.harvestapp.com/oauth2_clients to get these
let harvest = new Harvest({
subdomain: 'your-shop-name',
redirectUri: 'your-redirect-uri'
identifier: 'your-client-identifier',
secret: 'your-client-secret'
});
harvest.company
.get()
.then((response) => {
const company = response;
// Do some things with the company data
});
```

// Send the user to harvest.getAccessTokenURL()) and grab the access code passed as a get parameter
// e.g. By running an express.js server at redirect_url
let access_code = req.query.code;
## OAuth Authentication

harvest.parseAccessCode(access_code, function(err, message) {
// Do something here....
});
```
*NOTE:* This feature has not yet been coded. To track its progress or provide feedback, use the following issue: https://github.com/simplyspoke/node-harvest/issues/85

## Resources

Every resource is accessed via your `harvest` instance:

```js
const harvest = new Harvest({
subdomain: 'your-shop-name',
accessToken: 'your-oauth-token'
});

// harvest.<resouce_name>.<method_name>
```

Each method returns to a callback with the results:
Each method returns to a promise that resolves the results:

```js
harvest.projects.list({}, function(error, res, body) {

harvest.projects.list().then((projects) =>{
// Do something with the projects list.
})
```

### Available resources and methods

- account
- `get(callback)`
- `rate_limit_status(callback)`
- clientContacts
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- `listByClient(clientId, callback)`
### Available resources and methods (Method documentation not complete.)

- clients
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- `toggle(id, callback)`
- company
- contacts
- estimateItemCategories
- estimateMessages
- estimates
- expenseCategories
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- expenses
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- `attachReceipt(id, {params}, callback)`
- `getReceipt(id, callback)`
- invoiceCategories
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- invoiceItemCategories
- invoiceMessages
- `list(invoiceId, {params}, callback)`
- `get(invoiceId, id, callback)`
- `send(invoiceId, callback)`
- `delete(invoiceId, id, callback)`
- `mark(invoiceId, status, callback)`
- invoicePayments
- `list(invoiceId, {params}, callback)`
- `get(invoiceId, id, callback)`
- `create(invoiceId, {params}, callback)`
- `delete(invoiceId, id, callback)`
- invoices
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- projectAssignments
- projects
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- `toggle(id, callback)`
- reports
- `timeEntriesByProject(id, {params}, callback)`
- `timeEntriesByUser(id, {params}, callback)`
- `expensesByProject(id, {params}, callback)`
- `expensesByUser(id, {params}, callback)`
- taskAssignment
- `list(projectId, {params}, callback)`
- `get(projectId, id, callback)`
- `update(projectId, id, {params}, callback)`
- `delete(projectId, id, callback)`
- `assign(projectId, {params}, callback)`
- roles
- taskAssignments
- tasks
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- `activate(id, callback)`
- timeTracking
- `daily({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- `toggleTimer(id, callback)`
- timeEntries
- userAssignments
- users
- `list({params}, callback)`
- `get(id, callback)`
- `create({params}, callback)`
- `update(id, {params}, callback)`
- `delete(id, callback)`
- `toggle(id, callback)`
- userAssignment
- `list(projectId, {params}, callback)`
- `get(projectId, id, callback)`
- `assign(projectId, {params}, callback)`
- `update(projectId, id, {params}, callback)`
- `delete(projectId, id, callback)`

For all methods, the last variable is expected to be a callback function. The possible options avalible for the params object can be found in the [Harvest API Documentation](http://help.getharvest.com/api/).

# Testing
For all methods, the last variable is expected to be a callback function. The possible options available for the params object can be found in the [Harvest API Documentation](http://help.getharvest.com/api/).

**Note: Many of the current tests are configured with hard set variables set in the testing Harvest account. Future updates will resolve these issues, but at the moment testing will likely break we run locally.**
# Testing

In order to test you will need to create a config file that uses your credentials inside `config/default.json`
In order to run the tests, you will need to have the following environmental variables defined:

```json
{
"harvest": {
"subdomain": "...",
"email": "...",
"password": "...",
"identifier": "...",
"secret": "...",
"userAgent": "node-harvest test runner"
}
}
```
SUBDOMAIN=''
ACCESS_TOKEN=''
ACCOUNT_ID=''
```

This API is designed to work either using HTTP Basic authentication, or OAuth so either set of credentials will work. Subdomain is always required.
For additional information about setting up harvest access tokens, visit the following page: https://help.getharvest.com/api-v2/authentication-api/authentication/authentication/

## Running the tests

npm test

# or

mocha
npm run test:watch
npm run test:integration
npm run test:integration:watch

## Projects using this library

Expand Down
1 change: 1 addition & 0 deletions jest.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require('dotenv').config();
module.exports = {
collectCoverage: true,
collectCoverageFrom: ['**/*.ts'],
coverageDirectory: '<rootDir>/coverage/integration',
coveragePathIgnorePatterns: [
'/node_modules/',
'/tools/',
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ export default class Harvest {
clients;
company;
contacts;
estimates;
estimateItemCategories;
estimateMessages;
expenses;
estimates;
expenseCategories;
invoices;
expenses;
invoiceItemCategories;
invoiceMessages;
invoicePayments;
projects;
invoices;
projectAssignments;
projects;
roles;
tasks;
taskAssignments;
tasks;
timeEntries;
users;
userAssignments;
users;

constructor(config) {
this.host = 'https://' + config.subdomain + '.harvestapp.com';
Expand Down

0 comments on commit 73c3310

Please sign in to comment.