Skip to content

Commit 94cc7b4

Browse files
Added new endpoints for batch cobV and endpoint to change expire date of carnet
1 parent 8cd857d commit 94cc7b4

File tree

7 files changed

+48
-10
lines changed

7 files changed

+48
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.0.5
2+
3+
- Added new endpoints for batch cobV
4+
- Added a new endpoint to change expire date of carnet
5+
16
# 1.0.4
27

38
- Added the User-Agent in the header

README-en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For more informations about [parameters](http://dev.sejaefi.com.br) and [values]
2222
**Via gradle:**
2323

2424
```gradle
25-
implementation 'br.com.efipay.efisdk:sdk-java-apis-efi:1.0.4'
25+
implementation 'br.com.efipay.efisdk:sdk-java-apis-efi:1.0.5'
2626
```
2727

2828
**Via maven:**
@@ -31,7 +31,7 @@ implementation 'br.com.efipay.efisdk:sdk-java-apis-efi:1.0.4'
3131
<dependency>
3232
    <groupId>br.com.efipay.efisdk</groupId>
3333
<artifactId>sdk-java-apis-efi</artifactId>
34-
<version>1.0.4</version>
34+
<version>1.0.5</version>
3535
</dependency>
3636
```
3737

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Para mais informações sobre [parâmetros](http://sejaefi.com.br/api) e [valore
2323
**Via gradle:**
2424

2525
```gradle
26-
implementation 'br.com.efipay.efisdk:sdk-java-apis-efi:1.0.4'
26+
implementation 'br.com.efipay.efisdk:sdk-java-apis-efi:1.0.5'
2727
```
2828

2929
**Via maven:**
@@ -32,7 +32,7 @@ implementation 'br.com.efipay.efisdk:sdk-java-apis-efi:1.0.4'
3232
<dependency>
3333
<groupId>br.com.efipay.efisdk</groupId>
3434
<artifactId>sdk-java-apis-efi</artifactId>
35-
<version>1.0.4</version>
35+
<version>1.0.5</version>
3636
</dependency>
3737
```
3838

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>br.com.efipay.efisdk</groupId>
55
<artifactId>sdk-java-apis-efi</artifactId>
6-
<version>1.0.4</version>
6+
<version>1.0.5</version>
77

88
<name>SDK JAVA APIS EFI</name>
99
<description>Java SDK for integrating with Efí API</description>

src/main/java/br/com/efi/efisdk/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*/
1313
public class Config {
14-
private final static String version = "1.0.4";
14+
private final static String version = "1.0.5";
1515
private JSONObject conf = new JSONObject();
1616
private JSONObject endpoints = new JSONObject();
1717
private JSONObject urls = new JSONObject();

src/main/java/br/com/efi/efisdk/Request.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package br.com.efi.efisdk;
22

3+
import java.io.BufferedReader;
34
import java.io.IOException;
45
import java.io.InputStream;
6+
import java.io.InputStreamReader;
57
import java.io.OutputStream;
68
import java.net.HttpURLConnection;
79
import java.nio.charset.StandardCharsets;
@@ -25,15 +27,14 @@ public class Request {
2527
private HttpURLConnection client;
2628

2729
public Request(String method, HttpURLConnection conn) throws IOException {
28-
this.client = conn;
30+
this.client = conn;
2931
this.client.setRequestProperty("Content-Type", "application/json");
3032
this.client.setRequestProperty("charset", "UTF-8");
3133
this.client.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36");
3234
this.client.setRequestProperty("api-sdk", "efi-java-" + Config.getVersion());
3335

3436
if (method.toUpperCase().equals("PATCH")) {
3537
this.client.setRequestProperty("X-HTTP-Method-Override", "PATCH");
36-
this.client.setRequestMethod("POST");
3738
} else {
3839
this.client.setRequestMethod(method.toUpperCase());
3940
}
@@ -56,7 +57,7 @@ public JSONObject send(JSONObject requestOptions) throws AuthorizationException,
5657
}
5758

5859
int responseCode = client.getResponseCode();
59-
if (client.getResponseMessage().equals("No Content")){
60+
if (client.getResponseMessage().equals("No Content") || client.getResponseMessage().equals("Accepted")){
6061
throw new RuntimeException("{\"code: " + responseCode + "\"}");
6162
} else{
6263
if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED
@@ -75,6 +76,18 @@ public JSONObject send(JSONObject requestOptions) throws AuthorizationException,
7576
}
7677
}
7778
}
79+
80+
private String readInputStreamToString(InputStream inputStream) throws IOException {
81+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
82+
StringBuilder stringBuilder = new StringBuilder();
83+
String line;
84+
while ((line = reader.readLine()) != null) {
85+
stringBuilder.append(line);
86+
}
87+
return stringBuilder.toString();
88+
}
89+
}
90+
7891
public String sendString(JSONObject requestOptions)
7992
throws AuthorizationException, EfiPayException, IOException {
8093
byte[] postDataBytes;
@@ -95,7 +108,7 @@ public String sendString(JSONObject requestOptions)
95108
if (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_CREATED
96109
|| responseCode == HttpURLConnection.HTTP_ACCEPTED) {
97110
InputStream responseStream = client.getInputStream();
98-
String response = new String(responseStream.readAllBytes(), StandardCharsets.UTF_8);
111+
String response = readInputStreamToString(responseStream);
99112
return new String(response);
100113
} else if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED
101114
|| responseCode == HttpURLConnection.HTTP_FORBIDDEN) {

src/main/resources/config.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
"route": "/v1/carnet/:id/parcel/:parcel",
5959
"method": "put"
6060
},
61+
"updateCarnetParcels": {
62+
"route": "/v1/carnet/:id/parcels",
63+
"method": "put"
64+
},
6165
"updateCarnetMetadata": {
6266
"route": "/v1/carnet/:id/metadata",
6367
"method": "put"
@@ -369,6 +373,22 @@
369373
"detailReport": {
370374
"route": "/v2/gn/relatorios/:id",
371375
"method": "get"
376+
},
377+
"pixCreateDueChargeBatch": {
378+
"route": "/v2/lotecobv/:id",
379+
"method": "put"
380+
},
381+
"pixUpdateDueChargeBatch": {
382+
"route": "/v2/lotecobv/:id",
383+
"method": "patch"
384+
},
385+
"pixDetailDueChargeBatch": {
386+
"route": "/v2/lotecobv/:id",
387+
"method": "get"
388+
},
389+
"pixListDueChargeBatch": {
390+
"route": "/v2/lotecobv",
391+
"method": "get"
372392
}
373393
}
374394
},

0 commit comments

Comments
 (0)