Skip to content

Commit 9691ad6

Browse files
committed
Client update
1 parent 76e554f commit 9691ad6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+359
-424
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ This API client provides a type-safe Java interface for WooCommerce REST API v3,
6565
6666
## 📦 Version information
6767

68-
- **Current version**: `0.9.5`
68+
- **Current version**: `0.9.6`
6969
- **Supported WooCommerce API version**: `v3`
7070
- **Java compatibility**: Java 8+
7171

@@ -106,7 +106,7 @@ Then add the locally built artifact to your project:
106106
<dependency>
107107
<groupId>pl.wtx.woocommerce</groupId>
108108
<artifactId>woocommerce-api-client</artifactId>
109-
<version>0.9.5</version>
109+
<version>0.9.6</version>
110110
</dependency>
111111
```
112112

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>pl.wtx.woocommerce</groupId>
88
<artifactId>woocommerce-api-client</artifactId>
9-
<version>0.9.5</version>
9+
<version>0.9.6</version>
1010
<packaging>jar</packaging>
1111

1212
<name>WooCommerce API Client for Java</name>

src/main/java/pl/wtx/woocommerce/api/client/CustomersApi.java

Lines changed: 25 additions & 25 deletions
Large diffs are not rendered by default.

src/main/java/pl/wtx/woocommerce/api/client/OrdersApi.java

Lines changed: 25 additions & 25 deletions
Large diffs are not rendered by default.

src/main/java/pl/wtx/woocommerce/api/client/ProductCategoriesApi.java

Lines changed: 25 additions & 25 deletions
Large diffs are not rendered by default.

src/main/java/pl/wtx/woocommerce/api/client/ProductVariationsApi.java

Lines changed: 25 additions & 25 deletions
Large diffs are not rendered by default.

src/main/java/pl/wtx/woocommerce/api/client/ProductsApi.java

Lines changed: 30 additions & 30 deletions
Large diffs are not rendered by default.

src/main/java/pl/wtx/woocommerce/api/client/ReportsApi.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public okhttp3.Call reportOrderTotalsSummaryAsync(final ApiCallback<List<ReportO
212212
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
213213
</table>
214214
*/
215-
public okhttp3.Call reportSalesSummaryCall(String period, String dateMin, String dateMax, final ApiCallback _callback) throws ApiException {
215+
public okhttp3.Call reportSalesSummaryCall(@javax.annotation.Nullable String period, @javax.annotation.Nullable String dateMin, @javax.annotation.Nullable String dateMax, final ApiCallback _callback) throws ApiException {
216216
String basePath = null;
217217
// Operation Servers
218218
String[] localBasePaths = new String[] { };
@@ -269,7 +269,7 @@ public okhttp3.Call reportSalesSummaryCall(String period, String dateMin, String
269269
}
270270

271271
@SuppressWarnings("rawtypes")
272-
private okhttp3.Call reportSalesSummaryValidateBeforeCall(String period, String dateMin, String dateMax, final ApiCallback _callback) throws ApiException {
272+
private okhttp3.Call reportSalesSummaryValidateBeforeCall(@javax.annotation.Nullable String period, @javax.annotation.Nullable String dateMin, @javax.annotation.Nullable String dateMax, final ApiCallback _callback) throws ApiException {
273273
return reportSalesSummaryCall(period, dateMin, dateMax, _callback);
274274

275275
}
@@ -291,7 +291,7 @@ private okhttp3.Call reportSalesSummaryValidateBeforeCall(String period, String
291291
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
292292
</table>
293293
*/
294-
public List<ReportSalesSummary> reportSalesSummary(String period, String dateMin, String dateMax) throws ApiException {
294+
public List<ReportSalesSummary> reportSalesSummary(@javax.annotation.Nullable String period, @javax.annotation.Nullable String dateMin, @javax.annotation.Nullable String dateMax) throws ApiException {
295295
ApiResponse<List<ReportSalesSummary>> localVarResp = reportSalesSummaryWithHttpInfo(period, dateMin, dateMax);
296296
return localVarResp.getData();
297297
}
@@ -313,7 +313,7 @@ public List<ReportSalesSummary> reportSalesSummary(String period, String dateMin
313313
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
314314
</table>
315315
*/
316-
public ApiResponse<List<ReportSalesSummary>> reportSalesSummaryWithHttpInfo(String period, String dateMin, String dateMax) throws ApiException {
316+
public ApiResponse<List<ReportSalesSummary>> reportSalesSummaryWithHttpInfo(@javax.annotation.Nullable String period, @javax.annotation.Nullable String dateMin, @javax.annotation.Nullable String dateMax) throws ApiException {
317317
okhttp3.Call localVarCall = reportSalesSummaryValidateBeforeCall(period, dateMin, dateMax, null);
318318
Type localVarReturnType = new TypeToken<List<ReportSalesSummary>>(){}.getType();
319319
return localVarApiClient.execute(localVarCall, localVarReturnType);
@@ -337,7 +337,7 @@ public ApiResponse<List<ReportSalesSummary>> reportSalesSummaryWithHttpInfo(Stri
337337
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
338338
</table>
339339
*/
340-
public okhttp3.Call reportSalesSummaryAsync(String period, String dateMin, String dateMax, final ApiCallback<List<ReportSalesSummary>> _callback) throws ApiException {
340+
public okhttp3.Call reportSalesSummaryAsync(@javax.annotation.Nullable String period, @javax.annotation.Nullable String dateMin, @javax.annotation.Nullable String dateMax, final ApiCallback<List<ReportSalesSummary>> _callback) throws ApiException {
341341

342342
okhttp3.Call localVarCall = reportSalesSummaryValidateBeforeCall(period, dateMin, dateMax, _callback);
343343
Type localVarReturnType = new TypeToken<List<ReportSalesSummary>>(){}.getType();

src/main/java/pl/wtx/woocommerce/api/client/config/OffsetDateTimeAdapter.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package pl.wtx.woocommerce.api.client.config;
22

33
import java.io.IOException;
4+
import java.time.LocalDateTime;
45
import java.time.OffsetDateTime;
56
import java.time.ZoneOffset;
67
import java.time.format.DateTimeFormatter;
8+
import java.time.format.DateTimeParseException;
79

810
import com.google.gson.TypeAdapter;
911
import com.google.gson.stream.JsonReader;
@@ -22,6 +24,7 @@ public void write(JsonWriter out, OffsetDateTime value) throws IOException {
2224
} else {
2325
out.nullValue();
2426
}
27+
2528
}
2629

2730
@Override
@@ -33,8 +36,14 @@ public OffsetDateTime read(JsonReader in) throws IOException {
3336
}
3437

3538
String date = in.nextString();
39+
3640
if (date != null && !date.isEmpty()) {
37-
return OffsetDateTime.parse(date, FORMATTER.withZone(ZoneOffset.UTC));
41+
try {
42+
return OffsetDateTime.parse(date);
43+
} catch (DateTimeParseException e) {
44+
LocalDateTime ldt = LocalDateTime.parse(date);
45+
return ldt.atOffset(ZoneOffset.UTC);
46+
}
3847
}
3948

4049
return null;

src/main/java/pl/wtx/woocommerce/api/client/invoker/ApiClient.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -912,17 +912,8 @@ public <T> T deserialize(Response response, Type returnType) throws ApiException
912912
return (T) downloadFileFromResponse(response);
913913
}
914914

915-
String respBody;
916-
try {
917-
if (response.body() != null)
918-
respBody = response.body().string();
919-
else
920-
respBody = null;
921-
} catch (IOException e) {
922-
throw new ApiException(e);
923-
}
924-
925-
if (respBody == null || "".equals(respBody)) {
915+
ResponseBody respBody = response.body();
916+
if (respBody == null) {
926917
return null;
927918
}
928919

@@ -931,17 +922,25 @@ public <T> T deserialize(Response response, Type returnType) throws ApiException
931922
// ensuring a default content type
932923
contentType = "application/json";
933924
}
934-
if (isJsonMime(contentType)) {
935-
return JSON.deserialize(respBody, returnType);
936-
} else if (returnType.equals(String.class)) {
937-
// Expecting string, return the raw response body.
938-
return (T) respBody;
939-
} else {
940-
throw new ApiException(
925+
try {
926+
if (isJsonMime(contentType)) {
927+
return JSON.deserialize(respBody.byteStream(), returnType);
928+
} else if (returnType.equals(String.class)) {
929+
String respBodyString = respBody.string();
930+
if (respBodyString.isEmpty()) {
931+
return null;
932+
}
933+
// Expecting string, return the raw response body.
934+
return (T) respBodyString;
935+
} else {
936+
throw new ApiException(
941937
"Content type \"" + contentType + "\" is not supported for type: " + returnType,
942938
response.code(),
943939
response.headers().toMultimap(),
944-
respBody);
940+
response.body().string());
941+
}
942+
} catch (IOException e) {
943+
throw new ApiException(e);
945944
}
946945
}
947946

0 commit comments

Comments
 (0)