diff --git a/src/main/java/com/icoderman/woocommerce/oauth/OAuthSignature.java b/src/main/java/com/icoderman/woocommerce/oauth/OAuthSignature.java index 1cb5997..6a9929a 100644 --- a/src/main/java/com/icoderman/woocommerce/oauth/OAuthSignature.java +++ b/src/main/java/com/icoderman/woocommerce/oauth/OAuthSignature.java @@ -38,7 +38,7 @@ public static Map getAsMap(OAuthConfig config, String endpoint, authParams.put(OAuthHeader.OAUTH_TIMESTAMP.getValue(), String.valueOf(System.currentTimeMillis() / 1000L)); authParams.put(OAuthHeader.OAUTH_NONCE.getValue(), UUID.randomUUID().toString()); authParams.put(OAuthHeader.OAUTH_SIGNATURE_METHOD.getValue(), SIGNATURE_METHOD_HMAC_SHA256); - authParams.putAll(params); + authParams.putAll(colonEncodeValue(params)); // WooCommerce specified param if (HttpMethod.DELETE.equals(httpMethod)) { @@ -139,4 +139,14 @@ private static String percentEncode(String s) { private static Map getSortedParameters(Map parameters) { return new TreeMap<>(parameters); } + + private static Map colonEncodeValue(Map parameter) { + Map encoded = new HashMap<>(); + + for (Map.Entry param : parameter.entrySet()) { + encoded.put(param.getKey(), param.getValue().replace(SpecialSymbol.COLON.getPlain(), SpecialSymbol.COLON.getEncoded())); + } + + return encoded; + } } diff --git a/src/main/java/com/icoderman/woocommerce/oauth/SpecialSymbol.java b/src/main/java/com/icoderman/woocommerce/oauth/SpecialSymbol.java index c677460..fe80867 100644 --- a/src/main/java/com/icoderman/woocommerce/oauth/SpecialSymbol.java +++ b/src/main/java/com/icoderman/woocommerce/oauth/SpecialSymbol.java @@ -9,7 +9,8 @@ public enum SpecialSymbol { EQUAL("=", "%3D"), PLUS("+", "%2B"), STAR("*", "%2A"), - TILDE("~", "%7E"); + TILDE("~", "%7E"), + COLON(":", "%3A"); private String plain; private String encoded; diff --git a/src/test/java/com/icoderman/woocommerce/integration/WooCommerceClientTest.java b/src/test/java/com/icoderman/woocommerce/integration/WooCommerceClientTest.java index be37195..f5496f6 100644 --- a/src/test/java/com/icoderman/woocommerce/integration/WooCommerceClientTest.java +++ b/src/test/java/com/icoderman/woocommerce/integration/WooCommerceClientTest.java @@ -47,6 +47,8 @@ public void apiGetAllProductsTest() { Map params = new HashMap<>(); params.put("per_page","100"); params.put("offset","0"); + params.put("after", "2020-01-01T00:00:00.000Z"); + params.put("before", "2020-01-15T00:00:00.000Z"); Object products = wooCommerce.getAll(EndpointBaseType.PRODUCTS.getValue(), params); Assert.assertNotNull(products); }