Merge remote-tracking branch 'origin/master'

This commit is contained in:
Gilbert Kimutai 2019-02-19 04:59:59 +03:00
commit df5f1b0868

View File

@ -9,6 +9,7 @@ This is an android sdk for woocommerce
Built-based on the documentation: http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction Built-based on the documentation: http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction
## Installation ## Installation
Please note that files are still being moved around - the project should be stable before end Feb 2019
### Maven dependency: ### Maven dependency:
Step 1. Add the JitPack repository to your build file Step 1. Add the JitPack repository to your build file
@ -64,7 +65,7 @@ Setup for the new WP REST API integration (WooCommerce 2.6 or later):
```kotlin ```kotlin
val woocommerce = Woocommerce.Builder() val woocommerce = Woocommerce.Builder()
.setSiteUrl("http://example.com") .setSiteUrl("http://example.com")
.setApiVersion("2") .setApiVersion(Woocommerce.API_V2)
.setConsumerKey("ck_XXXXX") .setConsumerKey("ck_XXXXX")
.setConsumerSecret("cs_XXXX") .setConsumerSecret("cs_XXXX")
.build() .build()
@ -74,15 +75,17 @@ Setup for the new WP REST API integration (WooCommerce 2.6 or later):
Getting products example Getting products example
```kotlin ```kotlin
woocommerce.products.enqueue(object : Callback<ArrayList<Product>> { woocommerce.ProductRepository().products().enqueue(object : Callback<List<Product>> {
override fun onResponse(call: Call<ArrayList<Product>>, response: Response<ArrayList<Product>>) { override fun onResponse(call: Call<List<Product>>, response: Response<List<Product>>) {
val products = response.body() val productsResponse = response.body()
for (product in products!!) { for (product in productsResponse!!) {
tvText.append(product.title + "\n") products.add(product)
}
} }
override fun onFailure(call: Call<ArrayList<Product>>, t: Throwable) { adapter.notifyDataSetChanged()
}
override fun onFailure(call: Call<List<Product>>, t: Throwable) {
} }
}) })