FINERACT-1724: Client search V2 API

This commit is contained in:
Arnold Galovics
2023-05-23 13:41:30 +02:00
committed by Arnold Gálovics
parent c18fead7f3
commit 68c6053bd7
31 changed files with 1473 additions and 6 deletions
@@ -52,6 +52,7 @@ import org.apache.fineract.client.services.ChargesApi;
import org.apache.fineract.client.services.ClientApi;
import org.apache.fineract.client.services.ClientChargesApi;
import org.apache.fineract.client.services.ClientIdentifierApi;
import org.apache.fineract.client.services.ClientSearchV2Api;
import org.apache.fineract.client.services.ClientTransactionApi;
import org.apache.fineract.client.services.ClientsAddressApi;
import org.apache.fineract.client.services.CodeValuesApi;
@@ -153,7 +154,7 @@ import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory;
/**
* Fineract Client Java SDK API entry point. Use this instead of the {@link ApiClient}.
* Fineract Client Java SDK API entry point.
*
* @author Michael Vorburger.ch
*/
@@ -187,6 +188,8 @@ public final class FineractClient {
public final CentersApi centers;
public final ChargesApi charges;
public final ClientApi clients;
public final ClientSearchV2Api clientSearchV2;
public final ClientChargesApi clientCharges;
public final ClientIdentifierApi clientIdentifiers;
public final ClientsAddressApi clientAddresses;
@@ -305,6 +308,7 @@ public final class FineractClient {
centers = retrofit.create(CentersApi.class);
charges = retrofit.create(ChargesApi.class);
clients = retrofit.create(ClientApi.class);
clientSearchV2 = retrofit.create(ClientSearchV2Api.class);
clientCharges = retrofit.create(ClientChargesApi.class);
clientIdentifiers = retrofit.create(ClientIdentifierApi.class);
clientAddresses = retrofit.create(ClientsAddressApi.class);
@@ -537,7 +541,6 @@ public final class FineractClient {
* Obtain the internal Retrofit Builder. This method is typically not required to be invoked for simple API
* usages, but can be a handy back door for non-trivial advanced customizations of the API client.
*
* @return the {@link ApiClient} which {@link #build()} will use.
*/
public retrofit2.Retrofit.Builder getRetrofitBuilder() {
return retrofitBuilder;
@@ -547,7 +550,6 @@ public final class FineractClient {
* Obtain the internal OkHttp Builder. This method is typically not required to be invoked for simple API
* usages, but can be a handy back door for non-trivial advanced customizations of the API client.
*
* @return the {@link ApiClient} which {@link #build()} will use.
*/
public okhttp3.OkHttpClient.Builder getOkBuilder() {
return okBuilder;
@@ -37,6 +37,8 @@ import java.time.format.DateTimeFormatter;
import java.util.Date;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import org.apache.fineract.client.models.ExternalId;
import org.apache.fineract.client.util.adapter.ExternalIdAdapter;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
@@ -51,12 +53,14 @@ public class JSON {
private final SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
private final OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private final LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private final ExternalIdAdapter externalIdAdapter = new ExternalIdAdapter();
public JSON() {
gson = new GsonFireBuilder().createGsonBuilder().registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter).create();
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter).registerTypeAdapter(ExternalId.class, externalIdAdapter)
.create();
}
public Gson getGson() {
@@ -0,0 +1,50 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.client.util.adapter;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import org.apache.fineract.client.models.ExternalId;
public class ExternalIdAdapter extends TypeAdapter<ExternalId> {
@Override
public void write(JsonWriter out, ExternalId value) throws IOException {
if (value != null && Boolean.FALSE.equals(value.getEmpty())) {
out.value(value.getValue());
} else {
out.nullValue();
}
}
@Override
public ExternalId read(JsonReader in) throws IOException {
ExternalId result = new ExternalId().empty(true);
switch (in.peek()) {
case NULL:
in.nextNull();
return result;
default:
String value = in.nextString();
return new ExternalId().empty(false).value(value);
}
}
}