Skip to content

Commit 4a64549

Browse files
committed
The createCustomer POST method added.
1 parent 8393be9 commit 4a64549

30 files changed

+207
-54
lines changed

README.md

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,55 @@
1-
# The WooCommerce REST API Client for Java
1+
# The WooCommerce REST API Client for Java
22

3-
Effortlessly integrate your Java applications with WooCommerce using our REST API client! 🚀
4-
This library provides an intuitive and developer-friendly way to interact with the latest **WooCommerce REST API (v3)**, allowing seamless access to store data and operations.
3+
Effortlessly integrate your Java applications with WooCommerce using our REST API client! 🚀
54

6-
---
5+
This library provides an intuitive and developer-friendly way to interact with the latest **WooCommerce REST API (v3)**, allowing seamless access to store data and operations.
76

8-
> ⚠️ **Note: This is an early development version!**
9-
> We are actively expanding the API coverage to support more WooCommerce features.
7+
## 🚨 Project Status
8+
9+
> ⚠️ **Note: This is an early development version!**
10+
>
11+
> We are actively expanding the API coverage to support more WooCommerce features.
1012
> Contributions and feedback are welcome!
1113
12-
---
14+
## 📦 Version Information
15+
16+
- **Current Version**: `0.1.1-alpha-20250207`
17+
- **Supported WooCommerce API Version**: `v3`
18+
- **Java Compatibility**: Java 8+
19+
20+
## 🔓 License
21+
22+
**MIT License**
23+
24+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software.
25+
26+
The only requirement is to preserve the original author attribution in the source code and documentation.
1327

14-
## 🚀 Quick Start
28+
## 🚀 Quick Start
1529

16-
### 1️⃣ Install
17-
Clone this repository and build the library using Maven:
30+
### 1️⃣ Installation
31+
32+
Clone this repository and build the library using Maven:
1833

1934
```sh
35+
git clone https://github.com/your-org/woocommerce-java-client.git
36+
cd woocommerce-java-client
2037
mvn clean install
21-
```
38+
```
2239

23-
After a successful build, you can add the generated artifact as a dependency in your Java project:
40+
After a successful build, add the generated artifact as a dependency in your Java project:
2441

2542
```xml
2643
<dependency>
2744
<groupId>wtx.woocommerce</groupId>
2845
<artifactId>woocommerce-api-client</artifactId>
29-
<version>0.1.0</version>
46+
<version>0.1.1-alpha-20250207</version>
3047
</dependency>
3148
```
3249

33-
### 2️⃣ Usage Example
50+
### 2️⃣ Usage Example
3451

35-
Easily fetch WooCommerce customer data:
52+
Easily fetch WooCommerce customer data:
3653

3754
```java
3855
import java.util.List;
@@ -41,9 +58,7 @@ import wtx.woocommerce.api.client.invoker.ApiException;
4158
import wtx.woocommerce.api.client.model.Customer;
4259

4360
public class WooCommerceClientDemo {
44-
4561
public static void main(String[] args) {
46-
4762
System.out.println(">>> Starting WooCommerceClientDemo...");
4863

4964
WooCommerceApiClient apiClient = new WooCommerceApiClient();
@@ -54,8 +69,13 @@ public class WooCommerceClientDemo {
5469
CustomersApi customersApi = new CustomersApi(apiClient);
5570

5671
try {
57-
List<Customer> customers = customersApi.listAllCustomers(null, null, null, null, null, null, null, null, null, null, null);
58-
customers.forEach(customer -> System.out.println("Customer: " + customer.getEmail()));
72+
List<Customer> customers = customersApi.listAllCustomers(
73+
null, null, null, null, null,
74+
null, null, null, null, null, null
75+
);
76+
customers.forEach(customer ->
77+
System.out.println("Customer: " + customer.getEmail())
78+
);
5979
} catch (ApiException e) {
6080
System.err.println("API Error: " + e.getMessage());
6181
}
@@ -65,13 +85,11 @@ public class WooCommerceClientDemo {
6585
}
6686
```
6787

68-
---
69-
70-
## 🔗 Stay Connected
88+
## 🔗 Stay Connected
7189

72-
✨ Were constantly improving this client with new features!
73-
💡 Have suggestions or need help? Open an [issue](https://github.com/YOUR_REPO/issues) or contribute!
90+
- ✨ We're constantly improving this client with new features!
91+
- 💡 Have suggestions or need help? Open an issue or contribute!
7492

75-
🚀 Happy coding! 😊
93+
🚀 Happy coding! 😊
7694

77-
**Your WTX Labs Team 🚀**
95+
**Your WTX Labs Team** 🚀

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.0</version>
8+
<version>0.1.1-alpha-20250207</version>
99
<packaging>jar</packaging>
1010

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

src/main/java/wtx/woocommerce/api/client/CustomersApi.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 createCustomer
78+
* @param customer Customer 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 customer. </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 createCustomerCall(Customer customer, 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 = customer;
106+
107+
// create path and map variables
108+
String localVarPath = "/customers";
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 createCustomerValidateBeforeCall(Customer customer, final ApiCallback _callback) throws ApiException {
138+
// verify the required parameter 'customer' is set
139+
if (customer == null) {
140+
throw new ApiException("Missing the required parameter 'customer' when calling createCustomer(Async)");
141+
}
142+
143+
return createCustomerCall(customer, _callback);
144+
145+
}
146+
147+
/**
148+
* This API helps you to create a new customer.
149+
*
150+
* @param customer Customer object with data to create. (required)
151+
* @return Customer
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 customer. </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 Customer createCustomer(Customer customer) throws ApiException {
163+
ApiResponse<Customer> localVarResp = createCustomerWithHttpInfo(customer);
164+
return localVarResp.getData();
165+
}
166+
167+
/**
168+
* This API helps you to create a new customer.
169+
*
170+
* @param customer Customer object with data to create. (required)
171+
* @return ApiResponse&lt;Customer&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 customer. </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<Customer> createCustomerWithHttpInfo(Customer customer) throws ApiException {
183+
okhttp3.Call localVarCall = createCustomerValidateBeforeCall(customer, null);
184+
Type localVarReturnType = new TypeToken<Customer>(){}.getType();
185+
return localVarApiClient.execute(localVarCall, localVarReturnType);
186+
}
187+
188+
/**
189+
* This API helps you to create a new customer. (asynchronously)
190+
*
191+
* @param customer Customer 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 customer. </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 createCustomerAsync(Customer customer, final ApiCallback<Customer> _callback) throws ApiException {
205+
206+
okhttp3.Call localVarCall = createCustomerValidateBeforeCall(customer, _callback);
207+
Type localVarReturnType = new TypeToken<Customer>(){}.getType();
208+
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
209+
return localVarCall;
210+
}
76211
/**
77212
* Build call for listAllCustomers
78213
* @param context Scope under which the request is made; determines fields present in response. (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 = "2024-12-28T00:49:53.851918900+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
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")
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 = "2024-12-28T00:49:53.851918900+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
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")
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 = "2024-12-28T00:49:53.851918900+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
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")
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 = "2024-12-28T00:49:53.851918900+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
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")
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 = "2024-12-28T00:49:53.851918900+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
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")
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 = "2024-12-28T00:49:53.851918900+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
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")
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 = "2024-12-28T00:49:53.851918900+01:00[Europe/Warsaw]", comments = "Generator version: 7.10.0")
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")
2424
public class ApiKeyAuth implements Authentication {
2525
private final String location;
2626
private final String paramName;

0 commit comments

Comments
 (0)