@@ -52,36 +52,51 @@ After a successful build, add the generated artifact as a dependency in your Jav
5252Easily fetch WooCommerce customer data:
5353
5454``` java
55+ package wtx.woocommerce ;
56+
5557import java.util.List ;
56- import wtx.woocommerce.api.client.* ;
58+
59+ import wtx.woocommerce.api.client.CustomersApi ;
5760import wtx.woocommerce.api.client.invoker.ApiException ;
5861import wtx.woocommerce.api.client.model.Customer ;
5962
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+
6170 public static void main (String [] args ) {
62- System . out. println(" >>> Starting WooCommerceClientDemo..." );
6371
72+ System . out. println(" >>> Start running the WooCommerceApiClientUsageDemo..." );
73+
74+ // Use WooCommerceApiClient(true) if you need to log API communication messages.
6475 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 );
6880
6981 CustomersApi customersApi = new CustomersApi (apiClient);
7082
7183 try {
84+
7285 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
7887 );
88+
89+ // Example list of customer's emails:
90+ customers. forEach(customer - > System . out. println(" Customer: " + customer. getEmail()));
91+
7992 } catch (ApiException e) {
80- System . err. println(" API Error : " + e. getMessage() );
93+ System . err. println(" Error occurred during API call : " + e);
8194 }
8295
83- System . out. println(" <<< WooCommerceClientDemo finished." );
96+ System . out. println(" <<< The WooCommerceApiClientUsageDemo has been finished." );
97+
8498 }
99+
85100}
86101```
87102
@@ -92,4 +107,4 @@ public class WooCommerceClientDemo {
92107
93108🚀 Happy coding! 😊
94109
95- ** Your WTX Labs Team** 🚀
110+ ** Your WTX Labs Team** 🚀
0 commit comments