bloomy 0.2.1 → 0.3.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 +4 -4
- data/lib/bloomy/client.rb +3 -3
- data/lib/bloomy/operations/goals.rb +109 -0
- data/lib/bloomy/version.rb +1 -1
- metadata +3 -3
- data/lib/bloomy/operations/rocks.rb +0 -109
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 787640980ef91fe249c30313f21be2230cc0671de398f714f38e1200fc104a6f
|
4
|
+
data.tar.gz: 6c2bb8a0b8e78371674fe5f18bc66ab44d91629d03484863442f4d3953c59707
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da4639a0e6e6e633f972d31df14818ed64e3b690f565c7308f49ae53a08c061b74d944f4d7088f8ab024ed54b4301d4186a9747802c34b24c2b7f476afdab77a
|
7
|
+
data.tar.gz: 6f4674b867eec7d42f5735c1c7a6725ff173ee2c8f7a1c8b22ef329ed8aa9f384e40632235a578e4d1efe654bccdda75255abbc9ab35313c11375d1815944dcb
|
data/lib/bloomy/client.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "faraday"
|
4
4
|
require_relative "operations/users"
|
5
5
|
require_relative "operations/todos"
|
6
|
-
require_relative "operations/
|
6
|
+
require_relative "operations/goals"
|
7
7
|
require_relative "operations/meetings"
|
8
8
|
require_relative "operations/scorecard"
|
9
9
|
require_relative "operations/issues"
|
@@ -13,7 +13,7 @@ module Bloomy
|
|
13
13
|
# The Client class is the main entry point for interacting with the Bloomy API.
|
14
14
|
# It provides methods for managing Bloom Growth features.
|
15
15
|
class Client
|
16
|
-
attr_reader :configuration, :user, :todo, :
|
16
|
+
attr_reader :configuration, :user, :todo, :goal, :meeting, :scorecard, :issue, :headline
|
17
17
|
|
18
18
|
# Initializes a new Client instance
|
19
19
|
#
|
@@ -36,7 +36,7 @@ module Bloomy
|
|
36
36
|
@user = User.new(@conn)
|
37
37
|
@user_id = @user.default_user_id
|
38
38
|
@todo = Todo.new(@conn, @user_id)
|
39
|
-
@
|
39
|
+
@goal = Goal.new(@conn, @user_id)
|
40
40
|
@meeting = Meeting.new(@conn, @user_id)
|
41
41
|
@scorecard = Scorecard.new(@conn, @user_id)
|
42
42
|
@issue = Issue.new(@conn, @user_id)
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Class to handle all the operations related to goals
|
4
|
+
class Goal
|
5
|
+
# Initializes a new Goal instance
|
6
|
+
#
|
7
|
+
# @param conn [Object] the connection object to interact with the API
|
8
|
+
# @param user_id [Integer] the ID of the user
|
9
|
+
def initialize(conn, user_id)
|
10
|
+
@conn = conn
|
11
|
+
@user_id = user_id
|
12
|
+
end
|
13
|
+
|
14
|
+
# Lists all goals for a specific user
|
15
|
+
#
|
16
|
+
# @param user_id [Integer] the ID of the user (default is the initialized user ID)
|
17
|
+
# @param archived [Boolean] whether to include archived goals (default: false)
|
18
|
+
# @return [Array<Hash>] an array of hashes containing goal details or a hash with active and archived goals
|
19
|
+
# @example
|
20
|
+
# client.goal.list
|
21
|
+
# #=> [{ id: 1, title: "Complete project", created_at: "2024-06-10", ... }, ...]
|
22
|
+
def list(user_id: @user_id, archived: false)
|
23
|
+
active_goals = @conn.get("rocks/user/#{user_id}?include_origin=true").body.map do |goal|
|
24
|
+
{
|
25
|
+
id: goal["Id"],
|
26
|
+
title: goal["Name"],
|
27
|
+
created_at: goal["CreateTime"],
|
28
|
+
due_date: goal["DueDate"],
|
29
|
+
status: goal["Complete"] ? "Completed" : "Incomplete",
|
30
|
+
meeting_id: goal["Origins"].empty? ? nil : goal["Origins"][0]["Id"],
|
31
|
+
meeting_name: goal["Origins"].empty? ? nil : goal["Origins"][0]["Name"]
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
archived ? {active: active_goals, archived: get_archived_goals(user_id: @user_id)} : active_goals
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates a new goal
|
39
|
+
#
|
40
|
+
# @param title [String] the title of the new goal
|
41
|
+
# @param meeting_id [Integer] the ID of the meeting associated with the goal
|
42
|
+
# @param user_id [Integer] the ID of the user responsible for the goal (default: initialized user ID)
|
43
|
+
# @return [Hash] a hash containing the new goal's details
|
44
|
+
# @example
|
45
|
+
# client.goal.create(title: "New Goal", meeting_id: 1)
|
46
|
+
# #=> { goal_id: 1, title: "New Goal", meeting_id: 1, ... }
|
47
|
+
def create(title:, meeting_id:, user_id: @user_id)
|
48
|
+
payload = {title: title, accountableUserId: user_id}.to_json
|
49
|
+
response = @conn.post("/api/v1/L10/#{meeting_id}/rocks", payload).body
|
50
|
+
{
|
51
|
+
goal_id: response["Id"],
|
52
|
+
title: title,
|
53
|
+
meeting_id: meeting_id,
|
54
|
+
meeting_name: response["Origins"][0]["Name"],
|
55
|
+
user_id: user_id,
|
56
|
+
user_name: response["Owner"]["Name"],
|
57
|
+
created_at: DateTime.parse(response["CreateTime"])
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# Deletes a goal
|
62
|
+
#
|
63
|
+
# @param goal_id [Integer] the ID of the goal to delete
|
64
|
+
# @return [Hash] a hash containing the status of the delete operation
|
65
|
+
# @example
|
66
|
+
# client.goal.delete(1)
|
67
|
+
# #=> { status: 200 }
|
68
|
+
def delete(goal_id)
|
69
|
+
response = @conn.delete("/api/v1/rocks/#{goal_id}")
|
70
|
+
{status: response.status}
|
71
|
+
end
|
72
|
+
|
73
|
+
# Updates a goal
|
74
|
+
#
|
75
|
+
# @param goal_id [Integer] the ID of the goal to update
|
76
|
+
# @param title [String] the new title of the goal
|
77
|
+
# @param accountable_user [Integer] the ID of the user responsible for the goal (default: initialized user ID)
|
78
|
+
# @return [Hash] a hash containing the status of the update operation
|
79
|
+
# @example
|
80
|
+
# client.goal.update(goal_id: 1, title: "Updated Goal")
|
81
|
+
# #=> { status: 200 }
|
82
|
+
def update(goal_id:, title:, accountable_user: @user_id)
|
83
|
+
payload = {title: title, accountableUserId: accountable_user}.to_json
|
84
|
+
response = @conn.put("/api/v1/rocks/#{goal_id}", payload)
|
85
|
+
{status: response.status}
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
# Retrieves all archived goals for a specific user (private method)
|
91
|
+
#
|
92
|
+
# @param user_id [Integer] the ID of the user (default is the initialized user ID)
|
93
|
+
# @return [Array<Hash>] an array of hashes containing archived goal details
|
94
|
+
# @example
|
95
|
+
# goal.send(:get_archived_goals)
|
96
|
+
# #=> [{ id: 1, title: "Archived Goal", created_at: "2024-06-10", ... }, ...]
|
97
|
+
def get_archived_goals(user_id: @user_id)
|
98
|
+
response = @conn.get("archivedrocks/user/#{user_id}").body
|
99
|
+
response.map do |goal|
|
100
|
+
{
|
101
|
+
id: goal["Id"],
|
102
|
+
title: goal["Name"],
|
103
|
+
created_at: goal["CreateTime"],
|
104
|
+
due_date: goal["DueDate"],
|
105
|
+
status: goal["Complete"] ? "Complete" : "Incomplete"
|
106
|
+
}
|
107
|
+
end
|
108
|
+
end
|
109
|
+
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.3.0
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -57,10 +57,10 @@ files:
|
|
57
57
|
- lib/bloomy.rb
|
58
58
|
- lib/bloomy/client.rb
|
59
59
|
- lib/bloomy/configuration.rb
|
60
|
+
- lib/bloomy/operations/goals.rb
|
60
61
|
- lib/bloomy/operations/headlines.rb
|
61
62
|
- lib/bloomy/operations/issues.rb
|
62
63
|
- lib/bloomy/operations/meetings.rb
|
63
|
-
- lib/bloomy/operations/rocks.rb
|
64
64
|
- lib/bloomy/operations/scorecard.rb
|
65
65
|
- lib/bloomy/operations/todos.rb
|
66
66
|
- lib/bloomy/operations/users.rb
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Class to handle all the operations related to rocks
|
4
|
-
class Rock
|
5
|
-
# Initializes a new Rock instance
|
6
|
-
#
|
7
|
-
# @param conn [Object] the connection object to interact with the API
|
8
|
-
# @param user_id [Integer] the ID of the user
|
9
|
-
def initialize(conn, user_id)
|
10
|
-
@conn = conn
|
11
|
-
@user_id = user_id
|
12
|
-
end
|
13
|
-
|
14
|
-
# Lists all rocks for a specific user
|
15
|
-
#
|
16
|
-
# @param user_id [Integer] the ID of the user (default is the initialized user ID)
|
17
|
-
# @param archived [Boolean] whether to include archived rocks (default: false)
|
18
|
-
# @return [Array<Hash>] an array of hashes containing rock details or a hash with active and archived rocks
|
19
|
-
# @example
|
20
|
-
# client.rock.list
|
21
|
-
# #=> [{ id: 1, title: "Complete project", created_at: "2024-06-10", ... }, ...]
|
22
|
-
def list(user_id: @user_id, archived: false)
|
23
|
-
active_rocks = @conn.get("rocks/user/#{user_id}?include_origin=true").body.map do |rock|
|
24
|
-
{
|
25
|
-
id: rock["Id"],
|
26
|
-
title: rock["Name"],
|
27
|
-
created_at: rock["CreateTime"],
|
28
|
-
due_date: rock["DueDate"],
|
29
|
-
status: rock["Complete"] ? "Completed" : "Incomplete",
|
30
|
-
meeting_id: rock["Origins"].empty? ? nil : rock["Origins"][0]["Id"],
|
31
|
-
meeting_name: rock["Origins"].empty? ? nil : rock["Origins"][0]["Name"]
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
archived ? {active: active_rocks, archived: get_archived_rocks(user_id: @user_id)} : active_rocks
|
36
|
-
end
|
37
|
-
|
38
|
-
# Creates a new rock
|
39
|
-
#
|
40
|
-
# @param title [String] the title of the new rock
|
41
|
-
# @param meeting_id [Integer] the ID of the meeting associated with the rock
|
42
|
-
# @param user_id [Integer] the ID of the user responsible for the rock (default: initialized user ID)
|
43
|
-
# @return [Hash] a hash containing the new rock's details
|
44
|
-
# @example
|
45
|
-
# client.rock.create(title: "New Rock", meeting_id: 1)
|
46
|
-
# #=> { rock_id: 1, title: "New Rock", meeting_id: 1, ... }
|
47
|
-
def create(title:, meeting_id:, user_id: @user_id)
|
48
|
-
payload = {title: title, accountableUserId: user_id}.to_json
|
49
|
-
response = @conn.post("/api/v1/L10/#{meeting_id}/rocks", payload).body
|
50
|
-
{
|
51
|
-
rock_id: response["Id"],
|
52
|
-
title: title,
|
53
|
-
meeting_id: meeting_id,
|
54
|
-
meeting_name: response["Origins"][0]["Name"],
|
55
|
-
user_id: user_id,
|
56
|
-
user_name: response["Owner"]["Name"],
|
57
|
-
created_at: DateTime.parse(response["CreateTime"])
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
# Deletes a rock
|
62
|
-
#
|
63
|
-
# @param rock_id [Integer] the ID of the rock to delete
|
64
|
-
# @return [Hash] a hash containing the status of the delete operation
|
65
|
-
# @example
|
66
|
-
# client.rock.delete(1)
|
67
|
-
# #=> { status: 200 }
|
68
|
-
def delete(rock_id)
|
69
|
-
response = @conn.delete("/api/v1/rocks/#{rock_id}")
|
70
|
-
{status: response.status}
|
71
|
-
end
|
72
|
-
|
73
|
-
# Updates a rock
|
74
|
-
#
|
75
|
-
# @param rock_id [Integer] the ID of the rock to update
|
76
|
-
# @param title [String] the new title of the rock
|
77
|
-
# @param accountable_user [Integer] the ID of the user responsible for the rock (default: initialized user ID)
|
78
|
-
# @return [Hash] a hash containing the status of the update operation
|
79
|
-
# @example
|
80
|
-
# client.rock.update(rock_id: 1, title: "Updated Rock")
|
81
|
-
# #=> { status: 200 }
|
82
|
-
def update(rock_id:, title:, accountable_user: @user_id)
|
83
|
-
payload = {title: title, accountableUserId: accountable_user}.to_json
|
84
|
-
response = @conn.put("/api/v1/rocks/#{rock_id}", payload)
|
85
|
-
{status: response.status}
|
86
|
-
end
|
87
|
-
|
88
|
-
private
|
89
|
-
|
90
|
-
# Retrieves all archived rocks for a specific user (private method)
|
91
|
-
#
|
92
|
-
# @param user_id [Integer] the ID of the user (default is the initialized user ID)
|
93
|
-
# @return [Array<Hash>] an array of hashes containing archived rock details
|
94
|
-
# @example
|
95
|
-
# rock.send(:get_archived_rocks)
|
96
|
-
# #=> [{ id: 1, title: "Archived Rock", created_at: "2024-06-10", ... }, ...]
|
97
|
-
def get_archived_rocks(user_id: @user_id)
|
98
|
-
response = @conn.get("archivedrocks/user/#{user_id}").body
|
99
|
-
response.map do |rock|
|
100
|
-
{
|
101
|
-
id: rock["Id"],
|
102
|
-
title: rock["Name"],
|
103
|
-
created_at: rock["CreateTime"],
|
104
|
-
due_date: rock["DueDate"],
|
105
|
-
status: rock["Complete"] ? "Complete" : "Incomplete"
|
106
|
-
}
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|