marlens-harvest-api-v2 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/marlens/harvest_api_v2/client.rb +10 -0
- data/lib/marlens/harvest_api_v2/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bcdb4b08de49c06c864e36f99148584e16c417b6be5e81737190a4af9ddd755b
|
|
4
|
+
data.tar.gz: 9a8d23305042aa8c23f29ce18dc228ceace62eb418419d77c814fb2b5060b09f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 467a8070925de931f4a9be9bb66d31f35dd0b035d5e55d756103e5181cba4e5cbcddb0806a514dff764b16b64b4b7cf68994bcecfc1bc4da418e12a003468935
|
|
7
|
+
data.tar.gz: 6b3d155a25b8e708cfe01b1b5ce91f11909196c05ca5193e222915bb8e1cd1c2eefcef77fac4e2b0e0dcd4695ed3a11a0ee56dd849b70bd8e6630d9b771a8277
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Marlens Harvest API V2
|
|
2
2
|
|
|
3
|
-
Small Ruby client for the Harvest API V2. It uses Ruby's standard library and exposes `Marlens::HarvestApiV2::Client#request
|
|
3
|
+
Small Ruby client for the Harvest API V2. It uses Ruby's standard library and exposes `Marlens::HarvestApiV2::Client#request`, manager-only `#active_task_assignments`, member-safe `#active_personal_task_assignments`, and duration-time-entry calls used by the companion `harvest-time-off` CLI.
|
|
4
4
|
|
|
5
5
|
```ruby
|
|
6
6
|
require "marlens/harvest_api_v2"
|
|
@@ -47,6 +47,16 @@ module Marlens::HarvestApiV2
|
|
|
47
47
|
request(:get, "/v2/task_assignments", params: { is_active: true, per_page: 2000 }).fetch("task_assignments")
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
def active_personal_task_assignments
|
|
51
|
+
request(:get, "/v2/users/me/project_assignments", params: { per_page: 2000 })
|
|
52
|
+
.fetch("project_assignments")
|
|
53
|
+
.flat_map do |project_assignment|
|
|
54
|
+
project_assignment.fetch("task_assignments", []).filter_map do |task_assignment|
|
|
55
|
+
task_assignment.merge("project" => project_assignment.fetch("project")) if task_assignment["is_active"]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
50
60
|
def create_time_entry(project_id:, task_id:, spent_date:, hours:, notes: nil)
|
|
51
61
|
body = { project_id:, task_id:, spent_date: spent_date.iso8601, hours: }
|
|
52
62
|
body[:notes] = notes unless notes.nil? || notes.empty?
|