Skip to content

Commit

Permalink
generating code with jdk8
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkaspa committed Oct 30, 2023
1 parent e1a868e commit 25c4ae0
Show file tree
Hide file tree
Showing 73 changed files with 454 additions and 336 deletions.
Empty file modified src/main/AndroidManifest.xml
100755 → 100644
Empty file.
15 changes: 14 additions & 1 deletion src/main/java/com/lob/api/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -265,6 +268,16 @@ public ApiClient setSqlDateFormat(DateFormat dateFormat) {
return this;
}

public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
this.json.setOffsetDateTimeFormat(dateFormat);
return this;
}

public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
this.json.setLocalDateFormat(dateFormat);
return this;
}

public ApiClient setLenientOnJson(boolean lenientOnJson) {
this.json.setLenientOnJson(lenientOnJson);
return this;
Expand Down Expand Up @@ -525,7 +538,7 @@ public ApiClient setWriteTimeout(int writeTimeout) {
public String parameterToString(Object param) {
if (param == null) {
return "";
} else if (param instanceof Date ) {
} else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) {
//Serialize to json string and remove the " enclosing characters
String jsonStr = json.serialize(param);
return jsonStr.substring(1, jsonStr.length() - 1);
Expand Down
102 changes: 102 additions & 0 deletions src/main/java/com/lob/api/JSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
Expand All @@ -43,6 +46,8 @@ public class JSON {
private boolean isLenientOnJson = false;
private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -80,6 +85,8 @@ public JSON() {
gson = createGson()
.registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
.registerTypeAdapter(byte[].class, byteArrayAdapter)
.create();
}
Expand Down Expand Up @@ -177,6 +184,101 @@ public byte[] read(JsonReader in) throws IOException {
}
}

/**
* Gson TypeAdapter for JSR310 OffsetDateTime type
*/
public static class OffsetDateTimeTypeAdapter extends TypeAdapter<OffsetDateTime> {

private DateTimeFormatter formatter;

public OffsetDateTimeTypeAdapter() {
this(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
}

public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) {
this.formatter = formatter;
}

public void setFormat(DateTimeFormatter dateFormat) {
this.formatter = dateFormat;
}

@Override
public void write(JsonWriter out, OffsetDateTime date) throws IOException {
if (date == null) {
out.nullValue();
} else {
out.value(formatter.format(date));
}
}

@Override
public OffsetDateTime read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
if (date.endsWith("+0000")) {
date = date.substring(0, date.length()-5) + "Z";
}
return OffsetDateTime.parse(date, formatter);
}
}
}

/**
* Gson TypeAdapter for JSR310 LocalDate type
*/
public class LocalDateTypeAdapter extends TypeAdapter<LocalDate> {

private DateTimeFormatter formatter;

public LocalDateTypeAdapter() {
this(DateTimeFormatter.ISO_LOCAL_DATE);
}

public LocalDateTypeAdapter(DateTimeFormatter formatter) {
this.formatter = formatter;
}

public void setFormat(DateTimeFormatter dateFormat) {
this.formatter = dateFormat;
}

@Override
public void write(JsonWriter out, LocalDate date) throws IOException {
if (date == null) {
out.nullValue();
} else {
out.value(formatter.format(date));
}
}

@Override
public LocalDate read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
return LocalDate.parse(date, formatter);
}
}
}

public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
offsetDateTimeTypeAdapter.setFormat(dateFormat);
return this;
}

public JSON setLocalDateFormat(DateTimeFormatter dateFormat) {
localDateTypeAdapter.setFormat(dateFormat);
return this;
}

