Class: ChatWork::Room

Inherits:
Entity
  • Object
show all
Defined in:
lib/chatwork/room.rb

Constant Summary

Constants included from Operations

Operations::ACCEPT_PARAMS_ID

Instance Attribute Summary

Attributes inherited from Entity

#attributes

Attributes included from Operations

#assign_path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

convert, hash_compact, #initialize

Methods included from Operations

#define_create, #define_get, #install_class_operations

Constructor Details

This class inherits a constructor from ChatWork::Entity

Class Method Details

.create(description: nil, icon_preset: nil, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, name:) ⇒ Hash

Create a new group chat

Examples:

response format

{
  "room_id": 1234
}

Parameters:

  • description (String) (defaults to: nil)

    Description of the group chat

  • icon_preset (String) (defaults to: nil)

    Type of the group chat icon (group, check, document, meeting, event, project, business, study, security, star, idea, heart, magcup, beer, music, sports, travel)

  • members_admin_ids (Array<Integer>, String)

    List of user IDs who will be given administrator permission for the group chat. At least one user must be specified as an administrator.

  • members_member_ids (Array<Integer>, String) (defaults to: nil)

    List of user IDs who will be given member permission for the group chat.

  • members_readonly_ids (Array<Integer>, String) (defaults to: nil)

    List of user IDs who will be given read-only permission for the group chat.

  • name (String)

    Title of the group chat.

Returns:

  • (Hash)

See Also:


54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/chatwork/room.rb', line 54

def self.create(description: nil, icon_preset: nil, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, name:)
  params = {
    description:       description,
    icon_preset:       icon_preset,
    members_admin_ids: Array(members_admin_ids).join(","),
    name:              name,
  }
  params[:members_member_ids] = Array(members_member_ids).join(",") if members_member_ids
  params[:members_readonly_ids] = Array(members_readonly_ids).join(",") if members_readonly_ids

  _create(hash_compact(params))
end

.getArray<Hash>

Get the list of all chats on your account

Examples:

response format

[
  {
    "room_id": 123,
    "name": "Group Chat Name",
    "type": "group",
    "role": "admin",
    "sticky": false,
    "unread_num": 10,
    "mention_num": 1,
    "mytask_num": 0,
    "message_num": 122,
    "file_num": 10,
    "task_num": 17,
    "icon_path": "https://example.com/ico_group.png",
    "last_update_time": 1298905200
  }
]

Returns:

  • (Array<Hash>)

See Also:


29
30
31
# File 'lib/chatwork/room.rb', line 29

def self.get
  _get
end

.pathObject

rubocop:enable Metrics/ParameterLists


69
70
71
# File 'lib/chatwork/room.rb', line 69

def self.path
  "/rooms"
end

Instance Method Details

#pathObject


73
74
75
# File 'lib/chatwork/room.rb', line 73

def path
  "/rooms"
end