Added usage example
This commit is contained in:
parent
4de65a2b25
commit
42542ecafe
43
README.md
43
README.md
@ -6,15 +6,50 @@ This is an android sdk for woocommerce
|
||||
|
||||
Built-based on the documentation: http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction
|
||||
|
||||
## Installation
|
||||
|
||||
#### Maven dependency:
|
||||
### Maven dependency:
|
||||
```xml
|
||||
TODO
|
||||
```
|
||||
|
||||
#### Gradle dependency:
|
||||
### Gradle dependency:
|
||||
TODO
|
||||
|
||||
#### Usage
|
||||
## Getting started
|
||||
|
||||
TODO
|
||||
Generate API credentials (Consumer Key & Consumer Secret) following this instructions <http://docs.woocommerce.com/document/woocommerce-rest-api/>
|
||||
.
|
||||
|
||||
Check out the WooCommerce API endpoints and data that can be manipulated in <https://woocommerce.github.io/woocommerce-rest-api-docs/>.
|
||||
|
||||
## Setup
|
||||
|
||||
Setup for the new WP REST API integration (WooCommerce 2.6 or later):
|
||||
|
||||
```kotlin
|
||||
val woocommerce = Woocommerce.Builder()
|
||||
.setSiteUrl("http://example.com")
|
||||
.setApiVersion("2")
|
||||
.setConsumerKey("ck_XXXXX")
|
||||
.setConsumerSecret("cs_XXXX")
|
||||
.build()
|
||||
```
|
||||
|
||||
## Usage
|
||||
Getting products example
|
||||
|
||||
```kotlin
|
||||
woocommerce.products.enqueue(object : Callback<ArrayList<Product>> {
|
||||
override fun onResponse(call: Call<ArrayList<Product>>, response: Response<ArrayList<Product>>) {
|
||||
val products = response.body()
|
||||
for (product in products!!) {
|
||||
tvText.append(product.title + "\n")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<ArrayList<Product>>, t: Throwable) {
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Loading…
Reference in New Issue
Block a user