chatwork 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +113 -38
- data/lib/chatwork.rb +35 -3
- data/lib/chatwork/base_client.rb +9 -4
- data/lib/chatwork/client.rb +43 -8
- data/lib/chatwork/client/contacts_methods.rb +29 -0
- data/lib/chatwork/client/file_methods.rb +67 -0
- data/lib/chatwork/client/incoming_request_methods.rb +77 -0
- data/lib/chatwork/client/invitation_link_methods.rb +110 -0
- data/lib/chatwork/client/me_methods.rb +38 -0
- data/lib/chatwork/client/member_methods.rb +64 -0
- data/lib/chatwork/client/message_methods.rb +178 -0
- data/lib/chatwork/client/my_status_methods.rb +25 -0
- data/lib/chatwork/client/my_task_methods.rb +41 -0
- data/lib/chatwork/client/room_methods.rb +156 -0
- data/lib/chatwork/client/task_methods.rb +109 -0
- data/lib/chatwork/contacts.rb +6 -4
- data/lib/chatwork/converter.rb +18 -0
- data/lib/chatwork/file.rb +12 -6
- data/lib/chatwork/incoming_request.rb +18 -8
- data/lib/chatwork/invitation_link.rb +24 -20
- data/lib/chatwork/me.rb +6 -4
- data/lib/chatwork/member.rb +18 -12
- data/lib/chatwork/message.rb +42 -16
- data/lib/chatwork/my_status.rb +6 -4
- data/lib/chatwork/my_task.rb +6 -4
- data/lib/chatwork/oauth_client.rb +10 -2
- data/lib/chatwork/oauth_client/token_methods.rb +25 -0
- data/lib/chatwork/room.rb +37 -20
- data/lib/chatwork/task.rb +18 -14
- data/lib/chatwork/token.rb +1 -7
- data/lib/chatwork/version.rb +1 -1
- data/spec/lib/chatwork/client/contacts_methods_spec.rb +11 -0
- data/spec/lib/chatwork/client/file_methods_spec.rb +37 -0
- data/spec/lib/chatwork/client/incoming_request_methods_spec.rb +35 -0
- data/spec/lib/chatwork/client/invitation_link_methods_spec.rb +71 -0
- data/spec/lib/chatwork/client/me_methods_spec.rb +21 -0
- data/spec/lib/chatwork/client/member_methods_spec.rb +47 -0
- data/spec/lib/chatwork/client/message_methods_spec.rb +102 -0
- data/spec/lib/chatwork/client/my_status_methods_spec.rb +11 -0
- data/spec/lib/chatwork/client/my_task_methods_spec.rb +20 -0
- data/spec/lib/chatwork/client/room_methods_spec.rb +111 -0
- data/spec/lib/chatwork/client/task_methods_spec.rb +80 -0
- data/spec/lib/chatwork/client_spec.rb +8 -1
- data/spec/lib/chatwork/contacts_spec.rb +2 -2
- data/spec/lib/chatwork/{entity_methods_spec.rb → converter_spec.rb} +2 -2
- data/spec/lib/chatwork/file_spec.rb +2 -2
- data/spec/lib/chatwork/incoming_request_spec.rb +3 -3
- data/spec/lib/chatwork/invitation_link_spec.rb +4 -2
- data/spec/lib/chatwork/me_spec.rb +3 -21
- data/spec/lib/chatwork/member_spec.rb +2 -1
- data/spec/lib/chatwork/message_spec.rb +7 -7
- data/spec/lib/chatwork/my_status_spec.rb +1 -1
- data/spec/lib/chatwork/my_task_spec.rb +1 -0
- data/spec/lib/chatwork/{token_spec.rb → oauth_client/token_methods_spec.rb} +4 -7
- data/spec/lib/chatwork/oauth_client_spec.rb +7 -1
- data/spec/lib/chatwork/room_spec.rb +5 -2
- data/spec/lib/chatwork/task_spec.rb +3 -0
- data/spec/support/contexts/api_context.rb +4 -3
- data/spec/support/examples/a_chatwork_api.rb +22 -5
- data/spec/support/utils/raml_parser.rb +2 -3
- metadata +42 -8
- data/lib/chatwork/entity_methods.rb +0 -36
@@ -0,0 +1,77 @@
|
|
1
|
+
module ChatWork::Client::IncomingRequestMethods
|
2
|
+
# You can get the list of contact approval request you received
|
3
|
+
#
|
4
|
+
# (*This method returns up to 100 entries. We are planning to implement pagination to support larger number of data retrieval)
|
5
|
+
#
|
6
|
+
# @see http://developer.chatwork.com/ja/endpoint_incoming_requests.html#GET-incoming_requests
|
7
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
8
|
+
#
|
9
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
10
|
+
# @yieldparam response_body [Array<Hashie::Mash>] response body
|
11
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
12
|
+
#
|
13
|
+
# @return [Array<Hashie::Mash>]
|
14
|
+
#
|
15
|
+
# @example response format
|
16
|
+
# [
|
17
|
+
# {
|
18
|
+
# "request_id": 123,
|
19
|
+
# "account_id": 363,
|
20
|
+
# "message": "hogehoge",
|
21
|
+
# "name": "John Smith",
|
22
|
+
# "chatwork_id": "tarochatworkid",
|
23
|
+
# "organization_id": 101,
|
24
|
+
# "organization_name": "Hello Company",
|
25
|
+
# "department": "Marketing",
|
26
|
+
# "avatar_image_url": "https://example.com/abc.png"
|
27
|
+
# }
|
28
|
+
# ]
|
29
|
+
def get_incoming_requests(&block)
|
30
|
+
get("/incoming_requests", &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
# You can approve a contact approval request you received
|
34
|
+
#
|
35
|
+
# @see http://developer.chatwork.com/ja/endpoint_incoming_requests.html#PUT-incoming_requests-request_id
|
36
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
37
|
+
#
|
38
|
+
# @param request_id [Integer]
|
39
|
+
#
|
40
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
41
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
42
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
43
|
+
#
|
44
|
+
# @return [Hashie::Mash]
|
45
|
+
#
|
46
|
+
# @example response format
|
47
|
+
# {
|
48
|
+
# "account_id": 363,
|
49
|
+
# "room_id": 1234,
|
50
|
+
# "name": "John Smith",
|
51
|
+
# "chatwork_id": "tarochatworkid",
|
52
|
+
# "organization_id": 101,
|
53
|
+
# "organization_name": "Hello Company",
|
54
|
+
# "department": "Marketing",
|
55
|
+
# "avatar_image_url": "https://example.com/abc.png"
|
56
|
+
# }
|
57
|
+
def update_incoming_request(request_id:, &block)
|
58
|
+
put("/incoming_requests/#{request_id}", &block)
|
59
|
+
end
|
60
|
+
|
61
|
+
# You can decline a contact approval request you received
|
62
|
+
#
|
63
|
+
# @see http://developer.chatwork.com/ja/endpoint_incoming_requests.html#DELETE-incoming_requests-request_id
|
64
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
65
|
+
#
|
66
|
+
# @param request_id [Integer]
|
67
|
+
#
|
68
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
69
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
70
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
71
|
+
def destroy_incoming_request(request_id:, &block)
|
72
|
+
delete("/incoming_requests/#{request_id}", &block)
|
73
|
+
end
|
74
|
+
|
75
|
+
alias_method :approve_incoming_request, :update_incoming_request
|
76
|
+
alias_method :decline_incoming_request, :destroy_incoming_request
|
77
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module ChatWork::Client::InvitationLinkMethods
|
2
|
+
# Get invitation link
|
3
|
+
#
|
4
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-link
|
5
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
6
|
+
#
|
7
|
+
# @param room_id [Integer]
|
8
|
+
#
|
9
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
10
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
11
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
12
|
+
#
|
13
|
+
# @return [Hashie::Mash]
|
14
|
+
#
|
15
|
+
# @example response format
|
16
|
+
# {
|
17
|
+
# "public": true,
|
18
|
+
# "url": "https://example.chatwork.com/g/randomcode42",
|
19
|
+
# "need_acceptance": true,
|
20
|
+
# "description": "Link description text"
|
21
|
+
# }
|
22
|
+
def get_invitation_link(room_id:, &block)
|
23
|
+
get("/rooms/#{room_id}/link", &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create invitation link
|
27
|
+
#
|
28
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms-room_id-link
|
29
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
30
|
+
#
|
31
|
+
# @param room_id [Integer]
|
32
|
+
# @param code [String] link path (default. random string)
|
33
|
+
# @param description [String] description of link page
|
34
|
+
# @param need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
|
35
|
+
#
|
36
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
37
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
38
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
39
|
+
#
|
40
|
+
# @return [Hashie::Mash]
|
41
|
+
#
|
42
|
+
# @example response format
|
43
|
+
# {
|
44
|
+
# "public": true,
|
45
|
+
# "url": "https://example.chatwork.com/g/unique-link-name",
|
46
|
+
# "need_acceptance": true,
|
47
|
+
# "description": "This is a public room for topic A."
|
48
|
+
# }
|
49
|
+
def create_invitation_link(room_id:, code: nil, description: nil, need_acceptance: nil, &block)
|
50
|
+
params = {
|
51
|
+
code: code,
|
52
|
+
description: description,
|
53
|
+
need_acceptance: boolean_to_integer(need_acceptance),
|
54
|
+
}
|
55
|
+
post("/rooms/#{room_id}/link", params, &block)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Update invitation link
|
59
|
+
#
|
60
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-link
|
61
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
62
|
+
#
|
63
|
+
# @param room_id [Integer]
|
64
|
+
# @param code [String] link path (default. random string)
|
65
|
+
# @param description [String] description of link page
|
66
|
+
# @param need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
|
67
|
+
#
|
68
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
69
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
70
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
71
|
+
#
|
72
|
+
# @return [Hashie::Mash]
|
73
|
+
#
|
74
|
+
# @example response format
|
75
|
+
# {
|
76
|
+
# "public": true,
|
77
|
+
# "url": "https://example.chatwork.com/g/another_link_name",
|
78
|
+
# "need_acceptance": false,
|
79
|
+
# "description": "Public room for everybody"
|
80
|
+
# }
|
81
|
+
def update_invitation_link(room_id:, code: nil, description: nil, need_acceptance: nil, &block)
|
82
|
+
params = {
|
83
|
+
code: code,
|
84
|
+
description: description,
|
85
|
+
need_acceptance: boolean_to_integer(need_acceptance),
|
86
|
+
}
|
87
|
+
put("/rooms/#{room_id}/link", params, &block)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Delete invitation link
|
91
|
+
#
|
92
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#DELETE-rooms-room_id-link
|
93
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
94
|
+
#
|
95
|
+
# @param room_id [Integer]
|
96
|
+
#
|
97
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
98
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
99
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
100
|
+
#
|
101
|
+
# @return [Hashie::Mash]
|
102
|
+
#
|
103
|
+
# @example response format
|
104
|
+
# {
|
105
|
+
# "public": false
|
106
|
+
# }
|
107
|
+
def destroy_invitation_link(room_id:, &block)
|
108
|
+
delete("/rooms/#{room_id}/link", &block)
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ChatWork::Client::MeMethods
|
2
|
+
# Get your account information
|
3
|
+
#
|
4
|
+
# @see http://developer.chatwork.com/ja/endpoint_me.html#GET-me
|
5
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
6
|
+
#
|
7
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
8
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
9
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
10
|
+
#
|
11
|
+
# @return [Hashie::Mash]
|
12
|
+
#
|
13
|
+
# @example response format
|
14
|
+
# {
|
15
|
+
# "account_id": 123,
|
16
|
+
# "room_id": 322,
|
17
|
+
# "name": "John Smith",
|
18
|
+
# "chatwork_id": "tarochatworkid",
|
19
|
+
# "organization_id": 101,
|
20
|
+
# "organization_name": "Hello Company",
|
21
|
+
# "department": "Marketing",
|
22
|
+
# "title": "CMO",
|
23
|
+
# "url": "http://mycompany.example.com",
|
24
|
+
# "introduction": "Self Introduction",
|
25
|
+
# "mail": "taro@example.com",
|
26
|
+
# "tel_organization": "XXX-XXXX-XXXX",
|
27
|
+
# "tel_extension": "YYY-YYYY-YYYY",
|
28
|
+
# "tel_mobile": "ZZZ-ZZZZ-ZZZZ",
|
29
|
+
# "skype": "myskype_id",
|
30
|
+
# "facebook": "myfacebook_id",
|
31
|
+
# "twitter": "mytwitter_id",
|
32
|
+
# "avatar_image_url": "https://example.com/abc.png",
|
33
|
+
# "login_mail": "account@example.com"
|
34
|
+
# }
|
35
|
+
def get_me(&block)
|
36
|
+
get("/me", &block)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module ChatWork::Client::MemberMethods
|
2
|
+
# Get the list of all chat members associated with the specified chat
|
3
|
+
#
|
4
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-members
|
5
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
6
|
+
#
|
7
|
+
# @param room_id [Integer]
|
8
|
+
#
|
9
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
10
|
+
# @yieldparam response_body [Array<Hashie::Mash>] response body
|
11
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
12
|
+
#
|
13
|
+
# @return [Array<Hashie::Mash>]
|
14
|
+
#
|
15
|
+
# @example response format
|
16
|
+
# [
|
17
|
+
# {
|
18
|
+
# "account_id": 123,
|
19
|
+
# "role": "member",
|
20
|
+
# "name": "John Smith",
|
21
|
+
# "chatwork_id": "tarochatworkid",
|
22
|
+
# "organization_id": 101,
|
23
|
+
# "organization_name": "Hello Company",
|
24
|
+
# "department": "Marketing",
|
25
|
+
# "avatar_image_url": "https://example.com/abc.png"
|
26
|
+
# }
|
27
|
+
# ]
|
28
|
+
def get_members(room_id:, &block)
|
29
|
+
get("/rooms/#{room_id}/members", &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Change associated members of group chat at once
|
33
|
+
#
|
34
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-members
|
35
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
36
|
+
#
|
37
|
+
# @param room_id [Integer]
|
38
|
+
# @param members_admin_ids [Array<Integer>, String] List of user IDs who will be given administrator permission for the group chat.
|
39
|
+
# At least one user must be specified as an administrator.
|
40
|
+
# @param members_member_ids [Array<Integer>, String] List of user IDs who will be given member permission for the group chat.
|
41
|
+
# @param members_readonly_ids [Array<Integer>, String] List of user IDs who will be given read-only permission for the group chat.
|
42
|
+
#
|
43
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
44
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
45
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
46
|
+
#
|
47
|
+
# @return [Hashie::Mash]
|
48
|
+
#
|
49
|
+
# @example response format
|
50
|
+
# {
|
51
|
+
# "admin": [123, 542, 1001],
|
52
|
+
# "member": [10, 103],
|
53
|
+
# "readonly": [6, 11]
|
54
|
+
# }
|
55
|
+
def update_all_members(room_id:, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, &block)
|
56
|
+
params = {
|
57
|
+
members_admin_ids: Array(members_admin_ids).join(","),
|
58
|
+
}
|
59
|
+
params[:members_member_ids] = Array(members_member_ids).join(",") if members_member_ids
|
60
|
+
params[:members_readonly_ids] = Array(members_readonly_ids).join(",") if members_readonly_ids
|
61
|
+
|
62
|
+
put("/rooms/#{room_id}/members", params, &block)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
module ChatWork::Client::MessageMethods
|
2
|
+
# Get all messages associated with the specified chat (returns up to 100 entries).
|
3
|
+
#
|
4
|
+
# If the parameter is not set, it returns the next 100 entries from previous call.
|
5
|
+
#
|
6
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-messages
|
7
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
8
|
+
#
|
9
|
+
# @param room_id [Integer]
|
10
|
+
# @param force [Boolean, Integer] Flag which forces to get 100 newest entries regardless of previous calls.
|
11
|
+
#
|
12
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
13
|
+
# @yieldparam response_body [Array<Hashie::Mash>] response body
|
14
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
15
|
+
#
|
16
|
+
# @return [Array<Hashie::Mash>]
|
17
|
+
#
|
18
|
+
# @example response format
|
19
|
+
# [
|
20
|
+
# {
|
21
|
+
# "message_id": "5",
|
22
|
+
# "account": {
|
23
|
+
# "account_id": 123,
|
24
|
+
# "name": "Bob",
|
25
|
+
# "avatar_image_url": "https://example.com/ico_avatar.png"
|
26
|
+
# },
|
27
|
+
# "body": "Hello Chatwork!",
|
28
|
+
# "send_time": 1384242850,
|
29
|
+
# "update_time": 0
|
30
|
+
# }
|
31
|
+
# ]
|
32
|
+
def get_messages(room_id:, force: nil, &block)
|
33
|
+
get("/rooms/#{room_id}/messages", force: boolean_to_integer(force), &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Add new message to the chat
|
37
|
+
#
|
38
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms-room_id-messages
|
39
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
40
|
+
#
|
41
|
+
# @param room_id [Integer]
|
42
|
+
# @param body [String] message body
|
43
|
+
#
|
44
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
45
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
46
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
47
|
+
#
|
48
|
+
# @return [Hashie::Mash]
|
49
|
+
#
|
50
|
+
# @example response format
|
51
|
+
# {
|
52
|
+
# "message_id": "1234"
|
53
|
+
# }
|
54
|
+
def create_message(room_id:, body:, &block)
|
55
|
+
post("/rooms/#{room_id}/messages", body: body, &block)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Mark messages as read
|
59
|
+
#
|
60
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-messages-read
|
61
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
62
|
+
#
|
63
|
+
# @param room_id [Integer]
|
64
|
+
# @param message_id [String]
|
65
|
+
#
|
66
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
67
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
68
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
69
|
+
#
|
70
|
+
# @return [Hashie::Mash]
|
71
|
+
#
|
72
|
+
# @example response format
|
73
|
+
# {
|
74
|
+
# "unread_num": 461,
|
75
|
+
# "mention_num": 0
|
76
|
+
# }
|
77
|
+
def read_message(room_id:, message_id: nil, &block)
|
78
|
+
put("/rooms/#{room_id}/messages/read", message_id: message_id, &block)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Mark messages as unread
|
82
|
+
#
|
83
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-messages-unread
|
84
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
85
|
+
#
|
86
|
+
# @param room_id [Integer]
|
87
|
+
# @param message_id [String]
|
88
|
+
#
|
89
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
90
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
91
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
92
|
+
#
|
93
|
+
# @return [Hashie::Mash]
|
94
|
+
#
|
95
|
+
# @example response format
|
96
|
+
# {
|
97
|
+
# "unread_num": 3,
|
98
|
+
# "mention_num": 0
|
99
|
+
# }
|
100
|
+
def unread_message(room_id:, message_id:, &block)
|
101
|
+
put("/rooms/#{room_id}/messages/unread", message_id: message_id, &block)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Get information about the specified message
|
105
|
+
#
|
106
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-messages-message_id
|
107
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
108
|
+
#
|
109
|
+
# @param room_id [Integer]
|
110
|
+
# @param message_id [String]
|
111
|
+
#
|
112
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
113
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
114
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
115
|
+
#
|
116
|
+
# @return [Hashie::Mash]
|
117
|
+
#
|
118
|
+
# @example response format
|
119
|
+
# {
|
120
|
+
# "message_id": "5",
|
121
|
+
# "account": {
|
122
|
+
# "account_id": 123,
|
123
|
+
# "name": "Bob",
|
124
|
+
# "avatar_image_url": "https://example.com/ico_avatar.png"
|
125
|
+
# },
|
126
|
+
# "body": "Hello Chatwork!",
|
127
|
+
# "send_time": 1384242850,
|
128
|
+
# "update_time": 0
|
129
|
+
# }
|
130
|
+
def find_message(room_id:, message_id:, &block)
|
131
|
+
get("/rooms/#{room_id}/messages/#{message_id}", &block)
|
132
|
+
end
|
133
|
+
|
134
|
+
# Update the specified message
|
135
|
+
#
|
136
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-messages-message_id
|
137
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
138
|
+
#
|
139
|
+
# @param room_id [Integer]
|
140
|
+
# @param message_id [String]
|
141
|
+
# @param body [String] message body
|
142
|
+
#
|
143
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
144
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
145
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
146
|
+
#
|
147
|
+
# @return [Hashie::Mash]
|
148
|
+
#
|
149
|
+
# @example response format
|
150
|
+
# {
|
151
|
+
# "message_id": "1234"
|
152
|
+
# }
|
153
|
+
def update_message(room_id:, message_id:, body:, &block)
|
154
|
+
put("/rooms/#{room_id}/messages/#{message_id}", body: body, &block)
|
155
|
+
end
|
156
|
+
|
157
|
+
# Destroy the specified message
|
158
|
+
#
|
159
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-messages-message_id
|
160
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
161
|
+
#
|
162
|
+
# @param room_id [Integer]
|
163
|
+
# @param message_id [String]
|
164
|
+
#
|
165
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
166
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
167
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
168
|
+
#
|
169
|
+
# @return [Hashie::Mash]
|
170
|
+
#
|
171
|
+
# @example response format
|
172
|
+
# {
|
173
|
+
# "message_id": "1234"
|
174
|
+
# }
|
175
|
+
def destroy_message(room_id:, message_id:, &block)
|
176
|
+
delete("/rooms/#{room_id}/messages/#{message_id}", &block)
|
177
|
+
end
|
178
|
+
end
|