|
1
|
|
|
package com.base; |
|
2
|
|
|
|
|
3
|
|
|
import com.base.Http.Server.Responses.Channel.*; |
|
4
|
|
|
import com.base.Http.Server.Responses.ChannelMember.CreateChannelMemberResponse; |
|
5
|
|
|
import com.base.Http.Server.Responses.ChannelMember.DeleteChannelMemberResponse; |
|
6
|
|
|
import com.base.Http.Server.Responses.ChannelMember.GetAllChannelMembersResponse; |
|
7
|
|
|
import com.base.Http.Server.Responses.ChannelMember.GetChannelMemberResponse; |
|
8
|
|
|
import com.base.Http.Server.Responses.ServerResponseInterface; |
|
9
|
|
|
import com.base.Http.Server.Responses.Team.*; |
|
10
|
|
|
import com.base.Http.Server.Responses.TeamMember.CreateTeamMemberResponse; |
|
11
|
|
|
import com.base.Http.Server.Responses.TeamMember.DeleteTeamMemberResponse; |
|
12
|
|
|
import com.base.Http.Server.Responses.TeamMember.GetAllTeamMembersResponse; |
|
13
|
|
|
import com.base.Http.Server.Responses.TeamMember.GetTeamMemberResponse; |
|
14
|
|
|
import com.base.Http.Server.Responses.Thread.CreateChannelThreadResponse; |
|
15
|
|
|
import com.base.Http.Server.Responses.User.GetUserResponse; |
|
16
|
|
|
import com.base.Http.Server.Responses.User.UserLoginResponse; |
|
17
|
|
|
|
|
18
|
|
|
import java.util.HashMap; |
|
19
|
|
|
import java.util.Map; |
|
20
|
|
|
|
|
21
|
|
|
public class RouteMappings { |
|
22
|
|
|
|
|
23
|
|
|
public static Map<String, ServerResponseInterface> routes = new HashMap<>(); |
|
24
|
|
|
|
|
25
|
|
|
public RouteMappings() { |
|
26
|
|
|
registerUserMappings(); |
|
27
|
|
|
registerChannelMappings(); |
|
28
|
|
|
registerTeamMapping(); |
|
29
|
|
|
registerTeamMemberMappings(); |
|
30
|
|
|
registerChannelMemberMappings(); |
|
31
|
|
|
registerThreadMappings(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
private void registerThreadMappings() { |
|
35
|
|
|
routes.put("POST localhost/teams/".concat(CreateChannelThreadResponse.VALID_TEAM_SLUG) |
|
36
|
|
|
.concat("/channels/").concat(CreateChannelThreadResponse.VALID_CHANNEL_SLUG) |
|
37
|
|
|
.concat("/threads"), new CreateChannelThreadResponse()); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
private void registerChannelMemberMappings() { |
|
41
|
|
|
routes.put("POST localhost/teams/".concat(CreateChannelMemberResponse.VALID_TEAM_SLUG) |
|
42
|
|
|
.concat("/channels/").concat(CreateChannelMemberResponse.VALID_CHANNEL_SLUG) |
|
43
|
|
|
.concat("/members"), new CreateChannelMemberResponse()); |
|
44
|
|
|
|
|
45
|
|
|
routes.put("GET localhost/teams/".concat(GetChannelMemberResponse.VALID_TEAM_SLUG) |
|
46
|
|
|
.concat("/channels/").concat(GetChannelMemberResponse.VALID_CHANNEL_SLUG) |
|
47
|
|
|
.concat("/members/").concat(String.valueOf(GetChannelMemberResponse.VALID_USER_ID)), |
|
48
|
|
|
new GetChannelMemberResponse()); |
|
49
|
|
|
|
|
50
|
|
|
routes.put("GET localhost/teams/".concat(GetAllChannelMembersResponse.VALID_TEAM_SLUG) |
|
51
|
|
|
.concat("/channels/").concat(GetAllChannelMembersResponse.VALID_CHANNEL_SLUG) |
|
52
|
|
|
.concat("/members"), new GetAllChannelMembersResponse()); |
|
53
|
|
|
|
|
54
|
|
|
routes.put("DELETE localhost/teams/".concat(DeleteChannelMemberResponse.VALID_TEAM_SLUG) |
|
55
|
|
|
.concat("/channels/").concat(DeleteChannelMemberResponse.VALID_CHANNEL_SLUG) |
|
56
|
|
|
.concat("/members/").concat(String.valueOf(DeleteChannelMemberResponse.VALID_USER_ID)), |
|
57
|
|
|
new DeleteChannelMemberResponse()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
private void registerTeamMemberMappings() { |
|
61
|
|
|
routes.put("POST localhost/teams/".concat(CreateTeamMemberResponse.VALID_SLUG).concat("/members"), new CreateTeamMemberResponse()); |
|
62
|
|
|
routes.put("GET localhost/teams/".concat(GetTeamMemberResponse.VALID_TEAM_SLUG).concat("/members/").concat(GetTeamMemberResponse.VALID_USER_ID + ""), |
|
63
|
|
|
new GetTeamMemberResponse()); |
|
64
|
|
|
routes.put("GET localhost/teams/".concat(GetAllTeamMembersResponse.VALID_TEAM_SLUG).concat("/members"), new GetAllTeamMembersResponse()); |
|
65
|
|
|
routes.put("DELETE localhost/teams/".concat(DeleteTeamMemberResponse.VALID_TEAM_SLUG).concat("/members/") |
|
66
|
|
|
.concat(DeleteTeamMemberResponse.VALID_USER_ID), new DeleteTeamMemberResponse()); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
private void registerTeamMapping() { |
|
70
|
|
|
routes.put("POST localhost/teams", new CreateTeamResponse()); |
|
71
|
|
|
routes.put("GET localhost/teams/" + GetTeamResponse.VALID_TEAM_SLUG, |
|
72
|
|
|
new GetTeamResponse()); |
|
73
|
|
|
routes.put("GET localhost/teams", new GetAllTeamsResponse()); |
|
74
|
|
|
routes.put("PATCH localhost/teams/".concat(UpdateTeamResponse.VALID_SLUG), new UpdateTeamResponse()); |
|
75
|
|
|
routes.put("DELETE localhost/teams/".concat(DeleteChannelResponse.VALID_TEAM_SLUG), new DeleteChannelResponse()); |
|
76
|
|
|
routes.put("GET localhost/teams/".concat(ListStaredMessagesResponse.VALID_TEAM_SLUG.concat("/starred-messages")), new ListStaredMessagesResponse()); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
private void registerUserMappings() { |
|
80
|
|
|
routes.put("POST localhost/users/login", new UserLoginResponse()); |
|
81
|
|
|
routes.put("GET localhost/users/" + String.valueOf(GetUserResponse.VALID_USER_ID), |
|
82
|
|
|
new GetUserResponse()); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
private void registerChannelMappings() { |
|
86
|
|
|
routes.put("POST localhost/teams/".concat(CreateChannelResponse.VALID_TEAM_SLUG).concat("/channels"), |
|
87
|
|
|
new CreateChannelResponse()); |
|
88
|
|
|
routes.put("GET localhost/teams/".concat(GetChannelResponse.VALID_TEAM_SLUG).concat("/channels/").concat(GetChannelResponse.VALID_CHANNEL_SLUG), |
|
89
|
|
|
new GetChannelResponse()); |
|
90
|
|
|
routes.put("GET localhost/teams/".concat(GetAllChannelsResponse.VALID_TEAM_SLUG).concat("/channels"), new GetAllChannelsResponse()); |
|
91
|
|
|
routes.put("PATCH localhost/teams/".concat(UpdateChannelResponse.VALID_TEAM_SLUG).concat("/channels/".concat(UpdateChannelResponse.VALID_CHANNEL_SLUG)), |
|
92
|
|
|
new UpdateChannelResponse()); |
|
93
|
|
|
routes.put("DELETE localhost/teams/".concat(DeleteChannelResponse.VALID_TEAM_SLUG).concat("/channels/".concat(DeleteChannelResponse.VALID_CHANNEL_SLUG)), |
|
94
|
|
|
new DeleteChannelResponse()); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public Map<String, ServerResponseInterface> getRoutes() { |
|
98
|
|
|
return routes; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|