Skip to content

Commit f406ac1

Browse files
committed
Orders and Products delete API methods added. Create for variations.
1 parent dbf38ac commit f406ac1

File tree

5 files changed

+444
-3
lines changed

5 files changed

+444
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This library provides an intuitive and developer-friendly way to interact with t
1313
1414
## 📦 Version Information
1515

16-
- **Current Version**: `0.1.5-alpha-20250323`
16+
- **Current Version**: `0.1.5-alpha-20250412`
1717
- **Supported WooCommerce API Version**: `v3`
1818
- **Java Compatibility**: Java 8+
1919

@@ -43,7 +43,7 @@ After a successful build, add the generated artifact as a dependency in your Jav
4343
<dependency>
4444
<groupId>wtx.woocommerce</groupId>
4545
<artifactId>woocommerce-api-client</artifactId>
46-
<version>0.1.5-alpha-20250323</version>
46+
<version>0.1.5-alpha-20250412</version>
4747
</dependency>
4848
```
4949

pom.xml

Lines changed: 1 addition & 1 deletion
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.5-alpha-20250323</version>
8+
<version>0.1.5-alpha-20250412</version>
99
<packaging>jar</packaging>
1010

1111
<name>WooCommerce REST API Client</name>

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

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,154 @@ public okhttp3.Call createOrderAsync(Order order, final ApiCallback<Order> _call
208208
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
209209
return localVarCall;
210210
}
211+
/**
212+
* Build call for deleteOrderById
213+
* @param orderId ID of order to delete (required)
214+
* @param force Required to be true, as resource does not support trashing. (required)
215+
* @param _callback Callback for upload/download progress
216+
* @return Call to execute
217+
* @throws ApiException If fail to serialize the request body object
218+
* @http.response.details
219+
<table border="1">
220+
<caption>Response Details</caption>
221+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
222+
<tr><td> 200 </td><td> Returns deleted order. </td><td> - </td></tr>
223+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
224+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
225+
</table>
226+
*/
227+
public okhttp3.Call deleteOrderByIdCall(Integer orderId, Boolean force, final ApiCallback _callback) throws ApiException {
228+
String basePath = null;
229+
// Operation Servers
230+
String[] localBasePaths = new String[] { };
231+
232+
// Determine Base Path to Use
233+
if (localCustomBaseUrl != null){
234+
basePath = localCustomBaseUrl;
235+
} else if ( localBasePaths.length > 0 ) {
236+
basePath = localBasePaths[localHostIndex];
237+
} else {
238+
basePath = null;
239+
}
240+
241+
Object localVarPostBody = null;
242+
243+
// create path and map variables
244+
String localVarPath = "/orders/{orderId}"
245+
.replace("{" + "orderId" + "}", localVarApiClient.escapeString(orderId.toString()));
246+
247+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
248+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
249+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
250+
Map<String, String> localVarCookieParams = new HashMap<String, String>();
251+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
252+
253+
if (force != null) {
254+
localVarQueryParams.addAll(localVarApiClient.parameterToPair("force", force));
255+
}
256+
257+
final String[] localVarAccepts = {
258+
"application/json"
259+
};
260+
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
261+
if (localVarAccept != null) {
262+
localVarHeaderParams.put("Accept", localVarAccept);
263+
}
264+
265+
final String[] localVarContentTypes = {
266+
};
267+
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
268+
if (localVarContentType != null) {
269+
localVarHeaderParams.put("Content-Type", localVarContentType);
270+
}
271+
272+
String[] localVarAuthNames = new String[] { "basicAuth" };
273+
return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
274+
}
275+
276+
@SuppressWarnings("rawtypes")
277+
private okhttp3.Call deleteOrderByIdValidateBeforeCall(Integer orderId, Boolean force, final ApiCallback _callback) throws ApiException {
278+
// verify the required parameter 'orderId' is set
279+
if (orderId == null) {
280+
throw new ApiException("Missing the required parameter 'orderId' when calling deleteOrderById(Async)");
281+
}
282+
283+
// verify the required parameter 'force' is set
284+
if (force == null) {
285+
throw new ApiException("Missing the required parameter 'force' when calling deleteOrderById(Async)");
286+
}
287+
288+
return deleteOrderByIdCall(orderId, force, _callback);
289+
290+
}
291+
292+
/**
293+
* This API helps you delete an order.
294+
*
295+
* @param orderId ID of order to delete (required)
296+
* @param force Required to be true, as resource does not support trashing. (required)
297+
* @return Order
298+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
299+
* @http.response.details
300+
<table border="1">
301+
<caption>Response Details</caption>
302+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
303+
<tr><td> 200 </td><td> Returns deleted order. </td><td> - </td></tr>
304+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
305+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
306+
</table>
307+
*/
308+
public Order deleteOrderById(Integer orderId, Boolean force) throws ApiException {
309+
ApiResponse<Order> localVarResp = deleteOrderByIdWithHttpInfo(orderId, force);
310+
return localVarResp.getData();
311+
}
312+
313+
/**
314+
* This API helps you delete an order.
315+
*
316+
* @param orderId ID of order to delete (required)
317+
* @param force Required to be true, as resource does not support trashing. (required)
318+
* @return ApiResponse&lt;Order&gt;
319+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
320+
* @http.response.details
321+
<table border="1">
322+
<caption>Response Details</caption>
323+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
324+
<tr><td> 200 </td><td> Returns deleted order. </td><td> - </td></tr>
325+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
326+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
327+
</table>
328+
*/
329+
public ApiResponse<Order> deleteOrderByIdWithHttpInfo(Integer orderId, Boolean force) throws ApiException {
330+
okhttp3.Call localVarCall = deleteOrderByIdValidateBeforeCall(orderId, force, null);
331+
Type localVarReturnType = new TypeToken<Order>(){}.getType();
332+
return localVarApiClient.execute(localVarCall, localVarReturnType);
333+
}
334+
335+
/**
336+
* This API helps you delete an order. (asynchronously)
337+
*
338+
* @param orderId ID of order to delete (required)
339+
* @param force Required to be true, as resource does not support trashing. (required)
340+
* @param _callback The callback to be executed when the API call finishes
341+
* @return The request call
342+
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
343+
* @http.response.details
344+
<table border="1">
345+
<caption>Response Details</caption>
346+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
347+
<tr><td> 200 </td><td> Returns deleted order. </td><td> - </td></tr>
348+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
349+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
350+
</table>
351+
*/
352+
public okhttp3.Call deleteOrderByIdAsync(Integer orderId, Boolean force, final ApiCallback<Order> _callback) throws ApiException {
353+
354+
okhttp3.Call localVarCall = deleteOrderByIdValidateBeforeCall(orderId, force, _callback);
355+
Type localVarReturnType = new TypeToken<Order>(){}.getType();
356+
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
357+
return localVarCall;
358+
}
211359
/**
212360
* Build call for listAllOrders
213361
* @param page Current page of the collection. Default is 1. (optional)

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

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

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

0 commit comments

Comments
 (0)