summaryrefslogtreecommitdiff
path: root/src/main/java/com/p4square/ccbapi/model/GetGroupProfilesRequest.java
blob: 85bf752867a7a7482e7d65fa040ba9204d38df1e (plain)
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
package com.p4square.ccbapi.model;

import java.time.LocalDate;

/**
 * GetGroupProfilesRequest is the set of options for retrieving group profiles.
 *
 * If {@link #withGroupId(int)} is used, this request will return only the
 * requested group.
 *
 * Otherwise, this request allows you to pass in a given date and have all
 * groups created or modified since that date returned to you. If a date is
 * not provided, all groups in the system will be returned.
 *
 * The image link in the image element will expire, and should be cached.
 * Including it will significantly increase the runtime of the service and may
 * cause a timeout. Please consider using {@link #withPerPage(int)} and
 * {@link #withPage(int)} if you want to get the images from your groups.
 */
public class GetGroupProfilesRequest {

    // Used with group_profile_from_id
    private int id;

    // Used with group_profiles
    private LocalDate modifiedSince;
    private int page;
    private int perPage;
    private Boolean includeParticipants;

    // Used with any.
    private Boolean includeImageLink;

    public int getId() {
        return id;
    }

    /**
     * Request the {@link GroupProfile} for the given group id.
     *
     * @param id The id.
     * @return this.
     */
    public GetGroupProfilesRequest withGroupId(final int id) {
        this.id = id;
        return this;
    }

    public Boolean getIncludeImageUrl() {
        return includeImageLink;
    }

    /**
     * Include the image URL in the result.
     *
     * Note: The image link in the image element will expire, and should be cached.
     *
     * @param value True if the image link should be included.
     * @return this.
     */
    public GetGroupProfilesRequest withIncludeImageUrl(final boolean value) {
        this.includeImageLink = value;
        return this;
    }

    public LocalDate getModifiedSince() {
        return modifiedSince;
    }

    /**
     * Retrieve all groups modified since the given time.
     *
     * Note: This cannot be used with {@link #withGroupId(int)}.
     *
     * @param modifiedSince The given time.
     * @return this.
     */
    public GetGroupProfilesRequest withModifiedSince(final LocalDate modifiedSince) {
        this.modifiedSince = modifiedSince;
        return this;
    }

    public int getPage() {
        return page;
    }


    /**
     * Select the page of results when paginating results.
     *
     * Note: This cannot be used with {@link #withGroupId(int)}.
     *
     * Defaults to 1 if {@link #withPerPage(int)} is specified on the request.
     *
     * @param page The starting page number.
     * @return this.
     */
    public GetGroupProfilesRequest withPage(final int page) {
        this.page = page;
        return this;
    }

    public int getPerPage() {
        return perPage;
    }

    /**
     * Limit the number of groups returned.
     *
     * Note: This cannot be used with {@link #withGroupId(int)}.
     *
     * Defaults to 25 if {@link #withPage(int)} is specified on the request.
     *
     * @param perPage The maximum number to return.
     * @return this.
     */
    public GetGroupProfilesRequest withPerPage(final int perPage) {
        this.perPage = perPage;
        return this;
    }

    public Boolean getIncludeParticipants() {
        return includeParticipants;
    }

    /**
     * Include all participants from the group in the response.
     *
     * {@link GroupProfile#getMainLeader()} and {@link GroupProfile#getLeaders()}
     * are always populated, regardless of the value.
     *
     * Note: This cannot be used with {@link #withGroupId(int)}.
     *
     * Defaults to True.
     *
     * @see {@link GroupProfile#getParticipants()}
     *
     * @param includeParticipants
     * @return this.
     */
    public GetGroupProfilesRequest withIncludeParticipants(final boolean includeParticipants) {
        this.includeParticipants = includeParticipants;
        return this;
    }
}