firespring_dev_commands 2.1.15.pre.alpha.4 → 2.1.16.pre.alpha.1
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/lib/firespring_dev_commands/bloom_growth/rock.rb +5 -11
- data/lib/firespring_dev_commands/bloom_growth/seat.rb +16 -0
- data/lib/firespring_dev_commands/bloom_growth/user.rb +13 -1
- data/lib/firespring_dev_commands/bloom_growth.rb +11 -2
- data/lib/firespring_dev_commands/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aefeda65512010d23b7d8ebac7ea669fcd2594a8b9b395a5de0d25862f0a3a8
|
4
|
+
data.tar.gz: 2edd1f29077209e1ab7822779bf952a92ecbd1e2a957a1c12334b2a00d6ebbb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afe5f89c78a0263a41a30442e875eb8e690c5912cf8ef00f499648556de5e3af22384f16ff67ff0519a0682b84ec98d8d28c6e8cffe979a208e65264f9b7ec6d
|
7
|
+
data.tar.gz: 2adc381033fe2505a7189fe817b1e7a51b98df017dca422420aea90dde27f689dddca1dcfd26a8de708e9cb99987c9ac055343f708a7a71c9ea4bdb7ab7619e4
|
@@ -2,7 +2,8 @@ module Dev
|
|
2
2
|
class BloomGrowth
|
3
3
|
# Class containing rock information
|
4
4
|
class Rock
|
5
|
-
attr_accessor :data, :id, :type, :name, :owner, :complete, :
|
5
|
+
attr_accessor :data, :id, :type, :name, :owner, :complete, :completion_id, :created, :due
|
6
|
+
attr_reader :state
|
6
7
|
|
7
8
|
def initialize(data)
|
8
9
|
@data = data
|
@@ -11,13 +12,14 @@ module Dev
|
|
11
12
|
@name = data['Name'].to_s.strip
|
12
13
|
@owner = User.new(data['Owner']) if data['Owner']
|
13
14
|
@complete = data['Complete']
|
14
|
-
@
|
15
|
+
@completion_id = data['Completion']
|
15
16
|
@created = Time.parse(data['CreateTime']) if data['CreateTime']
|
16
17
|
@due = Time.parse(data['DueDate']) if data['DueDate']
|
17
18
|
@archived = data['Archived']
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
+
# Convert the completion_id bloom growth gives us into a text version
|
22
|
+
def state
|
21
23
|
case completion_id
|
22
24
|
when 0
|
23
25
|
'Off Track'
|
@@ -27,14 +29,6 @@ module Dev
|
|
27
29
|
'Complete'
|
28
30
|
end
|
29
31
|
end
|
30
|
-
|
31
|
-
def colorized_state
|
32
|
-
return unless state
|
33
|
-
return state.light_red if state.downcase.include?('off track')
|
34
|
-
return state.light_green if state.downcase.include?('complete')
|
35
|
-
|
36
|
-
state.light_white
|
37
|
-
end
|
38
32
|
end
|
39
33
|
end
|
40
34
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Dev
|
2
|
+
class BloomGrowth
|
3
|
+
# Class containing seat information
|
4
|
+
class Seat
|
5
|
+
attr_accessor :data, :id, :type, :name
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
@data = data
|
9
|
+
position = data.dig('Group', 'Position')
|
10
|
+
@id = position&.fetch('Id')
|
11
|
+
@type = position&.fetch('Type')
|
12
|
+
@name = position&.fetch('Name').to_s.strip
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -2,13 +2,16 @@ module Dev
|
|
2
2
|
class BloomGrowth
|
3
3
|
# Class containing user information
|
4
4
|
class User
|
5
|
-
attr_accessor :data, :id, :type, :name, :rocks, :direct_reports
|
5
|
+
attr_accessor :data, :id, :type, :name, :rocks, :direct_reports, :seats
|
6
6
|
|
7
7
|
def initialize(data)
|
8
8
|
@data = data
|
9
9
|
@id = data['Id']
|
10
10
|
@type = data['Type']
|
11
11
|
@name = data['Name'].to_s.strip
|
12
|
+
@rocks = nil
|
13
|
+
@direct_reports = nil
|
14
|
+
@seats = nil
|
12
15
|
end
|
13
16
|
|
14
17
|
def rocks
|
@@ -26,6 +29,15 @@ module Dev
|
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
32
|
+
|
33
|
+
def seats
|
34
|
+
@seats ||= [].tap do |ary|
|
35
|
+
Dev::BloomGrowth.new.get("/api/v1/users/#{id}/seats") do |data|
|
36
|
+
ary << Seat.new(data)
|
37
|
+
puts ary.last.inspect
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
29
41
|
end
|
30
42
|
end
|
31
43
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
3
|
module Dev
|
4
|
+
# Class for interacting with the Bloom Growth api
|
4
5
|
class BloomGrowth
|
5
6
|
# The config file to try to load credentials from
|
6
7
|
CONFIG_FILE = "#{Dir.home}/.env.bloom".freeze
|
@@ -11,6 +12,7 @@ module Dev
|
|
11
12
|
# The text of the password variable key
|
12
13
|
BLOOM_PASSWORD = 'BLOOM_PASSWORD'.freeze
|
13
14
|
|
15
|
+
# The text of the token variable key
|
14
16
|
BLOOM_TOKEN = 'BLOOM_TOKEN'.freeze
|
15
17
|
|
16
18
|
# The text of the url variable key
|
@@ -65,7 +67,10 @@ module Dev
|
|
65
67
|
}
|
66
68
|
end
|
67
69
|
|
68
|
-
#
|
70
|
+
# Method for getting a bearer token for the bloom growth api. There are a couple of possible logic paths
|
71
|
+
# - If a token has already been defined, use it
|
72
|
+
# - If a token is found in the ENV, use it
|
73
|
+
# - Otherwise, use the username and passowrd that has been configured to request a new token from bloom
|
69
74
|
def token
|
70
75
|
@token ||= ENV.fetch(BLOOM_TOKEN, nil)
|
71
76
|
|
@@ -82,13 +87,15 @@ module Dev
|
|
82
87
|
'accept' => 'application/json'
|
83
88
|
}
|
84
89
|
)
|
85
|
-
|
90
|
+
# TODO: Should we look at https://github.com/DannyBen/lightly for caching the token?
|
91
|
+
@token = ENV[BLOOM_TOKEN] = response['access_token']
|
86
92
|
LOG.info("Retrieved BloomGrowth token. Expires on #{Time.now + response['expires_in']}")
|
87
93
|
end
|
88
94
|
|
89
95
|
@token
|
90
96
|
end
|
91
97
|
|
98
|
+
# Return all user objects visible to the logged in user
|
92
99
|
def visible_users(&)
|
93
100
|
[].tap do |ary|
|
94
101
|
get('/api/v1/users/mineviewable') do |user_data|
|
@@ -112,6 +119,8 @@ module Dev
|
|
112
119
|
nil
|
113
120
|
end
|
114
121
|
|
122
|
+
# Perform a post request to the given path using the gien data
|
123
|
+
# Return the parsed json body
|
115
124
|
def post(path, data, headers: default_headers)
|
116
125
|
data = data.to_json unless data.is_a?(String)
|
117
126
|
response = client.request_post(path, data, headers)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firespring_dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.16.pre.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -329,6 +329,7 @@ files:
|
|
329
329
|
- lib/firespring_dev_commands/aws/s3.rb
|
330
330
|
- lib/firespring_dev_commands/bloom_growth.rb
|
331
331
|
- lib/firespring_dev_commands/bloom_growth/rock.rb
|
332
|
+
- lib/firespring_dev_commands/bloom_growth/seat.rb
|
332
333
|
- lib/firespring_dev_commands/bloom_growth/user.rb
|
333
334
|
- lib/firespring_dev_commands/boolean.rb
|
334
335
|
- lib/firespring_dev_commands/common.rb
|