harvested 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -0
- data/Gemfile +1 -1
- data/HISTORY +3 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/harvested.gemspec +3 -2
- data/lib/harvest/api/reports.rb +4 -2
- data/lib/harvest/api/time.rb +3 -3
- data/lib/harvest/behavior/crud.rb +2 -2
- data/spec/functional/reporting_spec.rb +10 -0
- metadata +4 -3
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p429
|
data/Gemfile
CHANGED
data/HISTORY
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
1.0.1 - June 21, 2013
|
2
|
+
* Adds ability to pass updated_since paramter to report methods (thanks Pete McWilliams)
|
3
|
+
* Adds ability to create time entries for a given user
|
1
4
|
1.0.0 - April 26, 2013
|
2
5
|
* Same as 0.6.4 - This should have been v1.0 long ago.
|
3
6
|
0.6.4 - October 24, 2012
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ harvest = Harvest.client('yoursubdomain', 'yourusername', 'yourpassword')
|
|
25
25
|
harvest.projects.all(nil, :client => 12345)
|
26
26
|
```
|
27
27
|
|
28
|
-
Note, the
|
28
|
+
Note, the first parameter is a User ID field that is optional, but needs to be specified
|
29
29
|
as nil if not included.
|
30
30
|
|
31
31
|
You can pass in any hash of query attributes you wish as per the
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/harvested.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "harvested"
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Zach Moazeni"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-06-21"
|
13
13
|
s.description = "Harvested wraps the Harvest API concisely without the use of Rails dependencies. More information about the Harvest API can be found on their website (http://www.getharvest.com/api). For support hit up the Mailing List (http://groups.google.com/group/harvested)"
|
14
14
|
s.email = "zach.moazeni@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
+
".ruby-version",
|
21
22
|
"Gemfile",
|
22
23
|
"HISTORY",
|
23
24
|
"MIT-LICENSE",
|
data/lib/harvest/api/reports.rb
CHANGED
@@ -6,7 +6,8 @@ module Harvest
|
|
6
6
|
query = {:from => start_date.strftime("%Y%m%d"), :to => end_date.strftime("%Y%m%d")}
|
7
7
|
query[:user_id] = options[:user].to_i if options[:user]
|
8
8
|
query[:billable] = (options[:billable] ? "yes" : "no") unless options[:billable].nil?
|
9
|
-
|
9
|
+
query[:updated_since] = options[:updated_since].to_s if options[:updated_since]
|
10
|
+
|
10
11
|
response = request(:get, credentials, "/projects/#{project.to_i}/entries", :query => query)
|
11
12
|
Harvest::TimeEntry.parse(JSON.parse(response.body).map {|h| h["day_entry"]})
|
12
13
|
end
|
@@ -15,7 +16,8 @@ module Harvest
|
|
15
16
|
query = {:from => start_date.strftime("%Y%m%d"), :to => end_date.strftime("%Y%m%d")}
|
16
17
|
query[:project_id] = options[:project].to_i if options[:project]
|
17
18
|
query[:billable] = (options[:billable] ? "yes" : "no") unless options[:billable].nil?
|
18
|
-
|
19
|
+
query[:updated_since] = options[:updated_since].to_s if options[:updated_since]
|
20
|
+
|
19
21
|
response = request(:get, credentials, "/people/#{user.to_i}/entries", :query => query)
|
20
22
|
Harvest::TimeEntry.parse(JSON.parse(response.body).map {|h| h["day_entry"]})
|
21
23
|
end
|
data/lib/harvest/api/time.rb
CHANGED
@@ -13,11 +13,11 @@ module Harvest
|
|
13
13
|
Harvest::TimeEntry.parse(JSON.parse(response.body)["day_entries"])
|
14
14
|
end
|
15
15
|
|
16
|
-
def create(entry)
|
17
|
-
response = request(:post, credentials, '/daily/add', :body => entry.to_json)
|
16
|
+
def create(entry, user = nil)
|
17
|
+
response = request(:post, credentials, '/daily/add', :body => entry.to_json, :query => of_user_query(user))
|
18
18
|
Harvest::TimeEntry.parse(response.parsed_response).first
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def update(entry, user = nil)
|
22
22
|
request(:put, credentials, "/daily/update/#{entry.to_i}", :body => entry.to_json, :query => of_user_query(user))
|
23
23
|
find(entry.id, user)
|
@@ -27,9 +27,9 @@ module Harvest
|
|
27
27
|
# Creates an item
|
28
28
|
# @param [Harvest::BaseModel] model the item you want to create
|
29
29
|
# @return [Harvest::BaseModel] the created model depending on where you're calling it from (e.g. Harvest::Client from Harvest::Base#clients)
|
30
|
-
def create(model)
|
30
|
+
def create(model, user = nil)
|
31
31
|
model = api_model.wrap(model)
|
32
|
-
response = request(:post, credentials, "#{api_model.api_path}", :body => model.to_json)
|
32
|
+
response = request(:post, credentials, "#{api_model.api_path}", :body => model.to_json, :query => of_user_query(user))
|
33
33
|
id = response.headers["location"].match(/\/.*\/(\d+)/)[1]
|
34
34
|
find(id, model.impersonated_user_id)
|
35
35
|
end
|
@@ -32,6 +32,8 @@ describe 'harvest reporting' do
|
|
32
32
|
harvest.reports.time_by_project(project2, Time.utc(2009, 12, 20), Time.utc(2009,12,30), :billable => true).should == []
|
33
33
|
harvest.reports.time_by_project(project2, Time.utc(2009, 12, 20), Time.utc(2009,12,30), :billable => false).first.should == entry2
|
34
34
|
|
35
|
+
harvest.reports.time_by_project(project1, Time.utc(2009, 12, 10), Time.utc(2009,12,30), {:updated_since => Time.now.utc}).should == []
|
36
|
+
|
35
37
|
harvest.reports.time_by_user(user, Time.utc(2009, 12, 20), Time.utc(2009,12,30)).map(&:id).should == [entry1, entry2].map(&:id)
|
36
38
|
|
37
39
|
harvest.reports.time_by_user(user, Time.utc(2009, 12, 20), Time.utc(2009,12,30), :project => project1).first.should == entry1
|
@@ -41,6 +43,12 @@ describe 'harvest reporting' do
|
|
41
43
|
harvest.reports.time_by_user(user, Time.utc(2009, 12, 20), Time.utc(2009,12,30), :billable => true).first.should == entry1
|
42
44
|
harvest.reports.time_by_user(user, Time.utc(2009, 12, 20), Time.utc(2009,12,30), :billable => false).first.should == entry2
|
43
45
|
|
46
|
+
entry3_time = Time.now.utc
|
47
|
+
entry3 = harvest.time.create("notes" => "test entry for checking updated_since", "hours" => 5, "spent_at" => "2009/12/15", "task_id" => task1.id, "project_id" => project1.id, "of_user" => user.id)
|
48
|
+
entries = harvest.reports.time_by_user(user, Time.utc(2009, 12, 10), Time.utc(2009,12,30), {:project => project1, :updated_since => entry3_time})
|
49
|
+
entries.first.should == entry3
|
50
|
+
entries.size.should == 1
|
51
|
+
|
44
52
|
client2 = harvest.clients.create("name" => "Phil's Sandwich Shop")
|
45
53
|
harvest.reports.projects_by_client(client).map(&:id).to_set.should == [project1, project2].map(&:id).to_set
|
46
54
|
harvest.reports.projects_by_client(client2).should == []
|
@@ -72,6 +80,8 @@ describe 'harvest reporting' do
|
|
72
80
|
|
73
81
|
harvest.reports.expenses_by_user(user, Time.utc(2009, 12, 20), Time.utc(2009,12,30)).first.should == expense
|
74
82
|
|
83
|
+
harvest.reports.expenses_by_user(user, Time.utc(2009, 12, 20), Time.utc(2009,12,30), {:updated_since => Time.now.utc}).should == []
|
84
|
+
|
75
85
|
my_user = harvest.users.all.detect {|u| u.email == credentials["username"]}
|
76
86
|
my_user.should_not be_nil
|
77
87
|
harvest.reports.expenses_by_user(my_user, Time.utc(2009, 12, 20), Time.utc(2009,12,30)).should == []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harvested
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -214,6 +214,7 @@ extra_rdoc_files:
|
|
214
214
|
- TODO
|
215
215
|
files:
|
216
216
|
- .document
|
217
|
+
- .ruby-version
|
217
218
|
- Gemfile
|
218
219
|
- HISTORY
|
219
220
|
- MIT-LICENSE
|
@@ -315,7 +316,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
316
|
version: '0'
|
316
317
|
segments:
|
317
318
|
- 0
|
318
|
-
hash:
|
319
|
+
hash: -4545923220079875304
|
319
320
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
320
321
|
none: false
|
321
322
|
requirements:
|