-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from MaciejDybowski/common
Dodanie do clienta obsługi endpointu do pobierania faktur bez uwierzy…
- Loading branch information
Showing
7 changed files
with
126 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
ksef-api/src/main/java/io/alapierre/ksef/client/model/rest/common/InvoiceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.alapierre.ksef.client.model.rest.common; | ||
|
||
import io.alapierre.ksef.client.model.rest.query.InvoiceQueryResponse; | ||
import lombok.*; | ||
|
||
@Data | ||
@Builder | ||
public class InvoiceRequest { | ||
private InvoiceDetails invoiceDetails; | ||
private String ksefReferenceNumber; | ||
|
||
|
||
@Data | ||
@Builder | ||
public static class InvoiceDetails { | ||
private String dueValue; | ||
private String invoiceOryginalNumber; | ||
private InvoiceQueryResponse.SubjectTo subjectTo; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,10 @@ | |
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.util.*; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* @author Adrian Lapierre {@literal [email protected]} | ||
|
@@ -123,7 +126,7 @@ public void getStream(@NotNull String endpoint, @NotNull String token, @NotNull | |
throw createException(response); | ||
} | ||
|
||
if(response.body() != null) { | ||
if (response.body() != null) { | ||
try (val is = response.body().byteStream()) { | ||
IOUtils.copy(is, os); | ||
} | ||
|
@@ -133,7 +136,28 @@ public void getStream(@NotNull String endpoint, @NotNull String token, @NotNull | |
} | ||
} | ||
|
||
protected <B, R> Optional<R> doPostJson(@NotNull String endpoint, @NotNull B body, @NotNull Class<R> classOfR, Map<String, String> headers) throws ApiException { | ||
@Override | ||
public void postStream(@NotNull String endpoint, @NotNull Object body, @NotNull OutputStream os) throws ApiException { | ||
RequestBody requestBody = RequestBody.create(serializer.toJson(body), JSON); | ||
Request request = createRequest(endpoint, requestBody, Collections.emptyMap(), true); | ||
|
||
try (Response response = client.newCall(request).execute()) { | ||
if (!response.isSuccessful()) { | ||
throw createException(response); | ||
} | ||
|
||
if (response.body() != null) { | ||
try (val is = response.body().byteStream()) { | ||
IOUtils.copy(is, os); | ||
} | ||
} | ||
} catch (IOException ex) { | ||
throw new ApiException(ex); | ||
} | ||
} | ||
|
||
|
||
protected <B, R> Optional<R> doPostJson(@NotNull String endpoint, @NotNull B body, @NotNull Class<R> classOfR, Map<String, String> headers) throws ApiException { | ||
|
||
RequestBody requestBody = RequestBody.create(serializer.toJson(body), JSON); | ||
Request request = createRequest(endpoint, requestBody, headers, true); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters