Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EDGEPATRON-141]-Removed Address0 #121

Merged
merged 6 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions ramls/examples/external_patron.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
"middleName": "M",
"lastName": "Doe"
},
"address0": {
"addressLine0": "123 Main St",
"addressLine1": "Apt 4B",
"city": "Metropolis",
"province": "NY",
"zip": "12345",
"country": "USA"
},
"address1": {
"addressInfo": {
"addressLine0": "456 Side St",
"addressLine1": "Suite 500",
"city": "Metropolis",
Expand Down
4 changes: 2 additions & 2 deletions ramls/examples/external_patron_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"middleName": "Michael",
"lastName": "Doe"
},
"address0": {
"addressInfo": {
"addressLine0": "123 Main St",
"addressLine1": "",
"city": "Anytown",
Expand All @@ -30,7 +30,7 @@
"preferredFirstName": "Janey",
"lastName": "Smith"
},
"address0": {
"addressInfo": {
"addressLine0": "456 Oak Ave",
"addressLine1": "Apt 2B",
"city": "Smallville",
Expand Down
56 changes: 11 additions & 45 deletions ramls/external_patron.json
Original file line number Diff line number Diff line change
@@ -1,72 +1,40 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "User Information Schema",
"description": "Schema for user information including general info, addresses, contact info",
"description": "Schema for external patron information including general info, addresses, contact info",
"type": "object",
"properties": {
"generalInfo": {
"type": "object",
"description": "General info of patron",
"description": "General info of external patron",
"properties": {
"externalSystemId": {
"type": "string",
"description": "A unique ID that corresponds to an external authority"
},
"firstName": {
"type": "string",
"description": "The user's given name"
"description": "The external patron's given name"
},
"preferredFirstName": {
"type": "string",
"description": "The user's preferred name"
},
"middleName": {
"type": "string",
"description": "The user's middle name (if any)"
"description": "The external patron's middle name (if any)"
},
"lastName": {
"type": "string",
"description": "The user's surname"
"description": "The external patron's surname"
}
},
"required": ["externalSystemId", "firstName", "lastName"],
"additionalProperties": false
},
"address0": {
"addressInfo": {
"type": "object",
"description": "Primary address info of patron",
"properties": {
"addressLine0": {
"type": "string",
"description": "Address, Line 0"
},
"addressLine1": {
"type": "string",
"description": "Address, Line 1"
},
"city": {
"type": "string",
"description": "City name"
},
"province": {
"type": "string",
"description": "Province"
},
"zip": {
"type": "string",
"description": "Zip Code"
},
"country": {
"type": "string",
"description": "Country"
}
},
"required": ["addressLine0", "city", "province", "zip", "country"],
"additionalProperties": false
},
"address1": {
"type": "object",
"description": "Secondary address info of patron",
"description": "Primary address info of external patron",
"properties": {
"addressLine0": {
"type": "string",
Expand Down Expand Up @@ -98,7 +66,7 @@
},
"contactInfo": {
"type": "object",
"description": "Contact info of patron",
"description": "Contact info of external patron",
"properties": {
"phone": {
"type": "string",
Expand All @@ -119,17 +87,15 @@
},
"preferredEmailCommunication": {
"type": "array",
"description": "Email communication info of patron",
"description": "Email communication info of external patron",
"items": {
"type": "string",
"enum": ["Support", "Programs", "Service"]
},
"minItems": 1,
"maxItems": 3,
"uniqueItems": true,
"description": "Preferred email communication types"
"uniqueItems": true
}
},
"required": ["generalInfo", "address0", "contactInfo", "preferredEmailCommunication"],
"required": ["generalInfo", "addressInfo", "contactInfo"],
"additionalProperties": false
}
29 changes: 9 additions & 20 deletions src/main/java/org/folio/edge/patron/model/Patron.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@
@JsonDeserialize(builder = Patron.Builder.class)
@JsonPropertyOrder({
"generalInfo",
"address0",
"address1",
"addressInfo",
"contactInfo",
"preferredEmailCommunication"
})
public final class Patron {
public final GeneralInfo generalInfo;
public final Address address0;
public final Address address1;
public final AddressInfo address;
public final ContactInfo contactInfo;
public final List<String> preferredEmailCommunication;

private Patron(Builder builder) {
this.generalInfo = builder.generalInfo;
this.address0 = builder.address0;
this.address1 = builder.address1;
this.address = builder.address;
this.contactInfo = builder.contactInfo;
this.preferredEmailCommunication = builder.preferredEmailCommunication;
}
Expand All @@ -46,11 +43,8 @@ public static class Builder {
@JsonProperty("generalInfo")
private GeneralInfo generalInfo;

@JsonProperty("address0")
private Address address0;

@JsonProperty("address1")
private Address address1;
@JsonProperty("addressInfo")
private AddressInfo address;

@JsonProperty("contactInfo")
private ContactInfo contactInfo;
Expand All @@ -63,13 +57,8 @@ public Builder generalInfo(GeneralInfo generalInfo) {
return this;
}

public Builder address0(Address address0) {
this.address0 = address0;
return this;
}

public Builder address1(Address address1) {
this.address1 = address1;
public Builder address(AddressInfo address) {
this.address = address;
return this;
}

Expand Down Expand Up @@ -127,7 +116,7 @@ public GeneralInfo(
"zip",
"country"
})
public static class Address {
public static class AddressInfo {
public final String addressLine0;
public final String addressLine1;
public final String city;
Expand All @@ -136,7 +125,7 @@ public static class Address {
public final String country;

@JsonCreator
public Address(
public AddressInfo(
@JsonProperty("addressLine0") String addressLine0,
@JsonProperty("addressLine1") String addressLine1,
@JsonProperty("city") String city,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,7 @@ public static Hold getHold(String itemId, Date holdReqDate) {

public static Patron getPatron() {
return Patron.builder()
.address0(new Patron.Address("fdsf","sds", "fsd", "dasd", "123", "sdsd"))
.address1(new Patron.Address("fdsf","sds", "fsd", "dasd", "123", "sdsd"))
.address(new Patron.AddressInfo("fdsf","sds", "fsd", "dasd", "123", "sdsd"))
.contactInfo(new Patron.ContactInfo("342424","232321","fgh@mail"))
.generalInfo(new Patron.GeneralInfo("1234","sds","a","s", "45"))
.preferredEmailCommunication(new ArrayList<>())
Expand Down
Loading