Skip to content

Commit 5095d07

Browse files
committed
The createOrder POST method added
1 parent 1d02d16 commit 5095d07

File tree

3 files changed

+138
-3
lines changed

3 files changed

+138
-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.2-alpha-20250210`
16+
- **Current Version**: `0.1.3-alpha-20250212`
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.2-alpha-20250210</version>
46+
<version>0.1.3-alpha-20250212</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.2-alpha-20250210</version>
8+
<version>0.1.3-alpha-20250212</version>
99
<packaging>jar</packaging>
1010

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

src/main/java/wtx/woocommerce/api/client/OrdersApi.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 createOrder
78+
* @param order Order 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 order. </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 createOrderCall(Order order, 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 = order;
106+
107+
// create path and map variables
108+
String localVarPath = "/orders";
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 createOrderValidateBeforeCall(Order order, final ApiCallback _callback) throws ApiException {
138+
// verify the required parameter 'order' is set
139+
if (order == null) {
140+
throw new ApiException("Missing the required parameter 'order' when calling createOrder(Async)");
141+
}
142+
143+
return createOrderCall(order, _callback);
144+
145+
}
146+
147+
/**
148+
* This API helps you to create a new order.
149+
*
150+
* @param order Order object with data to create. (required)
151+
* @return Order
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 order. </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 Order createOrder(Order order) throws ApiException {
163+
ApiResponse<Order> localVarResp = createOrderWithHttpInfo(order);
164+
return localVarResp.getData();
165+
}
166+
167+
/**
168+
* This API helps you to create a new order.
169+
*
170+
* @param order Order object with data to create. (required)
171+
* @return ApiResponse&lt;Order&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 order. </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<Order> createOrderWithHttpInfo(Order order) throws ApiException {
183+
okhttp3.Call localVarCall = createOrderValidateBeforeCall(order, null);
184+
Type localVarReturnType = new TypeToken<Order>(){}.getType();
185+
return localVarApiClient.execute(localVarCall, localVarReturnType);
186+
}
187+
188+
/**
189+
* This API helps you to create a new order. (asynchronously)
190+
*
191+
* @param order Order 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 order. </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 createOrderAsync(Order order, final ApiCallback<Order> _callback) throws ApiException {
205+
206+
okhttp3.Call localVarCall = createOrderValidateBeforeCall(order, _callback);
207+
Type localVarReturnType = new TypeToken<Order>(){}.getType();
208+
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
209+
return localVarCall;
210+
}
76211
/**
77212
* Build call for listAllOrders
78213
* @param page Current page of the collection. Default is 1. (optional)

0 commit comments

Comments
 (0)