Skip to content

Commit 49e352c

Browse files
committed
Added createProduct method and change approach to generated jar (with dependencies)
1 parent 39cdb57 commit 49e352c

29 files changed

+187
-39
lines changed

pom.xml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>wtx.woocommerce</groupId>
77
<artifactId>woocommerce-api-client</artifactId>
8-
<version>0.1.1-alpha-20250207</version>
8+
<version>0.1.2-alpha-20250210</version>
99
<packaging>jar</packaging>
1010

1111
<name>WooCommerce REST API Client</name>
@@ -79,17 +79,30 @@
7979
</plugin>
8080

8181
<plugin>
82-
<groupId>org.apache.maven.plugins</groupId>
83-
<artifactId>maven-jar-plugin</artifactId>
84-
<version>3.3.0</version>
85-
<configuration>
86-
<archive>
87-
<manifest>
88-
<mainClass>com.example.MyApp</mainClass>
89-
</manifest>
90-
</archive>
91-
</configuration>
92-
</plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-assembly-plugin</artifactId>
84+
<version>3.3.0</version>
85+
<configuration>
86+
<descriptorRefs>
87+
<descriptorRef>jar-with-dependencies</descriptorRef>
88+
</descriptorRefs>
89+
<archive>
90+
<manifest>
91+
<mainClass>wtx.woocommerce.WooCommerceApiClientUsageDemo</mainClass>
92+
</manifest>
93+
</archive>
94+
<appendAssemblyId>false</appendAssemblyId>
95+
</configuration>
96+
<executions>
97+
<execution>
98+
<id>assemble-jar-with-dependencies</id>
99+
<phase>package</phase>
100+
<goals>
101+
<goal>single</goal>
102+
</goals>
103+
</execution>
104+
</executions>
105+
</plugin>
93106

94107
</plugins>
95108
</build>

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

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,141 @@ public void setCustomBaseUrl(String customBaseUrl) {
7373
this.localCustomBaseUrl = customBaseUrl;
7474
}
7575

