OrderService and CustomerService are now available from API
This commit is contained in:
parent
91c6ac52d4
commit
b56ac5f17d
@ -47,7 +47,7 @@ class ShopActivity : BaseActivity() {
|
||||
.setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
.build()
|
||||
|
||||
woocommerce.products.enqueue(object : Callback<List<Product>> {
|
||||
woocommerce.Product().products().enqueue(object : Callback<List<Product>> {
|
||||
override fun onResponse(call: Call<List<Product>>, response: Response<List<Product>>) {
|
||||
val productsResponse = response.body()
|
||||
for (product in productsResponse!!) {
|
||||
|
||||
@ -1,25 +1,19 @@
|
||||
package me.gilo.woodroid;
|
||||
|
||||
import me.gilo.woodroid.models.Product;
|
||||
import me.gilo.woodroid.repo.ProductRepository;
|
||||
import me.gilo.woodroid.services.CouponService;
|
||||
import retrofit2.Call;
|
||||
|
||||
import java.util.List;
|
||||
import me.gilo.woodroid.services.CustomerService;
|
||||
import me.gilo.woodroid.services.OrderService;
|
||||
import me.gilo.woodroid.services.ProductService;
|
||||
|
||||
public class Woocommerce {
|
||||
|
||||
public static final ApiVersion API_V1 = ApiVersion.API_VERSION1;
|
||||
public static final ApiVersion API_V2 = ApiVersion.API_VERSION2;
|
||||
|
||||
private String baseUrl;
|
||||
private String siteUrl;
|
||||
private ApiVersion apiVerion;
|
||||
private String consumerKey;
|
||||
private String consumerSecret;
|
||||
|
||||
final ProductRepository productRepository;
|
||||
final CouponService couponService;
|
||||
final CustomerService customerService;
|
||||
final OrderService orderService;
|
||||
final ProductService productService;
|
||||
|
||||
enum ApiVersion {
|
||||
API_VERSION1{
|
||||
@ -33,19 +27,21 @@ public class Woocommerce {
|
||||
public String toString() {
|
||||
return "2";
|
||||
}
|
||||
};
|
||||
},
|
||||
API_VERSION3{
|
||||
@Override
|
||||
public String toString() {
|
||||
return "3";
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
public Woocommerce(String siteUrl, ApiVersion apiVerion, String consumerKey, String consumerSecret) {
|
||||
this.siteUrl = siteUrl;
|
||||
this.apiVerion = apiVerion;
|
||||
this.consumerKey = consumerKey;
|
||||
this.consumerSecret = consumerSecret;
|
||||
|
||||
this.baseUrl = siteUrl + "/wp-json/wc/v" + apiVerion + "/";
|
||||
|
||||
productRepository = new ProductRepository(baseUrl, consumerKey, consumerSecret);
|
||||
String baseUrl = siteUrl + "/wp-json/wc/v" + apiVerion + "/";
|
||||
couponService = new CouponService(baseUrl, consumerKey, consumerSecret);
|
||||
customerService = new CustomerService(baseUrl, consumerKey, consumerSecret);
|
||||
orderService = new OrderService(baseUrl, consumerKey, consumerSecret);
|
||||
productService = new ProductService(baseUrl, consumerKey, consumerSecret);
|
||||
}
|
||||
|
||||
|
||||
@ -85,12 +81,19 @@ public class Woocommerce {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Call<List<Product>> getProducts() {
|
||||
return productRepository.products();
|
||||
}
|
||||
|
||||
public CouponService Coupon() {
|
||||
return couponService;
|
||||
}
|
||||
|
||||
public CustomerService Customer() {
|
||||
return customerService;
|
||||
}
|
||||
|
||||
public OrderService Order() {
|
||||
return orderService;
|
||||
}
|
||||
|
||||
public ProductService Product() {
|
||||
return productService;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user