Skip to content

Commit fba44bf

Browse files
committed
Updated README.md
1 parent 85951b4 commit fba44bf

File tree

10 files changed

+218
-80
lines changed

10 files changed

+218
-80
lines changed

.project

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>WoocommerceSDK</name>
4+
<comment>Project android-woocommerce-sdk created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
<filteredResources>
18+
<filter>
19+
<id>1637496141578</id>
20+
<name></name>
21+
<type>30</type>
22+
<matcher>
23+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
24+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25+
</matcher>
26+
</filter>
27+
</filteredResources>
28+
</projectDescription>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arguments=
2+
auto.sync=false
3+
build.scans.enabled=false
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5+
connection.project.dir=
6+
eclipse.preferences.version=1
7+
gradle.user.home=
8+
java.home=/home/amir/.sdkman/candidates/java/current
9+
jvm.arguments=
10+
offline.mode=false
11+
override.workspace.settings=true
12+
show.console.view=true
13+
show.executions.view=true

AndroidWoocommerceSDK/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin/default"/>
6+
</classpath>

AndroidWoocommerceSDK/.project

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>AndroidWoocommerceSDK</name>
4+
<comment>Project AndroidWoocommerceSDK created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1637496141575</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
34+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=..
2+
eclipse.preferences.version=1

README.md

Lines changed: 68 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
[![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")
22

33
[![](https://jitpack.io/v/amir-shiati/android-woocommerce-sdk.svg)](https://jitpack.io/#amir-shiati/android-woocommerce-sdk)
4+
45
# Implementation
6+
57
Step 1. Add the JitPack repository to your build file
68
Add it in your root build.gradle at the end of repositories:
9+
710
```bash
811
allprojects {
912
repositories {
@@ -13,14 +16,18 @@ Add it in your root build.gradle at the end of repositories:
1316
}
1417

1518
```
19+
1620
Step 2. Add the dependency
21+
1722
```bash
1823
implementation 'com.github.amir-shiati:android-woocommerce-sdk:lastes_version'
1924

2025
```
2126
2227
# Usage
28+
2329
### Initialize WooSDK
30+
2431
```java
2532
WooSDK wooSDK = new WooSDK(
2633
context,
@@ -29,92 +36,79 @@ Step 2. Add the dependency
2936
"domain"
3037
);
3138
```
39+
3240
### To get a list of products:
41+
3342
```java
34-
wooSDK.getProducts()
35-
.setPage(3)
36-
.setPerPage(25)
43+
ProductBuilder productBuilder = new ProductBuilder()
44+
.page(3)
45+
.perPage(25)
3746
.search("Hoodie")
38-
.setOrder(Order.ASC)
39-
.setOrderBy(OrderBy.SLUG)
40-
41-
.addCallBack(new OnGetProductsFinished() {
42-
@Override
43-
public void onSuccess(ArrayList<Product> products) {
44-
for (Product product : products)
45-
Log.i(TAG, product.getName());
46-
}
47-
48-
@Override
49-
public void onFail(String message) {
50-
Log.i(TAG, message);
51-
}
52-
})
53-
54-
.start();
47+
.orderSort(OrderSort.ASC)
48+
.orderBy(OrderBy.SLUG);
49+
50+
wooSDK.getProducts(productBuilder, new OnResponse() {
51+
@Override
52+
public void onSuccess(Object object) {
53+
ArrayList<Product> products = (ArrayList<Product>) object;
54+
for (Product product : products)
55+
Log.i(TAG, String.valueOf(product.getName()));
56+
}
57+
58+
@Override
59+
public void onFail(String err) {
60+
Log.i(TAG, err);
61+
}
62+
});
5563
```
64+
5665
### To get a list of orders:
66+
5767
```java
58-
wooSDK.getOrders()
59-
.setPage(1)
60-
.setPerPage(100)
61-
.setOrderBy(OrderBy.DATE)
62-
.setInclude(new int[102])
63-
.setExclude(new int[22])
64-
.addGetOrdersCallBack(new OnGetOrdersFinished() {
65-
@Override
66-
public void onSuccess(ArrayList<Order> orders) {
67-
for (Order order : orders)
68-
Log.i(TAG, "order id : " + order.getId());
69-
}
70-
71-
@Override
72-
public void onFail(String message) {
73-
Log.i(TAG, message);
74-
}
75-
})
76-
.start();
77-
```
68+
ParamBuilder paramBuilder = new OrderBuilder()
69+
.page(1)
70+
.perPage(100)
71+
.orderBy(OrderBy.DATE)
72+
.include(new int[]{102})
73+
.exclude(new int[]{22});
74+
75+
wooSDK.getOrders(paramBuilder, new OnResponse() {
76+
@Override
77+
public void onSuccess(Object object) {
78+
ArrayList<Order> orders = (ArrayList<Order>) object;
79+
for (Order order : orders)
80+
Log.i(TAG, String.valueOf(order.getId()));
81+
}
7882

83+
@Override
84+
public void onFail(String err) {
85+
Log.i(TAG, err);
86+
}
87+
});
88+
```
7989
8090
### To get a list of categories:
91+
8192
```java
82-
wooSDK.getCategories()
93+
CategoryBuilder categoryBuilder = new CategoryBuilder()
8394
.setPage(1)
8495
.setPerPage(100)
8596
.setExclude(new int[200])
8697
.setExclude(new int[]{201})
8798
.setParent(323)
88-
.setOrder(Order.DESC)
89-
.hideEmpty(true)
90-
.addGetCategoriesCallBack(new OnGetCategoriesFinished() {
91-
@Override
92-
public void onSuccess(ArrayList<Category> categories) {
93-
for (Category category : categories)
94-
Log.i(TAG, category.getName());
95-
}
96-
97-
@Override
98-
public void onFail(String message) {
99-
Log.i(TAG, message);
100-
}
101-
})
102-
.start();
103-
```
104-
### To get a list of Attributes:
105-
```java
106-
wooSDK.getAttributes()
107-
.addGetAttributesCallBack(new OnGetAttributesFinished() {
108-
@Override
109-
public void onSuccess(ArrayList<Attribute> attributes) {
110-
for (Attribute attribute : attributes)
111-
Log.i(TAG, attribute.getName());
112-
}
113-
114-
@Override
115-
public void onFail(String message) {
116-
Log.i(TAG, message);
117-
}
118-
})
119-
.start();
120-
```
99+
.setOrderSort(OrderSort.DESC)
100+
.hideEmpty(true);
101+
wooSDK.getCategories(categoryBuilder, new OnResponse() {
102+
@Override
103+
public void onSuccess(Object object) {
104+
ArrayList<Category> categories = (ArrayList<Category>) object;
105+
for (Category category : categories)
106+
Log.i(TAG, String.valueOf(category.getName()));
107+
}
108+
109+
@Override
110+
public void onFail(String err) {
111+
Log.i(TAG, err);
112+
}
113+
});
114+
```

app/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin/default"/>
6+
</classpath>

app/.project

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>app</name>
4+
<comment>Project app created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1637496141581</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
34+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=..
2+
eclipse.preferences.version=1

app/src/main/java/com/amirshiati/woocommercesdk/MainActivity.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.amirshiati.androidwoocommercesdk.builder.CategoryBuilder;
1010
import com.amirshiati.androidwoocommercesdk.builder.OrderBuilder;
1111
import com.amirshiati.androidwoocommercesdk.builder.ProductBuilder;
12+
import com.amirshiati.androidwoocommercesdk.enums.OrderBy;
13+
import com.amirshiati.androidwoocommercesdk.enums.OrderSort;
1214
import com.amirshiati.androidwoocommercesdk.enums.OrderStatus;
1315
import com.amirshiati.androidwoocommercesdk.helper.UriBuilderSingleton;
1416
import com.amirshiati.androidwoocommercesdk.interfaces.OnResponse;
@@ -47,7 +49,12 @@ public void onFail(String err) {
4749
}
4850
});
4951

50-
ParamBuilder paramBuilder = new OrderBuilder().exclude(new int[]{843});
52+
ParamBuilder paramBuilder = new OrderBuilder()
53+
.page(1)
54+
.perPage(100)
55+
.orderBy(OrderBy.DATE)
56+
.include(new int[]{102})
57+
.exclude(new int[]{22});
5158

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

6067
@Override
6168
public void onFail(String err) {
62-
69+
Log.i(TAG, err);
6370
}
6471
});
6572

