getChannels
last analyzed

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
1
package com.base.Http.Server.Responses.Channel;
2
3
import com.base.Http.Request.Request;
4
import com.base.Http.Response.Response;
5
import com.base.Http.Server.Responses.BaseResponse;
6
import com.base.Models.Channel;
7
8
import java.util.ArrayList;
9
import java.util.List;
10
11
public class GetAllChannelsResponse extends BaseResponse {
12
13
    public static String VALID_TEAM_SLUG = "twitter";
14
    public static String VALID_CHANNEL_SLUG = "design";
15
    public static String VALID_NAME = "Design";
16
    public static String VALID_DESCRIPTION = "Design Channel for Twitter";
17
    public static String VALID_COLOR = "000000";
18
    public static String VALID_STATUS = "1";
19
20
    public GetAllChannelsResponse() {
21
        super();
22
    }
23
24
    public GetAllChannelsResponse(String teamSlug, String channelSlug) {
25
        super();
26
        VALID_CHANNEL_SLUG = channelSlug;
27
        VALID_TEAM_SLUG = teamSlug;
28
    }
29
30
    @Override
31
    public Response getResponse(Request request, Response response) {
32
        return response.setStatusCode(200)
33
                .setBody(generateResponseBody(getChannels()));
34
    }
35
36
    private List<Channel> getChannels() {
37
        List<Channel> channels = new ArrayList<>();
38
39
        for (int i = 1; i <= 3; i++) {
40
            channels.add(new Channel().setColor(GetAllChannelsResponse.VALID_COLOR)
41
                    .setName(GetAllChannelsResponse.VALID_NAME.concat(" " + i))
42
                    .setDescription(GetAllChannelsResponse.VALID_DESCRIPTION)
43
                    .setIs_private(GetAllChannelsResponse.VALID_STATUS)
44
                    .setSlug(GetAllChannelsResponse.VALID_CHANNEL_SLUG.concat("-" + i)));
45
        }
46
        return channels;
47
    }
48
}
49