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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* <p>ApiException class.</p>
2222
*/
2323
@SuppressWarnings("serial")
24-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
24+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
2525
public class ApiException extends Exception {
2626
private static final long serialVersionUID = 1L;
2727

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

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,51 @@
1313

1414
package pl.wtx.woocommerce.api.client.invoker;
1515

16-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
16+
import java.util.Objects;
17+
import java.util.concurrent.atomic.AtomicReference;
18+
import java.util.function.Supplier;
19+
20+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
1721
public class Configuration {
18-
public static final String VERSION = "v3";
19-
20-
private static ApiClient defaultApiClient = new ApiClient();
21-
22-
/**
23-
* Get the default API client, which would be used when creating API
24-
* instances without providing an API client.
25-
*
26-
* @return Default API client
27-
*/
28-
public static ApiClient getDefaultApiClient() {
29-
return defaultApiClient;
30-
}
22+
public static final String VERSION = "v3";
23+
24+
private static final AtomicReference<ApiClient> defaultApiClient = new AtomicReference<>();
25+
private static volatile Supplier<ApiClient> apiClientFactory = ApiClient::new;
3126

32-
/**
33-
* Set the default API client, which would be used when creating API
34-
* instances without providing an API client.
35-
*
36-
* @param apiClient API client
37-
*/
38-
public static void setDefaultApiClient(ApiClient apiClient) {
39-
defaultApiClient = apiClient;
27+
/**
28+
* Get the default API client, which would be used when creating API instances without providing an API client.
29+
*
30+
* @return Default API client
31+
*/
32+
public static ApiClient getDefaultApiClient() {
33+
ApiClient client = defaultApiClient.get();
34+
if (client == null) {
35+
client = defaultApiClient.updateAndGet(val -> {
36+
if (val != null) { // changed by another thread
37+
return val;
38+
}
39+
return apiClientFactory.get();
40+
});
4041
}
41-
}
42+
return client;
43+
}
44+
45+
/**
46+
* Set the default API client, which would be used when creating API instances without providing an API client.
47+
*
48+
* @param apiClient API client
49+
*/
50+
public static void setDefaultApiClient(ApiClient apiClient) {
51+
defaultApiClient.set(apiClient);
52+
}
53+
54+
/**
55+
* set the callback used to create new ApiClient objects
56+
*/
57+
public static void setApiClientFactory(Supplier<ApiClient> factory) {
58+
apiClientFactory = Objects.requireNonNull(factory);
59+
}
60+
61+
private Configuration() {
62+
}
63+
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@
2727
import okio.ByteString;
2828

2929
import java.io.IOException;
30+
import java.io.InputStream;
31+
import java.io.InputStreamReader;
3032
import java.io.StringReader;
3133
import java.lang.reflect.Type;
34+
import java.nio.charset.StandardCharsets;
3235
import java.text.DateFormat;
3336
import java.text.ParseException;
3437
import java.text.ParsePosition;
@@ -183,6 +186,28 @@ public static <T> T deserialize(String body, Type returnType) {
183186
}
184187
}
185188

189+
/**
190+
* Deserialize the given JSON InputStream to a Java object.
191+
*
192+
* @param <T> Type
193+
* @param inputStream The JSON InputStream
194+
* @param returnType The type to deserialize into
195+
* @return The deserialized Java object
196+
*/
197+
@SuppressWarnings("unchecked")
198+
public static <T> T deserialize(InputStream inputStream, Type returnType) throws IOException {
199+
try (InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
200+
if (isLenientOnJson) {
201+
// see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean)
202+
JsonReader jsonReader = new JsonReader(reader);
203+
jsonReader.setLenient(true);
204+
return gson.fromJson(jsonReader, returnType);
205+
} else {
206+
return gson.fromJson(reader, returnType);
207+
}
208+
}
209+
}
210+
186211
/**
187212
* Gson TypeAdapter for Byte Array type
188213
*/

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

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

1414
package pl.wtx.woocommerce.api.client.invoker;
1515

16-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
16+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
1717
public class Pair {
1818
private String name = "";
1919
private String value = "";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* Representing a Server configuration.
2020
*/
21-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
2222
public class ServerConfiguration {
2323
public String URL;
2424
public String description;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* Representing a Server Variable for server URL template substitution.
2020
*/
21-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
2222
public class ServerVariable {
2323
public String description;
2424
public String defaultValue;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.Collection;
1717
import java.util.Iterator;
1818

19-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
19+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
2020
public class StringUtil {
2121
/**
2222
* Check if the given array contains the given value (with case-insensitive comparison).

src/main/java/pl/wtx/woocommerce/api/client/invoker/auth/ApiKeyAuth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.Map;
2121
import java.util.List;
2222

23-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
23+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
2424
public class ApiKeyAuth implements Authentication {
2525
private final String location;
2626
private final String paramName;

src/main/java/pl/wtx/woocommerce/api/client/invoker/auth/Authentication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121
import java.util.List;
2222

23+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
2324
public interface Authentication {
2425
/**
2526
* Apply authentication settings to header and query params.

src/main/java/pl/wtx/woocommerce/api/client/invoker/auth/HttpBearerAuth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.util.Optional;
2323
import java.util.function.Supplier;
2424

25-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
25+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
2626
public class HttpBearerAuth implements Authentication {
2727
private final String scheme;
2828
private Supplier<String> tokenSupplier;

src/main/java/pl/wtx/woocommerce/api/client/model/AbstractOpenApiSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
2323
*/
24-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
24+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
2525
public abstract class AbstractOpenApiSchema {
2626

2727
// store the actual instance of the schema/object

src/main/java/pl/wtx/woocommerce/api/client/model/ApiError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
/**
5050
* ApiError
5151
*/
52-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
52+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
5353
public class ApiError {
5454
public static final String SERIALIZED_NAME_CODE = "code";
5555
@SerializedName(SERIALIZED_NAME_CODE)

src/main/java/pl/wtx/woocommerce/api/client/model/ApiErrorData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
/**
4949
* ApiErrorData
5050
*/
51-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
51+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
5252
public class ApiErrorData {
5353
public static final String SERIALIZED_NAME_STATUS = "status";
5454
@SerializedName(SERIALIZED_NAME_STATUS)

src/main/java/pl/wtx/woocommerce/api/client/model/Billing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
/**
4949
* Billing
5050
*/
51-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
51+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
5252
public class Billing {
5353
public static final String SERIALIZED_NAME_FIRST_NAME = "first_name";
5454
@SerializedName(SERIALIZED_NAME_FIRST_NAME)

src/main/java/pl/wtx/woocommerce/api/client/model/Customer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
/**
5555
* Customer
5656
*/
57-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
57+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.13.0")
5858
public class Customer {
5959
public static final String SERIALIZED_NAME_ID = "id";
6060
@SerializedName(SERIALIZED_NAME_ID)

0 commit comments

Comments
 (0)