abt-cli 0.0.5 → 0.0.6

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: 46ae22fa656f0ef8cbabad171a43087a3642df0336eb2fe9cf3adf031ea0ad4e
4
- data.tar.gz: dea107e2ce9f7a4ed405d6b1c323bad31b643ba836162534e6b601d735a03d7d
3
+ metadata.gz: 48f55dc71fb2babaa1b1b6ce4aa99dfdc3eea8a31f0cdc8bd43eecd94cd220f0
4
+ data.tar.gz: 94ece036845a7375e434bde005f388bf7e8e9a7f0f1b89c6b19ecfa7bbb8bb7a
5
5
  SHA512:
6
- metadata.gz: 18bc1dd8b3aca70fb1f38bb2ca7b62650c9ba5dc8a62f5acae6bef9bf08f4edcca6259805d546adcc42d463c26ca882aa9ec735e3ea30f94295853eb927071bd
7
- data.tar.gz: 4cf57895173624b581eb09a74597ce0f3f4081d7525fd9926d73cb1f14b493f8ec8da7d9fef729cc0b306002cba16c3cbe4fb85ad50b1f316c693adbf6a8e710
6
+ metadata.gz: 56ab38ab3607b95f420cb8178250d6bb83f338a92695011d753b9218a462292f2a0c95cb06d32a7b316142ace8def6a20be441df0e01f1dbb214384af239cf99
7
+ data.tar.gz: 96927e87f95be0cb844dbabbceb855ee26f5d77ef0f44e3728166f3e9e84123a71d4a71f5eb38f9c8ebb099be7ba3eda46dd7ed8fd1e5e41ddf5bcc0f71c2061
@@ -58,22 +58,24 @@ module Abt
58
58
  end
59
59
 
60
60
  def project
61
- @project ||= api.get("projects/#{project_id}")
61
+ @project ||= project_assignment['project'].merge('client' => project_assignment['client'])
62
62
  end
63
63
 
64
64
  def task
65
- project_task_assignments
66
- .map { |assignment| assignment['task'] }
67
- .find { |task| task['id'].to_s == task_id }
65
+ @task ||= project_assignment['task_assignments'].map { |ta| ta['task'] }.find do |task|
66
+ task['id'].to_s == task_id
67
+ end
68
68
  end
69
69
 
70
- def project_task_assignments
71
- @project_task_assignments ||= begin
72
- api.get_paged("projects/#{project_id}/task_assignments", is_active: true)
73
- rescue Abt::HttpError::HttpError # rubocop:disable Layout/RescueEnsureAlignment
74
- []
70
+ def project_assignment
71
+ @project_assignment ||= begin
72
+ project_assignments.find { |pa| pa['project']['id'].to_s == project_id }
75
73
  end
76
74
  end
75
+
76
+ def project_assignments
77
+ @project_assignments ||= api.get_paged('users/me/project_assignments')
78
+ end
77
79
  end
78
80
  end
79
81
  end
@@ -58,9 +58,15 @@ module Abt
58
58
  def projects
59
59
  @projects ||= begin
60
60
  cli.warn 'Fetching projects...'
61
- api.get_paged('projects')
61
+ project_assignments.map do |project_assignment|
62
+ project_assignment['project'].merge('client' => project_assignment['client'])
63
+ end
62
64
  end
63
65
  end
66
+
67
+ def project_assignments
68
+ @project_assignments ||= api.get_paged('users/me/project_assignments')
69
+ end
64
70
  end
65
71
  end
66
72
  end
@@ -28,20 +28,22 @@ module Abt
28
28
  private
29
29
 
30
30
  def project
31
- @project ||= api.get("projects/#{project_id}")
31
+ project_assignment['project']
32
32
  end
33
33
 
34
34
  def tasks
35
- project_task_assignments.map { |assignment| assignment['task'] }
35
+ @tasks ||= project_assignment['task_assignments'].map { |ta| ta['task'] }
36
36
  end
37
37
 
