Skip to content

Commit

Permalink
load pdfcrowd api key
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash91 committed Mar 4, 2018
1 parent 650e279 commit 58d59da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/at/chaoticbits/render/HtmlImageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public InputStream generateCryptoDetailsImage(CurrencyDetails currencyDetails) {
try {

// create the API client instance
Pdfcrowd.HtmlToImageClient client = new Pdfcrowd.HtmlToImageClient("yashino", "f87ad728dca1d05ad348a431c6bcc249");
Pdfcrowd.HtmlToImageClient client = new Pdfcrowd.HtmlToImageClient("yashino", System.getenv("PDF_CROWD_API_KEY"));

// configure the conversion
client.setOutputFormat("png");
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/at/chaoticbits/updateshandlers/CryptoHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,17 @@ public void onUpdateReceived(Update update) {

InputStream imageInputStream = CoinMarketCapService.getInstance().getCurrencyDetailsImage(command.substring(1, command.length()));

SendPhoto photo = new SendPhoto();
photo.setChatId(message.getChatId());
photo.setNewPhoto(command, imageInputStream);
sendPhoto(photo);
if (imageInputStream == null) {
BotLogger.error(LOGTAG, "Error creating image input stream");
sendMessageRequest.setText("Error creating image input stream");
sendMessage(sendMessageRequest);
} else {

SendPhoto photo = new SendPhoto();
photo.setChatId(message.getChatId());
photo.setNewPhoto(command, imageInputStream);
sendPhoto(photo);
}
}

} catch (IllegalStateException e) {
Expand Down

0 comments on commit 58d59da

Please sign in to comment.