Module: Harvest

Defined in:
lib/harvest/base.rb,
lib/harvest/task.rb,
lib/harvest/user.rb,
lib/harvest/client.rb,
lib/harvest/errors.rb,
lib/harvest/contact.rb,
lib/harvest/expense.rb,
lib/harvest/project.rb,
lib/harvest/api/base.rb,
lib/harvest/api/time.rb,
lib/harvest/api/tasks.rb,
lib/harvest/api/users.rb,
lib/harvest/timezones.rb,
lib/quilted-harvested.rb,
lib/harvest/base_model.rb,
lib/harvest/time_entry.rb,
lib/harvest/api/account.rb,
lib/harvest/api/clients.rb,
lib/harvest/api/reports.rb,
lib/harvest/credentials.rb,
lib/harvest/api/contacts.rb,
lib/harvest/api/expenses.rb,
lib/harvest/api/projects.rb,
lib/harvest/hardy_client.rb,
lib/harvest/behavior/crud.rb,
lib/harvest/task_assignment.rb,
lib/harvest/user_assignment.rb,
lib/harvest/expense_category.rb,
lib/harvest/rate_limit_status.rb,
lib/harvest/api/task_assignments.rb,
lib/harvest/api/user_assignments.rb,
lib/harvest/behavior/activatable.rb,
lib/harvest/api/expense_categories.rb

Defined Under Namespace

Modules: API, Behavior, Timezones Classes: BadRequest, Base, BaseModel, Client, Contact, Credentials, Expense, ExpenseCategory, HTTPError, HardyClient, InformHarvest, InvalidCredentials, NotFound, Project, RateLimitStatus, RateLimited, ServerError, Task, TaskAssignment, TimeEntry, Unavailable, User, UserAssignment

Constant Summary collapse

VERSION =
"0.3.2".freeze

Class Method Summary collapse

Class Method Details

.client(subdomain, username, password, options = {}) ⇒ Harvest::Base

Creates a standard client that will raise all errors it encounters

Options

  • :ssl - Whether or not to use SSL when connecting to Harvest. This is dependent on whether your account supports it. Set to true by default

Examples

Harvest.client('mysubdomain', 'myusername', 'mypassword', :ssl => false)

Returns:



31
32
33
# File 'lib/quilted-harvested.rb', line 31

def client(subdomain, username, password, options = {})
  Harvest::Base.new(subdomain, username, password, options)
end

.hardy_client(subdomain, username, password, options = {}) ⇒ Harvest::HardyClient

Creates a hardy client that will retry common HTTP errors it encounters and sleep() if it determines it is over your rate limit

Options

  • :ssl - Whether or not to use SSL when connecting to Harvest. This is dependent on whether your account supports it. Set to true by default

  • :retry - How many times the hardy client should retry errors. Set to 5 by default.

Examples

Harvest.hardy_client('mysubdomain', 'myusername', 'mypassword', :ssl => true, :retry => 3)

Errors

The hardy client will retry the following errors

  • Harvest::Unavailable

  • Harvest::InformHarvest

  • Net::HTTPError

  • Net::HTTPFatalError

  • Errno::ECONNRESET

Rate Limits

The hardy client will make as many requests as it can until it detects it has gone over the rate limit. Then it will sleep() for the how ever long it takes for the limit to reset. You can find more information about the Rate Limiting at www.getharvest.com/api

Returns:

See Also:



57
58
59
60
# File 'lib/quilted-harvested.rb', line 57

def hardy_client(subdomain, username, password, options = {})
  retries = options.delete(:retry)
  Harvest::HardyClient.new(client(subdomain, username, password, options), (retries || 5))
end