Git Product home page Git Product logo

harvest's Introduction

harvest

A ruby library wrapping (most of) the Harvest Api.

DESCRIPTION:

This library uses ActiveResource and activeresource_throttle to provide simple, reliable access to the Harvest Api. Good for building reporting scripts and simple apps.

Note that this library does not support the complete Harvest Api at this time. See Features/Issues below for details.

USAGE:

Creating a new harvest object:

All calls to the Harvest API will originate from a Harvest object. Initialize it like so:

@harvest = Harvest(:email      => "[email protected]", 
                   :password   => "secret", 
                   :sub_domain => "joeandcompany",
                   :headers    => {"User-Agent" => "MyCompany"})

The headers argument is optional. Use :ssl => true if your account requires HTTPS.

Clients

Index

@harvest.clients.find(:all)

Show

@harvest.clients.find(43235)

Create

@client = @harvest.clients.new
@client.attributes = {:name => "Company, LLC", :details => "New York, NY"}
@client.save

Update

@client.first_name = "Smith"
@client.save

Destroy

@client.destroy

Toggle (Active/Inactive)

@client.toggle

Tasks

Index

@harvest.tasks.find(:all)

Show

@harvest.tasks.find(123)

Create

@task = @harvest.tasks.new
@task.attributes = {:name => "Meeting",   :billable_by_default => false,
                    :is_default => false, :default_hourly_rate => 100}
@task.save

Update

@task.name = "Client Meeting"
@task.save

Destroy

@task.destroy

People

Index

@harvest.people.find(:all)

Show

@harvest.people.find(123)

Projects

Index

@harvest.projects.find(:all)

Show

@harvest.projects.find(123)

Create

@project = @harvest.projects.new
@project.attributes = {:name => "Refactor", :active => true, 
                       :bill_by => "None", :client_id => @client.id, }
@project.save

Update

@project.name = "Mega-Refactor"
@project.save

Destroy

@project.destroy

Toggle (Active/Inactive)

@project.toggle

Invoices

Index

@invoices = @harvest.invoices.find(:all)

Show

@invoice = @harvest.invoices.find(1)

Find By Invoice Number

@invoice = @harvest.invoices.find_by_number('200')

Create

@invoice = @harvest.invoices.new
@invoice.attributes = {:amount => '250.32', :client_id => @client.id}
@invoice.save

Update

@invoice.notes = "Pending payment"
@invoice.save

Destroy

@invoice.destroy

Return parsed csv line items

@invoice.parsed_csv_line_items

User and Task Assignments

@project.users.find(:all)
@project.users.find(:first)
@project.tasks.find(:all)
@project.tasks.find(:first)

Reports

@project.entries(:from => Time.now, :to => Time.now)
@project.entries(:from => Time.now, :to => Time.now, :user_id => @person.id)
@person.entries(:from => Time.now, :to => Time.now)
@person.expenses(:from => Time.now, :to => Time.now)

FEATURES/PROBLEMS:

Supports most of the Harvest Api (www.getharvest.com/api).

Though RESTful, the Harvest Api does not entirely follow ActiveResource conventions. In order to support the complete API, certain customizations will be required. We welcome any contributions/modifications to help complete this Api.

The following Api features are incomplete due to incompatibilities with ActiveResource conventions (CRUD actions in parentheses):

  1. People (CUD)

  2. User & Task Assignments (CUD)

  3. Expenses (CUD)

In addition, the following have not been implemented at all due to time constraints:

  1. Time Tracking Api

  2. Invoices, Invoice Payments, Invoice Categories, and Invoice Messages

Expect a more complete library in the near future. Again, contributions are welcome.

TEST SUITE

This library includes a fairly thorough set of unit and integration tests. The unit tests can be run with the “rake” command.

The integration tests require a Harvest account. It is best to use a trial account when running these tests.

The credentials may be entered in test/test_helper.rb. To run the integration suite:

rake test:integration

Note that the integration test structure is somewhat unorthodox, as it requires tests to run in a particular order. The main test file is test/integration/harvest_integration_test.rb. Examine this to see how the integration suite works.

REQUIREMENTS:

Requires active_resource >= 2.1 and activeresource_throttle >= 1.0.

active_resource_throttle should install automaticallt, but just in case you need to install manually:

gem sources -a http://gems.github.com
sudo gem install aiaio-active_resource_throttle

INSTALL:

gem sources -a http://gems.github.com
gem install aiaio-harvest

harvest's People

Contributors

dce avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.