diff --git a/pom.xml b/pom.xml index c99a24e..a155a02 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,7 @@ 2.15.2 5.10.0 1.9.0 - 1.18.28 + 1.18.30 1.18.20.0 4.11.0 6.55.0 diff --git a/src/main/java/org/hyperledger/aries/api/AcaPyRequestFilter.java b/src/main/java/org/hyperledger/aries/api/AcaPyRequestFilter.java index 073395a..211d083 100644 --- a/src/main/java/org/hyperledger/aries/api/AcaPyRequestFilter.java +++ b/src/main/java/org/hyperledger/aries/api/AcaPyRequestFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 - for information on the respective copyright owner + * Copyright (c) 2020-2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository at * https://github.com/hyperledger-labs/acapy-java-client * @@ -49,7 +49,7 @@ default HttpUrl.Builder buildParams(@NonNull HttpUrl.Builder b) { value = ((Boolean) o).toString().toLowerCase(Locale.US); } if (value != null) { - b.addQueryParameter(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES.translateName(f), value); + b.addQueryParameter(translateFieldName(f), value); } } } catch (IllegalAccessException e) { @@ -58,4 +58,12 @@ default HttpUrl.Builder buildParams(@NonNull HttpUrl.Builder b) { }); return b; } + + private static String translateFieldName(Field field) { + SerializedName sn = field.getAnnotation(SerializedName.class); + if (sn != null) { + return sn.value(); + } + return FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES.translateName(field); + } } diff --git a/src/main/java/org/hyperledger/aries/api/connection/CreateInvitationParams.java b/src/main/java/org/hyperledger/aries/api/connection/CreateInvitationParams.java index 11df625..6d40c07 100644 --- a/src/main/java/org/hyperledger/aries/api/connection/CreateInvitationParams.java +++ b/src/main/java/org/hyperledger/aries/api/connection/CreateInvitationParams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 - for information on the respective copyright owner + * Copyright (c) 2020-2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository at * https://github.com/hyperledger-labs/acapy-java-client * @@ -7,6 +7,7 @@ */ package org.hyperledger.aries.api.connection; +import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -18,5 +19,6 @@ public class CreateInvitationParams implements AcaPyRequestFilter { private String alias; private Boolean autoAccept; private Boolean multiUse; + @SerializedName("public") private Boolean isPublic; } diff --git a/src/main/java/org/hyperledger/aries/api/present_proof/PresentationRequestCredentialsFilter.java b/src/main/java/org/hyperledger/aries/api/present_proof/PresentationRequestCredentialsFilter.java index 35218c0..aecd973 100644 --- a/src/main/java/org/hyperledger/aries/api/present_proof/PresentationRequestCredentialsFilter.java +++ b/src/main/java/org/hyperledger/aries/api/present_proof/PresentationRequestCredentialsFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 - for information on the respective copyright owner + * Copyright (c) 2020-2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository at * https://github.com/hyperledger-labs/acapy-java-client * @@ -40,7 +40,7 @@ public HttpUrl.Builder buildParams(@NonNull HttpUrl.Builder b) { if (StringUtils.isNotEmpty(extraQuery)) { b.addQueryParameter("extra_query", extraQuery); } - if (referent != null && referent.size() > 0) { + if (referent != null && !referent.isEmpty()) { StringBuilder sb = new StringBuilder(); Iterator it = referent.stream().iterator(); while (it.hasNext()) { diff --git a/src/test/java/org/hyperledger/aries/api/AcaPyRequestFilterTest.java b/src/test/java/org/hyperledger/aries/api/AcaPyRequestFilterTest.java index 137036f..0172d34 100644 --- a/src/test/java/org/hyperledger/aries/api/AcaPyRequestFilterTest.java +++ b/src/test/java/org/hyperledger/aries/api/AcaPyRequestFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 - for information on the respective copyright owner + * Copyright (c) 2020-2023 - for information on the respective copyright owner * see the NOTICE file and/or the repository at * https://github.com/hyperledger-labs/acapy-java-client * @@ -55,6 +55,13 @@ void testListWalletDid() { Assertions.assertEquals(url + "?key_type=bls12381g2", f.buildParams(b).toString()); } + @Test + void testAnnotatedBoolean() { + HttpUrl.Builder b = Objects.requireNonNull(base).newBuilder(); + AnnotatedBoolean ab = AnnotatedBoolean.builder().isPublic(Boolean.TRUE).build(); + Assertions.assertEquals(url + "?public=true", ab.buildParams(b).toString()); + } + @Test void testEmptyString() { HttpUrl.Builder b = Objects.requireNonNull(base).newBuilder(); @@ -79,4 +86,10 @@ private enum AnnotatedDummyEnum { @SerializedName("value_2") VALUE2 } + + @Builder + private static final class AnnotatedBoolean implements AcaPyRequestFilter { + @SerializedName("public") + private Boolean isPublic; + } }