AL-4280 preview layout

master
Lucas 2024-07-18 22:37:29 -03:00
parent 622fd86887
commit 0ce92cd755
3 changed files with 60 additions and 2 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId>
<artifactId>ModelWeb</artifactId>
<version>1.85.0</version>
<version>1.86.0</version>
<distributionManagement>
<repository>
@ -223,6 +223,12 @@
<version>1.18.32</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
<dependencyManagement>
</dependencyManagement>

View File

@ -3,6 +3,7 @@ package com.rjconsultores.ventaboletos.enums;
public enum EnumLinguagemImpresion {
HTML(0),
ZPL(1),
TEXT(2),
;
private Integer id;

View File

@ -0,0 +1,51 @@
package com.rjconsultores.ventaboletos.rest;
import java.io.InputStream;
import org.apache.http.HttpStatus;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
public class LabelaryService {
private static final Logger log = LogManager.getLogger(LabelaryService.class);
private static LabelaryService instance;
private String URL = "http://api.labelary.com/v1/printers";
private LabelaryService() {
}
public static synchronized LabelaryService getInstance() {
if (instance == null) {
instance = new LabelaryService();
}
return instance;
}
public InputStream retornarImagem(String texto) {
try {
Unirest.setTimeouts(0, 0);
HttpResponse<InputStream> response = Unirest.post(URL + "/8dpmm/labels/4x6/0/>label.png?")
.header("Content-Type", "application/x-www-form-urlencoded")
.body(texto)
.asObject(InputStream.class);
if (response != null
&& (response.getStatus() == HttpStatus.SC_OK || response.getStatus() == HttpStatus.SC_CREATED)) {
return response.getBody();
} else {
throw new Exception("erro ao enviar requisicao labelary " + response.getStatusText());
}
} catch (Exception e) {
log.error("erro ao enviar requisicao ", e);
}
return null;
}
}