Merge pull request 'AL-4280 preview layout' (!231) from AL-4280_1 into master
Reviewed-on: adm/ModelWeb#231 Reviewed-by: fabio <fabio.faria@rjconsultores.com.br>master
commit
ceb3592b02
10
pom.xml
10
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>br.com.rjconsultores</groupId>
|
<groupId>br.com.rjconsultores</groupId>
|
||||||
<artifactId>ModelWeb</artifactId>
|
<artifactId>ModelWeb</artifactId>
|
||||||
<version>1.85.0</version>
|
<version>1.86.0</version>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
|
@ -221,7 +221,13 @@
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.32</version>
|
<version>1.18.32</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mashape.unirest</groupId>
|
||||||
|
<artifactId>unirest-java</artifactId>
|
||||||
|
<version>1.4.9</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.rjconsultores.ventaboletos.enums;
|
||||||
public enum EnumLinguagemImpresion {
|
public enum EnumLinguagemImpresion {
|
||||||
HTML(0),
|
HTML(0),
|
||||||
ZPL(1),
|
ZPL(1),
|
||||||
|
TEXT(2),
|
||||||
;
|
;
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue