zmoazeni / harvested Goto Github PK
View Code? Open in Web Editor NEWA Ruby Wrapper for the Harvest API http://www.getharvest.com/api
Home Page: http://zmoazeni.github.io/harvested/
License: MIT License
A Ruby Wrapper for the Harvest API http://www.getharvest.com/api
Home Page: http://zmoazeni.github.io/harvested/
License: MIT License
When I request the current rate limit I should get the following: # features/step_definitions/account_steps.rb:1
| max_calls | 40 |
expected: "40"
got: "100" (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/account_steps.rb:4:in block (2 levels) in <top (required)>' ./features/step_definitions/account_steps.rb:3:in
each'
./features/step_definitions/account_steps.rb:3:in /^I\ request\ the\ current\ rate\ limit\ I\ should\ get\ the\ following:$/' features/account.feature:6:in
When I request the current rate limit I should get the following:'
When I create an expense for the project "Test Project" with the category "Mileage" with the following: # features/step_definitions/expenses_steps.rb:1
| notes | Drive to Chicago |
| total_cost | 75.00 |
| spent_at | 12/28/2009 |
argument out of range (ArgumentError)
/Users/o_o/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/time.rb:198:in local' /Users/o_o/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/time.rb:198:in
make_time'
/Users/o_o/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/time.rb:267:in parse' ./lib/harvest/expense.rb:16:in
spent_at='
./lib/harvest/base_model.rb:24:in block in attributes=' ./lib/harvest/base_model.rb:24:in
each'
./lib/harvest/base_model.rb:24:in attributes=' ./lib/harvest/base_model.rb:11:in
initialize'
./features/step_definitions/expenses_steps.rb:5:in new' ./features/step_definitions/expenses_steps.rb:5:in
/^I\ create\ an\ expense\ for\ the\ project\ "(.)"\ with\ the\ category\ "(.)"\ with\ the\ following:$/'
features/expenses.feature:15:in `When I create an expense for the project "Test Project" with the category "Mileage" with the following:'
When I make a request with the hardy client # features/step_definitions/error_steps.rb:40
undefined method first' for "5":String (NoMethodError) ./lib/harvest/hardy_client.rb:62:in
rescue in retry_rate_limits'
./lib/harvest/hardy_client.rb:58:in retry_rate_limits' (eval):2:in
all'
./features/step_definitions/error_steps.rb:42:in block (2 levels) in <top (required)>' ./features/support/error_helpers.rb:6:in
set_time_and_return_and_error'
./features/step_definitions/error_steps.rb:41:in /^I\ make\ a\ request\ with\ the\ hardy\ client$/' features/hardy_client.feature:10:in
When I make a request with the hardy client'
It seems the API was updated and this property is missing when trying to add a new timeentry.
If I run this code:
harvest = Harvest.client(ENV["HARVEST_DOMAIN"], ENV["HARVEST_USERNAME"], ENV["HARVEST_PASSWORD"])
item = harvest.projects.find(nil)
I get back a Harvest project..
<#Harvest::Project active=false active_task_assignments_count=1 active_user_assignments_count=3 basecamp_id=nil bill_by="none" billable=true budget=nil budget_by="none" cache_version=2801717504 client_id=731781 code=nil cost_budget=nil cost_budget_include_expenses=false created_at="2011-09-27T11:51:25Z" earliest_record_at="2011-09-27" estimate=nil estimate_by="none" fees=nil highrise_deal_id=nil hint_earliest_record_at="2011-09-27" hint_latest_record_at="2011-09-27" hourly_rate=nil id=1545881 latest_record_at="2011-09-27" name="API Project" notes="" notify_when_over_budget=false over_budget_notification_percentage="8000.0" over_budget_notified_at=nil show_budget_to_all=false updated_at="2011-09-28T22:38:31Z">
I'm not sure this is a bug persé, but I find the behavior quite weird. Don't you agree ?
Hello, harvested stopped to work for me, check the log below. Was there any API change?
harvest = Harvest.hardy_client('foo', '[email protected]', 'bazz')
=> #<Harvest::Base:0x106f6f4f8 @credentials=#<Harvest::Credentials:0x106f6f408 @ssl=true, @username="[email protected]", @subdomain="foo", @password="bazz">>
(development) 1.8.7-p249 :002 > harvest.users.all
NoMethodError: The property 'password_change_required' is not defined for this Dash.
from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/hashie-1.2.0/lib/hashie/dash.rb:127:in assert_property_exists!' from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/hashie-1.2.0/lib/hashie/dash.rb:119:in
[]='
from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/hashie-1.2.0/lib/hashie/dash.rb:97:in initialize' from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/hashie-1.2.0/lib/hashie/dash.rb:96:in
each_pair'
from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/hashie-1.2.0/lib/hashie/dash.rb:96:in initialize' from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/harvested-0.5.1/lib/harvest/user.rb:65:in
initialize'
from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/harvested-0.5.1/lib/harvest/model.rb:61:in new' from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/harvested-0.5.1/lib/harvest/model.rb:61:in
parse'
from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/harvested-0.5.1/lib/harvest/model.rb:61:in map' from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/harvested-0.5.1/lib/harvest/model.rb:61:in
parse'
from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/harvested-0.5.1/lib/harvest/behavior/crud.rb:8:in all' from (eval):3:in
send'
from (eval):3:in all' from /Users/nazgob/.rvm/gems/ruby-1.8.7-p249/gems/harvested-0.5.1/lib/harvest/hardy_client.rb:59:in
retry_rate_limits'
from (eval):2:in `all'
from (irb):2
When I do a harvest.time.find(id), it return the Harvest::TimeEntry object but the spent_at is nil. When I troubleshoot looks the Harvest JSON API always missed the spent_at field.
ruby-1.8.7-p302 > response = harvest.time.request :get, harvest.time.credentials, '/daily/show/58972905'
=> #<HTTParty::Response:0x1024ec3b8 @parsed_response="{ \"project_id\": \"1188836\",\n \"p....
ruby-1.8.7-p302 > response.body
=> "{ \"project_id\": \"1188836\",\n \"project\": \"General Support\",\n \"task_id\": \"322617\",\n \"task\": \"Development\",\n \"client\": \"Mr. X\",\n \"id\": 58972905,\n \"notes\": \"r2700\",\n \"created_at\": \"2011-10-07T03:00:05Z\",\n \"updated_at\": \"2011-10-07T04:02:54Z\",\n \n \"hours\": 2.50}\n"
Looks Harvest API JSON isn't stable yet, isn't it?
Is it possible to lock a time entry via the API?
I noticed that harvested 0.3.3 doesn't support filters for reports, which I happen to need. I've forked the project and started hacking up Harvest::API::Reports#time_by_project to add the updated_since and billable filters because they're the only ones I currently need, but if you're ok with the approach, it could be easily expanded to include the other supported filters as well as support the other reports.
The only controversial thing I've done so far is replace the user parameter with a filters hash (including the user as a filter option). I did it just so I wouldn't have to pass nil into the method all the time. Here's a gist of the reports.rb file: https://gist.github.com/859238
What do you think? How would you prefer to move forward?
I typically use awesome_print for console logging during development because it's a bit nice than a standard puts
.
I thought I was going crazy becuase i'd do:
harvest = Harvest.client(x, y, z)
ap harvest.clients.all
and wind up with this error message:
NoMethodError: undefined method `id' for {}:Hash
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/harvested-1.0.0/lib/harvest/model.rb:26:in `=='
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:99:in `awesome_hash'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:26:in `format'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:137:in `unnested'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:104:in `awesome'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:85:in `block (2 levels) in awesome_array'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:329:in `indented'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:84:in `block in awesome_array'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:81:in `each'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:81:in `inject'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:81:in `awesome_array'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:26:in `format'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:137:in `unnested'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:104:in `awesome'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/core_ext/kernel.rb:10:in `ai'
from /Users/mrickert/.rvm/gems/ruby-2.0.0-p195@tractor/gems/awesome_print-1.1.0/lib/awesome_print/core_ext/kernel.rb:15:in `ap'
from /Users/mrickert/Dropbox/Skookum/tractor/models/Harvester.rb:17:in `clients'
from (irb):3
from /Users/mrickert/.rvm/rubies/ruby-2.0.0-p195/bin/irb:16:in `<main>'2.0.0p195 :004
but this works just fine:
harvest = Harvest.client(x, y, z)
puts harvest.clients.all
Not sure if this is a Harvested
bug or an awesome_print
bug?
Is there any way we can loosen the dependency on the Hashie gem to allow for 2.0 ?
I'm using some other gems that require Hashie > 2.
Regardless of which calls I make (#invoices
, #projects
, etc) I get back an instance of the appropriate class, but with only my credentials:
> h = Harvest.client('test', '[email protected]', 'secret')
=> #<Harvest::Base:0x007fa7620ec570 @credentials=#<Harvest::Credentials:0x007fa7620ec548 @subdomain="test", @username="[email protected]", @password="secret", @ssl=true>>
> h.invoices
=> #<Harvest::API::Invoices:0x007fa7620e9398 @credentials=#<Harvest::Credentials:0x007fa7620ec548 @subdomain="test", @username="[email protected]", @password="secret", @ssl=true>>
I tried running the tests to make sure nothing has changed with the API, but as #36 points out the test suite is in disrepair (ಠ_ಠ). Is there something I'm missing?
When calling harvest.invoices.all, I get this error:
The property 'created_by_id' is not defined for this Dash.
Hello gentlemen, it appears that every data call that I make results in a 404 error. Authentication appears to be successful though. Any advice?
>> harvest = Harvest.hardy_client('subdomain', '[email protected]', 'secretpassword')
=> #<Harvest::Base:0x10729fe98 @credentials=#<Harvest::Credentials:0x10729fd08 @ssl=true, @subdomain="subdomain", @password="secretpassword", @username="[email protected]">>
>> harvest.invoices.all
Harvest::NotFound: Harvest::NotFound : 404
from /Library/Ruby/Gems/1.8/gems/harvested-0.6.4/lib/harvest/api/base.rb:49:in `request'
from /Library/Ruby/Gems/1.8/gems/harvested-0.6.4/lib/harvest/api/invoices.rb:30:in `all'
from (eval):3:in `send'
from (eval):3:in `all'
from /Library/Ruby/Gems/1.8/gems/harvested-0.6.4/lib/harvest/hardy_client.rb:59:in `retry_rate_limits'
from (eval):2:in `all'
from (irb):7
>> harvest.projects.all
Harvest::NotFound: Harvest::NotFound : 404
from /Library/Ruby/Gems/1.8/gems/harvested-0.6.4/lib/harvest/api/base.rb:49:in `request'
from /Library/Ruby/Gems/1.8/gems/harvested-0.6.4/lib/harvest/behavior/crud.rb:8:in `all'
from (eval):3:in `send'
from (eval):3:in `all'
from /Library/Ruby/Gems/1.8/gems/harvested-0.6.4/lib/harvest/hardy_client.rb:59:in `retry_rate_limits'
from (eval):2:in `all'
from (irb):8
I forked the repo, created a new harvest account, updated my harvest_credentials.yml, and ran RSpec.
On my first attempt, I received this error:
harvested/lib/harvest/api/base.rb:45:in `request': Harvest::BadRequest : 400 {"message":"Has recorded hours"} (Harvest::BadRequest)
This was resolved by deleting the sample hour entry in Harvest.
My tests now run with seven failures. Before digging into each one, I wanted to see if there is some step I am missing a "out of the box" setup.
Has anyone been able to successfully run their tests off a fresh clone? I'm on ruby 1.9.3.
Finished in 23.11 seconds
57 examples, 7 failures, 3 pending
Failed examples:
rspec ./spec/functional/expenses_spec.rb:25 # harvest expenses allows adding, updating, and removing expenses
rspec ./spec/functional/reporting_spec.rb:4 # harvest reporting allows project and people entry reporting
rspec ./spec/functional/reporting_spec.rb:50 # harvest reporting allows expense reporting
rspec ./spec/functional/time_tracking_spec.rb:4 # harvest time tracking allows adding, updating and removing entries
rspec ./spec/functional/time_tracking_spec.rb:23 # harvest time tracking allows you to save entries for a different user
rspec ./spec/functional/users_spec.rb:4 # harvest users allows adding, updating, and removing users
rspec ./spec/functional/users_spec.rb:47 # harvest users allows password resets
21 client = Harvest::Client.new(:name => 'SuprCorp')
22 client = harvest.clients.create(client)
/Users/o_o/.rvm/gems/ruby-1.9.2-p180/gems/harvested-0.3.3/lib/harvest/behavior/crud.rb:30:in create': undefined method
first' for "/clients/634515":String (NoMethodError)
from basics.rb:22:in `
location may not exist
id = response.headers["location"].first.match(/\/.*\/(\d+)/)[1]
31
31 headers = headers.first if headers.respond_to? :first
32 id = headers.match(//.*/(\d+)/)[1]
You should be able to authenticate using OAuth2 in addition to HTTP Basic.
In a Rails application, you don't want to store the user's Harvest HTTP basic credentials, so OAuth provides a means of storing their credentials in a secure fashion.
I ran all specs while refreshing the cassettes and it seems something changed with the invoices API:
1) harvest invoices allows finding one invoice or all invoices with parameters
Failure/Error: invoice.due_at.should == "2011-05-31"
expected: "2011-05-31"
got: "2014-12-01" (using ==)
# ./spec/functional/invoice_spec.rb:80:in `block (3 levels) in <top (required)>'
# ./spec/functional/invoice_spec.rb:43:in `block (2 levels) in <top (required)>'
2) harvest reporting allows expense reporting
Failure/Error: expense = harvest.expenses.create(
Harvest::NotFound:
Harvest::NotFound : 404 <!DOCTYPE html>
<html> ... snip ... </html>
# ./lib/harvest/api/base.rb:49:in `request'
# ./lib/harvest/behavior/crud.rb:23:in `find'
# ./lib/harvest/behavior/crud.rb:34:in `create'
# ./spec/functional/reporting_spec.rb:72:in `block (3 levels) in <top (required)>'
# ./spec/functional/reporting_spec.rb:59:in `block (2 levels) in <top (required)>'
Attempting to authenticate a user with OAuth - I'm using omniauth-harvest to get a token. I then try to pass that token to the "OAuthCredentials.initialize('XXX')" method but recieve an error. What might I be missing?
token = auth_hash['credentials']['token']
harvest = Harvest::OAuthCredentials.initialize(token)
Receiving the error "Wrong number of arguments (1 for 3..4)", when I include the following snippet in my Rails app:
harvest = Harvest.client(subdomain: 'mysubdomain', username: 'myusername', password: 'mypassword')
harvest.projects.all # list out projects
I installed the "harvested" gem. The first line is what's flagged. Tested on 1.9.3, 2.0.0, 2.1.0, same error on versions.
Any ideas what's causing this?
cc: @rileytg
This was previously working but now fails. Perhaps a change to the API has caused this? Here is the error that is displayed when I run my script
/gems/hashie-1.2.0/lib/hashie/dash.rb:127:in `assert_property_exists!': The property 'can_create_invoices' is not defined for this Dash. (NoMethodError)
from /gems/hashie-1.2.0/lib/hashie/dash.rb:119:in `[]='
from /gems/hashie-1.2.0/lib/hashie/dash.rb:97:in `block in initialize'
from /gems/hashie-1.2.0/lib/hashie/dash.rb:96:in `each_pair'
from /gems/hashie-1.2.0/lib/hashie/dash.rb:96:in `initialize'
from /gems/harvested-0.4.0/lib/harvest/user.rb:63:in `initialize'
from /gems/harvested-0.4.0/lib/harvest/model.rb:61:in `new'
from /gems/harvested-0.4.0/lib/harvest/model.rb:61:in `block in parse'
from /gems/harvested-0.4.0/lib/harvest/model.rb:61:in `map'
from /gems/harvested-0.4.0/lib/harvest/model.rb:61:in `parse'
from /gems/harvested-0.4.0/lib/harvest/behavior/crud.rb:8:in `all'
from (eval):3:in `block in all'
from /gems/harvested-0.4.0/lib/harvest/hardy_client.rb:59:in `retry_rate_limits'
from (eval):2:in `all'
from main.rb:25:in `getHarvestUsers'
from main.rb:32:in `<main>'*
Thanks!
Hey there,
First of all, thanks for the great work on this API.
I was wondering if there is a way to mark a time_entry as invoiced
using the API. I'm currently doing it manually after each of my periods by going to Reports
> Detailed Reports
in the webapp, and I select in the Mark Hours
dropdown invoiced
.
I looked into the codebase but wasn't able to find something. Is it supported? Will it?
Thanks
I can successfully use the api to attach users to a project but when I try and delete the assignment I get a 404 error.
The harvest forum mentioned 404's being caused by insufficient access rights is this a issue with the API?
I use my admin credentials to create the api object.
Any ideas?
Simply using something like
harvest.invoices.find(params[:id])
results in "undefined method to_hash" - but other objects, like projects, seem to work just fine. Any ideas?
For a while bundler has great support for packaging and managing gems. We should do away with jeweler and just stick with bundler.
04cb1be bit me on this.
it would be awesome to see harvested on travis, passing tests on 1.8.7, 1.9.2 and perhaps others. just an idea, it's super easy to setup but it has to be done by project maintainer.
Hey folks,
I originally wrote harvested a few years ago to scratch an itch that I no longer have.
Keeping it maintained is not a priority for me, or even fun at this point. So if someone wants to take over the reins, apply fixes, and perhaps even take it in a new direction, please reply to this issue or send me an email.
The error I get is:
NoMethodError at /
The property 'password_change_required' is not defined for this Dash.
/app/vendor/bundle/ruby/1.9.1/gems/hashie-1.2.0/lib/hashie/dash.rb in assert_property_exists!
raise NoMethodError, "The property '#{property}' is not defined for this Dash."
/app/vendor/bundle/ruby/1.9.1/gems/hashie-1.2.0/lib/hashie/dash.rb in []=
assert_property_exists! property
/app/vendor/bundle/ruby/1.9.1/gems/hashie-1.2.0/lib/hashie/dash.rb in block in initialize
self[att] = value
/app/vendor/bundle/ruby/1.9.1/gems/hashie-1.2.0/lib/hashie/dash.rb in each_pair
attributes.each_pair do |att, value|
/app/vendor/bundle/ruby/1.9.1/gems/hashie-1.2.0/lib/hashie/dash.rb in initialize
attributes.each_pair do |att, value|
/app/vendor/bundle/ruby/1.9.1/gems/harvested-0.5.1/lib/harvest/user.rb in initialize
super
/app/vendor/bundle/ruby/1.9.1/gems/harvested-0.5.1/lib/harvest/model.rb in new
Array.wrap(parsed).map {|attrs| skip_json_root? ? new(attrs) : new(attrs[json_root])}
/app/vendor/bundle/ruby/1.9.1/gems/harvested-0.5.1/lib/harvest/model.rb in block in parse
Array.wrap(parsed).map {|attrs| skip_json_root? ? new(attrs) : new(attrs[json_root])}
/app/vendor/bundle/ruby/1.9.1/gems/harvested-0.5.1/lib/harvest/model.rb in map
Array.wrap(parsed).map {|attrs| skip_json_root? ? new(attrs) : new(attrs[json_root])}
/app/vendor/bundle/ruby/1.9.1/gems/harvested-0.5.1/lib/harvest/model.rb in parse
Array.wrap(parsed).map {|attrs| skip_json_root? ? new(attrs) : new(attrs[json_root])}
/app/vendor/bundle/ruby/1.9.1/gems/harvested-0.5.1/lib/harvest/behavior/crud.rb in all
api_model.parse(response.parsed_response)
/app/vendor/bundle/ruby/1.9.1/gems/harvested-0.5.1/lib/harvest/hardy_client.rb in retry_rate_limits
yield
app.rb in get_users
users = harvest.users.all
app.rb in block in
When I attempt to run this:
client.reports.time_by_user(12345, Time.parse("2012-08-01"), Time.parse("2012-08-31"))
An exception is thrown because the underlying HTTP query results in a 404.
Anything I'm doing wrong?
I am able to create a client using the Harvested API, but I have no luck deleting.
What is the recommended best practice to get the test suite running?
Thanks - Adam
There are many duplicated keys in timezones.rb. For example lines 5 and 6 have the same key. In Ruby 2.2.0 this will produce a deprecation warning. Is this able to be fixed? I am willing to do the fix also I am just not sure which one to take since they have the same key?
lib/harvest/timezones.rb:5: warning: duplicated key at line 6 ignored: "pacific/midway"
lib/harvest/timezones.rb:18: warning: duplicated key at line 19 ignored: "america/mexico_city"
lib/harvest/timezones.rb:25: warning: duplicated key at line 26 ignored: "america/lima"
lib/harvest/timezones.rb:39: warning: duplicated key at line 40 ignored: "europe/dublin"
lib/harvest/timezones.rb:60: warning: duplicated key at line 61 ignored: "europe/berlin"
lib/harvest/timezones.rb:80: warning: duplicated key at line 81 ignored: "europe/moscow"
lib/harvest/timezones.rb:80: warning: duplicated key at line 82 ignored: "europe/moscow"
lib/harvest/timezones.rb:88: warning: duplicated key at line 89 ignored: "asia/muscat"
lib/harvest/timezones.rb:95: warning: duplicated key at line 96 ignored: "asia/karachi"
lib/harvest/timezones.rb:98: warning: duplicated key at line 99 ignored: "asia/kolkata"
lib/harvest/timezones.rb:98: warning: duplicated key at line 100 ignored: "asia/kolkata"
lib/harvest/timezones.rb:98: warning: duplicated key at line 101 ignored: "asia/kolkata"
lib/harvest/timezones.rb:103: warning: duplicated key at line 104 ignored: "asia/dhaka"
lib/harvest/timezones.rb:109: warning: duplicated key at line 110 ignored: "asia/bangkok"
lib/harvest/timezones.rb:124: warning: duplicated key at line 125 ignored: "asia/tokyo"
lib/harvest/timezones.rb:124: warning: duplicated key at line 126 ignored: "asia/tokyo"
lib/harvest/timezones.rb:130: warning: duplicated key at line 131 ignored: "australia/melbourne"
lib/harvest/timezones.rb:138: warning: duplicated key at line 139 ignored: "asia/magadan"
lib/harvest/timezones.rb:144: warning: duplicated key at line 145 ignored: "pacific/auckland"
When trying to update a time tracking entry in our live system using the harvested gem, we encounter a 500 error.
The resulting HTTParty request:
The same request is working for another newly created account. We also wrote a support request to the harvest team to investigate in this error scenario.
If they find a solution for this error, we can close this issue.
Cheers,
Julian Weber
I have connected to my harvest account as an admin (on some projects):
hc = Harvest.client 'mycompany', '[email protected]', 'password'
hc.projects.all # returns all projects
hc.tasks.all #Harvest::NotFound: Harvest::NotFound : 404
hc.clients.all #Harvest::NotFound: Harvest::NotFound : 404
hc.users.all #Harvest::NotFound: Harvest::NotFound : 404
I tried creating a task and it works. I only want to test creating a timer and it seems it needs a task id. What could be the cause of this? Could this be a permission problem? I have admin access to certain projects only. Also, if it's a permission problem, I suggest a different error message as 404 is misleading.
I've been thinking about it, and I don't think there's any need to maintain ruby 1.8.x support. 1.9.x is the future and we're maintaining dead weight.
Stuff like this will also become simplified.
From @schneems article http://www.schneems.com/2014/12/15/hashie-considered-harmful.html
I really don't have a good argument for keeping around hashie. I seriously doubt anyone is using harvested as heavily as a project like omniauth, but we can be a good citizen.
I don't have a strong preference between returning Hashes vs OpenStructs. I think either will require a major version bump. (I haven't verified but I doubt we can get away with minor version bump if we choose OpenStruct).
I'd rather not go with Struct or our own Poros. I went that route early on and it caused way too much maintenance churn as things were added to the Harvest API.
I'm not able to install the harvested
gem on Windows 7 64-bit. The install fails with many missing: to_path
messages as it tries to make libxml-ruby-1.1.4
If I try to install this version of libxml-ruby
myself I get the same errors unless I specify the correct platform like this:
gem install libxml-ruby --version 1.1.4 --platform x86-mswin32-60
However, even with this installed the harvested
gem still tries to make the version for the wrong platform.
I'm a bit of a Ruby n00b so I don't know how to track down the dependency any further. I've manually installed all the gems in the harvested
Gemfile but this doesn't help.
It's mentioned in https://github.com/harvesthq/api/blob/master/Sections/Time%20Tracking.md and is a common issue for regular users.
Refs: #53
Regardless of which project I inspect, all results show hint_earliest_record_at=nil and hint_latest_record_at=nil. I noticed in project.rb that some interesting things are being done with those two fields. Is there a secret to gettiing those two values? Alternatively, can I just use updated_at? Does a project record's updated_at datetime get updated when a timesheet entry is made against it?
Harvest will soon be removing the ability to make non-SSL API requests.
All Harvest accounts now support SSL, so the option should be removed.
The gem should be namespaced under a Harvested module rather than Harvest.
Hi, it used to work for me but now there seems to be a problem. I get same error when when trying to create project etc.
BUT, it get created.! Despite this error it kinda works from Harvest web app perspective. Rate limit is ok.
harvest = Harvest.hardy_client('foo', '[email protected]', 'baz')
client = Harvest::Client.new(:name => 'SuprCorp')
(development) ruby-1.8.7-p330 :013 > client = harvest.clients.create(client)
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
from /Users/nazgob/.rvm/gems/ruby-1.8.7-p330@fs/gems/harvested-0.3.3/lib/harvest/behavior/crud.rb:30:in `create'
from (eval):3:in `send'
from (eval):3:in `create'
from /Users/nazgob/.rvm/gems/ruby-1.8.7-p330@fs/gems/harvested-0.3.3/lib/harvest/hardy_client.rb:59:in `retry_rate_limits'
from (eval):2:in `create'
from (irb):13
Instead of having specific reports, let the calls be stringed together, and only go out and get the value when it is needed -
@harvest.project(123).user(456).times(789,120)
2012-08-21T16:28:21+00:00 app[web.1]: ActionView::Template::Error (The property 'has_timesheet_2012_beta' is not defined for this Dash.):
2012-08-21T16:28:21+00:00 app[web.1]: 9: %th= ""
2012-08-21T16:28:21+00:00 app[web.1]: 8: %th= "Used Vacation"
2012-08-21T16:28:21+00:00 app[web.1]: 11: - @employees.each_with_index do |employee, index|
2012-08-21T16:28:21+00:00 app[web.1]: 13: %td.name
2012-08-21T16:28:21+00:00 app[web.1]: Rendered employees/show.haml (1339.0ms)
2012-08-21T16:28:21+00:00 app[web.1]: 14: - if current_user.admin?
2012-08-21T16:28:21+00:00 app[web.1]: 10: %tbody
Yay! I'm going to fork harvested and submit a pull request; looks like it's the same problem as before, just a new field. In the meanwhile, maybe it's time to think of a slightly more accepting way of dealing with the received data?
I get the following error
/Library/Ruby/Gems/2.0.0/gems/harvested-1.2.0/lib/harvest/api/reports.rb:16:in time_by_user': undefined method
strftime' for "2014-04-13 17:32:06 -0400":String (NoMethodError)
from harvest-trends.rb:23:in `
Seems like the gem doesn't require 'time'
?
I'm hoping I'm missing something basic about the example given in the readme, which asserts "You can pass in any hash of query attributes you wish as per the Harvest API page.", giving as an example:
harvest.projects.all(nil, :client => 12345)
This works for :client
, but seemingly not for other attributes:
harvest.projects.all # correctly returns all of our projects
harvest.projects.all(nil, :client => 1914731) # correctly returns 2 items
harvest.projects.all(nil, :billable => false) # incorrectly returns all projects, should return fewer
harvest.projects.all(nil, :active => false) # incorrectly returns all projects, should return way fewer
harvest.projects.all(nil, :name => "Holiday") # incorrectly returns all projects, should return 1
harvest.projects.all(nil, :name => "Total rubbish") # incorrectly returns all projects, should return 0
I'm verifying my assumptions about API data against the XML returned by a naked POST API call for /projects
, while signed in as the same user in the ruby script. The only thing they agree on is the total count of projects. I also see expected results when I dump the objects returned by an .all
method — that is, some projects are and aren't billable, are and aren't active, etc. Similar results when I try to filter for clients, and for people/users.
Am I overlooking a syntactical wrinkle? Thanks.
It appears that the API has changed or that this method does not work..
Has the harvested gem been abandoned? There seem to be other similar issues popping up in the queue.
My code:
harvest = Harvest.hardy_client(i.subdomain, i.login, i.password, :ssl => true)
puts harvest.tasks.all.inspect
Results in NotFound404. Please advise.
See this in the harvest docs, and specifically:
https://YOURACCOUNT.harvestapp.com/projects/{PROJECT_ID}/expenses?from=YYYYMMDD&to=YYYYMMDD
It would be nice to be able to do:
harvest = Harvest.client(
# ...
)
harvest.expenses.find_by_project_and_date_range(my_harvest_project_id, from: 1.month.ago, to: DateTime.now)
I'm currently supporting an application that should be using this, but it currently uses expenses.all(Date.now)
, which means for a long lived project (could span months and maybe over a year), I could be querying by week a number of times, and this application may be responsible for hundreds of projects in harvest, which means I am probably really hitting the limits of the api calls.
It would be better if I could just say harvest.expenses.find_by_project(my_harvest_project_id)
, but I don't think there is any sort of api end point for that (but there really really should be!).
I've run across an issue while trying to output time entries. This error also happens when I try and create a new TimeEntry in order to submit it.
Code to reproduce in 0.6.1:
project = harvest.projects.find(2520876) #needs a valid project ID
puts project #outputs valid project
entries = harvest.reports.time_by_project(project, Date.parse("2012-08-20"), Date.parse("2012-08-26"))
puts "Entries:"
entries.each {|e| p e}
Error generated:
/Volumes/me/.rvm/gems/ruby-1.9.3-p194/gems/harvested-0.6.1/lib/harvest/time_entry.rb:9:in `initialize': wrong number of arguments (2 for 1) (ArgumentError)
from /Volumes/me/.rvm/gems/ruby-1.9.3-p194/gems/hashie-1.2.0/lib/hashie/mash.rb:107:in `new'
from /Volumes/me/.rvm/gems/ruby-1.9.3-p194/gems/hashie-1.2.0/lib/hashie/mash.rb:107:in `dup'
from /Volumes/me/.rvm/gems/ruby-1.9.3-p194/gems/hashie-1.2.0/lib/hashie/hash_extensions.rb:25:in `hashie_stringify_keys'
from /Volumes/me/.rvm/gems/ruby-1.9.3-p194/gems/hashie-1.2.0/lib/hashie/hash_extensions.rb:42:in `hashie_inspect'
from lp2harvest.rb:93:in `p'
from lp2harvest.rb:93:in `block in <main>'
from lp2harvest.rb:93:in `each'
from lp2harvest.rb:93:in `<main>'
Any help or a potential fix would be greatly appreciated!
Is it possible to get the current user's company info through Harvested?—the who_am_i
method seems to ignore the company data returned from that endpoint.
Upon reading the code for time_by_user:
def time_by_user(user, start_date, end_date, options = {})
query = {:from => start_date.strftime("%Y%m%d"), :to => end_date.strftime("%Y%m%d")}
query[:project_id] = options[:project].to_i if options[:project]
query[:billable] = (options[:billable] ? "yes" : "no") unless options[:billable].nil?
query[:updated_since] = options[:updated_since].to_s if options[:updated_since]
response = request(:get, credentials, "/people/#{user.to_i}/entries", :query => query)
Harvest::TimeEntry.parse(JSON.parse(response.body).map {|h| h["day_entry"]})
end
I noticed that it hardcoded all of the options and so I can't pass in parameters such as only_unbilled
.
Is there a clear reason why the code doesn't merge in the options, like this:
def time_by_user(user, start_date, end_date, options = {})
query = {:from => start_date.strftime("%Y%m%d"), :to => end_date.strftime("%Y%m%d")}
query[:project_id] = options.delete(:project).to_i if options[:project]
query[:billable] = (options.delete(:billable) ? "yes" : "no") unless options[:billable].nil?
query[:updated_since] = options.delete(:updated_since).to_s if options[:updated_since]
# Merge in any options that we don't know about but are in a newer version of the API
query.update(options)
response = request(:get, credentials, "/people/#{user.to_i}/entries", :query => query)
Harvest::TimeEntry.parse(JSON.parse(response.body).map {|h| h["day_entry"]})
end
I wanted to ask this before attempting to refactor the API code or maybe there's a better way to achieve what I want?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.