76+
/**
77+
* Build call for createProduct
78+
* @param product Product object with data to create. (required)
79+
* @param _callback Callback for upload/download progress
80+
* @return Call to execute
81+
* @throws ApiException If fail to serialize the request body object
82+
* @http.response.details
83+
<table border="1">
84+
<caption>Response Details</caption>
85+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
86+
<tr><td> 200 </td><td> Returns specified product. </td><td> - </td></tr>
87+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
88+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
89+
</table>
90+
*/
91+
public okhttp3.Call createProductCall(Product product, final ApiCallback _callback) throws ApiException {
92+
String basePath = null;
93+
// Operation Servers
94+
String[] localBasePaths = new String[] { };
95+
96+
// Determine Base Path to Use
97+
if (localCustomBaseUrl != null){
98+
basePath = localCustomBaseUrl;
99+
} else if ( localBasePaths.length > 0 ) {
100+
basePath = localBasePaths[localHostIndex];
101+
} else {
102+
basePath = null;
103+
}
104+
105+
Object localVarPostBody = product;
106+
107+
// create path and map variables
108+
String localVarPath = "/products";
109+
110+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
111+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
112+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
113+
Map<String, String> localVarCookieParams = new HashMap<String, String>();
114+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
115+
116+
final String[] localVarAccepts = {
117+
"application/json"
118+
};
119+
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
120+
if (localVarAccept != null) {
121+
localVarHeaderParams.put("Accept", localVarAccept);
122+
}
123+
124+
final String[] localVarContentTypes = {
125+
"application/json"
126+
};
127+
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
128+
if (localVarContentType != null) {
129+
localVarHeaderParams.put("Content-Type", localVarContentType);
130+
}
131+
132+
String[] localVarAuthNames = new String[] { "basicAuth" };
133+
return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
134+
}
135+
136+
@SuppressWarnings("rawtypes")
137+
private okhttp3.Call createProductValidateBeforeCall(Product product, final ApiCallback _callback) throws ApiException {
138+
// verify the required parameter 'product' is set
139+
if (product == null) {
140+
throw new ApiException("Missing the required parameter 'product' when calling createProduct(Async)");
141+
}
142+
143+
return createProductCall(product, _callback);
144+
145+
}
146+
147+
/**
148+
* This API helps you to create a new product.
149+
*
150+
* @param product Product object with data to create. (required)
151+
* @return Product
152+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
153+
* @http.response.details
154+
<table border="1">
155+
<caption>Response Details</caption>
156+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
157+
<tr><td> 200 </td><td> Returns specified product. </td><td> - </td></tr>
158+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
159+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
160+
</table>
161+
*/
162+
public Product createProduct(Product product) throws ApiException {
163+
ApiResponse<Product> localVarResp = createProductWithHttpInfo(product);
164+
return localVarResp.getData();
165+
}
166+
167+
/**
168+
* This API helps you to create a new product.
169+
*
170+
* @param product Product object with data to create. (required)
171+
* @return ApiResponse&lt;Product&gt;
172+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
173+
* @http.response.details
174+
<table border="1">
175+
<caption>Response Details</caption>
176+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
177+
<tr><td> 200 </td><td> Returns specified product. </td><td> - </td></tr>
178+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
179+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
180+
</table>
181+
*/
182+
public ApiResponse<Product> createProductWithHttpInfo(Product product) throws ApiException {
183+
okhttp3.Call localVarCall = createProductValidateBeforeCall(product, null);
184+
Type localVarReturnType = new TypeToken<Product>(){}.getType();
185+
return localVarApiClient.execute(localVarCall, localVarReturnType);
186+
}
187+
188+
/**
189+
* This API helps you to create a new product. (asynchronously)
190+
*
191+
* @param product Product object with data to create. (required)
192+
* @param _callback The callback to be executed when the API call finishes
193+
* @return The request call
194+
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
195+
* @http.response.details
196+
<table border="1">
197+
<caption>Response Details</caption>
198+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
199+
<tr><td> 200 </td><td> Returns specified product. </td><td> - </td></tr>
200+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
201+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
202+
</table>
203+
*/
204+
public okhttp3.Call createProductAsync(Product product, final ApiCallback<Product> _callback) throws ApiException {
205+
206+
okhttp3.Call localVarCall = createProductValidateBeforeCall(product, _callback);
207+
Type localVarReturnType = new TypeToken<Product>(){}.getType();
208+
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
209+
return localVarCall;
210+
}
76211
/**
77212
* Build call for listAllProducts
78213
* @param sku Limit result set to products with a specific SKU. (optional)

src/main/java/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", date = "2025-02-07T13:35:20.422255800+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
24+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
2525
public class ApiException extends Exception {
2626
private static final long serialVersionUID = 1L;
2727

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

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

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

16-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-02-07T13:35:20.422255800+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
16+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
1717
public class Configuration {
1818
public static final String VERSION = "v3";
1919

src/main/java/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 wtx.woocommerce.api.client.invoker;
1515

16-
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-02-07T13:35:20.422255800+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
16+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
1717
public class Pair {
1818
private String name = "";
1919
private String value = "";

src/main/java/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", date = "2025-02-07T13:35:20.422255800+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
2222
public class ServerConfiguration {
2323
public String URL;
2424
public String description;

src/main/java/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", date = "2025-02-07T13:35:20.422255800+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
21+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
2222
public class ServerVariable {
2323
public String description;
2424
public String defaultValue;

src/main/java/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", date = "2025-02-07T13:35:20.422255800+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
19+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
2020
public class StringUtil {
2121
/**
2222
* Check if the given array contains the given value (with case-insensitive comparison).

src/main/java/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", date = "2025-02-07T13:35:20.422255800+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
23+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
2424
public class ApiKeyAuth implements Authentication {
2525
private final String location;
2626
private final String paramName;

src/main/java/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", date = "2025-02-07T13:35:20.422255800+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
25+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0")
2626
public class HttpBearerAuth implements Authentication {
2727
private final String scheme;
2828
private Supplier<String> tokenSupplier;

0 commit comments

Comments
 (0)