This repository has been archived by the owner on May 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rooms.ex
298 lines (272 loc) · 11.5 KB
/
rooms.ex
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# Code generated by `$ mix hipchat.generate`
defmodule Hipchat.V2.Rooms do
@moduledoc """
HipChat V2 Rooms API module.
"""
alias Hipchat.{Client, Httpc}
@endpoint "https://api.hipchat.com/v2"
@doc """
[https://www.hipchat.com/docs/apiv2/method/add_member](https://www.hipchat.com/docs/apiv2/method/add_member)
"""
@spec add_member(Client.t, String.t, String.t, map) :: Httpc.res_t
def add_member(client, room_id_or_name, user_id_or_email, body) do
Httpc.request(:put,
"#{@endpoint}/room/#{room_id_or_name}/member/#{user_id_or_email}",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/create_room](https://www.hipchat.com/docs/apiv2/method/create_room)
"""
@spec create_room(Client.t, map) :: Httpc.res_t
def create_room(client, body) do
Httpc.request(:post,
"#{@endpoint}/room",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/create_room_action](https://www.hipchat.com/docs/apiv2/method/create_room_action)
"""
@spec create_room_action(Client.t, String.t, String.t, map) :: Httpc.res_t
def create_room_action(client, room_id_or_name, key, body) do
Httpc.request(:put,
"#{@endpoint}/room/#{room_id_or_name}/extension/action/#{key}",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/delete_room](https://www.hipchat.com/docs/apiv2/method/delete_room)
"""
@spec delete_room(Client.t, String.t) :: Httpc.res_t
def delete_room(client, room_id_or_name) do
Httpc.request(:delete,
"#{@endpoint}/room/#{room_id_or_name}",
"",
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/delete_room_action](https://www.hipchat.com/docs/apiv2/method/delete_room_action)
"""
@spec delete_room_action(Client.t, String.t, String.t) :: Httpc.res_t
def delete_room_action(client, room_id_or_name, key) do
Httpc.request(:delete,
"#{@endpoint}/room/#{room_id_or_name}/extension/action/#{key}",
"",
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/delete_room_avatar](https://www.hipchat.com/docs/apiv2/method/delete_room_avatar)
"""
@spec delete_room_avatar(Client.t, String.t) :: Httpc.res_t
def delete_room_avatar(client, room_id_or_name) do
Httpc.request(:delete,
"#{@endpoint}/room/#{room_id_or_name}/avatar",
"",
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/get_all_members](https://www.hipchat.com/docs/apiv2/method/get_all_members)
"""
@spec get_all_members(Client.t, String.t, Client.query_params_t) :: Httpc.res_t
def get_all_members(client, room_id_or_name, query_params) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}/member",
"",
Client.headers(client),
Client.options(client, query_params))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/get_all_participants](https://www.hipchat.com/docs/apiv2/method/get_all_participants)
"""
@spec get_all_participants(Client.t, String.t, Client.query_params_t) :: Httpc.res_t
def get_all_participants(client, room_id_or_name, query_params) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}/participant",
"",
Client.headers(client),
Client.options(client, query_params))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/get_all_rooms](https://www.hipchat.com/docs/apiv2/method/get_all_rooms)
"""
@spec get_all_rooms(Client.t, Client.query_params_t) :: Httpc.res_t
def get_all_rooms(client, query_params) do
Httpc.request(:get,
"#{@endpoint}/room",
"",
Client.headers(client),
Client.options(client, query_params))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/view_recent_room_history](https://www.hipchat.com/docs/apiv2/method/view_recent_room_history)
"""
@spec get_recent_room_history(Client.t, String.t, Client.query_params_t) :: Httpc.res_t
def get_recent_room_history(client, room_id_or_name, query_params) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}/history/latest",
"",
Client.headers(client),
Client.options(client, query_params))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/get_room](https://www.hipchat.com/docs/apiv2/method/get_room)
"""
@spec get_room(Client.t, String.t) :: Httpc.res_t
def get_room(client, room_id_or_name) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}",
"",
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/get_room_action](https://www.hipchat.com/docs/apiv2/method/get_room_action)
"""
@spec get_room_action(Client.t, String.t, String.t) :: Httpc.res_t
def get_room_action(client, room_id_or_name, key) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}/extension/action/#{key}",
"",
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/get_room_avatar](https://www.hipchat.com/docs/apiv2/method/get_room_avatar)
"""
@spec get_room_avatar(Client.t, String.t) :: Httpc.res_t
def get_room_avatar(client, room_id_or_name) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}/avatar",
"",
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/view_room_history](https://www.hipchat.com/docs/apiv2/method/view_room_history)
"""
@spec get_room_history(Client.t, String.t, Client.query_params_t) :: Httpc.res_t
def get_room_history(client, room_id_or_name, query_params) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}/history",
"",
Client.headers(client),
Client.options(client, query_params))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/get_room_message](https://www.hipchat.com/docs/apiv2/method/get_room_message)
"""
@spec get_room_message(Client.t, String.t, String.t, Client.query_params_t) :: Httpc.res_t
def get_room_message(client, room_id_or_name, message_id, query_params) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}/history/#{message_id}",
"",
Client.headers(client),
Client.options(client, query_params))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/get_room_statistics](https://www.hipchat.com/docs/apiv2/method/get_room_statistics)
"""
@spec get_room_statistics(Client.t, String.t) :: Httpc.res_t
def get_room_statistics(client, room_id_or_name) do
Httpc.request(:get,
"#{@endpoint}/room/#{room_id_or_name}/statistics",
"",
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/invite_user](https://www.hipchat.com/docs/apiv2/method/invite_user)
"""
@spec invite_user(Client.t, String.t, String.t, map) :: Httpc.res_t
def invite_user(client, room_id_or_name, user_id_or_email, body) do
Httpc.request(:post,
"#{@endpoint}/room/#{room_id_or_name}/invite/#{user_id_or_email}",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/remove_member](https://www.hipchat.com/docs/apiv2/method/remove_member)
"""
@spec remove_member(Client.t, String.t, String.t) :: Httpc.res_t
def remove_member(client, room_id_or_name, user_id_or_email) do
Httpc.request(:delete,
"#{@endpoint}/room/#{room_id_or_name}/member/#{user_id_or_email}",
"",
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/reply_to_message](https://www.hipchat.com/docs/apiv2/method/reply_to_message)
"""
@spec reply_to_message(Client.t, String.t, map) :: Httpc.res_t
def reply_to_message(client, room_id_or_name, body) do
Httpc.request(:post,
"#{@endpoint}/room/#{room_id_or_name}/reply",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/send_message](https://www.hipchat.com/docs/apiv2/method/send_message)
"""
@spec send_message(Client.t, String.t, map) :: Httpc.res_t
def send_message(client, room_id_or_name, body) do
Httpc.request(:post,
"#{@endpoint}/room/#{room_id_or_name}/message",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/send_room_notification](https://www.hipchat.com/docs/apiv2/method/send_room_notification)
"""
@spec send_room_notification(Client.t, String.t, map) :: Httpc.res_t
def send_room_notification(client, room_id_or_name, body) do
Httpc.request(:post,
"#{@endpoint}/room/#{room_id_or_name}/notification",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/share_link_with_room](https://www.hipchat.com/docs/apiv2/method/share_link_with_room)
"""
@spec share_link_with_room(Client.t, String.t, map) :: Httpc.res_t
def share_link_with_room(client, room_id_or_name, body) do
Httpc.request(:post,
"#{@endpoint}/room/#{room_id_or_name}/share/link",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/update_room](https://www.hipchat.com/docs/apiv2/method/update_room)
"""
@spec update_room(Client.t, String.t, map) :: Httpc.res_t
def update_room(client, room_id_or_name, body) do
Httpc.request(:put,
"#{@endpoint}/room/#{room_id_or_name}",
body,
Client.headers(client),
Client.options(client, []))
end
@doc """
[https://www.hipchat.com/docs/apiv2/method/update_room_avatar](https://www.hipchat.com/docs/apiv2/method/update_room_avatar)
"""
@spec update_room_avatar(Client.t, String.t, map) :: Httpc.res_t
def update_room_avatar(client, room_id_or_name, body) do
Httpc.request(:put,
"#{@endpoint}/room/#{room_id_or_name}/avatar",
body,
Client.headers(client),
Client.options(client, []))
end
end