Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: maven
directory: /
schedule:
interval: monthly
open-pull-requests-limit: 5
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
open-pull-requests-limit: 5
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
branches: [master]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['8', '11', '17', '21']
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: maven
- run: mvn --batch-mode --no-transfer-progress verify -Dgpg.skip=true
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## Unreleased

- Restored continuous integration across supported Java versions.
- Removed embedded WooCommerce credentials from integration tests.
- Updated maintained dependencies and build plugins.
- Updated project ownership, security, and contribution documentation.

## 1.4 - 2019-11-05

- Latest historical Maven Central release before the project revival.
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing

Issues and focused pull requests are welcome. Before proposing a substantial API change, open an issue so the design and compatibility impact can be discussed.

## Development

Requirements: JDK 8 or newer and Maven 3.8 or newer.

```bash
mvn verify -Dgpg.skip=true
```

The legacy live-store integration tests are currently disabled with JUnit's `@Ignore`. For manual testing, use a disposable WooCommerce store and supply `WC_URL`, `WC_CONSUMER_KEY`, and `WC_CONSUMER_SECRET` through environment variables. Never commit real credentials.
81 changes: 46 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,56 @@
# WooCommerce API Java Wrapper
[![Build Status](https://travis-ci.org/icoderman/wc-api-java.svg?branch=master)](https://travis-ci.org/icoderman/wc-api-java)

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.
[![CI](https://github.com/omandryk/wc-api-java/actions/workflows/ci.yml/badge.svg)](https://github.com/omandryk/wc-api-java/actions/workflows/ci.yml)
[![Maven Central](https://img.shields.io/maven-central/v/com.icoderman/wc-api-java.svg)](https://central.sonatype.com/artifact/com.icoderman/wc-api-java)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

A small Java wrapper for the WooCommerce REST API, originally released in 2016 and distributed through Maven Central.

> **Project revival:** version 1.4 is the latest published release. The 1.5 line restores maintenance, testing, and modern release infrastructure while preserving the existing API. Do not use unreleased snapshots in production.

## Installation

## Setup
wc-api-java is available on maven central:
```xml
<dependency>
<groupId>com.icoderman</groupId>
<artifactId>wc-api-java</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.icoderman</groupId>
<artifactId>wc-api-java</artifactId>
<version>1.4</version>
</dependency>
```

## Usage

```java
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());
}
OAuthConfig config = new OAuthConfig(
"http://localhost",
System.getenv("WC_CONSUMER_KEY"),
System.getenv("WC_CONSUMER_SECRET")
);
WooCommerce wooCommerce = new WooCommerceAPI(config, ApiVersionType.V3);

Map<String, String> params = new HashMap<>();
params.put("per_page", "100");
List products = wooCommerce.getAll(EndpointBaseType.PRODUCTS.getValue(), params);
```

Never commit WooCommerce credentials. Supply them through a secret manager or environment variables.

## Compatibility

- Java 8 or newer
- WooCommerce REST API v2/v3 endpoints
- Legacy OAuth 1.0a request signing over HTTP

The 1.x client does not implement WooCommerce HTTPS Basic Authentication. Use it only in a controlled environment until HTTPS-first authentication is available in a future major release.

## Development

```bash
mvn verify -Dgpg.skip=true
```

See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md) before opening an issue or pull request.

## License

MIT © Oleksandr Mandryk
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Security policy

The latest release is the only supported version. Please report suspected vulnerabilities privately through GitHub Security Advisories instead of opening a public issue.

Never include WooCommerce consumer keys, consumer secrets, access tokens, or customer data in a report. Use redacted requests and a minimal reproduction whenever possible.
60 changes: 18 additions & 42 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<name>WooCommerce API Java Wrapper</name>
<description>Java wrapper for WooCommerce REST API</description>
<url>https://github.com/icoderman/wc-api-java</url>
<url>https://github.com/omandryk/wc-api-java</url>

<licenses>
<license>
Expand All @@ -22,33 +22,25 @@
<developer>
<id>icoderman</id>
<name>Oleksandr Mandryk</name>
<email>icoderman@gmail.com</email>
<url>https://github.com/icoderman</url>
<email>hello@omandryk.com</email>
<url>https://github.com/omandryk</url>
</developer>
</developers>

<scm>
<connection>scm:git:git@github.com:icoderman/wc-api-java.git</connection>
<developerConnection>scm:git:git@github.com:icoderman/wc-api-java.git</developerConnection>
<url>git@github.com/icoderman/wc-api-java.git</url>
<connection>scm:git:https://github.com/omandryk/wc-api-java.git</connection>
<developerConnection>scm:git:ssh://git@github.com/omandryk/wc-api-java.git</developerConnection>
<url>https://github.com/omandryk/wc-api-java</url>
<tag>HEAD</tag>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<properties>
<jackson.version>2.10.0</jackson.version>
<httpclient.version>4.5.10</httpclient.version>
<junit.version>4.12</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<jackson.version>2.18.6</jackson.version>
<httpclient.version>4.5.14</httpclient.version>
<junit.version>4.13.2</junit.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -84,17 +76,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<version>3.14.1</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -108,7 +96,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<version>3.11.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -122,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.2.8</version>
<configuration>
<useAgent>true</useAgent>
</configuration>
Expand All @@ -140,22 +128,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
<version>3.1.1</version>
</plugin>

</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

public class WooCommerceClientTest {

private static final String CONSUMER_KEY = "ck_d35e7be7cc695d87f23490729dd80e173f88c8f5";
private static final String CONSUMER_SECRET = "cs_53a835760712ebf0c8bcf2a21197af4b2323a052";
private static final String WC_URL = "http://localhost/index.php";
private static final String CONSUMER_KEY = System.getenv("WC_CONSUMER_KEY");
private static final String CONSUMER_SECRET = System.getenv("WC_CONSUMER_SECRET");
private static final String WC_URL = System.getenv("WC_URL");

private WooCommerce wooCommerce;

Expand Down
Loading