Class: Bloomy::Meeting

Inherits:
Object
  • Object
show all
Includes:
Utilities::Transform, Utilities::UserIdUtility, Utilities::Validation
Defined in:
lib/bloomy/operations/meetings.rb

Overview

Note:

This class is already initialized via the client and usable as ‘client.meeting.method`

Class to handle all the operations related to meeting

Constant Summary

Constants included from Utilities::Transform

Utilities::Transform::DATE_FIELDS

Instance Method Summary collapse

Methods included from Utilities::Validation

#validate_id!, #validate_title!

Methods included from Utilities::Transform

#transform_array, #transform_response

Methods included from Utilities::UserIdUtility

#user_id

Constructor Details

#initialize(conn) ⇒ Meeting

Initializes a new Meeting instance

Parameters:

  • conn (Object)

    the connection object to interact with the API



17
18
19
# File 'lib/bloomy/operations/meetings.rb', line 17

def initialize(conn)
  @conn = conn
end

Instance Method Details

#attendees(meeting_id) ⇒ Array<HashWithIndifferentAccess>

Lists all attendees for a specific meeting

Examples:

client.meeting.attendees(1)
#=> [{ name: "John Doe", id: 1 }, ...]

Parameters:

  • meeting_id (Integer)

    the ID of the meeting

Returns:

  • (Array<HashWithIndifferentAccess>)

    an array of hashes containing attendee details

Raises:



50
51
52
53
54
55
# File 'lib/bloomy/operations/meetings.rb', line 50

def attendees(meeting_id)
  response = @conn.get("L10/#{meeting_id}/attendees")
  data = handle_response(response, context: "get meeting attendees")

  transform_array(data.map { |attendee| {id: attendee.dig("Id"), name: attendee.dig("Name")} })
end

#create(title:, add_self: true, attendees: []) ⇒ HashWithIndifferentAccess

Creates a new meeting

Examples:

client.meeting.create(title: "New Meeting", attendees: [2, 3])
#=> { id: 1, title: "New Meeting", attendees: [2, 3] }

Parameters:

  • title (String)

    the title of the new meeting

  • add_self (Boolean) (defaults to: true)

    whether to add the current user as an attendee (default: true)

  • attendees (Array<Integer>) (defaults to: [])

    a list of user IDs to add as attendees

Returns:

  • (HashWithIndifferentAccess)

    a hash containing id, title and attendees array

Raises:

  • (ArgumentError)

    if title is empty

  • (ApiError)

    when the API request fails



180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/bloomy/operations/meetings.rb', line 180

def create(title:, add_self: true, attendees: [])
  validate_title!(title)

  payload = {title: title, addSelf: add_self}.to_json
  response = @conn.post("L10/create", payload)
  data = handle_response(response, context: "create meeting")

  meeting_id = data.dig("meetingId")
  attendees.each do |attendee|
    @conn.post("L10/#{meeting_id}/attendees/#{attendee}")
  end

  transform_response({id: meeting_id, title: title, attendees: attendees})
end

#delete(meeting_id) ⇒ Boolean

Deletes a meeting

Examples:

client.meeting.delete(1)
#=> true

Parameters:

  • meeting_id (Integer)

    the ID of the meeting to delete

Returns:

  • (Boolean)

    true if deletion was successful

Raises:



204
205
206
207
# File 'lib/bloomy/operations/meetings.rb', line 204

def delete(meeting_id)
  response = @conn.delete("L10/#{meeting_id}")
  handle_response!(response, context: "delete meeting")
end

#details(meeting_id, include_closed: false) ⇒ HashWithIndifferentAccess

Retrieves details of a specific meeting

Examples:

client.meeting.details(1)
#=> { id: 1, name: "Team Meeting", attendees: [...], issues: [...], todos: [...], metrics: [...] }

Parameters:

  • meeting_id (Integer)

    the ID of the meeting

  • include_closed (Boolean) (defaults to: false)

    whether to include closed issues and todos (default: false)

Returns:

  • (HashWithIndifferentAccess)

    a hash containing detailed information about the meeting

Raises:



157
158
159
160
161
162
163
164
165
166
167
# File 'lib/bloomy/operations/meetings.rb', line 157

def details(meeting_id, include_closed: false)
  meeting = list.find { |m| m[:id] == meeting_id }
  transform_response({
    id: meeting&.dig(:id),
    title: meeting&.dig(:title),
    attendees: attendees(meeting_id),
    issues: issues(meeting_id, include_closed: include_closed),
    todos: todos(meeting_id, include_closed: include_closed),
    metrics: metrics(meeting_id)
  })
end

#issues(meeting_id, include_closed: false) ⇒ Array<HashWithIndifferentAccess>

Lists all issues for a specific meeting

Examples:

client.meeting.issues(1)
#=> [{ id: 1, title: "Issue Title", created_at: "2024-06-10", ... }, ...]

Parameters:

  • meeting_id (Integer)

    the ID of the meeting

  • include_closed (Boolean) (defaults to: false)

    whether to include closed issues (default: false)

Returns:

  • (Array<HashWithIndifferentAccess>)

    an array of hashes containing issue details

Raises:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/bloomy/operations/meetings.rb', line 67

def issues(meeting_id, include_closed: false)
  response = @conn.get("L10/#{meeting_id}/issues?include_resolved=#{include_closed}")
  data = handle_response(response, context: "get meeting issues")

  transform_array(data.map do |issue|
    {
      id: issue.dig("Id"),
      title: issue.dig("Name"),
      notes_url: issue.dig("DetailsUrl"),
      created_at: issue.dig("CreateTime"),
      completed_at: issue.dig("CloseTime"),
      user_id: issue.dig("Owner", "Id"),
      user_name: issue.dig("Owner", "Name"),
      meeting_id: meeting_id,
      meeting_title: issue.dig("Origin")
    }
  end)
end

#list(user_id: nil) ⇒ Array<HashWithIndifferentAccess>

Lists all meetings for a specific user

Examples:

client.meeting.list
#=> [{ id: 123, title: "Team Meeting" }, ...]

List meetings for specific user

client.meeting.list(user_id: 42)

Parameters:

  • user_id (Integer, nil) (defaults to: nil)

    the ID of the user (default: current user)

Returns:

  • (Array<HashWithIndifferentAccess>)

    an array of hashes containing meeting details

Raises:



33
34
35
36
37
38
39
# File 'lib/bloomy/operations/meetings.rb', line 33

def list(user_id: nil)
  user_id ||= self.user_id
  response = @conn.get("L10/#{user_id}/list")
  data = handle_response(response, context: "list meetings")

  transform_array(data.map { |meeting| {id: meeting.dig("Id"), title: meeting.dig("Name")} })
end

#metrics(meeting_id) ⇒ Array<HashWithIndifferentAccess>

Lists all metrics for a specific meeting

Examples:

client.meeting.metrics(1)
#=> [{ id: 1, name: "Sales", target: 100, operator: ">", format: "currency", ... }, ...]

Parameters:

  • meeting_id (Integer)

    the ID of the meeting

Returns:

  • (Array<HashWithIndifferentAccess>)

    an array of hashes containing metric details

Raises:



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/bloomy/operations/meetings.rb', line 124

def metrics(meeting_id)
  response = @conn.get("L10/#{meeting_id}/measurables")
  data = handle_response(response, context: "get meeting metrics")

  return [] if data.nil? || !data.is_a?(Array)

  transform_array(data.filter_map do |measurable|
    next unless measurable.dig("Id") && measurable.dig("Name")

    {
      id: measurable.dig("Id"),
      title: measurable.dig("Name").to_s.strip,
      target: measurable.dig("Target").to_f,
      operator: measurable.dig("Direction").to_s,
      format: measurable.dig("Modifiers").to_s,
      user_id: measurable.dig("Owner", "Id"),
      user_name: measurable.dig("Owner", "Name"),
      admin_id: measurable.dig("Admin", "Id"),
      admin_name: measurable.dig("Admin", "Name")
    }
  end)
end

#todos(meeting_id, include_closed: false) ⇒ Array<HashWithIndifferentAccess>

Lists all todos for a specific meeting

Examples:

client.meeting.todos(1)
#=> [{ id: 1, title: "Todo Title", due_date: "2024-06-12", ... }, ...]

Parameters:

  • meeting_id (Integer)

    the ID of the meeting

  • include_closed (Boolean) (defaults to: false)

    whether to include closed todos (default: false)

Returns:

  • (Array<HashWithIndifferentAccess>)

    an array of hashes containing todo details

Raises:



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/bloomy/operations/meetings.rb', line 96

def todos(meeting_id, include_closed: false)
  response = @conn.get("L10/#{meeting_id}/todos?INCLUDE_CLOSED=#{include_closed}")
  data = handle_response(response, context: "get meeting todos")

  transform_array(data.map do |todo|
    {
      id: todo.dig("Id"),
      title: todo.dig("Name"),
      due_date: todo.dig("DueDate"),
      notes_url: todo.dig("DetailsUrl"),
      status: todo.dig("Complete") ? "Complete" : "Incomplete",
      created_at: todo.dig("CreateTime"),
      completed_at: todo.dig("CompleteTime"),
      user_id: todo.dig("Owner", "Id"),
      user_name: todo.dig("Owner", "Name")
    }
  end)
end