@@ -77,7 +84,12 @@ public void onFail(String err) {
7784
}
7885
});
7986

80-
ProductBuilder productBuilder = new ProductBuilder().perPage(5);
87+
ProductBuilder productBuilder = new ProductBuilder()
88+
.page(3)
89+
.perPage(25)
90+
.search("Hoodie")
91+
.orderSort(OrderSort.ASC)
92+
.orderBy(OrderBy.SLUG);
8193

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

90102
@Override
91103
public void onFail(String err) {
92-
104+
Log.i(TAG, err);
93105
}
94106
});
95107

@@ -106,7 +118,14 @@ public void onFail(String err) {
106118
}
107119
});
108120

109-
CategoryBuilder categoryBuilder = new CategoryBuilder().setPerPage(100);
121+
CategoryBuilder categoryBuilder = new CategoryBuilder()
122+
.setPage(1)
123+
.setPerPage(100)
124+
.setExclude(new int[200])
125+
.setExclude(new int[]{201})
126+
.setParent(323)
127+
.setOrderSort(OrderSort.DESC)
128+
.hideEmpty(true);
110129
wooSDK.getCategories(categoryBuilder, new OnResponse() {
111130
@Override
112131
public void onSuccess(Object object) {
@@ -117,7 +136,7 @@ public void onSuccess(Object object) {
117136

118137
@Override
119138
public void onFail(String err) {
120-
139+
Log.i(TAG, err);
121140
}
122141
});
123142

0 commit comments

Comments
 (0)