Module: ChatWork::Client::MemberMethods

Included in:
ChatWork::Client
Defined in:
lib/chatwork/client/member_methods.rb

Instance Method Summary collapse

Instance Method Details

#get_members(room_id:) {|response_body, response_header| ... } ⇒ Array<Hashie::Mash>

Get the list of all chat members associated with the specified chat

Examples:

response format

[
  {
    "account_id": 123,
    "role": "member",
    "name": "John Smith",
    "chatwork_id": "tarochatworkid",
    "organization_id": 101,
    "organization_name": "Hello Company",
    "department": "Marketing",
    "avatar_image_url": "https://example.com/abc.png"
  }
]

Parameters:

  • room_id (Integer)

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)

Returns:

  • (Array<Hashie::Mash>)

See Also:



28
29
30
# File 'lib/chatwork/client/member_methods.rb', line 28

def get_members(room_id:, &block)
  get("/rooms/#{room_id}/members", &block)
end

#update_all_members(room_id:, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil) {|response_body, response_header| ... } ⇒ Hashie::Mash

Change associated members of group chat at once

Examples:

response format

{
  "admin": [123, 542, 1001],
  "member": [10, 103],
  "readonly": [6, 11]
}

Parameters:

  • room_id (Integer)
  • 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.

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)

Returns:

  • (Hashie::Mash)

See Also:



55
56
57
58
59
60
61
62
63
# File 'lib/chatwork/client/member_methods.rb', line 55

def update_all_members(room_id:, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, &block)
  params = {
    members_admin_ids: Array(members_admin_ids).join(","),
  }
  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

  put("/rooms/#{room_id}/members", params, &block)
end