Module: ChatWork::Room

Defined in:
lib/chatwork/room.rb

Class Method Summary collapse

Class Method Details

.create(description: nil, icon_preset: nil, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, name:, link: nil, link_code: nil, link_need_acceptance: nil) {|response_body, response_header| ... } ⇒ Hashie::Mash

Create a new group chat

Examples:

response format

{
  "room_id": 1234
}

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Hashie::Mash)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)

See Also:



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/chatwork/room.rb', line 65

def self.create(description: nil, icon_preset: nil, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, name:,
                link: nil, link_code: nil, link_need_acceptance: nil, &block)
  ChatWork.client.create_room(
    description:          description,
    icon_preset:          icon_preset,
    members_admin_ids:    members_admin_ids,
    members_member_ids:   members_member_ids,
    members_readonly_ids: members_readonly_ids,
    name:                 name,
    link:                 link,
    link_code:            link_code,
    link_need_acceptance: link_need_acceptance,
    &block
  )
end

.destroy(room_id:, action_type:) {|response_body, response_header| ... } ⇒ Object

Leave/Delete a group chat

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Hashie::Mash)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)

See Also:



153
154
155
# File 'lib/chatwork/room.rb', line 153

def self.destroy(room_id:, action_type:, &block)
  ChatWork.client.destroy_room(room_id: room_id, action_type: action_type, &block)
end

.find(room_id:) {|response_body, response_header| ... } ⇒ Hashie::Mash

Get chat name, icon, and Type (my, direct, or group)

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,
  "description": "room description text"
}

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Hashie::Mash)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)

See Also:



113
114
115
# File 'lib/chatwork/room.rb', line 113

def self.find(room_id:, &block)
  ChatWork.client.find_room(room_id: room_id, &block)
end

.get {|response_body, response_header| ... } ⇒ Array<Hashie::Mash>

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
  }
]

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Array<Hashie::Mash>)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)

See Also:



32
33
34
# File 'lib/chatwork/room.rb', line 32

def self.get(&block)
  ChatWork.client.get_rooms(&block)
end

.update(room_id:, description: nil, icon_preset: nil, name: nil) {|response_body, response_header| ... } ⇒ Hashie::Mash

Change the title and icon type of the specified chat

Examples:

response format

{
  "room_id": 1234
}

Yields:

  • (response_body, response_header)

    if block was given, return response body and response header through block arguments

Yield Parameters:

  • response_body (Hashie::Mash)

    response body

  • response_header (Hash<String, String>)

    response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)

See Also:



138
139
140
# File 'lib/chatwork/room.rb', line 138

def self.update(room_id:, description: nil, icon_preset: nil, name: nil, &block)
  ChatWork.client.update_room(room_id: room_id, description: description, icon_preset: icon_preset, name: name, &block)
end