diff --git a/mdx-gateway-generator/gradle.lockfile b/mdx-gateway-generator/gradle.lockfile index fe22f864..eda2e55e 100644 --- a/mdx-gateway-generator/gradle.lockfile +++ b/mdx-gateway-generator/gradle.lockfile @@ -1,22 +1,29 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.auth0:java-jwt:4.5.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.auth0:java-jwt:4.5.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.datadoghq:dd-trace-api:1.38.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.fasterxml.jackson.core:jackson-annotations:2.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-core:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson:jackson-bom:2.21.3=runtimeClasspath,testRuntimeClasspath com.fasterxml.woodstox:woodstox-core:7.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.github.rholder:guava-retrying:2.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.github.spotbugs:spotbugs-annotations:4.9.8=annotationProcessor,compileClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath com.github.spotbugs:spotbugs:4.9.8=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,compileClasspath,runtimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotations:2.41.0=compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +com.google.code.gson:gson:2.13.2=spotbugs +com.google.code.gson:gson:2.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.google.errorprone:error_prone_annotations:2.41.0=spotbugs +com.google.errorprone:error_prone_annotations:2.48.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:failureaccess:1.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:guava:32.1.3-jre=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/mdx-gateways/gradle.lockfile b/mdx-gateways/gradle.lockfile index c17d9c1c..0112d853 100644 --- a/mdx-gateways/gradle.lockfile +++ b/mdx-gateways/gradle.lockfile @@ -1,14 +1,19 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.auth0:java-jwt:4.5.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.auth0:java-jwt:4.5.2=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.datadoghq:dd-trace-api:1.38.0=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.fasterxml.jackson.core:jackson-annotations:2.21=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-core:2.21.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-databind:2.21.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson:jackson-bom:2.21.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-core:2.21.3=annotationProcessor,runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.3=annotationProcessor,runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.3=annotationProcessor,runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.3=annotationProcessor,runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson:jackson-bom:2.21.3=annotationProcessor,runtimeClasspath,testRuntimeClasspath com.fasterxml.woodstox:woodstox-core:7.1.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.github.oowekyala.ooxml:nice-xml-messages:3.1=pmd com.github.rholder:guava-retrying:2.0.0=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath @@ -16,9 +21,11 @@ com.github.spotbugs:spotbugs-annotations:4.9.8=annotationProcessor,compileClassp com.github.spotbugs:spotbugs:4.9.8=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=annotationProcessor,compileClasspath,pmd,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +com.google.code.gson:gson:2.13.2=pmd,spotbugs +com.google.code.gson:gson:2.14.0=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.errorprone:error_prone_annotations:2.36.0=checkstyle -com.google.errorprone:error_prone_annotations:2.41.0=annotationProcessor,compileClasspath,pmd,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +com.google.errorprone:error_prone_annotations:2.41.0=pmd,spotbugs +com.google.errorprone:error_prone_annotations:2.48.0=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:failureaccess:1.0.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:failureaccess:1.0.3=checkstyle com.google.guava:guava:32.1.3-jre=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/mdx-models/gradle.lockfile b/mdx-models/gradle.lockfile index fd207971..c700dd8e 100644 --- a/mdx-models/gradle.lockfile +++ b/mdx-models/gradle.lockfile @@ -1,14 +1,19 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.auth0:java-jwt:4.5.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.auth0:java-jwt:4.5.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.datadoghq:dd-trace-api:1.38.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.fasterxml.jackson.core:jackson-annotations:2.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-core:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson:jackson-bom:2.21.3=runtimeClasspath,testRuntimeClasspath com.fasterxml.woodstox:woodstox-core:7.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.github.oowekyala.ooxml:nice-xml-messages:3.1=pmd com.github.rholder:guava-retrying:2.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath @@ -16,9 +21,11 @@ com.github.spotbugs:spotbugs-annotations:4.9.8=annotationProcessor,compileClassp com.github.spotbugs:spotbugs:4.9.8=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=compileClasspath,pmd,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +com.google.code.gson:gson:2.13.2=pmd,spotbugs +com.google.code.gson:gson:2.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.errorprone:error_prone_annotations:2.36.0=checkstyle -com.google.errorprone:error_prone_annotations:2.41.0=compileClasspath,pmd,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +com.google.errorprone:error_prone_annotations:2.41.0=pmd,spotbugs +com.google.errorprone:error_prone_annotations:2.48.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:failureaccess:1.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:failureaccess:1.0.3=checkstyle com.google.guava:guava:32.1.3-jre=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java index 3ed00011..abb294e8 100644 --- a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java +++ b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java @@ -99,6 +99,29 @@ public AccessorResponse updateSettings(Settings settings) { throw new AccessorMethodNotImplementedException(); } + /** + * Get Payment Settings - Version 20260427 + * + * @return + */ + @GatewayAPI + @API(description = "Get the current Payment Settings version 20260427") + public AccessorResponse settings20260427() { + throw new AccessorMethodNotImplementedException(); + } + + /** + * Update Payment Settings - Version 20260427 + * + * @param settings + * @return + */ + @GatewayAPI + @API(description = "Update the Payment Settings version 20260427") + public AccessorResponse updateSettings20260427(com.mx.path.model.mdx.model.payment.v20260427.Settings settings) { + throw new AccessorMethodNotImplementedException(); + } + /** * List accounts to pay from * diff --git a/mdx-models/src/main/java/com/mx/path/model/mdx/model/Resources.java b/mdx-models/src/main/java/com/mx/path/model/mdx/model/Resources.java index 92651b1f..2ddd5362 100644 --- a/mdx-models/src/main/java/com/mx/path/model/mdx/model/Resources.java +++ b/mdx-models/src/main/java/com/mx/path/model/mdx/model/Resources.java @@ -426,6 +426,7 @@ private static void registerPaymentsModels(GsonBuilder builder) { // Payment builder.registerTypeAdapter(Enrollment.class, new ModelWrappableSerializer("enrollment")); builder.registerTypeAdapter(Settings.class, new ModelWrappableSerializer("settings")); + builder.registerTypeAdapter(com.mx.path.model.mdx.model.payment.v20260427.Settings.class, new ModelWrappableSerializer("settings")); builder.registerTypeAdapter(Payment.class, new ModelWrappableSerializer("payment")); builder.registerTypeAdapter(new TypeToken>() { }.getType(), new ModelWrappableSerializer("payments")); diff --git a/mdx-models/src/main/java/com/mx/path/model/mdx/model/payment/v20260427/Settings.java b/mdx-models/src/main/java/com/mx/path/model/mdx/model/payment/v20260427/Settings.java new file mode 100644 index 00000000..44ad2e6b --- /dev/null +++ b/mdx-models/src/main/java/com/mx/path/model/mdx/model/payment/v20260427/Settings.java @@ -0,0 +1,19 @@ +package com.mx.path.model.mdx.model.payment.v20260427; + +import java.util.List; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import com.mx.path.model.mdx.model.MdxBase; +import com.mx.path.model.mdx.model.challenges.Challenge; + +@EqualsAndHashCode(callSuper = true) +@Data +public final class Settings extends MdxBase { + private List settings; + private List challenges; + + public Settings() { + } +} diff --git a/mdx-web/gradle.lockfile b/mdx-web/gradle.lockfile index 449b8cdc..2a868c7b 100644 --- a/mdx-web/gradle.lockfile +++ b/mdx-web/gradle.lockfile @@ -3,16 +3,23 @@ # This file is expected to be part of source control. ch.qos.logback:logback-classic:1.5.32=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath ch.qos.logback:logback-core:1.5.32=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.auth0:java-jwt:4.5.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.auth0:java-jwt:4.5.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.datadoghq:dd-trace-api:1.38.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.fasterxml.jackson.core:jackson-annotations:2.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.module:jackson-module-parameter-names:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-core:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.module:jackson-module-parameter-names:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.module:jackson-module-parameter-names:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson:jackson-bom:2.21.3=runtimeClasspath,testRuntimeClasspath com.fasterxml.woodstox:woodstox-core:7.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.github.oowekyala.ooxml:nice-xml-messages:3.1=pmd com.github.rholder:guava-retrying:2.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java b/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java index 2fd35632..0f49df8b 100644 --- a/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java +++ b/mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import jakarta.servlet.http.HttpServletRequest; + @RestController @RequestMapping(value = "{clientId}/users/{user_id}", produces = BaseController.MDX_MEDIA) public class PaymentsController extends BaseController { @@ -31,26 +33,55 @@ public final ResponseEntity setPaymentEnrollment(@RequestBody Enroll return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); } + @SuppressWarnings("MagicNumber") @RequestMapping(value = "/payments/settings", method = RequestMethod.GET) - public final ResponseEntity getPaymentSettings() { - AccessorResponse response = gateway().payments().settings(); - Settings result = response.getResult(); - // Return 202 returning challenge questions - if (result != null && result.getChallenges() != null && result.getChallenges().size() > 0) { - return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.ACCEPTED); - } - return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); + public final ResponseEntity getPaymentSettings(HttpServletRequest request) { + return versioned(request) + .defaultVersion(Settings.class, Settings.class, settings -> { + AccessorResponse response = gateway().payments().settings(); + Settings result = response.getResult(); + // Return 202 returning challenge questions + if (result != null && result.getChallenges() != null && !result.getChallenges().isEmpty()) { + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.ACCEPTED); + } + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); + }) + .version(20260427, com.mx.path.model.mdx.model.payment.v20260427.Settings.class, com.mx.path.model.mdx.model.payment.v20260427.Settings.class, settings -> { + AccessorResponse response = gateway().payments().settings20260427(); + com.mx.path.model.mdx.model.payment.v20260427.Settings result = response.getResult(); + // Return 202 returning settings and challenge questions + if ((result != null && result.getSettings() != null && !result.getSettings().isEmpty()) + || (result != null && result.getChallenges() != null && !result.getChallenges().isEmpty())) { + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.ACCEPTED); + } + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); + }) + .execute(); } + @SuppressWarnings("MagicNumber") @RequestMapping(value = "/payments/settings", method = RequestMethod.PUT, consumes = BaseController.MDX_MEDIA) - public final ResponseEntity setPaymentSettings(@RequestBody Settings settingsRequest) { - AccessorResponse response = gateway().payments().updateSettings(settingsRequest); - Settings result = response.getResult(); - // Return 202 returning challenge questions - if (result != null && result.getChallenges() != null && result.getChallenges().size() > 0) { - return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.ACCEPTED); - } - return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); + public final ResponseEntity setPaymentSettings(HttpServletRequest request) { + return versioned(request) + .defaultVersion(Settings.class, Settings.class, settings -> { + AccessorResponse response = gateway().payments().updateSettings(settings); + Settings result = response.getResult(); + // Return 202 returning challenge questions + if (result != null && result.getChallenges() != null && !result.getChallenges().isEmpty()) { + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.ACCEPTED); + } + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); + }) + .version(20260427, com.mx.path.model.mdx.model.payment.v20260427.Settings.class, com.mx.path.model.mdx.model.payment.v20260427.Settings.class, settings -> { + AccessorResponse response = gateway().payments().updateSettings20260427(settings); + com.mx.path.model.mdx.model.payment.v20260427.Settings result = response.getResult(); + // Return 202 returning challenge questions + if ((result != null && result.getSettings() != null && !result.getSettings().isEmpty()) + || (result != null && result.getChallenges() != null && !result.getChallenges().isEmpty())) { + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.ACCEPTED); + } + return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK); + }).execute(); } @RequestMapping(value = "/payments", method = RequestMethod.POST, consumes = BaseController.MDX_MEDIA) diff --git a/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy b/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy index 108e8b2a..21e0fa88 100644 --- a/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy +++ b/mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy @@ -1,12 +1,19 @@ package com.mx.path.model.mdx.web.controller +import static org.mockito.Mockito.any +import static org.mockito.Mockito.mock import static org.mockito.Mockito.spy import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import com.mx.path.core.context.Session import com.mx.path.gateway.accessor.AccessorResponse import com.mx.path.gateway.api.Gateway import com.mx.path.gateway.api.payment.PaymentGateway import com.mx.path.model.mdx.model.MdxList +import com.mx.path.model.mdx.model.Resources import com.mx.path.model.mdx.model.account.Account import com.mx.path.model.mdx.model.challenges.Challenge import com.mx.path.model.mdx.model.payment.Payment @@ -17,16 +24,24 @@ import org.springframework.http.HttpStatus import spock.lang.Specification +import jakarta.servlet.http.HttpServletRequest + class PaymentsControllerTest extends Specification { PaymentsController subject Gateway gateway PaymentGateway paymentGateway + Gson gson def setup() { paymentGateway = spy(PaymentGateway.builder().build()) gateway = Gateway.builder().payments(paymentGateway).build() subject = new PaymentsController() + + GsonBuilder builder = new GsonBuilder() + Resources.registerResources(builder) + + gson = builder.create() } def cleanup() { @@ -127,6 +142,18 @@ class PaymentsControllerTest extends Specification { verify(paymentGateway).accounts() || true } + def buildRequest(Object body, String contentType) { + HttpServletRequest request = mock(HttpServletRequest.class) + when(request.getReader()).thenReturn(new BufferedReader(new StringReader(gson.toJson(body)))) + if (Session.current() != null) { + when(request.getHeader("mx-session-key")).thenReturn(Session.current().getId()) + } + when(request.getHeaders("Content-Type")).thenReturn(Collections.enumeration([contentType])) + when(request.getHeaders("Accept")).thenReturn(Collections.enumeration([contentType])) + + return request + } + def "getPaymentSettings interacts with gateway - 202"() { given: BaseController.setGateway(gateway) @@ -139,7 +166,7 @@ class PaymentsControllerTest extends Specification { when: Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).settings() - def response = subject.getPaymentSettings() + def response = subject.getPaymentSettings(buildRequest(null, "application/vnd.moneydesktop.v2+json")) then: HttpStatus.ACCEPTED == response.getStatusCode() @@ -155,7 +182,7 @@ class PaymentsControllerTest extends Specification { when: Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).settings() - def response = subject.getPaymentSettings() + def response = subject.getPaymentSettings(buildRequest(null, "application/vnd.moneydesktop.v2+json")) then: HttpStatus.OK == response.getStatusCode() @@ -174,13 +201,13 @@ class PaymentsControllerTest extends Specification { } when: - Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).updateSettings(settings) - def response = subject.setPaymentSettings(settings) + Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).updateSettings(any(Settings.class)) + def response = subject.setPaymentSettings(buildRequest(settings, "application/vnd.moneydesktop.v2+json")) then: HttpStatus.ACCEPTED == response.getStatusCode() response.getBody() == settings - verify(paymentGateway).updateSettings(settings) || true + verify(paymentGateway).updateSettings(any(Settings.class)) || true } def "setPaymentSettings interacts with gateway - 200"() { @@ -190,12 +217,94 @@ class PaymentsControllerTest extends Specification { def settings = new Settings() when: - Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).updateSettings(settings) - def response = subject.setPaymentSettings(settings) + Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).updateSettings(any(Settings.class)) + def response = subject.setPaymentSettings(buildRequest(settings, "application/vnd.moneydesktop.v2+json")) then: HttpStatus.OK == response.getStatusCode() response.getBody() == settings - verify(paymentGateway).updateSettings(settings) || true + verify(paymentGateway).updateSettings(any(Settings.class)) || true + } + + def "getPaymentSettings v20260427 interacts with gateway - 202"() { + given: + BaseController.setGateway(gateway) + + def settings = new com.mx.path.model.mdx.model.payment.v20260427.Settings().tap { + setChallenges(new ArrayList().tap { + add(new Challenge()) + }) + setSettings(new ArrayList().tap { + add(new Challenge()) + }) + } + + when: + Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).settings20260427() + def response = subject.getPaymentSettings(buildRequest(null, "application/vnd.moneydesktop.v2+json;version=20260427")) + + then: + HttpStatus.ACCEPTED == response.getStatusCode() + response.getBody() instanceof com.mx.path.model.mdx.model.payment.v20260427.Settings + response.getBody().getSettings() == settings.getSettings() + verify(paymentGateway).settings20260427() || true + } + + def "getPaymentSettings v20260427 interacts with gateway - 200"() { + given: + BaseController.setGateway(gateway) + + def settings = new com.mx.path.model.mdx.model.payment.v20260427.Settings() + + when: + Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).settings20260427() + def response = subject.getPaymentSettings(buildRequest(null, "application/vnd.moneydesktop.v2+json;version=20260427")) + + then: + HttpStatus.OK == response.getStatusCode() + response.getBody() instanceof com.mx.path.model.mdx.model.payment.v20260427.Settings + response.getBody().getSettings() == settings.getSettings() + verify(paymentGateway).settings20260427() || true + } + + def "setPaymentSettings v20260427 interacts with gateway - 202"() { + given: + BaseController.setGateway(gateway) + + def settings = new com.mx.path.model.mdx.model.payment.v20260427.Settings().tap { + setChallenges(new ArrayList().tap { + add(new Challenge()) + }) + setSettings(new ArrayList().tap { + add(new Challenge()) + }) + } + + when: + Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).updateSettings20260427(any(com.mx.path.model.mdx.model.payment.v20260427.Settings.class)) + def response = subject.setPaymentSettings(buildRequest(settings.wrapped(), "application/vnd.moneydesktop.v2+json;version=20260427")) + + then: + HttpStatus.ACCEPTED == response.getStatusCode() + response.getBody() instanceof com.mx.path.model.mdx.model.payment.v20260427.Settings + response.getBody().getSettings() == settings.getSettings() + verify(paymentGateway).updateSettings20260427(any(com.mx.path.model.mdx.model.payment.v20260427.Settings.class)) || true + } + + def "setPaymentSettings v20260427 interacts with gateway - 200"() { + given: + BaseController.setGateway(gateway) + + def settings = new com.mx.path.model.mdx.model.payment.v20260427.Settings() + + when: + Mockito.doReturn(new AccessorResponse().withResult(settings)).when(paymentGateway).updateSettings20260427(any(com.mx.path.model.mdx.model.payment.v20260427.Settings.class)) + def response = subject.setPaymentSettings(buildRequest(settings, "application/vnd.moneydesktop.v2+json;version=20260427")) + + then: + HttpStatus.OK == response.getStatusCode() + response.getBody() instanceof com.mx.path.model.mdx.model.payment.v20260427.Settings + response.getBody().getSettings() == settings.getSettings() + verify(paymentGateway).updateSettings20260427(any(com.mx.path.model.mdx.model.payment.v20260427.Settings.class)) || true } } diff --git a/realtime/gradle.lockfile b/realtime/gradle.lockfile index 5fe6bd4a..f68685b7 100644 --- a/realtime/gradle.lockfile +++ b/realtime/gradle.lockfile @@ -1,14 +1,19 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -com.auth0:java-jwt:4.5.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.auth0:java-jwt:4.5.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.datadoghq:dd-trace-api:1.38.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.fasterxml.jackson.core:jackson-annotations:2.21=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-core:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-core:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.core:jackson-databind:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.21.3=runtimeClasspath,testRuntimeClasspath +com.fasterxml.jackson:jackson-bom:2.21.1=compileClasspath,testCompileClasspath +com.fasterxml.jackson:jackson-bom:2.21.3=runtimeClasspath,testRuntimeClasspath com.fasterxml.woodstox:woodstox-core:7.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.github.oowekyala.ooxml:nice-xml-messages:3.1=pmd com.github.rholder:guava-retrying:2.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath @@ -16,9 +21,11 @@ com.github.spotbugs:spotbugs-annotations:4.9.8=annotationProcessor,compileClassp com.github.spotbugs:spotbugs:4.9.8=spotbugs com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs com.google.code.findbugs:jsr305:3.0.2=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,spotbugs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=compileClasspath,pmd,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +com.google.code.gson:gson:2.13.2=pmd,spotbugs +com.google.code.gson:gson:2.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.errorprone:error_prone_annotations:2.36.0=checkstyle -com.google.errorprone:error_prone_annotations:2.41.0=compileClasspath,pmd,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath +com.google.errorprone:error_prone_annotations:2.41.0=pmd,spotbugs +com.google.errorprone:error_prone_annotations:2.48.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:failureaccess:1.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.google.guava:failureaccess:1.0.3=checkstyle com.google.guava:guava:32.1.3-jre=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath