diff options
Diffstat (limited to 'src/main/java/com/p4square/ccbapi/model')
6 files changed, 447 insertions, 3 deletions
diff --git a/src/main/java/com/p4square/ccbapi/model/Countries.java b/src/main/java/com/p4square/ccbapi/model/Countries.java new file mode 100644 index 0000000..ec9df70 --- /dev/null +++ b/src/main/java/com/p4square/ccbapi/model/Countries.java @@ -0,0 +1,8 @@ +package com.p4square.ccbapi.model; + +/** + * Constants which define common countries. + */ +public class Countries { + public static final Country UNITED_STATES = new Country("US", "United States"); +} diff --git a/src/main/java/com/p4square/ccbapi/model/Country.java b/src/main/java/com/p4square/ccbapi/model/Country.java index e6936a5..ac9e9ec 100644 --- a/src/main/java/com/p4square/ccbapi/model/Country.java +++ b/src/main/java/com/p4square/ccbapi/model/Country.java @@ -16,6 +16,30 @@ public class Country { private String name; /** + * Default Country constructor. + */ + public Country() { + + } + + /** + * This package-private Country constructor is used to create the + * constants in the {@link Countries} class. + * + * Usually the country name cannot be set except when binding to + * responses from CCB. This constructor is an exception so that the + * constants in {@link Countries} can be provide with + * <strong>known</strong> values used by CCB. + * + * @param code The two letter country code. + * @param name The country name as typically presented by CCB. + */ + Country(final String code, final String name) { + setCountryCode(code); + this.name = name; + } + + /** * @return The two letter country code. */ public String getCountryCode() { diff --git a/src/main/java/com/p4square/ccbapi/model/Gender.java b/src/main/java/com/p4square/ccbapi/model/Gender.java index eabaa42..cf6736a 100644 --- a/src/main/java/com/p4square/ccbapi/model/Gender.java +++ b/src/main/java/com/p4square/ccbapi/model/Gender.java @@ -6,8 +6,15 @@ import javax.xml.bind.annotation.XmlEnumValue; * Enum representing the gender of an individual in CCB. */ public enum Gender { - @XmlEnumValue("M") MALE("M"), - @XmlEnumValue("F") FEMALE("F"); + /** + * The documentation currently provides conflicting examples for the gender code. + * The documentation says it must be 'M' or 'F', but the example given uses 'm'. + * According to an API Village posting, it should actually be lower case. + * + * https://village.ccbchurch.com/message_comment_list.php?message_id=3308 + */ + @XmlEnumValue("M") MALE("m"), + @XmlEnumValue("F") FEMALE("f"); private final String code; diff --git a/src/main/java/com/p4square/ccbapi/model/GetIndividualProfilesResponse.java b/src/main/java/com/p4square/ccbapi/model/GetIndividualProfilesResponse.java index f88bcf7..bc7915c 100644 --- a/src/main/java/com/p4square/ccbapi/model/GetIndividualProfilesResponse.java +++ b/src/main/java/com/p4square/ccbapi/model/GetIndividualProfilesResponse.java @@ -4,7 +4,7 @@ import javax.xml.bind.annotation.*; import java.util.List; /** - * GetCustomFieldLabelsResponse models the response of a variety of APIs which return one or more Individual Profiles. + * GetIndividualProfilesResponse models the response of a variety of APIs which return one or more Individual Profiles. */ @XmlRootElement(name="response") @XmlAccessorType(XmlAccessType.NONE) diff --git a/src/main/java/com/p4square/ccbapi/model/UpdateIndividualProfileRequest.java b/src/main/java/com/p4square/ccbapi/model/UpdateIndividualProfileRequest.java new file mode 100644 index 0000000..613b678 --- /dev/null +++ b/src/main/java/com/p4square/ccbapi/model/UpdateIndividualProfileRequest.java @@ -0,0 +1,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; + } + +} diff --git a/src/main/java/com/p4square/ccbapi/model/UpdateIndividualProfileResponse.java b/src/main/java/com/p4square/ccbapi/model/UpdateIndividualProfileResponse.java new file mode 100644 index 0000000..9067d56 --- /dev/null +++ b/src/main/java/com/p4square/ccbapi/model/UpdateIndividualProfileResponse.java @@ -0,0 +1,27 @@ +package com.p4square.ccbapi.model; + +import javax.xml.bind.annotation.*; +import java.util.List; + +/** + * The response from an update_individual request. + */ +@XmlRootElement(name="response") +@XmlAccessorType(XmlAccessType.NONE) +public class UpdateIndividualProfileResponse extends CCBAPIResponse { + + @XmlElementWrapper(name = "individuals") + @XmlElement(name="individual") + private List<IndividualProfile> individuals; + + /** + * @return The list of individuals retrieved from CCB. + */ + public List<IndividualProfile> getIndividuals() { + return individuals; + } + + public void setIndividuals(List<IndividualProfile> individuals) { + this.individuals = individuals; + } +} |