-
Notifications
You must be signed in to change notification settings - Fork 27
/
incoming_request.rb
81 lines (78 loc) · 3.29 KB
/
incoming_request.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
module ChatWork
module IncomingRequest
# You can get the list of contact approval request you received
#
# (*This method returns up to 100 entries. We are planning to implement pagination to support larger number of data retrieval)
#
# @see http://developer.chatwork.com/ja/endpoint_incoming_requests.html#GET-incoming_requests
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
#
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
# @yieldparam response_body [Array<Hashie::Mash>] response body
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
#
# @return [Array<Hashie::Mash>]
#
# @example response format
# [
# {
# "request_id": 123,
# "account_id": 363,
# "message": "hogehoge",
# "name": "John Smith",
# "chatwork_id": "tarochatworkid",
# "organization_id": 101,
# "organization_name": "Hello Company",
# "department": "Marketing",
# "avatar_image_url": "https://example.com/abc.png"
# }
# ]
def self.get(&block)
ChatWork.client.get_incoming_requests(&block)
end
# You can approve a contact approval request you received
#
# @see http://developer.chatwork.com/ja/endpoint_incoming_requests.html#PUT-incoming_requests-request_id
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
#
# @param request_id [Integer]
#
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
# @yieldparam response_body [Hashie::Mash] response body
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
#
# @return [Hashie::Mash]
#
# @example response format
# {
# "account_id": 363,
# "room_id": 1234,
# "name": "John Smith",
# "chatwork_id": "tarochatworkid",
# "organization_id": 101,
# "organization_name": "Hello Company",
# "department": "Marketing",
# "avatar_image_url": "https://example.com/abc.png"
# }
def self.update(request_id:, &block)
ChatWork.client.update_incoming_request(request_id: request_id, &block)
end
# You can decline a contact approval request you received
#
# @see http://developer.chatwork.com/ja/endpoint_incoming_requests.html#DELETE-incoming_requests-request_id
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
#
# @param request_id [Integer]
#
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
# @yieldparam response_body [Hashie::Mash] response body
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
def self.destroy(request_id:, &block)
ChatWork.client.destroy_incoming_request(request_id: request_id, &block)
end
class << self
alias_method :approve, :update
alias_method :decline, :destroy
end
end
end