bloomy 0.9.0 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +7 -4
- data/lib/bloomy/client.rb +10 -8
- data/lib/bloomy/operations/goals.rb +140 -123
- data/lib/bloomy/operations/headlines.rb +122 -104
- data/lib/bloomy/operations/issues.rb +83 -99
- data/lib/bloomy/operations/meetings.rb +156 -154
- data/lib/bloomy/operations/scorecard.rb +91 -93
- data/lib/bloomy/operations/todos.rb +123 -128
- data/lib/bloomy/operations/users.rb +105 -67
- data/lib/bloomy/types/items.rb +119 -0
- data/lib/bloomy/version.rb +1 -1
- metadata +3 -2
@@ -2,80 +2,118 @@
|
|
2
2
|
|
3
3
|
require "bloomy/utils/get_user_id"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
module Bloomy
|
6
|
+
# Class to handle all the operations related to users
|
7
|
+
class User
|
8
|
+
include Bloomy::Utilities::UserIdUtility
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
# Initializes a new User instance
|
11
|
+
#
|
12
|
+
# @param conn [Object] the connection object to interact with the API
|
13
|
+
def initialize(conn)
|
14
|
+
@conn = conn
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
# Retrieves details of a specific user
|
18
|
+
#
|
19
|
+
# @param user_id [Integer] the ID of the user (default: the current user ID)
|
20
|
+
# @param direct_reports [Boolean] whether to include direct reports (default: false)
|
21
|
+
# @param positions [Boolean] whether to include positions (default: false)
|
22
|
+
# @param all [Boolean] whether to include both direct reports and positions (default: false)
|
23
|
+
# @return [Types::UserItem] a UserItem object containing user details
|
24
|
+
# @example
|
25
|
+
# client.user.details
|
26
|
+
# #=> #<Types::UserItem id: 1, name: "John Doe", image_url: "http://example.com/image.jpg">
|
27
|
+
def details(user_id = self.user_id, direct_reports: false, positions: false, all: false)
|
28
|
+
response = @conn.get("users/#{user_id}").body
|
29
|
+
user_details = Types::UserItem.new(
|
30
|
+
id: response["Id"],
|
31
|
+
name: response["Name"],
|
32
|
+
image_url: response["ImageUrl"]
|
33
|
+
)
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
user_details.direct_reports = direct_reports(user_id) if direct_reports || all
|
36
|
+
user_details.positions = positions(user_id) if positions || all
|
37
|
+
user_details
|
38
|
+
end
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
# Retrieves direct reports of a specific user
|
41
|
+
#
|
42
|
+
# @param user_id [Integer] the ID of the user (default: the current user ID)
|
43
|
+
# @return [Array<Types::UserItem>] an array of UserItem objects containing direct report details
|
44
|
+
# @example
|
45
|
+
# client.user.direct_reports
|
46
|
+
# #=> [#<Types::UserItem name: "Jane Smith", id: 2, image_url: "http://example.com/image.jpg">, ...]
|
47
|
+
def direct_reports(user_id = self.user_id)
|
48
|
+
direct_reports_response = @conn.get("users/#{user_id}/directreports").body
|
49
|
+
direct_reports_response.map do |report|
|
50
|
+
Types::UserItem.new(
|
51
|
+
name: report["Name"],
|
52
|
+
id: report["Id"],
|
53
|
+
image_url: report["ImageUrl"]
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
46
57
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
# Retrieves positions of a specific user
|
59
|
+
#
|
60
|
+
# @param user_id [Integer] the ID of the user (default: the current user ID)
|
61
|
+
# @return [Array<Types::UserItem>] an array of UserItem objects containing position details
|
62
|
+
# @example
|
63
|
+
# user.positions
|
64
|
+
# #=> [#<Types::UserItem name: "Manager", id: 3>, ...]
|
65
|
+
def positions(user_id = self.user_id)
|
66
|
+
position_response = @conn.get("users/#{user_id}/seats").body
|
67
|
+
position_response.map do |position|
|
68
|
+
Types::UserItem.new(
|
69
|
+
name: position["Group"]["Position"]["Name"],
|
70
|
+
id: position["Group"]["Position"]["Id"]
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Searches for users based on a search term
|
76
|
+
#
|
77
|
+
# @param term [String] the search term
|
78
|
+
# @return [Array<Types::UserItem>] an array of UserItem objects containing search results
|
79
|
+
# @example
|
80
|
+
# user.search("John")
|
81
|
+
# #=> [#<Types::UserItem id: 1, name: "John Doe", description: "Developer", ...>, ...]
|
82
|
+
def search(term)
|
83
|
+
response = @conn.get("search/user", term: term).body
|
84
|
+
response.map do |user|
|
85
|
+
Types::UserItem.new(
|
86
|
+
id: user["Id"],
|
87
|
+
name: user["Name"],
|
88
|
+
description: user["Description"],
|
89
|
+
email: user["Email"],
|
90
|
+
organization_id: user["OrganizationId"],
|
91
|
+
image_url: user["ImageUrl"]
|
92
|
+
)
|
93
|
+
end
|
58
94
|
end
|
59
|
-
end
|
60
95
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
96
|
+
# Retrieves all users in the system
|
97
|
+
#
|
98
|
+
# @param include_placeholders [Boolean] whether to include placeholder users (default: false)
|
99
|
+
# @return [Array<Types::UserItem>] an array of UserItem objects containing user details
|
100
|
+
# @example
|
101
|
+
# user.all
|
102
|
+
# #=> [#<Types::UserItem id: 1, name: "John Doe", email: "john@example.com", ...>, ...]
|
103
|
+
def all(include_placeholders: false)
|
104
|
+
users = @conn.get("search/all", term: "%").body
|
105
|
+
users
|
106
|
+
.select { |user| user["ResultType"] == "User" }
|
107
|
+
.reject { |user| !include_placeholders && user["ImageUrl"] == "/i/userplaceholder" }
|
108
|
+
.map do |user|
|
109
|
+
Types::UserItem.new(
|
110
|
+
id: user["Id"],
|
111
|
+
name: user["Name"],
|
112
|
+
email: user["Email"],
|
113
|
+
position: user["Description"],
|
114
|
+
image_url: user["ImageUrl"]
|
115
|
+
)
|
116
|
+
end
|
79
117
|
end
|
80
118
|
end
|
81
119
|
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bloomy
|
4
|
+
module Types
|
5
|
+
TodoItem = Struct.new(
|
6
|
+
:id,
|
7
|
+
:title,
|
8
|
+
:notes_url,
|
9
|
+
:due_date,
|
10
|
+
:created_at,
|
11
|
+
:completed_at,
|
12
|
+
:status,
|
13
|
+
:user_name,
|
14
|
+
:user_id,
|
15
|
+
keyword_init: true
|
16
|
+
)
|
17
|
+
|
18
|
+
HeadlineItem = Struct.new(
|
19
|
+
:id,
|
20
|
+
:title,
|
21
|
+
:notes_url,
|
22
|
+
:meeting_details,
|
23
|
+
:owner_details,
|
24
|
+
:archived,
|
25
|
+
:created_at,
|
26
|
+
:closed_at,
|
27
|
+
keyword_init: true
|
28
|
+
)
|
29
|
+
|
30
|
+
MeetingItem = Struct.new(
|
31
|
+
:id,
|
32
|
+
:title,
|
33
|
+
keyword_init: true
|
34
|
+
)
|
35
|
+
|
36
|
+
MeetingDetails = Struct.new(
|
37
|
+
:id,
|
38
|
+
:title,
|
39
|
+
:attendees,
|
40
|
+
:issues,
|
41
|
+
:todos,
|
42
|
+
:metrics,
|
43
|
+
keyword_init: true
|
44
|
+
)
|
45
|
+
|
46
|
+
MetricItem = Struct.new(
|
47
|
+
:id,
|
48
|
+
:title,
|
49
|
+
:target,
|
50
|
+
:operator,
|
51
|
+
:format,
|
52
|
+
:user_id,
|
53
|
+
:user_name,
|
54
|
+
:admin_id,
|
55
|
+
:admin_name,
|
56
|
+
keyword_init: true
|
57
|
+
)
|
58
|
+
|
59
|
+
UserItem = Struct.new(
|
60
|
+
:id,
|
61
|
+
:name,
|
62
|
+
:image_url,
|
63
|
+
:email,
|
64
|
+
:description,
|
65
|
+
:organization_id,
|
66
|
+
:position,
|
67
|
+
:direct_reports,
|
68
|
+
:positions,
|
69
|
+
keyword_init: true
|
70
|
+
)
|
71
|
+
|
72
|
+
GoalItem = Struct.new(
|
73
|
+
:id,
|
74
|
+
:title,
|
75
|
+
:created_at,
|
76
|
+
:due_date,
|
77
|
+
:status,
|
78
|
+
:meeting_id,
|
79
|
+
:meeting_title,
|
80
|
+
:user_id,
|
81
|
+
:user_name,
|
82
|
+
keyword_init: true
|
83
|
+
)
|
84
|
+
|
85
|
+
IssueItem = Struct.new(
|
86
|
+
:id,
|
87
|
+
:title,
|
88
|
+
:notes_url,
|
89
|
+
:created_at,
|
90
|
+
:completed_at,
|
91
|
+
:meeting_id,
|
92
|
+
:meeting_title,
|
93
|
+
:user_id,
|
94
|
+
:user_name,
|
95
|
+
keyword_init: true
|
96
|
+
)
|
97
|
+
|
98
|
+
WeekItem = Struct.new(
|
99
|
+
:id,
|
100
|
+
:week_number,
|
101
|
+
:week_start,
|
102
|
+
:week_end,
|
103
|
+
keyword_init: true
|
104
|
+
)
|
105
|
+
|
106
|
+
ScorecardItem = Struct.new(
|
107
|
+
:id,
|
108
|
+
:measurable_id,
|
109
|
+
:accountable_user_id,
|
110
|
+
:title,
|
111
|
+
:target,
|
112
|
+
:value,
|
113
|
+
:week,
|
114
|
+
:week_id,
|
115
|
+
:updated_at,
|
116
|
+
keyword_init: true
|
117
|
+
)
|
118
|
+
end
|
119
|
+
end
|
data/lib/bloomy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bloomy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franccesco Orozco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/bloomy/operations/scorecard.rb
|
67
67
|
- lib/bloomy/operations/todos.rb
|
68
68
|
- lib/bloomy/operations/users.rb
|
69
|
+
- lib/bloomy/types/items.rb
|
69
70
|
- lib/bloomy/utils/get_user_id.rb
|
70
71
|
- lib/bloomy/utils/plugin_loader.rb
|
71
72
|
- lib/bloomy/version.rb
|