Skip to content

Commit

Permalink
Add backwards compatible versions of getEmbedToken and getToken
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-gr4vy committed Jul 11, 2023
1 parent e3964d7 commit d60e633
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>gr4vy</artifactId>
<packaging>jar</packaging>
<name>gr4vy</name>
<version>0.13.0</version>
<version>0.14.0</version>
<url>https://gr4vy.com</url>
<description>Gr4vy Java SDK</description>

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/gr4vy/sdk/Gr4vyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public ApiClient getClient() throws Gr4vyException {
}
}

public String getEmbedToken(Map<String, Object> embed) throws Gr4vyException {
return getEmbedToken(embed, null);
}

public String getEmbedToken(Map<String, Object> embed, UUID checkoutSessionId) throws Gr4vyException {
try {
String key = getKey();
Expand All @@ -119,6 +123,10 @@ public String getEmbedToken(Map<String, Object> embed, UUID checkoutSessionId) t
}
}

public String getToken(String key, String[] scopes, Map<String, Object> embed) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException, JOSEException, ParseException {
return getToken(key, scopes, embed, null);
}

public String getToken(String key, String[] scopes, Map<String, Object> embed, UUID checkoutSessionId) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException, JOSEException, ParseException {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/gr4vy/sdk/Gr4vyClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void getEmbedTokenTest() throws Gr4vyException, ApiException {
embed.put("amount", 1299);
embed.put("currency", "USD");

String token = client.getEmbedToken(embed, null);
String token = client.getEmbedToken(embed);
assert token != null;
}

Expand All @@ -51,7 +51,7 @@ public void getTokenTest() throws Gr4vyException, ApiException, NoSuchAlgorithmE

String key = client.getKey();
String[] scopes = {"*.read", "*.write"};
String token = client.getToken(key, scopes, null, null);
String token = client.getToken(key, scopes, null);

System.out.println(token);
assert token != null;
Expand Down

0 comments on commit d60e633

Please sign in to comment.