summaryrefslogtreecommitdiff
path: root/src/main/java/com/p4square/ccbapi/model/UpdateIndividualProfileRequest.java
blob: 613b6788950608a39561adcbcac2a7e84c0e99df (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
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
package com.p4square.ccbapi.model;

import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * UpdateIndividualProfileRequest encapsulates a change to an IndividualProfile.
 *
 * The only property which must be set is {@link #withIndividualId(int)},
 * to indicate the profile to update.
 *
 * A property can be unset by setting it to null.
 */
public class UpdateIndividualProfileRequest {

    /**
     * The set of all valid custom text field names.
     */
    public static final Set<String> CUSTOM_TEXT_FIELD_NAMES =
            IntStream.rangeClosed(1, 12).mapToObj(x -> "udf_text_" + x).collect(Collectors.toSet());

    /**
     * The set of all valid custom date field names.
     */
    public static final Set<String> CUSTOM_DATE_FIELD_NAMES =
            IntStream.rangeClosed(1, 6).mapToObj(x -> "udf_date_" + x).collect(Collectors.toSet());

    /**
     * The set of all valid custom pulldown field names.
     */
    public static final Set<String> CUSTOM_PULLDOWN_FIELD_NAMES =
            IntStream.rangeClosed(1, 6).mapToObj(x -> "udf_pulldown_" + x).collect(Collectors.toSet());

    private int individualId;

    private Integer syncId;
    private String otherId;
    private String givingNumber;

    private String firstName;
    private String lastName;
    private String middleName;
    private String legalFirstName;
    private String salutation;
    private String suffix;

    private Integer familyId;

    private FamilyPosition familyPosition;

    private MaritalStatus maritalStatus;

    private Gender gender;
    private LocalDate birthday;
    private LocalDate anniversary;
    private LocalDate deceased;
    private LocalDate membershipDate;
    private LocalDate membershipEnd;

    private String email;

    private List<Address> addresses;
    private List<Phone> phones;

    private String emergencyContactName;
    private String allergies;
    private Boolean confirmedNoAllergies;
    private Boolean baptized;

    private Map<String, String> customTextFields = new HashMap<>();
    private Map<String, LocalDate> customDateFields = new HashMap<>();
    private Map<String, Integer> customPulldownFields = new HashMap<>();

    private Integer modifiedById;

    public int getIndividualId() {
        return individualId;
    }

    public UpdateIndividualProfileRequest withIndividualId(int individualId) {
        this.individualId = individualId;
        return this;
    }

    public Integer getSyncId() {
        return syncId;
    }

    public UpdateIndividualProfileRequest withSyncId(Integer syncId) {
        this.syncId = syncId;
        return this;
    }

    public String getOtherId() {
        return otherId;
    }

    public UpdateIndividualProfileRequest withOtherId(String otherId) {
        this.otherId = otherId;
        return this;
    }

    public String getGivingNumber() {
        return givingNumber;
    }

    public UpdateIndividualProfileRequest withGivingNumber(String givingNumber) {
        this.givingNumber = givingNumber;
        return this;
    }

    public String getFirstName() {
        return firstName;
    }

    public UpdateIndividualProfileRequest withFirstName(String firstName) {
        this.firstName = firstName;
        return this;
    }

    public String getLastName() {
        return lastName;
    }

    public UpdateIndividualProfileRequest withLastName(String lastName) {
        this.lastName = lastName;
        return this;
    }

    public String getMiddleName() {
        return middleName;
    }

    public UpdateIndividualProfileRequest withMiddleName(String middleName) {
        this.middleName = middleName;
        return this;
    }

    public String getLegalFirstName() {
        return legalFirstName;
    }

    public UpdateIndividualProfileRequest withLegalFirstName(String legalFirstName) {
        this.legalFirstName = legalFirstName;
        return this;
    }

    public String getSalutation() {
        return salutation;
    }

    public UpdateIndividualProfileRequest withSalutation(String salutation) {
        this.salutation = salutation;
        return this;
    }

    public String getSuffix() {
        return suffix;
    }

    public UpdateIndividualProfileRequest withSuffix(String suffix) {
        this.suffix = suffix;
        return this;
    }

    public Integer getFamilyId() {
        return familyId;
    }

    public UpdateIndividualProfileRequest withFamilyId(Integer familyId) {
        this.familyId = familyId;
        return this;
    }

    public FamilyPosition getFamilyPosition() {
        return familyPosition;
    }

    public UpdateIndividualProfileRequest withFamilyPosition(FamilyPosition familyPosition) {
        this.familyPosition = familyPosition;
        return this;
    }

    public MaritalStatus getMaritalStatus() {
        return maritalStatus;
    }

    public UpdateIndividualProfileRequest withMaritalStatus(MaritalStatus maritalStatus) {
        this.maritalStatus = maritalStatus;
        return this;
    }

    public Gender getGender() {
        return gender;
    }

    public UpdateIndividualProfileRequest withGender(Gender gender) {
        this.gender = gender;
        return this;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public UpdateIndividualProfileRequest withBirthday(LocalDate birthday) {
        this.birthday = birthday;
        return this;
    }

    public LocalDate getAnniversary() {
        return anniversary;
    }

    public UpdateIndividualProfileRequest withAnniversary(LocalDate anniversary) {
        this.anniversary = anniversary;
        return this;
    }

    public LocalDate getDeceased() {
        return deceased;
    }

    public UpdateIndividualProfileRequest withDeceased(LocalDate deceased) {
        this.deceased = deceased;
        return this;
    }

    public LocalDate getMembershipDate() {
        return membershipDate;
    }

    public UpdateIndividualProfileRequest withMembershipDate(LocalDate membershipDate) {
        this.membershipDate = membershipDate;
        return this;
    }

    public LocalDate getMembershipEnd() {
        return membershipEnd;
    }

    public UpdateIndividualProfileRequest withMembershipEnd(LocalDate membershipEnd) {
        this.membershipEnd = membershipEnd;
        return this;
    }

    public String getEmail() {
        return email;
    }

    public UpdateIndividualProfileRequest withEmail(String email) {
        this.email = email;
        return this;
    }

    public List<Address> getAddresses() {
        return addresses;
    }

    public UpdateIndividualProfileRequest withAddresses(List<Address> addresses) {
        this.addresses = addresses;
        return this;
    }

    public List<Phone> getPhones() {
        return phones;
    }

    public UpdateIndividualProfileRequest withPhones(List<Phone> phones) {
        this.phones = phones;
        return this;
    }

    public String getEmergencyContactName() {
        return emergencyContactName;
    }

    public UpdateIndividualProfileRequest withEmergencyContactName(String emergencyContactName) {
        this.emergencyContactName = emergencyContactName;
        return this;
    }

    public String getAllergies() {
        return allergies;
    }

    public UpdateIndividualProfileRequest withAllergies(String allergies) {
        this.allergies = allergies;
        return this;
    }

    public Boolean getConfirmedNoAllergies() {
        return confirmedNoAllergies;
    }

    public UpdateIndividualProfileRequest withConfirmedNoAllergies(Boolean confirmedNoAllergies) {
        this.confirmedNoAllergies = confirmedNoAllergies;
        return this;
    }

    public Boolean getBaptized() {
        return baptized;
    }

    public UpdateIndividualProfileRequest withBaptized(Boolean baptized) {
        this.baptized = baptized;
        return this;
    }

    /**
     * @return A map of custom field identifiers to text field values.
     */
    public Map<String, String> getCustomTextFields() {
        return customTextFields;
    }

    public UpdateIndividualProfileRequest withCustomTextField(final String name, final String value) {
        if (!CUSTOM_TEXT_FIELD_NAMES.contains(name)) {
            throw new IllegalArgumentException(name + " is not a valid a valid text field name.");
        }
        customTextFields.put(name, value);
        return this;
    }

    public UpdateIndividualProfileRequest withCustomTextField(final int number, final String value) {
        return withCustomTextField("udf_text_" + number, value);
    }

    /**
     * @return A map of custom field identifiers to date field values.
     */
    public Map<String, LocalDate> getCustomDateFields() {
        return customDateFields;
    }

    public UpdateIndividualProfileRequest withCustomDateField(final String name, final LocalDate value) {
        if (!CUSTOM_DATE_FIELD_NAMES.contains(name)) {
            throw new IllegalArgumentException(name + " is not a valid a valid date field name.");
        }
        customDateFields.put(name, value);
        return this;
    }

    public UpdateIndividualProfileRequest withCustomDateField(final int number, final LocalDate value) {
        return withCustomDateField("udf_date_" + number, value);
    }

    /**
     * @return A map of custom field identifiers to pulldown field values.
     */
    public Map<String, Integer> getCustomPulldownFields() {
        return customPulldownFields;
    }

    public UpdateIndividualProfileRequest withCustomPulldownField(final String name, final Integer value) {
        if (!CUSTOM_PULLDOWN_FIELD_NAMES.contains(name)) {
            throw new IllegalArgumentException(name + " is not a valid a valid pulldown field name.");
        }
        customPulldownFields.put(name, value);
        return this;
    }

    public UpdateIndividualProfileRequest withCustomPulldownField(final int number, final Integer value) {
        return withCustomPulldownField("udf_pulldown_" + number, value);
    }

    public Integer getModifiedById() {
        return modifiedById;
    }

    public UpdateIndividualProfileRequest withModifiedById(Integer modifiedById) {
        this.modifiedById = modifiedById;
        return this;
    }

}