2121import org .slf4j .Logger ;
2222import org .slf4j .LoggerFactory ;
2323
24- import software .xdev .bzst .dip .client .exception .HttpStatusCodeNotExceptedException ;
24+ import software .xdev .bzst .dip .client .generated .api .MdEinreichenProviderApi ;
25+ import software .xdev .bzst .dip .client .generated .client .ApiClient ;
2526import software .xdev .bzst .dip .client .model .configuration .BzstDipConfiguration ;
2627import software .xdev .bzst .dip .client .model .message .BzstDipCompleteResult ;
2728import software .xdev .bzst .dip .client .model .message .BzstDipMessage ;
@@ -45,10 +46,29 @@ public class BzstDipClient
4546{
4647 private static final Logger LOGGER = LoggerFactory .getLogger (BzstDipClient .class );
4748 private final BzstDipConfiguration configuration ;
49+ private final WebClient webClient ;
4850
4951 public BzstDipClient (final BzstDipConfiguration configuration )
52+ {
53+ this (configuration , new WebClient (configuration ));
54+ }
55+
56+ public BzstDipClient (final BzstDipConfiguration configuration , final ApiClient apiClient )
57+ {
58+ this (configuration , new WebClient (configuration , apiClient ));
59+ }
60+
61+ public BzstDipClient (
62+ final BzstDipConfiguration configuration ,
63+ final MdEinreichenProviderApi mdEinreichenProviderApi )
64+ {
65+ this (configuration , new WebClient (configuration , mdEinreichenProviderApi ));
66+ }
67+
68+ public BzstDipClient (final BzstDipConfiguration configuration , final WebClient webClient )
5069 {
5170 this .configuration = configuration ;
71+ this .webClient = webClient ;
5272 }
5373
5474 /**
@@ -60,7 +80,6 @@ public BzstDipClient(final BzstDipConfiguration configuration)
6080 * @return the result which only contains the dataTransferNumber
6181 */
6282 public BzstDipSendingResult sendDipOnly (final BzstDipMessage message )
63- throws HttpStatusCodeNotExceptedException
6483 {
6584 return this .sendDipOnly (message .toXmlType (this .configuration ));
6685 }
@@ -73,7 +92,6 @@ public BzstDipSendingResult sendDipOnly(final BzstDipMessage message)
7392 * @return the result which only contains the dataTransferNumber
7493 */
7594 public BzstDipSendingResult sendDipOnly (final String csvData )
76- throws HttpStatusCodeNotExceptedException
7795 {
7896 return this .sendDipOnly (ReportableSellerCsvFileParser .parseCsvData (csvData , this .configuration ));
7997 }
@@ -87,7 +105,6 @@ public BzstDipSendingResult sendDipOnly(final String csvData)
87105 */
88106 public BzstDipSendingResult sendDipOnly (
89107 final List <CorrectableReportableSellerType > correctableReportableSellerTypes )
90- throws HttpStatusCodeNotExceptedException
91108 {
92109 return this .sendDipOnly (
93110 correctableReportableSellerTypes ,
@@ -107,19 +124,15 @@ public BzstDipSendingResult sendDipOnly(
107124 public BzstDipSendingResult sendDipOnly (
108125 final List <CorrectableReportableSellerType > correctableReportableSellerTypes ,
109126 final CorrectablePlatformOperatorType correctablePlatformOperatorType )
110- throws HttpStatusCodeNotExceptedException
111127 {
112- try (final WebClient client = new WebClient (this .configuration ))
113- {
114- return this .sendDipOnlyInternal (correctableReportableSellerTypes , correctablePlatformOperatorType , client );
115- }
128+ return this .sendDipOnlyInternal (correctableReportableSellerTypes , correctablePlatformOperatorType );
116129 }
117130
118131 /**
119132 * Sends the message and queries a result.
120133 * <p>
121134 * Querying the result might take a few seconds and is configured in
122- * {@link BzstDipConfiguration#queryResultConfiguration }.
135+ * {@link BzstDipConfiguration#getQueryResultConfiguration() }.
123136 * </p>
124137 * <p>
125138 * In special cases {@link #sendDipOnly(BzstDipMessage)} can be used, if the result is not needed,
@@ -129,7 +142,7 @@ public BzstDipSendingResult sendDipOnly(
129142 * @return the result which contains the dataTransferNumber and all found responses in the API.
130143 */
131144 public BzstDipCompleteResult sendDipAndQueryResult (final BzstDipMessage message )
132- throws HttpStatusCodeNotExceptedException , InterruptedException , IOException
145+ throws InterruptedException , IOException
133146 {
134147 return this .sendDipAndQueryResult (message .toXmlType (this .configuration ));
135148 }
@@ -138,7 +151,7 @@ public BzstDipCompleteResult sendDipAndQueryResult(final BzstDipMessage message)
138151 * Sends the message and queries a result.
139152 * <p>
140153 * Querying the result might take a few seconds and is configured in
141- * {@link BzstDipConfiguration#queryResultConfiguration }.
154+ * {@link BzstDipConfiguration#getQueryResultConfiguration() }.
142155 * </p>
143156 * <p>
144157 * In special cases {@link #sendDipOnly(String)} can be used, if the result is not needed,
@@ -148,7 +161,7 @@ public BzstDipCompleteResult sendDipAndQueryResult(final BzstDipMessage message)
148161 * @return the result which contains the dataTransferNumber and all found responses in the API.
149162 */
150163 public BzstDipCompleteResult sendDipAndQueryResult (final String csvData )
151- throws HttpStatusCodeNotExceptedException , InterruptedException , IOException
164+ throws InterruptedException , IOException
152165 {
153166 return this .sendDipAndQueryResult (ReportableSellerCsvFileParser .parseCsvData (csvData , this .configuration ));
154167 }
@@ -157,7 +170,7 @@ public BzstDipCompleteResult sendDipAndQueryResult(final String csvData)
157170 * Sends the message and queries a result.
158171 * <p>
159172 * Querying the result might take a few seconds and is configured in
160- * {@link BzstDipConfiguration#queryResultConfiguration }.
173+ * {@link BzstDipConfiguration#getQueryResultConfiguration() }.
161174 * </p>
162175 * <p>
163176 * In special cases {@link #sendDipOnly(List)} can be used, if the result is not needed,
@@ -169,7 +182,7 @@ public BzstDipCompleteResult sendDipAndQueryResult(final String csvData)
169182 public BzstDipCompleteResult sendDipAndQueryResult (
170183 final List <CorrectableReportableSellerType > correctableReportableSellerTypes
171184 )
172- throws HttpStatusCodeNotExceptedException , InterruptedException , IOException
185+ throws InterruptedException , IOException
173186 {
174187 return this .sendDipAndQueryResult (
175188 correctableReportableSellerTypes ,
@@ -181,7 +194,7 @@ public BzstDipCompleteResult sendDipAndQueryResult(
181194 * Sends the message and queries a result.
182195 * <p>
183196 * Querying the result might take a few seconds and is configured in
184- * {@link BzstDipConfiguration#queryResultConfiguration }.
197+ * {@link BzstDipConfiguration#getQueryResultConfiguration() }.
185198 * </p>
186199 * <p>
187200 * In special cases {@link #sendDipOnly(List, CorrectablePlatformOperatorType)} can be used, if the result is
@@ -196,19 +209,16 @@ public BzstDipCompleteResult sendDipAndQueryResult(
196209 final List <CorrectableReportableSellerType > correctableReportableSellerTypes ,
197210 final CorrectablePlatformOperatorType correctablePlatformOperatorType
198211 )
199- throws HttpStatusCodeNotExceptedException , InterruptedException , IOException
212+ throws InterruptedException , IOException
200213 {
201- try (final WebClient client = new WebClient (this .configuration ))
202- {
203214 final BzstDipSendingResult sendingResult =
204- this .sendDipOnlyInternal (correctableReportableSellerTypes , correctablePlatformOperatorType , client );
215+ this .sendDipOnlyInternal (correctableReportableSellerTypes , correctablePlatformOperatorType );
205216
206217 Thread .sleep (this .configuration .getQueryResultConfiguration ().delayBeforeCheckingResults ().toMillis ());
207-
208- final BzstDipRequestStatusResult requestStatusResult = this .queryDipResultWithRetry (client , sendingResult );
218+
219+ final BzstDipRequestStatusResult requestStatusResult = this .queryDipResultWithRetry (sendingResult );
209220
210221 return BzstDipCompleteResult .fromResult (sendingResult , requestStatusResult );
211- }
212222 }
213223
214224 /**
@@ -217,19 +227,15 @@ public BzstDipCompleteResult sendDipAndQueryResult(
217227 * suggest only using this method, if specifically needed.
218228 * @return all found {@link BzstDipSingleTransferResult}s
219229 */
220- public BzstDipRequestStatusResult queryDipResult () throws HttpStatusCodeNotExceptedException , IOException
230+ public BzstDipRequestStatusResult queryDipResult () throws IOException
221231 {
222- try (final WebClient client = new WebClient (this .configuration ))
223- {
224- return client .readAndConfirmDataTransferNumbers ();
225- }
232+ return this .webClient .readAndConfirmDataTransferNumbers ();
226233 }
227234
228235 private BzstDipSendingResult sendDipOnlyInternal (
229236 final List <CorrectableReportableSellerType > correctableReportableSellerTypes ,
230- final CorrectablePlatformOperatorType correctablePlatformOperatorType ,
231- final WebClient client
232- ) throws HttpStatusCodeNotExceptedException
237+ final CorrectablePlatformOperatorType correctablePlatformOperatorType
238+ )
233239 {
234240 final XMLDocumentCreator xmlDocumentCreator = new XMLDocumentCreator (this .configuration );
235241 final String signedXML =
@@ -242,20 +248,19 @@ private BzstDipSendingResult sendDipOnlyInternal(
242248 LOGGER .debug ("Created following XML-Document:\n {}" , signedXML );
243249
244250 LOGGER .debug ("XML data will now be uploaded..." );
245- final String dataTransferNumber = client .getDataTransferNumber ();
251+ final String dataTransferNumber = this . webClient .getDataTransferNumber ();
246252 LOGGER .debug ("Data transfer number: {}" , dataTransferNumber );
247253
248- client .uploadMassData (dataTransferNumber , signedXML );
254+ this . webClient .uploadMassData (dataTransferNumber , signedXML );
249255
250- client .closeSubmission (dataTransferNumber );
256+ this . webClient .closeSubmission (dataTransferNumber );
251257
252258 return new BzstDipSendingResult (dataTransferNumber );
253259 }
254260
255261 private BzstDipRequestStatusResult queryDipResultWithRetry (
256- final WebClient webClient ,
257262 final BzstDipSendingResult sendingResult )
258- throws HttpStatusCodeNotExceptedException , InterruptedException , IOException
263+ throws InterruptedException , IOException
259264 {
260265 BzstDipRequestStatusResult requestStatusResult ;
261266 int retryCounter = 0 ;
@@ -265,7 +270,7 @@ private BzstDipRequestStatusResult queryDipResultWithRetry(
265270 {
266271 Thread .sleep (this .configuration .getQueryResultConfiguration ().delayInBetweenResultChecks ().toMillis ());
267272 }
268- requestStatusResult = webClient .readAndConfirmDataTransferNumbers ();
273+ requestStatusResult = this . webClient .readAndConfirmDataTransferNumbers ();
269274 retryCounter ++;
270275 }
271276 while (
0 commit comments