From 42542ecafe3cbfc620159d1e09c6306c1eec0923 Mon Sep 17 00:00:00 2001 From: Gilbert Kimutai Date: Sun, 3 Feb 2019 12:22:09 +0300 Subject: [PATCH] Added usage example --- README.md | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ebf64b0..d6af1cb 100644 --- a/README.md +++ b/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 +. + +Check out the WooCommerce API endpoints and data that can be manipulated in . + +## 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> { + override fun onResponse(call: Call>, response: Response>) { + val products = response.body() + for (product in products!!) { + tvText.append(product.title + "\n") + } + } + + override fun onFailure(call: Call>, t: Throwable) { + + } + }) +```