Skip to content

Commit 3ff1ce7

Browse files
author
София Корватовская
committed
delete retry
1 parent 7c88d37 commit 3ff1ce7

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

src/main/java/Diadoc/Api/print/PrintFormClient.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package Diadoc.Api.print;
22

33
import Diadoc.Api.exceptions.DiadocSdkException;
4+
import Diadoc.Api.httpClient.DiadocResponseInfo;
45
import Diadoc.Api.print.models.DocumentProtocolResult;
56
import Diadoc.Api.print.models.DocumentZipResult;
67
import Diadoc.Api.print.models.PrintFormContent;
@@ -145,6 +146,28 @@ public DocumentProtocolResult generateDocumentProtocol(String boxId, String mess
145146
}
146147

147148
public PrintFormResult generatePrintFormFromAttachment(String fromBoxId, String documentType, byte[] bytes) throws DiadocSdkException {
149+
validateInput(fromBoxId, documentType, bytes);
150+
151+
var response = executeGeneratePrintFormRequest(fromBoxId, documentType, bytes);
152+
153+
return new PrintFormResult(
154+
new PrintFormContent(
155+
response.getContentType(),
156+
response.getFileName(),
157+
response.getContent()
158+
)
159+
);
160+
}
161+
162+
public String generatePrintFormFromAttachmentId(String fromBoxId, String documentType, byte[] bytes) throws DiadocSdkException {
163+
validateInput(fromBoxId, documentType, bytes);
164+
165+
var response = executeGeneratePrintFormRequest(fromBoxId, documentType, bytes);
166+
167+
return response.getFileName();
168+
}
169+
170+
private void validateInput(String fromBoxId, String documentType, byte[] bytes) {
148171
if (Tools.isNullOrEmpty(fromBoxId)) {
149172
throw new IllegalArgumentException("fromBoxId");
150173
}
@@ -154,22 +177,18 @@ public PrintFormResult generatePrintFormFromAttachment(String fromBoxId, String
154177
if (bytes == null) {
155178
throw new IllegalArgumentException("bytes");
156179
}
180+
}
157181

182+
private DiadocResponseInfo executeGeneratePrintFormRequest(String fromBoxId, String documentType, byte[] bytes) throws DiadocSdkException {
158183
try {
159184
var request = RequestBuilder.get(new URIBuilder(diadocHttpClient.getBaseUrl())
160-
.setPath("/GeneratePrintFormFromAttachment")
161-
.addParameter("fromBoxId", fromBoxId)
162-
.addParameter("documentType", documentType)
163-
.build())
185+
.setPath("/GeneratePrintFormFromAttachment")
186+
.addParameter("fromBoxId", fromBoxId)
187+
.addParameter("documentType", documentType)
188+
.build())
164189
.setEntity(new ByteArrayEntity(bytes));
165190

166-
var response = diadocHttpClient.getRawResponse(request);
167-
168-
if (response.getRetryAfter() != null) {
169-
return new PrintFormResult(response.getRetryAfter());
170-
}
171-
172-
return new PrintFormResult(new PrintFormContent(response.getContentType(), response.getFileName(), response.getContent()));
191+
return diadocHttpClient.getRawResponse(request);
173192

174193
} catch (URISyntaxException | ParseException | IOException e) {
175194
throw new DiadocSdkException(e);

0 commit comments

Comments
 (0)