Skip to content

Commit 3cd2626

Browse files
committed
implemented endpoints for spayd qr code, hct qr code and pay by square qr code
1 parent ca41ed0 commit 3cd2626

3 files changed

Lines changed: 60 additions & 2 deletions

File tree

client/src/main/java/io/apistax/client/APIstaxClient.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.apistax.client;
22

3+
import io.apistax.ApiException;
34
import io.apistax.models.*;
45

56
import java.io.InputStream;
@@ -156,6 +157,33 @@ public interface APIstaxClient {
156157
*/
157158
byte[] convertPdfToPdfA(InputStream file) throws APIstaxException;
158159

160+
/**
161+
* Generate a valid Short Payment Descriptor (SPAYD) QR Code
162+
*
163+
* @param payload QR Code payload to generate (required)
164+
* @return byte[]
165+
* @throws APIstaxException if fails to make API call
166+
*/
167+
byte[] generateSpaydQrCode(SpaydQrCodePayload payload) throws APIstaxException;
168+
169+
/**
170+
* Generate a valid PAY by square QR Code
171+
*
172+
* @param payload QR Code payload to generate (required)
173+
* @return byte[]
174+
* @throws APIstaxException if fails to make API call
175+
*/
176+
byte[] generatePayBySquareQrCode(PayBySquareQrCodePayload payload) throws APIstaxException;
177+
178+
/**
179+
* Generate a valid Hungarian Instant Payment QR Code
180+
*
181+
* @param payload QR Code payload to generate (required)
182+
* @return byte[]
183+
* @throws APIstaxException if fails to make API call
184+
*/
185+
byte[] generateHctQrCode(HctQrCodePayload payload) throws APIstaxException;
186+
159187
/**
160188
* Create a invoice PDF
161189
*

client/src/main/java/io/apistax/client/APIstaxClientImpl.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,21 @@ public byte[] convertPdfToPdfA(InputStream file) throws APIstaxException {
137137
return requestBinary("/v1/pdf-to-pdf-a", new FileBodyProvider(file), "application/pdf");
138138
}
139139

140+
@Override
141+
public byte[] generateSpaydQrCode(SpaydQrCodePayload payload) throws APIstaxException {
142+
return requestBinary("/v1/spayd-qr-code", new JsonBodyProvider(payload, objectMapper), "image/png");
143+
}
144+
145+
@Override
146+
public byte[] generateHctQrCode(HctQrCodePayload payload) throws APIstaxException {
147+
return requestBinary("/v1/hct-qr-code", new JsonBodyProvider(payload, objectMapper), "image/png");
148+
}
149+
150+
@Override
151+
public byte[] generatePayBySquareQrCode(PayBySquareQrCodePayload payload) throws APIstaxException {
152+
return requestBinary("/v1/pay-by-square-qr-code", new JsonBodyProvider(payload, objectMapper), "image/png");
153+
}
154+
140155
@Override
141156
@Deprecated
142157
public byte[] generateInvoicePdfV1(InvoicePayloadV1 payload) throws APIstaxException {
@@ -191,15 +206,15 @@ private <T> T request(String path, BodyProvider body, String accept, Map<String,
191206
var errorMessage = objectMapper.readValue(response.body(), ErrorMessage.class);
192207
throw new APIstaxException(errorMessage.getMessages());
193208
} catch (IOException e) {
194-
if(response.statusCode() == 401) {
209+
if (response.statusCode() == 401) {
195210
throw new APIstaxException(List.of("message.forbidden"), e);
196211
}
197212

198213
throw new APIstaxException(List.of("message.unknownError"), e);
199214
}
200215
}
201216

202-
try(var inputStream = response.body()) {
217+
try (var inputStream = response.body()) {
203218
return mapper.apply(inputStream);
204219
}
205220
} catch (IOException e) {

client/src/main/java/io/apistax/client/APIstaxClientMock.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,19 @@ public byte[] convertPdfToPdfA(InputStream file) throws APIstaxException {
172172
public byte[] generateInvoicePdfV1(InvoicePayloadV1 payload) throws APIstaxException {
173173
return "INVOICE_PDF_V1".getBytes(StandardCharsets.UTF_8);
174174
}
175+
176+
@Override
177+
public byte[] generateSpaydQrCode(SpaydQrCodePayload payload) throws APIstaxException {
178+
return "SPAYD_QR_CODE".getBytes(StandardCharsets.UTF_8);
179+
}
180+
181+
@Override
182+
public byte[] generatePayBySquareQrCode(PayBySquareQrCodePayload payload) throws APIstaxException {
183+
return "PAY_BY_SQUARE_QR_CODE".getBytes(StandardCharsets.UTF_8);
184+
}
185+
186+
@Override
187+
public byte[] generateHctQrCode(HctQrCodePayload payload) throws APIstaxException {
188+
return "HCT_QR_CODE".getBytes(StandardCharsets.UTF_8);
189+
}
175190
}

0 commit comments

Comments
 (0)