Skip to content

Commit

Permalink
retrieving validated letters. issue #54.
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Oct 13, 2023
1 parent bb46c59 commit 9df26aa
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
Binary file modified j-lawyer-client/lib/j-lawyer-cloud/j-lawyer-cloud.jar
Binary file not shown.
32 changes: 32 additions & 0 deletions j-lawyer-fax/src/com/jdimension/jlawyer/epost/EpostAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,38 @@ public String login(String secret, String password) throws EpostException {
return token;
}

public byte[] getValidatedLetter(String token, String letterId) throws EpostException {
log.info("ePost API validated letter retrieval");

byte[] bytes=null;
WebTarget webTarget = this.getWebTarget(baseUri + "/api/Letter/TestResult?letterID=" + letterId);
try {
Response response = webTarget.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).header(AUTH_HEADERNAME, AUTH_HEADERPREFIX + token).get();
String returnValue = response.readEntity(String.class);
if (response.getStatus() != 200) {
log.error("Could not check ePost API status: " + returnValue + " [" + response.getStatus() + "]");
throw new EpostException("Could not check ePost API status: " + returnValue + " [" + response.getStatus() + "]");
}

Object jsonOutput = Jsoner.deserialize(returnValue);
if (jsonOutput instanceof JsonObject) {
JsonObject result = (JsonObject) jsonOutput;
JsonKey levelKey = Jsoner.mintJsonKey("data", null);
String base64 = result.getString(levelKey);
Base64 decoder = new Base64();
bytes=decoder.decode(base64);
}

} catch (Exception ex) {
log.error("Could not check ePost API status", ex);
throw new EpostException(ex.getMessage(), ex);
}

log.info("ePost API validated letter retrieval finished, received bytes: " + bytes.length);
return bytes;

}

public String validateLetter(String token, EpostLetter letter, String toEmail) throws EpostException {
log.info("ePost API letter validation");

Expand Down
Binary file added j-lawyer-fax/test/org/jlawyer/tests/validated.pdf
Binary file not shown.
Binary file modified j-lawyer-server/j-lawyer-server-ejb/lib/j-lawyer-cloud.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,6 @@ public BalanceInformation getBalance() throws SipgateException {



// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
@Override
@RolesAllowed({"loginRole"})
public ArrayList<SipUri> getOwnUris() throws SipgateException {
Expand Down

0 comments on commit 9df26aa

Please sign in to comment.