@@ -52,36 +52,51 @@ After a successful build, add the generated artifact as a dependency in your Jav
52
52
Easily fetch WooCommerce customer data:
53
53
54
54
``` java
55
+ package wtx.woocommerce ;
56
+
55
57
import java.util.List ;
56
- import wtx.woocommerce.api.client.* ;
58
+
59
+ import wtx.woocommerce.api.client.CustomersApi ;
57
60
import wtx.woocommerce.api.client.invoker.ApiException ;
58
61
import wtx.woocommerce.api.client.model.Customer ;
59
62
60
- public class WooCommerceClientDemo {
63
+ public class WooCommerceApiClientUsageDemo {
64
+
65
+ // TODO: Set your WooCommerce API base path!
66
+ private static final String API_BASE_PATH = " https://your-woocommerce-shop.com/wp-json/wc/v3" ;
67
+ private static final String API_USERNAME = " TODO_SET_API_USERNAME" ;
68
+ private static final String API_PASSWORD = " TODO_SET_API_PASSWORD" ;
69
+
61
70
public static void main (String [] args ) {
62
- System . out. println(" >>> Starting WooCommerceClientDemo..." );
63
71
72
+ System . out. println(" >>> Start running the WooCommerceApiClientUsageDemo..." );
73
+
74
+ // Use WooCommerceApiClient(true) if you need to log API communication messages.
64
75
WooCommerceApiClient apiClient = new WooCommerceApiClient ();
65
- apiClient. setBasePath(" https://your-woocommerce-shop.com/wp-json/wc/v3" );
66
- apiClient. setUsername(" YOUR_API_USERNAME" );
67
- apiClient. setPassword(" YOUR_API_PASSWORD" );
76
+
77
+ apiClient. setBasePath(API_BASE_PATH );
78
+ apiClient. setUsername(API_USERNAME );
79
+ apiClient. setPassword(API_PASSWORD );
68
80
69
81
CustomersApi customersApi = new CustomersApi (apiClient);
70
82
71
83
try {
84
+
72
85
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())
86
+ null , null , null , null , null , null , null , null , null , null , null
78
87
);
88
+
89
+ // Example list of customer's emails:
90
+ customers. forEach(customer - > System . out. println(" Customer: " + customer. getEmail()));
91
+
79
92
} catch (ApiException e) {
80
- System . err. println(" API Error : " + e. getMessage() );
93
+ System . err. println(" Error occurred during API call : " + e);
81
94
}
82
95
83
- System . out. println(" <<< WooCommerceClientDemo finished." );
96
+ System . out. println(" <<< The WooCommerceApiClientUsageDemo has been finished." );
97
+
84
98
}
99
+
85
100
}
86
101
```
87
102
@@ -92,4 +107,4 @@ public class WooCommerceClientDemo {
92
107
93
108
🚀 Happy coding! 😊
94
109
95
- ** Your WTX Labs Team** 🚀
110
+ ** Your WTX Labs Team** 🚀
0 commit comments