/**
* Gson TypeAdapter for java.sql.Date type
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/lob/api/client/AddressesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import com.lob.model.AddressDeletion;
import com.lob.model.AddressEditable;
import com.lob.model.AddressList;
import java.util.Date;
import com.lob.model.LobError;
import java.time.OffsetDateTime;

import java.lang.reflect.Type;
import java.util.ArrayList;
Expand Down Expand Up @@ -448,7 +448,7 @@ public okhttp3.Call getAsync(String adrId, final ApiCallback<Address> _callback)
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call listCall(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata, final ApiCallback _callback) throws ApiException {
public okhttp3.Call listCall(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = null;

// create path and map variables
Expand Down Expand Up @@ -503,7 +503,7 @@ public okhttp3.Call listCall(Integer limit, String before, String after, List<St
}

@SuppressWarnings("rawtypes")
private okhttp3.Call listValidateBeforeCall(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata, final ApiCallback _callback) throws ApiException {
private okhttp3.Call listValidateBeforeCall(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata, final ApiCallback _callback) throws ApiException {


okhttp3.Call localVarCall = listCall(limit, before, after, include, dateCreated, metadata, _callback);
Expand All @@ -529,7 +529,7 @@ private okhttp3.Call listValidateBeforeCall(Integer limit, String before, String
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public AddressList list(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata) throws ApiException {
public AddressList list(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata) throws ApiException {
try {
ApiResponse<AddressList> localVarResp = listWithHttpInfo(limit, before, after, include, dateCreated, metadata);
return localVarResp.getData();
Expand All @@ -556,7 +556,7 @@ public AddressList list(Integer limit, String before, String after, List<String>
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public ApiResponse<AddressList> listWithHttpInfo(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata) throws ApiException {
public ApiResponse<AddressList> listWithHttpInfo(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata) throws ApiException {
try {
okhttp3.Call localVarCall = listValidateBeforeCall(limit, before, after, include, dateCreated, metadata, null);
Type localVarReturnType = new TypeToken<AddressList>(){}.getType();
Expand Down Expand Up @@ -585,7 +585,7 @@ public ApiResponse<AddressList> listWithHttpInfo(Integer limit, String before, S
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call listAsync(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata, final ApiCallback<AddressList> _callback) throws ApiException {
public okhttp3.Call listAsync(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata, final ApiCallback<AddressList> _callback) throws ApiException {

okhttp3.Call localVarCall = listValidateBeforeCall(limit, before, after, include, dateCreated, metadata, _callback);
Type localVarReturnType = new TypeToken<AddressList>(){}.getType();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/lob/api/client/BankAccountsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import com.lob.model.BankAccountList;
import com.lob.model.BankAccountVerify;
import com.lob.model.BankAccountWritable;
import java.util.Date;
import com.lob.model.LobError;
import java.time.OffsetDateTime;

import java.lang.reflect.Type;
import java.util.ArrayList;
Expand Down Expand Up @@ -582,7 +582,7 @@ public okhttp3.Call verifyAsync(String bankId, BankAccountVerify bankAccountVeri
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call listCall(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata, final ApiCallback _callback) throws ApiException {
public okhttp3.Call listCall(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = null;

// create path and map variables
Expand Down Expand Up @@ -637,7 +637,7 @@ public okhttp3.Call listCall(Integer limit, String before, String after, List<St
}

@SuppressWarnings("rawtypes")
private okhttp3.Call listValidateBeforeCall(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata, final ApiCallback _callback) throws ApiException {
private okhttp3.Call listValidateBeforeCall(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata, final ApiCallback _callback) throws ApiException {


okhttp3.Call localVarCall = listCall(limit, before, after, include, dateCreated, metadata, _callback);
Expand All @@ -663,7 +663,7 @@ private okhttp3.Call listValidateBeforeCall(Integer limit, String before, String
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public BankAccountList list(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata) throws ApiException {
public BankAccountList list(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata) throws ApiException {
try {
ApiResponse<BankAccountList> localVarResp = listWithHttpInfo(limit, before, after, include, dateCreated, metadata);
return localVarResp.getData();
Expand All @@ -690,7 +690,7 @@ public BankAccountList list(Integer limit, String before, String after, List<Str
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public ApiResponse<BankAccountList> listWithHttpInfo(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata) throws ApiException {
public ApiResponse<BankAccountList> listWithHttpInfo(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata) throws ApiException {
try {
okhttp3.Call localVarCall = listValidateBeforeCall(limit, before, after, include, dateCreated, metadata, null);
Type localVarReturnType = new TypeToken<BankAccountList>(){}.getType();
Expand Down Expand Up @@ -719,7 +719,7 @@ public ApiResponse<BankAccountList> listWithHttpInfo(Integer limit, String befor
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call listAsync(Integer limit, String before, String after, List<String> include, Map<String, Date> dateCreated, Map<String, String> metadata, final ApiCallback<BankAccountList> _callback) throws ApiException {
public okhttp3.Call listAsync(Integer limit, String before, String after, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> metadata, final ApiCallback<BankAccountList> _callback) throws ApiException {

okhttp3.Call localVarCall = listValidateBeforeCall(limit, before, after, include, dateCreated, metadata, _callback);
Type localVarReturnType = new TypeToken<BankAccountList>(){}.getType();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/lob/api/client/BillingGroupsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import com.lob.model.BillingGroup;
import com.lob.model.BillingGroupEditable;
import com.lob.model.BillingGroupList;
import java.util.Date;
import com.lob.model.LobError;
import java.time.OffsetDateTime;
import com.lob.model.SortByDateModified;

import java.lang.reflect.Type;
Expand Down Expand Up @@ -457,7 +457,7 @@ public okhttp3.Call updateAsync(String bgId, BillingGroupEditable billingGroupEd
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call listCall(Integer limit, Integer offset, List<String> include, Map<String, Date> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified, final ApiCallback _callback) throws ApiException {
public okhttp3.Call listCall(Integer limit, Integer offset, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = null;

// create path and map variables
Expand Down Expand Up @@ -512,7 +512,7 @@ public okhttp3.Call listCall(Integer limit, Integer offset, List<String> include
}

@SuppressWarnings("rawtypes")
private okhttp3.Call listValidateBeforeCall(Integer limit, Integer offset, List<String> include, Map<String, Date> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified, final ApiCallback _callback) throws ApiException {
private okhttp3.Call listValidateBeforeCall(Integer limit, Integer offset, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified, final ApiCallback _callback) throws ApiException {


okhttp3.Call localVarCall = listCall(limit, offset, include, dateCreated, dateModified, sortByDateModified, _callback);
Expand All @@ -538,7 +538,7 @@ private okhttp3.Call listValidateBeforeCall(Integer limit, Integer offset, List<
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public BillingGroupList list(Integer limit, Integer offset, List<String> include, Map<String, Date> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified) throws ApiException {
public BillingGroupList list(Integer limit, Integer offset, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified) throws ApiException {
try {
ApiResponse<BillingGroupList> localVarResp = listWithHttpInfo(limit, offset, include, dateCreated, dateModified, sortByDateModified);
return localVarResp.getData();
Expand All @@ -565,7 +565,7 @@ public BillingGroupList list(Integer limit, Integer offset, List<String> include
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public ApiResponse<BillingGroupList> listWithHttpInfo(Integer limit, Integer offset, List<String> include, Map<String, Date> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified) throws ApiException {
public ApiResponse<BillingGroupList> listWithHttpInfo(Integer limit, Integer offset, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified) throws ApiException {
try {
okhttp3.Call localVarCall = listValidateBeforeCall(limit, offset, include, dateCreated, dateModified, sortByDateModified, null);
Type localVarReturnType = new TypeToken<BillingGroupList>(){}.getType();
Expand Down Expand Up @@ -594,7 +594,7 @@ public ApiResponse<BillingGroupList> listWithHttpInfo(Integer limit, Integer off
<tr><td> 0 </td><td> Lob uses RESTful HTTP response codes to indicate success or failure of an API request. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call listAsync(Integer limit, Integer offset, List<String> include, Map<String, Date> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified, final ApiCallback<BillingGroupList> _callback) throws ApiException {
public okhttp3.Call listAsync(Integer limit, Integer offset, List<String> include, Map<String, OffsetDateTime> dateCreated, Map<String, String> dateModified, SortByDateModified sortByDateModified, final ApiCallback<BillingGroupList> _callback) throws ApiException {

okhttp3.Call localVarCall = listValidateBeforeCall(limit, offset, include, dateCreated, dateModified, sortByDateModified, _callback);
Type localVarReturnType = new TypeToken<BillingGroupList>(){}.getType();
Expand Down
Loading

0 comments on commit 25c4ae0

Please sign in to comment.