Class: Bloomy::Meeting

Inherits:
Object
  • Object
show all
Includes:
Utilities::UserIdUtility
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

Instance Method Summary collapse

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



14
15
16
# File 'lib/bloomy/operations/meetings.rb', line 14

def initialize(conn)
  @conn = conn
end

Instance Method Details

#attendees(meeting_id) ⇒ Array<Hash>

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<Hash>)

    an array of hashes containing attendee details



37
38
39
40
# File 'lib/bloomy/operations/meetings.rb', line 37

def attendees(meeting_id)
  response = @conn.get("L10/#{meeting_id}/attendees").body
  response.map { |attendee| {id: attendee["Id"], name: attendee["Name"]} }
end

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

Creates a new meeting

Examples:

client.meeting.create("New Meeting", attendees: [2, 3])
#=> { meeting_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:

  • (Hash)

    a hash containing meeting_id, title and attendees array



149
150
151
152
153
154
155
156
157
158
# File 'lib/bloomy/operations/meetings.rb', line 149

def create(title, add_self: true, attendees: [])
  payload = {title: title, addSelf: add_self}.to_json
  response = @conn.post("L10/create", payload).body
  meeting_id = response["meetingId"]
  meeting_details = {meeting_id: meeting_id, title: title}
  attendees.each do |attendee|
    @conn.post("L10/#{meeting_id}/attendees/#{attendee}")
  end
  meeting_details.merge(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



167
168
169
170
# File 'lib/bloomy/operations/meetings.rb', line 167

def delete(meeting_id)
  response = @conn.delete("L10/#{meeting_id}")
  response.success?
end

#details(meeting_id, include_closed: false) ⇒ Hash

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:

  • (Hash)

    a hash containing detailed information about the meeting



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/bloomy/operations/meetings.rb', line 128

def details(meeting_id, include_closed: false)
  meeting = list.find { |m| m[:id] == meeting_id }
  {
    id: meeting[:id],
    title: meeting[: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<Hash>

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<Hash>)

    an array of hashes containing issue details



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/bloomy/operations/meetings.rb', line 50

def issues(meeting_id, include_closed: false)
  response = @conn.get("L10/#{meeting_id}/issues?include_resolved=#{include_closed}").body
  response.map do |issue|
    {
      id: issue["Id"],
      title: issue["Name"],
      notes_url: issue["DetailsUrl"],
      created_at: issue["CreateTime"],
      completed_at: issue["CloseTime"],
      user_id: issue.dig("Owner", "Id"),
      user_name: issue.dig("Owner", "Name"),
      meeting_id: meeting_id,
      meeting_title: issue["Origin"]
    }
  end
end

#list(user_id = self.user_id) ⇒ Array<Hash>

Lists all meetings for a specific user

Examples:

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

Parameters:

  • user_id (Integer) (defaults to: self.user_id)

    the ID of the user (default is the initialized user ID)

Returns:

  • (Array<Hash>)

    an array of hashes containing meeting details



25
26
27
28
# File 'lib/bloomy/operations/meetings.rb', line 25

def list(user_id = self.user_id)
  response = @conn.get("L10/#{user_id}/list").body
  response.map { |meeting| {id: meeting["Id"], title: meeting["Name"]} }
end

#metrics(meeting_id) ⇒ Array<Hash>

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<Hash>)

    an array of hashes containing metric details



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/bloomy/operations/meetings.rb', line 99

def metrics(meeting_id)
  response = @conn.get("L10/#{meeting_id}/measurables").body
  return [] if response.nil? || !response.is_a?(Array)

  response.map do |measurable|
    next unless measurable["Id"] && measurable["Name"]

    {
      id: measurable["Id"],
      title: measurable["Name"].to_s.strip,
      target: measurable["Target"].to_f,
      operator: measurable["Direction"].to_s,
      format: measurable["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.compact
end

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

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<Hash>)

    an array of hashes containing todo details



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/bloomy/operations/meetings.rb', line 75

def todos(meeting_id, include_closed: false)
  response = @conn.get("L10/#{meeting_id}/todos?INCLUDE_CLOSED=#{include_closed}").body
  response.map do |todo|
    {
      id: todo["Id"],
      title: todo["Name"],
      due_date: todo["DueDate"],
      notes_url: todo["DetailsUrl"],
      status: todo["Complete"] ? "Complete" : "Incomplete",
      created_at: todo["CreateTime"],
      completed_at: todo["CompleteTime"],
      user_id: todo.dig("Owner", "Id"),
      user_name: todo.dig("Owner", "Name")
    }
  end
end