bloomy 0.3.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bloomy/client.rb +6 -7
- data/lib/bloomy/operations/goals.rb +9 -8
- data/lib/bloomy/operations/headlines.rb +31 -12
- data/lib/bloomy/operations/issues.rb +32 -12
- data/lib/bloomy/operations/meetings.rb +6 -5
- data/lib/bloomy/operations/scorecard.rb +5 -4
- data/lib/bloomy/operations/todos.rb +61 -11
- data/lib/bloomy/operations/users.rb +8 -19
- data/lib/bloomy/utils/get_user_id.rb +22 -0
- data/lib/bloomy/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: 453b980c92f83f6acf3d9a1191dcf94484a9a3acbc57811509f534964d0d15d7
|
4
|
+
data.tar.gz: 2c1e08c2351256c4d16b37729ce8173f144ed3680cbdd2e46f55c2a7e57b23f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ae681b285f824f3ee6c5f5a9806a205d86d2c01fefe84263aa0b1d1d34bd1a3996b17dc98330051125a1b79d0f9e868ed79d7dc015294ba39a5fb71e3032ede
|
7
|
+
data.tar.gz: 9a7710243dc62d7bb21e6b1fb0f2795c44dbb034b0fab8f787a5b3d93c942be7ff9d25ed9bde6552e10859bfd52565d090d8b0d3f576dda31afe4da440a88707
|
data/lib/bloomy/client.rb
CHANGED
@@ -34,13 +34,12 @@ module Bloomy
|
|
34
34
|
faraday.headers["Authorization"] = "Bearer #{@api_key}"
|
35
35
|
end
|
36
36
|
@user = User.new(@conn)
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@headline = Headline.new(@conn, @user_id)
|
37
|
+
@todo = Todo.new(@conn)
|
38
|
+
@goal = Goal.new(@conn)
|
39
|
+
@meeting = Meeting.new(@conn)
|
40
|
+
@scorecard = Scorecard.new(@conn)
|
41
|
+
@issue = Issue.new(@conn)
|
42
|
+
@headline = Headline.new(@conn)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bloomy/utils/get_user_id"
|
4
|
+
|
3
5
|
# Class to handle all the operations related to goals
|
4
6
|
class Goal
|
7
|
+
include Bloomy::Utilities::UserIdUtility
|
5
8
|
# Initializes a new Goal instance
|
6
9
|
#
|
7
10
|
# @param conn [Object] the connection object to interact with the API
|
8
|
-
|
9
|
-
def initialize(conn, user_id)
|
11
|
+
def initialize(conn)
|
10
12
|
@conn = conn
|
11
|
-
@user_id = user_id
|
12
13
|
end
|
13
14
|
|
14
15
|
# Lists all goals for a specific user
|
@@ -19,7 +20,7 @@ class Goal
|
|
19
20
|
# @example
|
20
21
|
# client.goal.list
|
21
22
|
# #=> [{ id: 1, title: "Complete project", created_at: "2024-06-10", ... }, ...]
|
22
|
-
def list(user_id
|
23
|
+
def list(user_id = self.user_id, archived: false)
|
23
24
|
active_goals = @conn.get("rocks/user/#{user_id}?include_origin=true").body.map do |goal|
|
24
25
|
{
|
25
26
|
id: goal["Id"],
|
@@ -32,7 +33,7 @@ class Goal
|
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
35
|
-
archived ? {active: active_goals, archived: get_archived_goals(user_id
|
36
|
+
archived ? {active: active_goals, archived: get_archived_goals(self.user_id)} : active_goals
|
36
37
|
end
|
37
38
|
|
38
39
|
# Creates a new goal
|
@@ -44,7 +45,7 @@ class Goal
|
|
44
45
|
# @example
|
45
46
|
# client.goal.create(title: "New Goal", meeting_id: 1)
|
46
47
|
# #=> { goal_id: 1, title: "New Goal", meeting_id: 1, ... }
|
47
|
-
def create(title:, meeting_id:, user_id:
|
48
|
+
def create(title:, meeting_id:, user_id: self.user_id)
|
48
49
|
payload = {title: title, accountableUserId: user_id}.to_json
|
49
50
|
response = @conn.post("/api/v1/L10/#{meeting_id}/rocks", payload).body
|
50
51
|
{
|
@@ -79,7 +80,7 @@ class Goal
|
|
79
80
|
# @example
|
80
81
|
# client.goal.update(goal_id: 1, title: "Updated Goal")
|
81
82
|
# #=> { status: 200 }
|
82
|
-
def update(goal_id:, title:, accountable_user:
|
83
|
+
def update(goal_id:, title:, accountable_user: user_id)
|
83
84
|
payload = {title: title, accountableUserId: accountable_user}.to_json
|
84
85
|
response = @conn.put("/api/v1/rocks/#{goal_id}", payload)
|
85
86
|
{status: response.status}
|
@@ -94,7 +95,7 @@ class Goal
|
|
94
95
|
# @example
|
95
96
|
# goal.send(:get_archived_goals)
|
96
97
|
# #=> [{ id: 1, title: "Archived Goal", created_at: "2024-06-10", ... }, ...]
|
97
|
-
def get_archived_goals(user_id
|
98
|
+
def get_archived_goals(user_id = self.user_id)
|
98
99
|
response = @conn.get("archivedrocks/user/#{user_id}").body
|
99
100
|
response.map do |goal|
|
100
101
|
{
|
@@ -1,23 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bloomy/utils/get_user_id"
|
4
|
+
|
3
5
|
class Headline
|
6
|
+
include Bloomy::Utilities::UserIdUtility
|
4
7
|
# Initializes a new headline instance
|
5
8
|
#
|
6
9
|
# @param conn [Object] the connection object to interact with the API
|
7
|
-
|
8
|
-
def initialize(conn, user_id)
|
10
|
+
def initialize(conn)
|
9
11
|
@conn = conn
|
10
|
-
@user_id = user_id
|
11
12
|
end
|
12
13
|
|
13
14
|
# Creates a new headline
|
14
15
|
#
|
15
16
|
# @param meeting_id [Integer] the ID of the meeting
|
16
17
|
# @param title [String] the title of the headline
|
17
|
-
# @param owner_id [Integer] the ID of the owner
|
18
|
+
# @param owner_id [Integer] the ID of the headline owner
|
18
19
|
# @param notes [String] additional notes for the headline
|
19
20
|
# @return [Hash] the created headline details
|
20
|
-
def create(meeting_id, title, owner_id:
|
21
|
+
def create(meeting_id, title, owner_id: user_id, notes: nil)
|
21
22
|
response = @conn.post("/api/v1/L10/#{meeting_id}/headlines",
|
22
23
|
{title: title, ownerId: owner_id, notes: notes}.to_json)
|
23
24
|
raise "Failed to create headline" unless response.status == 200
|
@@ -26,7 +27,7 @@ class Headline
|
|
26
27
|
id: response.body["Id"],
|
27
28
|
title: response.body["Title"],
|
28
29
|
owner_id: response.body["OwnerId"],
|
29
|
-
|
30
|
+
notes_url: response.body["DetailsUrl"]
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
@@ -52,6 +53,7 @@ class Headline
|
|
52
53
|
{
|
53
54
|
id: response.body["Id"],
|
54
55
|
title: response.body["Name"],
|
56
|
+
notes_url: response.body["DetailsUrl"],
|
55
57
|
meeting_details: {
|
56
58
|
id: response.body["OriginId"],
|
57
59
|
name: response.body["Origin"]
|
@@ -66,13 +68,30 @@ class Headline
|
|
66
68
|
}
|
67
69
|
end
|
68
70
|
|
69
|
-
# Get user
|
71
|
+
# Get headlines for a user or a meeting.
|
70
72
|
#
|
71
|
-
# @param user_id [Integer] the ID of the user
|
72
|
-
# @
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
# @param user_id [Integer, nil] the ID of the user (defaults to initialized user_id)
|
74
|
+
# @param meeting_id [Integer, nil] the ID of the meeting
|
75
|
+
# @raise [ArgumentError] if both `user_id` and `meeting_id` are provided
|
76
|
+
# @return [Array<Hash>] the list of headlines
|
77
|
+
# @example
|
78
|
+
# # Fetch headlines for a user
|
79
|
+
# client.headline.list
|
80
|
+
# #=> [{ id: 1, title: "Headline Title", meeting_details: { id: 1, name: "Team Meeting" }, ... }, ...]
|
81
|
+
def list(user_id: nil, meeting_id: nil)
|
82
|
+
if user_id && meeting_id
|
83
|
+
raise ArgumentError, "Please provide either `user_id` or `meeting_id`, not both."
|
84
|
+
end
|
85
|
+
|
86
|
+
if meeting_id
|
87
|
+
response = @conn.get("/api/v1/l10/#{meeting_id}/headlines")
|
88
|
+
else
|
89
|
+
user_id ||= self.user_id
|
90
|
+
response = @conn.get("/api/v1/headline/users/#{user_id}")
|
91
|
+
end
|
92
|
+
|
93
|
+
raise "Failed to list headlines" unless response.success?
|
94
|
+
|
76
95
|
response.body.map do |headline|
|
77
96
|
{
|
78
97
|
id: headline["Id"],
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "json"
|
4
|
+
require "bloomy/utils/get_user_id"
|
4
5
|
|
5
6
|
# Class to handle all the operations related to issues
|
6
7
|
class Issue
|
8
|
+
include Bloomy::Utilities::UserIdUtility
|
7
9
|
# Initializes a new Issue instance
|
8
10
|
#
|
9
11
|
# @param conn [Object] the connection object to interact with the API
|
10
|
-
|
11
|
-
def initialize(conn, user_id)
|
12
|
+
def initialize(conn)
|
12
13
|
@conn = conn
|
13
|
-
@user_id = user_id
|
14
14
|
end
|
15
15
|
|
16
16
|
# Retrieves details of a specific issue
|
@@ -39,15 +39,33 @@ class Issue
|
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
|
-
# Lists issues for a specific user
|
42
|
+
# Lists issues for a specific user or meeting
|
43
43
|
#
|
44
|
-
# @param user_id [Integer] the ID of the user (
|
44
|
+
# @param user_id [Integer, nil] the ID of the user (defaults to initialized user_id)
|
45
|
+
# @param meeting_id [Integer, nil] the ID of the meeting
|
46
|
+
# @raise [ArgumentError] if both `user_id` and `meeting_id` are provided
|
45
47
|
# @return [Array<Hash>] an array of hashes containing issues details
|
46
48
|
# @example
|
49
|
+
# # Fetch issues for the current user
|
47
50
|
# issue.list
|
48
|
-
#
|
49
|
-
|
50
|
-
|
51
|
+
#
|
52
|
+
# # Fetch issues for a specific user
|
53
|
+
# issue.list(user_id: 42)
|
54
|
+
#
|
55
|
+
# # Fetch issues for a specific meeting
|
56
|
+
# issue.list(meeting_id: 99)
|
57
|
+
def list(user_id: nil, meeting_id: nil)
|
58
|
+
if user_id && meeting_id
|
59
|
+
raise ArgumentError, "Please provide either `user_id` or `meeting_id`, not both."
|
60
|
+
end
|
61
|
+
|
62
|
+
if meeting_id
|
63
|
+
response = @conn.get("l10/#{meeting_id}/issues").body
|
64
|
+
else
|
65
|
+
user_id ||= self.user_id
|
66
|
+
response = @conn.get("issues/users/#{user_id}").body
|
67
|
+
end
|
68
|
+
|
51
69
|
response.map do |issue|
|
52
70
|
{
|
53
71
|
id: issue["Id"],
|
@@ -74,13 +92,15 @@ class Issue
|
|
74
92
|
|
75
93
|
# Creates a new issue
|
76
94
|
#
|
77
|
-
# @param title [String] the title of the new issue
|
78
95
|
# @param meeting_id [Integer] the ID of the meeting associated with the issue
|
96
|
+
# @param title [String] the title of the new issue
|
97
|
+
# @param user_id [Integer] the ID of the user responsible for the issue (default: initialized user ID)
|
98
|
+
# @param notes [String, nil] the notes for the issue (optional)
|
79
99
|
# @return [Hash] a hash containing the new issue's ID and title
|
80
100
|
# @example
|
81
|
-
# issue.create("New Issue"
|
101
|
+
# issue.create(meeting_id: 123, title: "New Issue")
|
82
102
|
# #=> { id: 789, title: "New Issue" }
|
83
|
-
def create(meeting_id:, title:, user_id:
|
103
|
+
def create(meeting_id:, title:, user_id: self.user_id, notes: nil)
|
84
104
|
response = @conn.post("issues/create", {title: title, meetingid: meeting_id, ownerid: user_id, notes: notes}.to_json)
|
85
105
|
{
|
86
106
|
id: response.body["Id"],
|
@@ -88,7 +108,7 @@ class Issue
|
|
88
108
|
meeting_title: response.body["Origin"],
|
89
109
|
title: response.body["Name"],
|
90
110
|
user_id: response.body["Owner"]["Id"],
|
91
|
-
|
111
|
+
notes_url: response.body["DetailsUrl"]
|
92
112
|
}
|
93
113
|
end
|
94
114
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bloomy/utils/get_user_id"
|
4
|
+
|
3
5
|
# Class to handle all the operations related to meeting
|
4
6
|
# @note
|
5
7
|
# This class is already initialized via the client and usable as `client.measurable.method`
|
6
8
|
class Meeting
|
9
|
+
include Bloomy::Utilities::UserIdUtility
|
7
10
|
# Initializes a new Meeting instance
|
8
11
|
#
|
9
12
|
# @param conn [Object] the connection object to interact with the API
|
10
|
-
|
11
|
-
def initialize(conn, user_id)
|
13
|
+
def initialize(conn)
|
12
14
|
@conn = conn
|
13
|
-
@user_id = user_id
|
14
15
|
end
|
15
16
|
|
16
17
|
# Lists all meetings for a specific user
|
@@ -20,7 +21,7 @@ class Meeting
|
|
20
21
|
# @example
|
21
22
|
# client.meeting.list
|
22
23
|
# #=> [{ id: 123, name: "Team Meeting" }, ...]
|
23
|
-
def list(user_id
|
24
|
+
def list(user_id = self.user_id)
|
24
25
|
response = @conn.get("L10/#{user_id}/list").body
|
25
26
|
response.map { |meeting| {id: meeting["Id"], name: meeting["Name"]} }
|
26
27
|
end
|
@@ -148,7 +149,7 @@ class Meeting
|
|
148
149
|
# @example
|
149
150
|
# client.meeting.create(title: "New Meeting", attendees: [2, 3])
|
150
151
|
# #=> { meeting_id: 1, title: "New Meeting", attendees: [2, 3] }
|
151
|
-
def create(title
|
152
|
+
def create(title, add_self: true, attendees: [])
|
152
153
|
payload = {title: title, addSelf: add_self}.to_json
|
153
154
|
response = @conn.post("L10/create", payload).body
|
154
155
|
meeting_id = response["meetingId"]
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "json"
|
4
|
+
require "bloomy/utils/get_user_id"
|
4
5
|
|
5
6
|
# Class to handle all the operations related to scorecards
|
6
7
|
# @note
|
7
8
|
# This class is already initialized via the client and usable as `client.scorecard.method`
|
8
9
|
class Scorecard
|
10
|
+
include Bloomy::Utilities::UserIdUtility
|
11
|
+
|
9
12
|
# Initializes a new Scorecard instance
|
10
13
|
#
|
11
14
|
# @param conn [Object] the connection object to interact with the API
|
12
|
-
|
13
|
-
def initialize(conn, user_id)
|
15
|
+
def initialize(conn)
|
14
16
|
@conn = conn
|
15
|
-
@user_id = user_id
|
16
17
|
end
|
17
18
|
|
18
19
|
# Retrieves the current week details
|
@@ -56,7 +57,7 @@ class Scorecard
|
|
56
57
|
if meeting_id
|
57
58
|
response = @conn.get("scorecard/meeting/#{meeting_id}").body
|
58
59
|
else
|
59
|
-
user_id ||=
|
60
|
+
user_id ||= self.user_id
|
60
61
|
response = @conn.get("scorecard/user/#{user_id}").body
|
61
62
|
end
|
62
63
|
|
@@ -1,31 +1,54 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "date"
|
4
|
+
require_relative "../utils/get_user_id"
|
4
5
|
|
5
6
|
# Class to handle all the operations related to todos
|
6
7
|
class Todo
|
8
|
+
include Bloomy::Utilities::UserIdUtility
|
9
|
+
|
7
10
|
# Initializes a new Todo instance
|
8
11
|
#
|
9
12
|
# @param conn [Object] the connection object to interact with the API
|
10
|
-
|
11
|
-
def initialize(conn, user_id)
|
13
|
+
def initialize(conn)
|
12
14
|
@conn = conn
|
13
|
-
@user_id = user_id
|
14
15
|
end
|
15
16
|
|
16
|
-
# Lists all todos for a specific user
|
17
|
+
# Lists all todos for a specific user or meeting
|
17
18
|
#
|
18
|
-
# @param user_id [Integer] the ID of the user (default is the initialized user ID)
|
19
|
+
# @param user_id [Integer, nil] the ID of the user (default is the initialized user ID)
|
20
|
+
# @param meeting_id [Integer, nil] the ID of the meeting
|
19
21
|
# @return [Array<Hash>] an array of hashes containing todo details
|
22
|
+
# @raise [ArgumentError] if both `user_id` and `meeting_id` are provided
|
20
23
|
# @example
|
24
|
+
# # Fetch todos for the current user
|
21
25
|
# client.todo.list
|
22
|
-
# #=> [{ id: 1, title: "
|
23
|
-
|
24
|
-
|
26
|
+
# #=> [{ id: 1, title: "New Todo", due_date: "2024-06-15", ... }]
|
27
|
+
#
|
28
|
+
# # Fetch todos for a specific user
|
29
|
+
# client.todo.list(user_id: 42)
|
30
|
+
# # => [{ id: 1, title: "New Todo", due_date: "2024-06-15", ... }]
|
31
|
+
#
|
32
|
+
# # Fetch todos for a specific meeting
|
33
|
+
# client.todo.list(meeting_id: 99)
|
34
|
+
# # => [{ id: 1, title: "New Todo", due_date: "2024-06-15", ... }]
|
35
|
+
def list(user_id: nil, meeting_id: nil)
|
36
|
+
if user_id && meeting_id
|
37
|
+
raise ArgumentError, "Please provide either `user_id` or `meeting_id`, not both."
|
38
|
+
end
|
39
|
+
|
40
|
+
if meeting_id
|
41
|
+
response = @conn.get("l10/#{meeting_id}/todos").body
|
42
|
+
else
|
43
|
+
user_id ||= self.user_id
|
44
|
+
response = @conn.get("todo/user/#{user_id}").body
|
45
|
+
end
|
46
|
+
|
25
47
|
response.map do |todo|
|
26
48
|
{
|
27
49
|
id: todo["Id"],
|
28
50
|
title: todo["Name"],
|
51
|
+
notes_url: todo["DetailsUrl"],
|
29
52
|
due_date: todo["DueDate"],
|
30
53
|
created_at: todo["CreateTime"],
|
31
54
|
completed_at: todo["CompleteTime"],
|
@@ -40,12 +63,13 @@ class Todo
|
|
40
63
|
# @param meeting_id [Integer] the ID of the meeting associated with the todo
|
41
64
|
# @param due_date [String, nil] the due date of the todo (optional)
|
42
65
|
# @param user_id [Integer] the ID of the user responsible for the todo (default: initialized user ID)
|
66
|
+
# @param notes [String, nil] additional notes for the todo (optional)
|
43
67
|
# @return [Hash] a hash containing the new todo's details
|
44
68
|
# @example
|
45
69
|
# client.todo.create(title: "New Todo", meeting_id: 1, due_date: "2024-06-15")
|
46
70
|
# #=> { id: 1, title: "New Todo", meeting_name: "Team Meeting", ... }
|
47
|
-
def create(title:, meeting_id:, due_date: nil, user_id:
|
48
|
-
payload = {title: title, accountableUserId: user_id}
|
71
|
+
def create(title:, meeting_id:, due_date: nil, user_id: self.user_id, notes: nil)
|
72
|
+
payload = {title: title, accountableUserId: user_id, notes: notes}
|
49
73
|
payload[:dueDate] = due_date if due_date
|
50
74
|
response = @conn.post("/api/v1/L10/#{meeting_id}/todos", payload.to_json).body
|
51
75
|
|
@@ -54,7 +78,8 @@ class Todo
|
|
54
78
|
title: response["Name"],
|
55
79
|
meeting_name: response["Origin"],
|
56
80
|
meeting_id: response["OriginId"],
|
57
|
-
due_date: response["DueDate"]
|
81
|
+
due_date: response["DueDate"],
|
82
|
+
notes_url: response["DetailsUrl"]
|
58
83
|
}
|
59
84
|
end
|
60
85
|
|
@@ -96,4 +121,29 @@ class Todo
|
|
96
121
|
updated_at: DateTime.now.to_s
|
97
122
|
}
|
98
123
|
end
|
124
|
+
|
125
|
+
# Retrieves the details of a specific todo item by its ID.
|
126
|
+
#
|
127
|
+
# @param todo_id [String] The ID of the todo item to retrieve.
|
128
|
+
# @return [Hash] A hash containing the details of the todo item.
|
129
|
+
# @raise [RuntimeError] If the request to retrieve the todo details fails.
|
130
|
+
# @example
|
131
|
+
# client.todo.details(1)
|
132
|
+
# #=> { id: 1, title: "Updated Todo", due_date: "2024-11-01T01:41:41.528Z", ... }
|
133
|
+
def details(todo_id)
|
134
|
+
response = @conn.get("/api/v1/todo/#{todo_id}")
|
135
|
+
raise "Failed to get todo details. Status: #{response.status}" unless response.success?
|
136
|
+
|
137
|
+
todo = response.body
|
138
|
+
{
|
139
|
+
id: todo["Id"],
|
140
|
+
meeting_id: todo["OriginId"],
|
141
|
+
title: todo["Name"],
|
142
|
+
notes_url: todo["DetailsUrl"],
|
143
|
+
due_date: todo["DueDate"],
|
144
|
+
created_at: todo["CreateTime"],
|
145
|
+
completed_at: todo["CompleteTime"],
|
146
|
+
status: todo["Complete"] ? "Complete" : "Incomplete"
|
147
|
+
}
|
148
|
+
end
|
99
149
|
end
|
@@ -1,26 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bloomy/utils/get_user_id"
|
4
|
+
|
3
5
|
# Class to handle all the operations related to users
|
4
6
|
class User
|
5
|
-
|
7
|
+
include Bloomy::Utilities::UserIdUtility
|
6
8
|
|
7
9
|
# Initializes a new User instance
|
8
10
|
#
|
9
11
|
# @param conn [Object] the connection object to interact with the API
|
10
12
|
def initialize(conn)
|
11
13
|
@conn = conn
|
12
|
-
@default_user_id = current_user_id
|
13
|
-
end
|
14
|
-
|
15
|
-
# Retrieves the current user's ID
|
16
|
-
#
|
17
|
-
# @return [Integer] the ID of the current user
|
18
|
-
# @example
|
19
|
-
# client.user.current_user_id
|
20
|
-
# #=> 1
|
21
|
-
def current_user_id
|
22
|
-
response = @conn.get("users/mine").body
|
23
|
-
response["Id"]
|
24
14
|
end
|
25
15
|
|
26
16
|
# Retrieves details of a specific user
|
@@ -33,13 +23,12 @@ class User
|
|
33
23
|
# @example
|
34
24
|
# client.user.details
|
35
25
|
# #=> {name: "John Doe", id: 1, image_url: "http://example.com/image.jpg", ...}
|
36
|
-
def details(user_id
|
26
|
+
def details(user_id = self.user_id, direct_reports: false, positions: false, all: false)
|
37
27
|
response = @conn.get("users/#{user_id}").body
|
38
28
|
user_details = {name: response["Name"], id: response["Id"], image_url: response["ImageUrl"]}
|
39
29
|
|
40
|
-
user_details[:direct_reports] = direct_reports(user_id
|
41
|
-
user_details[:positions] = positions(user_id
|
42
|
-
|
30
|
+
user_details[:direct_reports] = direct_reports(user_id) if direct_reports || all
|
31
|
+
user_details[:positions] = positions(user_id) if positions || all
|
43
32
|
user_details
|
44
33
|
end
|
45
34
|
|
@@ -50,7 +39,7 @@ class User
|
|
50
39
|
# @example
|
51
40
|
# client.user.direct_reports
|
52
41
|
# #=> [{name: "Jane Smith", id: 2, image_url: "http://example.com/image.jpg"}, ...]
|
53
|
-
def direct_reports(user_id
|
42
|
+
def direct_reports(user_id = self.user_id)
|
54
43
|
direct_reports_response = @conn.get("users/#{user_id}/directreports").body
|
55
44
|
direct_reports_response.map { |report| {name: report["Name"], id: report["Id"], image_url: report["ImageUrl"]} }
|
56
45
|
end
|
@@ -62,7 +51,7 @@ class User
|
|
62
51
|
# @example
|
63
52
|
# user.positions
|
64
53
|
# #=> [{name: "Manager", id: 3}, ...]
|
65
|
-
def positions(user_id
|
54
|
+
def positions(user_id = self.user_id)
|
66
55
|
position_response = @conn.get("users/#{user_id}/seats").body
|
67
56
|
position_response.map do |position|
|
68
57
|
{name: position["Group"]["Position"]["Name"], id: position["Group"]["Position"]["Id"]}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Bloomy
|
2
|
+
module Utilities
|
3
|
+
module UserIdUtility
|
4
|
+
# Lazy loads the user_id of the default user
|
5
|
+
#
|
6
|
+
# @return [String] the user_id of the default user
|
7
|
+
def user_id
|
8
|
+
@user_id ||= default_user_id
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Returns the user_id of the default user
|
14
|
+
#
|
15
|
+
# @return [String] The user_id of the default user
|
16
|
+
def default_user_id
|
17
|
+
response = @conn.get("users/mine").body
|
18
|
+
response["Id"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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.4.2
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/bloomy/operations/scorecard.rb
|
65
65
|
- lib/bloomy/operations/todos.rb
|
66
66
|
- lib/bloomy/operations/users.rb
|
67
|
+
- lib/bloomy/utils/get_user_id.rb
|
67
68
|
- lib/bloomy/version.rb
|
68
69
|
- sig/bloomy.rbs
|
69
70
|
homepage: https://github.com/franccesco/bloomy
|