38
- def project_task_assignments
39
- @project_task_assignments ||= begin
40
- api.get_paged("projects/#{project_id}/task_assignments", is_active: true)
41
- rescue Abt::HttpError::HttpError # rubocop:disable Layout/RescueEnsureAlignment
42
- []
38
+ def project_assignment
39
+ @project_assignment ||= begin
40
+ project_assignments.find { |pa| pa['project']['id'].to_s == project_id }
43
41
  end
44
42
  end
43
+
44
+ def project_assignments
45
+ @project_assignments ||= api.get_paged('users/me/project_assignments')
46
+ end
45
47
  end
46
48
  end
47
49
  end
@@ -24,9 +24,15 @@ module Abt
24
24
  def projects
25
25
  @projects ||= begin
26
26
  cli.warn 'Fetching projects...'
27
- api.get_paged('projects', is_active: true)
27
+ project_assignments.map do |project_assignment|
28
+ project_assignment['project'].merge('client' => project_assignment['client'])
29
+ end
28
30
  end
29
31
  end
32
+
33
+ def project_assignments
34
+ @project_assignments ||= api.get_paged('users/me/project_assignments')
35
+ end
30
36
  end
31
37
  end
32
38
  end
@@ -52,11 +52,23 @@ module Abt
52
52
  end
53
53
 
54
54
  def project
55
- @project ||= api.get("projects/#{project_id}")
55
+ project_assignment['project']
56
56
  end
57
57
 
58
58
  def task
59
- @task ||= api.get("tasks/#{task_id}")
59
+ @task ||= project_assignment['task_assignments'].map { |ta| ta['task'] }.find do |task|
60
+ task['id'].to_s == task_id
61
+ end
62
+ end
63
+
64
+ def project_assignment
65
+ @project_assignment ||= begin
66
+ project_assignments.find { |pa| pa['project']['id'].to_s == project_id }
67
+ end
68
+ end
69
+
70
+ def project_assignments
71
+ @project_assignments ||= api.get_paged('users/me/project_assignments')
60
72
  end
61
73
 
62
74
  def external_link_data
@@ -14,23 +14,30 @@ module Abt
14
14
  end
15
15
 
16
16
  def call
17
- project_task_assignments.each do |a|
18
- project = a['project']
19
- task = a['task']
20
-
17
+ tasks.each do |task|
21
18
  print_task(project, task)
22
19
  end
23
20
  end
24
21
 
25
22
  private
26
23
 
27
- def project_task_assignments
28
- @project_task_assignments ||= begin
29
- api.get_paged("projects/#{project_id}/task_assignments", is_active: true)
30
- rescue Abt::HttpError::HttpError # rubocop:disable Layout/RescueEnsureAlignment
31
- []
24
+ def project
25
+ project_assignment['project']
26
+ end
27
+
28
+ def tasks
29
+ @tasks ||= project_assignment['task_assignments'].map { |ta| ta['task'] }
30
+ end
31
+
32
+ def project_assignment
33
+ @project_assignment ||= begin
34
+ project_assignments.find { |pa| pa['project']['id'].to_s == project_id }
32
35
  end
33
36
  end
37
+
38
+ def project_assignments
39
+ @project_assignments ||= api.get_paged('users/me/project_assignments')
40
+ end
34
41
  end
35
42
  end
36
43
  end
@@ -74,18 +74,17 @@ module Abt
74
74
  def user_id
75
75
  return git.global['userId'] unless git.global['userId'].nil?
76
76
 
77
- git.global['userId'] = cli.prompt([
78
- 'Please provide your harvest User ID.',
79
- 'To find it open "My profile" inside the harvest web UI.',
80
- 'The ID is the number part of the URL for that page.',
81
- '',
82
- 'Enter user id'
83
- ].join("\n"))
77
+ git.global['userId'] = api.get('users/me')['id'].to_s
84
78
  end
85
79
 
86
80
  private
87
81
 
88
82
  attr_reader :git
83
+
84
+ def api
85
+ @api ||=
86
+ Abt::Providers::Harvest::Api.new(access_token: access_token, account_id: account_id)
87
+ end
89
88
  end
90
89
  end
91
90
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abt
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abt-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesper Sørensen