Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions musen.woocommerce.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.3.3" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.3" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.3.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.3.6" level="project" />
<orderEntry type="library" name="Maven: org.json:jso;;;''n:20140107" level="project" />
<orderEntry type="library" name="Maven: com.mashape.unirest:unirest-java:1.4.9" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20160212" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.6" level="project" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/Desktop/authy-java.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/Desktop/slf4j-android-1.6.1-RC1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project [
<!ELEMENT project (modelVersion|groupId|artifactId|version|dependencies)*>
<!ATTLIST project
xmlns CDATA #REQUIRED
xmlns:xsi CDATA #REQUIRED
xsi:schemaLocation CDATA #REQUIRED>
<!ELEMENT modelVersion (#PCDATA)>
<!ELEMENT groupId (#PCDATA)>
<!ELEMENT artifactId (#PCDATA)>
<!ELEMENT version (#PCDATA)>
<!ELEMENT dependencies (dependency)*>
<!ELEMENT dependency (groupId|artifactId|version)*>
]>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand Down Expand Up @@ -45,6 +58,12 @@
<version>1.4.9</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6</version>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package musen.woocommerce;
package com.g360.woocommerce.client;

import com.mashape.unirest.http.exceptions.UnirestException;
import musen.woocommerce.httpclient.HttpClient;
import musen.woocommerce.httpclient.Options;
import com.g360.woocommerce.client.httpclient.HttpClient;
import com.g360.woocommerce.client.httpclient.Options;

import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
* Created by Muluneh on 8/15/2016.
*/
public class Client {

public static final String VERSION = "1.0.0";
Expand Down
86 changes: 86 additions & 0 deletions src/main/java/com/g360/woocommerce/client/WooCommerceClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.g360.woocommerce.client;

import com.g360.woocommerce.client.domain.order.Order;
import com.g360.woocommerce.client.domain.order.OrdersContainer;
import com.g360.woocommerce.client.domain.product.Product;
import com.g360.woocommerce.client.domain.product.ProductsContainer;
import com.g360.woocommerce.client.httpclient.Options;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class WooCommerceClient {

private static final String PRODUCTS_END_POINT = "products";
private static final String ORDERS_END_POINT = "orders";
private Client client;
private Gson gson;

public static void main(String[] args) {
WooCommerceClient wooCommerceClient = new WooCommerceClient();
System.out.println(wooCommerceClient.getProducts());
}

public WooCommerceClient() {
HashMap<String, String> arguments = new HashMap<String, String>();
Options options = new Options(arguments);
gson = new Gson();

client = new Client(
"http://localhost/lomistore",
"ck_a8f3dd9e2a73caaaf7b6dd3131d46fae70e6b462",
"cs_84924f2f2f58bb0df2d4ad0ed58967865eeb30ca",
options
);
}

public List<Order> getOrders() {

List<Order> orders = new ArrayList<Order>();

String jsonString = "";

try {

jsonString = this.client.get(ORDERS_END_POINT);

OrdersContainer ordersContainer = gson.fromJson(jsonString, OrdersContainer.class);

orders = ordersContainer.getOrders();

} catch(Exception e) {

System.out.println("Error getting orders");

System.out.println(e.getMessage());
}

return orders;
}

public List<Product> getProducts() {

List<Product> products = new ArrayList<Product>();

String jsonString = "";

try {

jsonString = this.client.get(PRODUCTS_END_POINT);

ProductsContainer productsContainer = gson.fromJson(jsonString, ProductsContainer.class);

products = productsContainer.getProducts();

} catch(Exception e) {

System.out.println("Error getting products");

System.out.println(e.getMessage());
}

return products;
}
}
83 changes: 83 additions & 0 deletions src/main/java/com/g360/woocommerce/client/domain/custom/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.g360.woocommerce.client.domain.custom;

import com.g360.woocommerce.client.domain.product.Download;
import com.g360.woocommerce.client.domain.product.Product;
import com.google.gson.Gson;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;

public class Book extends Product {

public String getBookTitle() {
return this.getTitle();
}

public String getBookPreview() {
return this.getDescription();
}

public String getBookDownloadLink() {
// validate payment
Download download = this.getDownloads().get(0);
return download.getFile();
}

public List<Book> getBookSearchResults() {
List<Book> books = new ArrayList<Book>();
books.add(new Book());

return books;
}

public static List<Book> getAllBooks() {
List<Book> books = new ArrayList<Book>();
books.add(new Book());

return books;
}

public static List<Book> getBooksByCategory() {
List<Book> books = new ArrayList<Book>();
books.add(new Book());

return books;
}

public static List<Book> getFeaturedBooks() {
List<Book> books = new ArrayList<Book>();
books.add(new Book());

return books;
}

public static List<Book> getPopularBooks() {
List<Book> books = new ArrayList<Book>();
books.add(new Book());

return books;
}

public static List<Book> getRecommendedBooks() {
List<Book> books = new ArrayList<Book>();
books.add(new Book());

return books;
}

public static List<Book> getLomiMonthSelectBooks() {
List<Book> books = new ArrayList<Book>();
books.add(new Book());

return books;
}

public static List<Book> getTopSellerBooks() {
List<Book> books = new ArrayList<Book>();
books.add(new Book());

return books;
}
}
Loading