Skip to content

Commit dbf38ac

Browse files
committed
Customer update and delete API methods added
1 parent 1a3a489 commit dbf38ac

File tree

3 files changed

+304
-3
lines changed

3 files changed

+304
-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.4-alpha-20250313`
16+
- **Current Version**: `0.1.5-alpha-20250323`
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.4-alpha-20250313</version>
46+
<version>0.1.5-alpha-20250323</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.4-alpha-20250313</version>
8+
<version>0.1.5-alpha-20250323</version>
99
<packaging>jar</packaging>
1010

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

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

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,162 @@ public okhttp3.Call createCustomerAsync(Customer customer, final ApiCallback<Cus
208208
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
209209
return localVarCall;
210210
}
211+
/**
212+
* Build call for deleteCustomerById
213+
* @param customerId ID of customer to delete (required)
214+
* @param force Required to be true, as resource does not support trashing. (required)
215+
* @param reassign User ID to reassign posts to. (optional)
216+
* @param _callback Callback for upload/download progress
217+
* @return Call to execute
218+
* @throws ApiException If fail to serialize the request body object
219+
* @http.response.details
220+
<table border="1">
221+
<caption>Response Details</caption>
222+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
223+
<tr><td> 200 </td><td> Returns deleted customer. </td><td> - </td></tr>
224+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
225+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
226+
</table>
227+
*/
228+
public okhttp3.Call deleteCustomerByIdCall(Integer customerId, String force, Integer reassign, final ApiCallback _callback) throws ApiException {
229+
String basePath = null;
230+
// Operation Servers
231+
String[] localBasePaths = new String[] { };
232+
233+
// Determine Base Path to Use
234+
if (localCustomBaseUrl != null){
235+
basePath = localCustomBaseUrl;
236+
} else if ( localBasePaths.length > 0 ) {
237+
basePath = localBasePaths[localHostIndex];
238+
} else {
239+
basePath = null;
240+
}
241+
242+
Object localVarPostBody = null;
243+
244+
// create path and map variables
245+
String localVarPath = "/customers/{customerId}"
246+
.replace("{" + "customerId" + "}", localVarApiClient.escapeString(customerId.toString()));
247+
248+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
249+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
250+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
251+
Map<String, String> localVarCookieParams = new HashMap<String, String>();
252+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
253+
254+
if (force != null) {
255+
localVarQueryParams.addAll(localVarApiClient.parameterToPair("force", force));
256+
}
257+
258+
if (reassign != null) {
259+
localVarQueryParams.addAll(localVarApiClient.parameterToPair("reassign", reassign));
260+
}
261+
262+
final String[] localVarAccepts = {
263+
"application/json"
264+
};
265+
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
266+
if (localVarAccept != null) {
267+
localVarHeaderParams.put("Accept", localVarAccept);
268+
}
269+
270+
final String[] localVarContentTypes = {
271+
};
272+
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
273+
if (localVarContentType != null) {
274+
localVarHeaderParams.put("Content-Type", localVarContentType);
275+
}
276+
277+
String[] localVarAuthNames = new String[] { "basicAuth" };
278+
return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
279+
}
280+
281+
@SuppressWarnings("rawtypes")
282+
private okhttp3.Call deleteCustomerByIdValidateBeforeCall(Integer customerId, String force, Integer reassign, final ApiCallback _callback) throws ApiException {
283+
// verify the required parameter 'customerId' is set
284+
if (customerId == null) {
285+
throw new ApiException("Missing the required parameter 'customerId' when calling deleteCustomerById(Async)");
286+
}
287+
288+
// verify the required parameter 'force' is set
289+
if (force == null) {
290+
throw new ApiException("Missing the required parameter 'force' when calling deleteCustomerById(Async)");
291+
}
292+
293+
return deleteCustomerByIdCall(customerId, force, reassign, _callback);
294+
295+
}
296+
297+
/**
298+
* This API helps you delete a customer.
299+
*
300+
* @param customerId ID of customer to delete (required)
301+
* @param force Required to be true, as resource does not support trashing. (required)
302+
* @param reassign User ID to reassign posts to. (optional)
303+
* @return Customer
304+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
305+
* @http.response.details
306+
<table border="1">
307+
<caption>Response Details</caption>
308+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
309+
<tr><td> 200 </td><td> Returns deleted customer. </td><td> - </td></tr>
310+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
311+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
312+
</table>
313+
*/
314+
public Customer deleteCustomerById(Integer customerId, String force, Integer reassign) throws ApiException {
315+
ApiResponse<Customer> localVarResp = deleteCustomerByIdWithHttpInfo(customerId, force, reassign);
316+
return localVarResp.getData();
317+
}
318+
319+
/**
320+
* This API helps you delete a customer.
321+
*
322+
* @param customerId ID of customer to delete (required)
323+
* @param force Required to be true, as resource does not support trashing. (required)
324+
* @param reassign User ID to reassign posts to. (optional)
325+
* @return ApiResponse&lt;Customer&gt;
326+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
327+
* @http.response.details
328+
<table border="1">
329+
<caption>Response Details</caption>
330+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
331+
<tr><td> 200 </td><td> Returns deleted customer. </td><td> - </td></tr>
332+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
333+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
334+
</table>
335+
*/
336+
public ApiResponse<Customer> deleteCustomerByIdWithHttpInfo(Integer customerId, String force, Integer reassign) throws ApiException {
337+
okhttp3.Call localVarCall = deleteCustomerByIdValidateBeforeCall(customerId, force, reassign, null);
338+
Type localVarReturnType = new TypeToken<Customer>(){}.getType();
339+
return localVarApiClient.execute(localVarCall, localVarReturnType);
340+
}
341+
342+
/**
343+
* This API helps you delete a customer. (asynchronously)
344+
*
345+
* @param customerId ID of customer to delete (required)
346+
* @param force Required to be true, as resource does not support trashing. (required)
347+
* @param reassign User ID to reassign posts to. (optional)
348+
* @param _callback The callback to be executed when the API call finishes
349+
* @return The request call
350+
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
351+
* @http.response.details
352+
<table border="1">
353+
<caption>Response Details</caption>
354+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
355+
<tr><td> 200 </td><td> Returns deleted customer. </td><td> - </td></tr>
356+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
357+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
358+
</table>
359+
*/
360+
public okhttp3.Call deleteCustomerByIdAsync(Integer customerId, String force, Integer reassign, final ApiCallback<Customer> _callback) throws ApiException {
361+
362+
okhttp3.Call localVarCall = deleteCustomerByIdValidateBeforeCall(customerId, force, reassign, _callback);
363+
Type localVarReturnType = new TypeToken<Customer>(){}.getType();
364+
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
365+
return localVarCall;
366+
}
211367
/**
212368
* Build call for listAllCustomers
213369
* @param context Scope under which the request is made; determines fields present in response. (optional)
@@ -556,4 +712,149 @@ public okhttp3.Call retrieveCustomerByIdAsync(Integer customerId, final ApiCallb
556712
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
557713
return localVarCall;
558714
}
715+
/**
716+
* Build call for updateCustomerById
717+
* @param customerId ID of customer to update (required)
718+
* @param customer Customer object with data to update. (required)
719+
* @param _callback Callback for upload/download progress
720+
* @return Call to execute
721+
* @throws ApiException If fail to serialize the request body object
722+
* @http.response.details
723+
<table border="1">
724+
<caption>Response Details</caption>
725+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
726+
<tr><td> 200 </td><td> Returns updated customer. </td><td> - </td></tr>
727+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
728+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
729+
</table>
730+
*/
731+
public okhttp3.Call updateCustomerByIdCall(Integer customerId, Customer customer, final ApiCallback _callback) throws ApiException {
732+
String basePath = null;
733+
// Operation Servers
734+
String[] localBasePaths = new String[] { };
735+
736+
// Determine Base Path to Use
737+
if (localCustomBaseUrl != null){
738+
basePath = localCustomBaseUrl;
739+
} else if ( localBasePaths.length > 0 ) {
740+
basePath = localBasePaths[localHostIndex];
741+
} else {
742+
basePath = null;
743+
}
744+
745+
Object localVarPostBody = customer;
746+
747+
// create path and map variables
748+
String localVarPath = "/customers/{customerId}"
749+
.replace("{" + "customerId" + "}", localVarApiClient.escapeString(customerId.toString()));
750+
751+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
752+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
753+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
754+
Map<String, String> localVarCookieParams = new HashMap<String, String>();
755+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
756+
757+
final String[] localVarAccepts = {
758+
"application/json"
759+
};
760+
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
761+
if (localVarAccept != null) {
762+
localVarHeaderParams.put("Accept", localVarAccept);
763+
}
764+
765+
final String[] localVarContentTypes = {
766+
"application/json"
767+
};
768+
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
769+
if (localVarContentType != null) {
770+
localVarHeaderParams.put("Content-Type", localVarContentType);
771+
}
772+
773+
String[] localVarAuthNames = new String[] { "basicAuth" };
774+
return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
775+
}
776+
777+
@SuppressWarnings("rawtypes")
778+
private okhttp3.Call updateCustomerByIdValidateBeforeCall(Integer customerId, Customer customer, final ApiCallback _callback) throws ApiException {
779+
// verify the required parameter 'customerId' is set
780+
if (customerId == null) {
781+
throw new ApiException("Missing the required parameter 'customerId' when calling updateCustomerById(Async)");
782+
}
783+
784+
// verify the required parameter 'customer' is set
785+
if (customer == null) {
786+
throw new ApiException("Missing the required parameter 'customer' when calling updateCustomerById(Async)");
787+
}
788+
789+
return updateCustomerByIdCall(customerId, customer, _callback);
790+
791+
}
792+
793+
/**
794+
* This API lets you make changes to a customer.
795+
*
796+
* @param customerId ID of customer to update (required)
797+
* @param customer Customer object with data to update. (required)
798+
* @return Customer
799+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
800+
* @http.response.details
801+
<table border="1">
802+
<caption>Response Details</caption>
803+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
804+
<tr><td> 200 </td><td> Returns updated customer. </td><td> - </td></tr>
805+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
806+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
807+
</table>
808+
*/
809+
public Customer updateCustomerById(Integer customerId, Customer customer) throws ApiException {
810+
ApiResponse<Customer> localVarResp = updateCustomerByIdWithHttpInfo(customerId, customer);
811+
return localVarResp.getData();
812+
}
813+
814+
/**
815+
* This API lets you make changes to a customer.
816+
*
817+
* @param customerId ID of customer to update (required)
818+
* @param customer Customer object with data to update. (required)
819+
* @return ApiResponse&lt;Customer&gt;
820+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
821+
* @http.response.details
822+
<table border="1">
823+
<caption>Response Details</caption>
824+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
825+
<tr><td> 200 </td><td> Returns updated customer. </td><td> - </td></tr>
826+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
827+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
828+
</table>
829+
*/
830+
public ApiResponse<Customer> updateCustomerByIdWithHttpInfo(Integer customerId, Customer customer) throws ApiException {
831+
okhttp3.Call localVarCall = updateCustomerByIdValidateBeforeCall(customerId, customer, null);
832+
Type localVarReturnType = new TypeToken<Customer>(){}.getType();
833+
return localVarApiClient.execute(localVarCall, localVarReturnType);
834+
}
835+
836+
/**
837+
* This API lets you make changes to a customer. (asynchronously)
838+
*
839+
* @param customerId ID of customer to update (required)
840+
* @param customer Customer object with data to update. (required)
841+
* @param _callback The callback to be executed when the API call finishes
842+
* @return The request call
843+
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
844+
* @http.response.details
845+
<table border="1">
846+
<caption>Response Details</caption>
847+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
848+
<tr><td> 200 </td><td> Returns updated customer. </td><td> - </td></tr>
849+
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
850+
<tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
851+
</table>
852+
*/
853+
public okhttp3.Call updateCustomerByIdAsync(Integer customerId, Customer customer, final ApiCallback<Customer> _callback) throws ApiException {
854+
855+
okhttp3.Call localVarCall = updateCustomerByIdValidateBeforeCall(customerId, customer, _callback);
856+
Type localVarReturnType = new TypeToken<Customer>(){}.getType();
857+
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
858+
return localVarCall;
859+
}
559860
}

0 commit comments

Comments
 (0)