lib/bloomy/operations/meetings.rb in bloomy-0.3.0 vs lib/bloomy/operations/meetings.rb in bloomy-0.4.2
- old
+ new
@@ -1,28 +1,29 @@
# frozen_string_literal: true
+require "bloomy/utils/get_user_id"
+
# Class to handle all the operations related to meeting
# @note
# This class is already initialized via the client and usable as `client.measurable.method`
class Meeting
+ include Bloomy::Utilities::UserIdUtility
# Initializes a new Meeting instance
#
# @param conn [Object] the connection object to interact with the API
- # @param user_id [Integer] the ID of the user
- def initialize(conn, user_id)
+ def initialize(conn)
@conn = conn
- @user_id = user_id
end
# Lists all meetings for a specific user
#
# @param user_id [Integer] the ID of the user (default is the initialized user ID)
# @return [Array<Hash>] an array of hashes containing meeting details
# @example
# client.meeting.list
# #=> [{ id: 123, name: "Team Meeting" }, ...]
- def list(user_id: @user_id)
+ def list(user_id = self.user_id)
response = @conn.get("L10/#{user_id}/list").body
response.map { |meeting| {id: meeting["Id"], name: meeting["Name"]} }
end
# Lists all attendees for a specific meeting
@@ -146,10 +147,10 @@
# @param attendees [Array<Integer>] a list of user IDs to add as attendees
# @return [Hash] a hash containing the new meeting's ID and title, and the list of attendees
# @example
# client.meeting.create(title: "New Meeting", attendees: [2, 3])
# #=> { meeting_id: 1, title: "New Meeting", attendees: [2, 3] }
- def create(title:, add_self: true, attendees: [])
+ 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|