./ct_report/coverage/mongoose_client_api_rooms_config_doc.COVER.html

1 %%% ==================================================================
2 %%% @doc
3 %%% This module provided documentation of MongooseIM client REST API Rooms: /api/rooms/[:id]/config
4 %%% @end
5 %%% ==================================================================
6
7 -module(mongoose_client_api_rooms_config_doc).
8
9 %%% ==================================================================
10 %%% Macros: HTTP Response Codes
11 %%% ==================================================================
12
13 -define(HTTP_204_NO_CONTENT, 204).
14 -define(HTTP_400_BAD_REQUEST, 400).
15 -define(HTTP_401_UNAUTHORIZED, 401).
16 -define(HTTP_500_INTERNAL_SERVER_ERROR, 500).
17
18 %%% ==================================================================
19 %%% Trails Callbacks
20 %%% ==================================================================
21
22 -behaviour(trails_handler).
23
24 -export([trails/0]).
25
26 trails() ->
27 %% Definitions
28 105 DefConfigRoomReq = <<"req-body-client-api-room-config">>,
29
30 %% Properties
31 105 PropConfigRoomReq = #{
32 <<"subject">> => #{
33 type => <<"string">>,
34 description => <<"The subject of the room">>,
35 default => <<"Only important things">>
36 },
37 <<"name">> => #{
38 type => <<"string">>,
39 description => <<"The room's name">>,
40 default => <<"Important room">>
41 }
42 },
43
44 %% Definitions and properties
45 105 DefinitionsAndProperties = [
46 {DefConfigRoomReq, PropConfigRoomReq}
47 ],
48
49 %% Add definitions
50 105 lists:foreach(
51 fun({Definition, DefinitionProperties}) ->
52 105 cowboy_swagger:add_definition(Definition, DefinitionProperties)
53 end, DefinitionsAndProperties),
54
55 %% Request Body
56 105 RequestBodyConfigRoom = #{
57 in => body,
58 name => <<"room">>,
59 type => <<"object">>,
60 description => <<"Room">>,
61 required => true,
62 schema => cowboy_swagger:schema(DefConfigRoomReq)
63 },
64
65 %% Pushs
66 105 RequestPushRoomId = #{
67 in => path,
68 name => <<"id">>,
69 type => <<"string">>,
70 description => <<"The ID of a room">>,
71 default => <<"1575-564351-207767">>,
72 required => true
73 },
74
75 %% Meta data
76 105 MetadataClientApiRoomConfig = #{
77 put => #{
78 tags => ["Rooms"],
79 description => <<"Changes room configuration">>,
80 consumes => ["application/json"],
81 produces => ["application/json"],
82 parameters => [RequestPushRoomId, RequestBodyConfigRoom],
83 responses => #{
84 ?HTTP_204_NO_CONTENT => #{description => <<"Configuration was successfully changed">>},
85 ?HTTP_400_BAD_REQUEST => #{description => <<"Bad Request">>},
86 ?HTTP_401_UNAUTHORIZED => #{description => <<"Unauthorized">>},
87 ?HTTP_500_INTERNAL_SERVER_ERROR => #{description => <<"Internal Server Error">>}
88 }
89 }
90 },
91
92 %% Paths
93 105 PathClientApiRoomsConfig = "/api/rooms/[:id]/config",
94
95 %% Trail all data
96 105 [trails:trail(PathClientApiRoomsConfig, mongoose_client_api_rooms_config, #{path => PathClientApiRoomsConfig}, MetadataClientApiRoomConfig)].
Line Hits Source