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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aba7eadb7f89f25f1e45ad2371a3cc691360ad4c885ab8ea20abb6aa57145be4
4
- data.tar.gz: 387642a33d117cb67503ed9119f4da4ea5c5096fa31f8d17de7e2d6e53a9eed6
3
+ metadata.gz: bcdb4b08de49c06c864e36f99148584e16c417b6be5e81737190a4af9ddd755b
4
+ data.tar.gz: 9a8d23305042aa8c23f29ce18dc228ceace62eb418419d77c814fb2b5060b09f
5
5
  SHA512:
6
- metadata.gz: 534a76a5e7f6b2434061b604d68930274eaa8d9bf5f70703839089d00ce0d79561746e0081b0b61704eb3637f8df6a82a984faa26a2dc96e48712dfa3ba3617c
7
- data.tar.gz: ecd9f2a214abef00170081b60dc61c4286f4e6473b66bb7d41bf8efaa49c7e0d1f419bb8be1f0f187a9c32a931e58a1723b1689a16a9824f0c089d02223ac479
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` plus the task-assignment and duration-time-entry calls used by the companion `harvest-time-off` CLI.
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?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Marlens
4
4
  module HarvestApiV2
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marlens-harvest-api-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marlen Brunner