Skip to content

Commit

Permalink
Merge pull request #168 from ConsumerDataStandardsAustralia/feature/2…
Browse files Browse the repository at this point in the history
….3.0

Update to CDS Spec 1.28.0
  • Loading branch information
vadkor authored Nov 30, 2023
2 parents 090f51a + ca7abf1 commit 49fe901
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 35 deletions.
8 changes: 4 additions & 4 deletions client-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ or, if you want to point to your own keystore:

docker run -p 8686:8686 -it -v /your/local/path/to/java-artefacts/client-cli/keystore:/keystore consumerdatastandardsaustralia/client-cli:x.x.x

Where `x.x.x` is the version, say, `2.2.0`
Where `x.x.x` is the version, say, `2.3.0`

Run locally-built image:

docker run -p 8383:8383 consumerdatastandardsaustralia/data-holder:2.2.1-SNAPSHOT
docker run -p 8383:8383 consumerdatastandardsaustralia/data-holder:2.3.1-SNAPSHOT

### Command Reference

Expand Down Expand Up @@ -183,8 +183,8 @@ or in the application.properties file before launching the application with `mvn

Example:

java -Dserver=http://localhost:8383/cds-au/v1 -jar target/client-cli-2.2.0.jar
java -Dserver=http://localhost:8383/cds-au/v1 -jar target/client-cli-2.3.0.jar

or

java -Dserver=http://localhost:8383/cds-au/v1 -jar target/client-cli-2.2.1-SNAPSHOT.jar
java -Dserver=http://localhost:8383/cds-au/v1 -jar target/client-cli-2.3.1-SNAPSHOT.jar
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ApiClient(boolean validating) {
json = new JSON(validating);

// Set default User-Agent.
setUserAgent("CDS Client/2.2.0/java");
setUserAgent("CDS Client/2.3.0/java");

addDefaultHeader("Accept", "application/json");
addDefaultHeader("Content-Type", "application/json");
Expand Down
6 changes: 3 additions & 3 deletions data-holder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you want to pass a [test data file](https://github.com/ConsumerDataStandardsA

java -jar target/data-holder-x.x.x.jar /your/local/path/to/testdata-cli/samples/output/u1-output.json

Where `x.x.x` is the version, say, `2.2.0`
Where `x.x.x` is the version, say, `2.3.0`

## Docker

Expand All @@ -36,8 +36,8 @@ If you want to pass a [test data file](https://github.com/ConsumerDataStandardsA

docker run -p 8383:8383 -v /your/local/path/to/testdata-cli/samples/output/u1-output.json:/testdata/u1-output.json consumerdatastandardsaustralia/data-holder:x.x.x /testdata/u1-output.json

Where `x.x.x` is the version, say, `2.2.0`
Where `x.x.x` is the version, say, `2.3.0`

Run locally-built image:

docker run -p 8383:8383 consumerdatastandardsaustralia/data-holder:2.2.1-SNAPSHOT
docker run -p 8383:8383 consumerdatastandardsaustralia/data-holder:2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.NativeWebRequest;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -57,6 +59,46 @@ protected void validatePageSize(Integer pageSize, UUID interactionId) {
}
}

protected void validateUpdatedSince(OffsetDateTime updatedSince, UUID interactionId) {
if (updatedSince != null && !updatedSince.isBefore(OffsetDateTime.now())) {
throwInvalidDate("updated-since is not in the past", interactionId);
}
}

protected void validateOldestNewestOffsetDateTime(OffsetDateTime oldestTime, OffsetDateTime newestTime, UUID interactionId) {
if (newestTime != null && !newestTime.isBefore(OffsetDateTime.now())) {
throwInvalidDate("newest-time is not in the past", interactionId);
}
if (oldestTime != null) {
if (!oldestTime.isBefore(OffsetDateTime.now())) {
throwInvalidDate("oldest-time is not in the past", interactionId);
}
if (newestTime != null && newestTime.isBefore(oldestTime)) {
throwInvalidDate("newest-time is before oldest-time", interactionId);
}
}
}

protected void validateOldestNewestLocalDate(LocalDate oldestDate, LocalDate newestDate, UUID interactionId) {
if (newestDate != null && !newestDate.isBefore(LocalDate.now())) {
throwInvalidDate("newest-date is not in the past", interactionId);
}
if (oldestDate != null) {
if (!oldestDate.isBefore(LocalDate.now())) {
throwInvalidDate("oldest-date is not in the past", interactionId);
}
if (newestDate != null && newestDate.isBefore(oldestDate)) {
throwInvalidDate("newest-date is before oldest-date", interactionId);
}
}
}

protected void throwInvalidDate(String message, UUID interactionId) {
throwCDSErrors(interactionId, Collections.singletonList(
new Error("Invalid Page Size", "urn:au-cds:error:cds-all:Field/InvalidDateTime", message)),
HttpStatus.BAD_REQUEST);
}

protected boolean hasSupportedVersion(Integer xMinV, Integer xV, int maxSupportedVersion) {
if (xMinV == null || xMinV > xV) {
return (maxSupportedVersion >= xV);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ ResponseEntity<ResponseBankingTransactionById> getTransactionDetail(
),
@ApiResponse(
code = 400,
message = "Invalid Version / Invalid Field / Missing Field / Invalid Date / Invalid Page Size",
message = "Invalid Field / Missing Field / Invalid Date / Invalid Page Size",
responseHeaders = @ResponseHeader(name = "x-fapi-interaction-id", response = UUID.class, description = "An **[[RFC4122]](#nref-RFC4122)** UUID used as a correlation id. If provided, the data holder must play back this value in the x-fapi-interaction-id response header. If not provided a **[[RFC4122]](#nref-RFC4122)** UUID value is required to be provided in the response header to track the interaction."),
response = ErrorListResponse.class
),
Expand Down Expand Up @@ -304,7 +304,7 @@ ResponseEntity<ResponseBankingTransactionList> getTransactions(
),
@ApiResponse(
code = 400,
message = "Invalid Version / Invalid Page Size / Invalid Field / Missing Field",
message = "Invalid Page Size / Invalid Field / Missing Field",
responseHeaders = @ResponseHeader(name = "x-fapi-interaction-id", response = UUID.class, description = "An **[[RFC4122]](#nref-RFC4122)** UUID used as a correlation id. If provided, the data holder must play back this value in the x-fapi-interaction-id response header. If not provided a **[[RFC4122]](#nref-RFC4122)** UUID value is required to be provided in the response header to track the interaction."),
response = ErrorListResponse.class
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public ResponseEntity<ResponseBankingTransactionList> getTransactions(String acc
Integer xV) {
int supportedVersion = validateHeaders(xCdsClientHeaders, xFapiCustomerIpAddress, xFapiInteractionId, xMinV, xV, 1);
validatePageSize(pageSize, xFapiInteractionId);
validateOldestNewestOffsetDateTime(oldestTime, newestTime, xFapiInteractionId);
HttpHeaders headers = generateResponseHeaders(xFapiInteractionId, supportedVersion);
Integer actualPage = getPagingValue(page, 1);
Integer actualPageSize = getPagingValue(pageSize, 25);
Expand All @@ -146,7 +147,7 @@ public ResponseEntity<ResponseBankingTransactionList> getTransactions(String acc
ResponseBankingTransactionList responseBankingTransactionList = new ResponseBankingTransactionList();
responseBankingTransactionList.setData(listData);
responseBankingTransactionList.setLinks(getLinkData(request, transactionPage, actualPage, actualPageSize));
responseBankingTransactionList.setMeta(getMetaData(transactionPage));
responseBankingTransactionList.setMeta(getTxMetaData(transactionPage, false));
return new ResponseEntity<>(responseBankingTransactionList, headers, HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ default Optional<NativeWebRequest> getRequest() {
),
@ApiResponse(
code = 400,
message = "Invalid Version / Invalid Page Size / Invalid Field / Missing Field",
message = "Invalid Page Size / Invalid Field / Missing Field",
responseHeaders = @ResponseHeader(name = "x-fapi-interaction-id", response = UUID.class, description = "An **[[RFC4122]](#nref-RFC4122)** UUID used as a correlation id. If provided, the data holder must play back this value in the x-fapi-interaction-id response header. If not provided a **[[RFC4122]](#nref-RFC4122)** UUID value is required to be provided in the response header to track the interaction."),
response = ErrorListResponse.class
),
Expand Down Expand Up @@ -134,7 +134,7 @@ ResponseEntity<ResponseBankingPayeeById> getPayeeDetail(
),
@ApiResponse(
code = 400,
message = "Invalid Version / Invalid Page Size / Invalid Field / Missing Field",
message = "Invalid Page Size / Invalid Field / Missing Field",
responseHeaders = @ResponseHeader(name = "x-fapi-interaction-id", response = UUID.class, description = "An **[[RFC4122]](#nref-RFC4122)** UUID used as a correlation id. If provided, the data holder must play back this value in the x-fapi-interaction-id response header. If not provided a **[[RFC4122]](#nref-RFC4122)** UUID value is required to be provided in the response header to track the interaction."),
response = ErrorListResponse.class
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ResponseEntity<ResponseBankingProductById> getProductDetail(
),
@ApiResponse(
code = 400,
message = "Invalid Version / Invalid Page Size / Invalid Field / Missing Field / Invalid Date",
message = "Invalid Page Size / Invalid Field / Missing Field / Invalid Date",
response = ErrorListResponse.class
),
@ApiResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public ResponseEntity<ResponseBankingProductList> listProducts(ParamEffective ef
effective, updatedSince, brand, productCategory, page, pageSize);
int supportedVersion = validateSupportedVersion(xMinV, xV, WebUtil.NO_INTERACTION_ID, 3);
validatePageSize(pageSize, WebUtil.NO_INTERACTION_ID);
validateUpdatedSince(updatedSince, WebUtil.NO_INTERACTION_ID);
HttpHeaders headers = generateResponseHeaders(null, supportedVersion);
BankingProduct bankingProduct = new BankingProductV2();
bankingProduct.setLastUpdated(updatedSince);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ ResponseEntity<ResponseBankingScheduledPaymentsList> listScheduledPayments(
),
@ApiResponse(
code = 400,
message = "Invalid Version / Invalid Page Size / Invalid Field / Missing Field",
message = "Invalid Page Size / Invalid Field / Missing Field",
responseHeaders = @ResponseHeader(name = "x-fapi-interaction-id", response = UUID.class, description = "An **[[RFC4122]](#nref-RFC4122)** UUID used as a correlation id. If provided, the data holder must play back this value in the x-fapi-interaction-id response header. If not provided a **[[RFC4122]](#nref-RFC4122)** UUID value is required to be provided in the response header to track the interaction."),
response = ErrorListResponse.class
),
Expand Down Expand Up @@ -222,7 +222,7 @@ ResponseEntity<ResponseBankingScheduledPaymentsList> listScheduledPaymentsBulk(
),
@ApiResponse(
code = 400,
message = "Invalid Version / Invalid Page Size / Invalid Field / Missing Field",
message = "Invalid Page Size / Invalid Field / Missing Field",
responseHeaders = @ResponseHeader(name = "x-fapi-interaction-id", response = UUID.class, description = "An **[[RFC4122]](#nref-RFC4122)** UUID used as a correlation id. If provided, the data holder must play back this value in the x-fapi-interaction-id response header. If not provided a **[[RFC4122]](#nref-RFC4122)** UUID value is required to be provided in the response header to track the interaction."),
response = ErrorListResponse.class
),
Expand Down
Loading

0 comments on commit 49fe901

Please sign in to comment.