Skip to content

calatonsystems/wc-api-java

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
September 29, 2016 00:26
November 5, 2019 21:39
September 29, 2016 00:14

WooCommerce API Java Wrapper

Build Status

Java wrapper for WooCommerce REST API. The library supports the latest versions of WooCommerce REST API only with the OAuth 1.0a authentication over the HTTP protocol.

Setup

wc-api-java is available on maven central:

    <dependency>
        <groupId>com.icoderman</groupId>
        <artifactId>wc-api-java</artifactId>
        <version>1.4</version>
    </dependency>

Usage

    public static void main(String[] args) {
        // Setup client
        OAuthConfig config = new OAuthConfig("http://woocommerce.com", "consumerKey", "consumerSecret");
        WooCommerce wooCommerce = new WooCommerceAPI(config, ApiVersionType.V3);

        // Prepare object for request
        Map<String, Object> productInfo = new HashMap<>();
        productInfo.put("name", "Premium Quality");
        productInfo.put("type", "simple");
        productInfo.put("regular_price", "21.99");
        productInfo.put("description", "Pellentesque habitant morbi tristique senectus et netus");

        // Make request and retrieve result
        Map product = wooCommerce.create(EndpointBaseType.PRODUCTS.getValue(), productInfo);

        System.out.println(product.get("id"));

        // Get all with request parameters
        Map<String, String> params = new HashMap<>();
        params.put("per_page","100");
        params.put("offset","0");
        List products = wooCommerce.getAll(EndpointBaseType.PRODUCTS.getValue(), params);

        System.out.println(products.size());
    }

About

Java wrapper for WooCommerce REST API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages