diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..542edcf --- /dev/null +++ b/.github/dependabot.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..deb2e18 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2022698..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: java -jdk: oraclejdk8 -dist: trusty - -install: mvn install -Dgpg.skip - -cache: - directories: - - $HOME/.m2 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..01c0b72 --- /dev/null +++ b/CHANGELOG.md @@ -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. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f459180 --- /dev/null +++ b/CONTRIBUTING.md @@ -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. diff --git a/README.md b/README.md index db19f97..2bb05b9 100644 --- a/README.md +++ b/README.md @@ -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 - - com.icoderman - wc-api-java - 1.4 - + + com.icoderman + wc-api-java + 1.4 + ``` ## 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 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 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 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 diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..f14d595 --- /dev/null +++ b/SECURITY.md @@ -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. diff --git a/pom.xml b/pom.xml index 9444510..0ba8999 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ WooCommerce API Java Wrapper Java wrapper for WooCommerce REST API - https://github.com/icoderman/wc-api-java + https://github.com/omandryk/wc-api-java @@ -22,33 +22,25 @@ icoderman Oleksandr Mandryk - icoderman@gmail.com - https://github.com/icoderman + hello@omandryk.com + https://github.com/omandryk - scm:git:git@github.com:icoderman/wc-api-java.git - scm:git:git@github.com:icoderman/wc-api-java.git - git@github.com/icoderman/wc-api-java.git + scm:git:https://github.com/omandryk/wc-api-java.git + scm:git:ssh://git@github.com/omandryk/wc-api-java.git + https://github.com/omandryk/wc-api-java HEAD - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - 2.10.0 - 4.5.10 - 4.12 + UTF-8 + 8 + 8 + 2.18.6 + 4.5.14 + 4.13.2 @@ -84,17 +76,13 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 - - 1.8 - 1.8 - + 3.14.1 org.apache.maven.plugins maven-source-plugin - 3.0.1 + 3.3.1 attach-sources @@ -108,7 +96,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.0.1 + 3.11.3 attach-javadocs @@ -122,7 +110,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.2.8 true @@ -140,22 +128,10 @@ org.apache.maven.plugins maven-release-plugin - 2.5.3 - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - true - - ossrh - https://oss.sonatype.org/ - true - + 3.1.1 - \ No newline at end of file + diff --git a/src/test/java/com/icoderman/woocommerce/integration/WooCommerceClientTest.java b/src/test/java/com/icoderman/woocommerce/integration/WooCommerceClientTest.java index be37195..5b450ad 100644 --- a/src/test/java/com/icoderman/woocommerce/integration/WooCommerceClientTest.java +++ b/src/test/java/com/icoderman/woocommerce/integration/WooCommerceClientTest.java @@ -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;