<commit_before>module Babili
  module Platform
    class Room < OpenStruct
      def self.path
        "platform/rooms"
      end

      def self.all
        raw_rooms = Babili::Client.get(path)
        raw_rooms["data"].map do |raw_room|
          room    = new(raw_room["attributes"])
          room.id = raw_room["id"]
          room
        end
      end

      def self.create(params = {})
        params = {
          data: {
            id:         params[:id] || params["id"],
            attributes: {
              name: params[:name] || params[:name]
            }
          }
        }
        raw_room = Babili::Client.post(path, params)["data"]
        room     = new(raw_room["attributes"])
        room.id  = raw_room["id"]
        room
      end

      def self.retreive(room_id)
        retreive_path = path + "/#{room_id}"
        raw_room      = Babili::Client.get(retreive_path)["data"]
        room          = new(raw_room["attributes"])
        room.id       = raw_room["id"]
        room
      end

      def delete
        path     = self.class.path + "/#{id}"
        raw_room = Babili::Client.delete(path)["data"]
        room     = self.class.new(raw_room["attributes"])
        room.id  = raw_room["id"]
        room
      end

      def users
        path      = self.class.path + "/#{id}/users"
        raw_users = Babili::Client.get(path)
        raw_users["data"].map do |raw_user|
          user    = Babili::Platform::User.new(raw_user["attributes"])
          user.id = raw_user["id"]
          user
        end<commit_msg>add user_ids params on message create<commit_after>module Babili
  module Platform
    class Room < OpenStruct
      def self.path
        "platform/rooms"
      end

      def self.all
        raw_rooms = Babili::Client.get(path)
        raw_rooms["data"].map do |raw_room|
          room    = new(raw_room["attributes"])
          room.id = raw_room["id"]
          room
        end
      end

      def self.create(params = {})
        formatted_params = {
          data: {
            id:         params[:id] || params["id"],
            attributes: {
              name: params[:name] || params[:name]
            },
            relationships: {}
          }
        }
        if params["user_ids"] || params[:user_ids]
          formatted_params[:relationships][:users] = params[:user_ids].map do |user_id|
            { id: user_id }
          end
        end
        raw_room = Babili::Client.post(path, formatted_params)["data"]
        room     = new(raw_room["attributes"])
        room.id  = raw_room["id"]
        room
      end

      def self.retreive(room_id)
        retreive_path = path + "/#{room_id}"
        raw_room      = Babili::Client.get(retreive_path)["data"]
        room          = new(raw_room["attributes"])
        room.id       = raw_room["id"]
        room
      end

      def delete
        path     = self.class.path + "/#{id}"
        raw_room = Babili::Client.delete(path)["data"]
        room     = self.class.new(raw_room["attributes"])
        room.id  = raw_room["id"]
        room
      end

      def users
        path      = self.class.path + "/#{id}/users"
        raw_users = Babili::Client.get(path)
        raw_users["data"].map do |raw_user|
          user    = Babili::Platform::User.new(raw_user["attributes"])
          user.id = raw_user["id"]
          user
        end
{'fraction_non_alphanumeric': 0.12965150620200827, 'fraction_numerical': 0.0, 'mean_word_length': 1.641965678627145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1178522', 'n_tokens_mistral': 1022, 'n_tokens_neox': 1018, 'n_words': 190}