Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
amir-shiati committed Nov 21, 2021
1 parent 85951b4 commit fba44bf
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 80 deletions.
28 changes: 28 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>WoocommerceSDK</name>
<comment>Project android-woocommerce-sdk created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1637496141578</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
13 changes: 13 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/home/amir/.sdkman/candidates/java/current
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
6 changes: 6 additions & 0 deletions AndroidWoocommerceSDK/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
34 changes: 34 additions & 0 deletions AndroidWoocommerceSDK/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AndroidWoocommerceSDK</name>
<comment>Project AndroidWoocommerceSDK created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1637496141575</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
142 changes: 68 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[![woocommerce android sdk](https://i.postimg.cc/g272TpwM/image-1.png "woocommerce android sdk")](https://i.postimg.cc/g272TpwM/image-1.png "woocommerce android sdk")

[![](https://jitpack.io/v/amir-shiati/android-woocommerce-sdk.svg)](https://jitpack.io/#amir-shiati/android-woocommerce-sdk)

# Implementation

Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:

```bash
allprojects {
repositories {
Expand All @@ -13,14 +16,18 @@ Add it in your root build.gradle at the end of repositories:
}

```
Step 2. Add the dependency
```bash
implementation 'com.github.amir-shiati:android-woocommerce-sdk:lastes_version'

```
# Usage
### Initialize WooSDK
```java
WooSDK wooSDK = new WooSDK(
context,
Expand All @@ -29,92 +36,79 @@ Step 2. Add the dependency
"domain"
);
```
### To get a list of products:
```java
wooSDK.getProducts()
.setPage(3)
.setPerPage(25)
ProductBuilder productBuilder = new ProductBuilder()
.page(3)
.perPage(25)
.search("Hoodie")
.setOrder(Order.ASC)
.setOrderBy(OrderBy.SLUG)

.addCallBack(new OnGetProductsFinished() {
@Override
public void onSuccess(ArrayList<Product> products) {
for (Product product : products)
Log.i(TAG, product.getName());
}

@Override
public void onFail(String message) {
Log.i(TAG, message);
}
})

.start();
.orderSort(OrderSort.ASC)
.orderBy(OrderBy.SLUG);

wooSDK.getProducts(productBuilder, new OnResponse() {
@Override
public void onSuccess(Object object) {
ArrayList<Product> products = (ArrayList<Product>) object;
for (Product product : products)
Log.i(TAG, String.valueOf(product.getName()));
}

@Override
public void onFail(String err) {
Log.i(TAG, err);
}
});
```
### To get a list of orders:
```java
wooSDK.getOrders()
.setPage(1)
.setPerPage(100)
.setOrderBy(OrderBy.DATE)
.setInclude(new int[102])
.setExclude(new int[22])
.addGetOrdersCallBack(new OnGetOrdersFinished() {
@Override
public void onSuccess(ArrayList<Order> orders) {
for (Order order : orders)
Log.i(TAG, "order id : " + order.getId());
}

@Override
public void onFail(String message) {
Log.i(TAG, message);
}
})
.start();
```
ParamBuilder paramBuilder = new OrderBuilder()
.page(1)
.perPage(100)
.orderBy(OrderBy.DATE)
.include(new int[]{102})
.exclude(new int[]{22});

wooSDK.getOrders(paramBuilder, new OnResponse() {
@Override
public void onSuccess(Object object) {
ArrayList<Order> orders = (ArrayList<Order>) object;
for (Order order : orders)
Log.i(TAG, String.valueOf(order.getId()));
}

@Override
public void onFail(String err) {
Log.i(TAG, err);
}
});
```
### To get a list of categories:
```java
wooSDK.getCategories()
CategoryBuilder categoryBuilder = new CategoryBuilder()
.setPage(1)
.setPerPage(100)
.setExclude(new int[200])
.setExclude(new int[]{201})
.setParent(323)
.setOrder(Order.DESC)
.hideEmpty(true)
.addGetCategoriesCallBack(new OnGetCategoriesFinished() {
@Override
public void onSuccess(ArrayList<Category> categories) {
for (Category category : categories)
Log.i(TAG, category.getName());
}

@Override
public void onFail(String message) {
Log.i(TAG, message);
}
})
.start();
```
### To get a list of Attributes:
```java
wooSDK.getAttributes()
.addGetAttributesCallBack(new OnGetAttributesFinished() {
@Override
public void onSuccess(ArrayList<Attribute> attributes) {
for (Attribute attribute : attributes)
Log.i(TAG, attribute.getName());
}

@Override
public void onFail(String message) {
Log.i(TAG, message);
}
})
.start();
```
.setOrderSort(OrderSort.DESC)
.hideEmpty(true);
wooSDK.getCategories(categoryBuilder, new OnResponse() {
@Override
public void onSuccess(Object object) {
ArrayList<Category> categories = (ArrayList<Category>) object;
for (Category category : categories)
Log.i(TAG, String.valueOf(category.getName()));
}

@Override
public void onFail(String err) {
Log.i(TAG, err);
}
});
```
6 changes: 6 additions & 0 deletions app/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
34 changes: 34 additions & 0 deletions app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1637496141581</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
2 changes: 2 additions & 0 deletions app/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
31 changes: 25 additions & 6 deletions app/src/main/java/com/amirshiati/woocommercesdk/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.amirshiati.androidwoocommercesdk.builder.CategoryBuilder;
import com.amirshiati.androidwoocommercesdk.builder.OrderBuilder;
import com.amirshiati.androidwoocommercesdk.builder.ProductBuilder;
import com.amirshiati.androidwoocommercesdk.enums.OrderBy;
import com.amirshiati.androidwoocommercesdk.enums.OrderSort;
import com.amirshiati.androidwoocommercesdk.enums.OrderStatus;
import com.amirshiati.androidwoocommercesdk.helper.UriBuilderSingleton;
import com.amirshiati.androidwoocommercesdk.interfaces.OnResponse;
Expand Down Expand Up @@ -47,7 +49,12 @@ public void onFail(String err) {
}
});

ParamBuilder paramBuilder = new OrderBuilder().exclude(new int[]{843});
ParamBuilder paramBuilder = new OrderBuilder()
.page(1)
.perPage(100)
.orderBy(OrderBy.DATE)
.include(new int[]{102})
.exclude(new int[]{22});

wooSDK.getOrders(paramBuilder, new OnResponse() {
@Override
Expand All @@ -59,7 +66,7 @@ public void onSuccess(Object object) {

@Override
public void onFail(String err) {

Log.i(TAG, err);
}
});

Expand All @@ -77,7 +84,12 @@ public void onFail(String err) {
}
});

ProductBuilder productBuilder = new ProductBuilder().perPage(5);
ProductBuilder productBuilder = new ProductBuilder()
.page(3)
.perPage(25)
.search("Hoodie")
.orderSort(OrderSort.ASC)
.orderBy(OrderBy.SLUG);

wooSDK.getProducts(productBuilder, new OnResponse() {
@Override
Expand All @@ -89,7 +101,7 @@ public void onSuccess(Object object) {

@Override
public void onFail(String err) {

Log.i(TAG, err);
}
});

Expand All @@ -106,7 +118,14 @@ public void onFail(String err) {
}
});

CategoryBuilder categoryBuilder = new CategoryBuilder().setPerPage(100);
CategoryBuilder categoryBuilder = new CategoryBuilder()
.setPage(1)
.setPerPage(100)
.setExclude(new int[200])
.setExclude(new int[]{201})
.setParent(323)
.setOrderSort(OrderSort.DESC)
.hideEmpty(true);
wooSDK.getCategories(categoryBuilder, new OnResponse() {
@Override
public void onSuccess(Object object) {
Expand All @@ -117,7 +136,7 @@ public void onSuccess(Object object) {

@Override
public void onFail(String err) {

Log.i(TAG, err);
}
});

Expand Down

0 comments on commit fba44bf

Please sign in to comment.