Skip to content

Commit 8ad8904

Browse files
committed
Fix return type for Attachments when passing FileName on query path
Return type was string json, when it should be ByteArrayInputStream Multiple endpoints updated.
1 parent 30ed97d commit 8ad8904

4 files changed

Lines changed: 39 additions & 57 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Add the dependency to your pom.xml. Gradle, sbt and other build tools can be fo
7474
<dependency>
7575
<groupId>com.github.xeroapi</groupId>
7676
<artifactId>xero-java</artifactId>
77-
<version>2.2.8</version>
77+
<version>2.2.9</version>
7878
</dependency>
7979

8080

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.github.xeroapi</groupId>
55
<artifactId>xero-java</artifactId>
66
<packaging>jar</packaging>
7-
<version>2.2.8</version>
7+
<version>2.2.9</version>
88
<name>Xero-Java SDK</name>
99
<description>This is the official Java SDK for Xero API</description>
1010
<url>https://github.com/XeroAPI/Xero-Java</url>

src/main/java/com/xero/api/JsonConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public String getAccessTokenUrl() {
132132

133133
@Override
134134
public String getUserAgent() {
135-
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.8]";
135+
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.9]";
136136
}
137137

138138
@Override

src/main/java/com/xero/api/client/AccountingApi.java

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,10 +2379,10 @@ public Accounts getAccount(UUID accountID) throws IOException {
23792379
* @param accountID The accountID parameter
23802380
* @param fileName The fileName parameter
23812381
* @param contentType The contentType parameter
2382-
* @return Attachments
2382+
* @return File
23832383
* @throws IOException if an error occurs while attempting to invoke the API
23842384
**/
2385-
public Attachments getAccountAttachmentByFileName(UUID accountID, String fileName, String contentType) throws IOException {
2385+
public ByteArrayInputStream getAccountAttachmentByFileName(UUID accountID, String fileName, String contentType) throws IOException {
23862386
try {
23872387
String strBody = null;
23882388
Map<String, String> params = null;
@@ -2402,11 +2402,9 @@ public Attachments getAccountAttachmentByFileName(UUID accountID, String fileNam
24022402
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
24032403
String url = uriBuilder.buildFromMap(uriVariables).toString();
24042404

2405+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
2406+
return response;
24052407

2406-
String response = this.DATA(url, strBody, params, "GET", contentType);
2407-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
2408-
return apiClient.getObjectMapper().readValue(response, typeRef);
2409-
24102408
} catch (IOException e) {
24112409
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
24122410
} catch (XeroApiException e) {
@@ -2564,10 +2562,10 @@ public BankTransactions getBankTransaction(UUID bankTransactionID) throws IOExce
25642562
* @param bankTransactionID The bankTransactionID parameter
25652563
* @param fileName The fileName parameter
25662564
* @param contentType The contentType parameter
2567-
* @return Attachments
2565+
* @return File
25682566
* @throws IOException if an error occurs while attempting to invoke the API
25692567
**/
2570-
public Attachments getBankTransactionAttachmentByFileName(UUID bankTransactionID, String fileName, String contentType) throws IOException {
2568+
public ByteArrayInputStream getBankTransactionAttachmentByFileName(UUID bankTransactionID, String fileName, String contentType) throws IOException {
25712569
try {
25722570
String strBody = null;
25732571
Map<String, String> params = null;
@@ -2587,11 +2585,9 @@ public Attachments getBankTransactionAttachmentByFileName(UUID bankTransactionID
25872585
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
25882586
String url = uriBuilder.buildFromMap(uriVariables).toString();
25892587

2588+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
2589+
return response;
25902590

2591-
String response = this.DATA(url, strBody, params, "GET", contentType);
2592-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
2593-
return apiClient.getObjectMapper().readValue(response, typeRef);
2594-
25952591
} catch (IOException e) {
25962592
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
25972593
} catch (XeroApiException e) {
@@ -2789,10 +2785,10 @@ public BankTransfers getBankTransfer(UUID bankTransferID) throws IOException {
27892785
* @param bankTransferID The bankTransferID parameter
27902786
* @param fileName The fileName parameter
27912787
* @param contentType The contentType parameter
2792-
* @return Attachments
2788+
* @return File
27932789
* @throws IOException if an error occurs while attempting to invoke the API
27942790
**/
2795-
public Attachments getBankTransferAttachmentByFileName(UUID bankTransferID, String fileName, String contentType) throws IOException {
2791+
public ByteArrayInputStream getBankTransferAttachmentByFileName(UUID bankTransferID, String fileName, String contentType) throws IOException {
27962792
try {
27972793
String strBody = null;
27982794
Map<String, String> params = null;
@@ -2812,11 +2808,9 @@ public Attachments getBankTransferAttachmentByFileName(UUID bankTransferID, Stri
28122808
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
28132809
String url = uriBuilder.buildFromMap(uriVariables).toString();
28142810

2811+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
2812+
return response;
28152813

2816-
String response = this.DATA(url, strBody, params, "GET", contentType);
2817-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
2818-
return apiClient.getObjectMapper().readValue(response, typeRef);
2819-
28202814
} catch (IOException e) {
28212815
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
28222816
} catch (XeroApiException e) {
@@ -3180,10 +3174,10 @@ public Contacts getContact(UUID contactID) throws IOException {
31803174
* @param contactID The contactID parameter
31813175
* @param fileName The fileName parameter
31823176
* @param contentType The contentType parameter
3183-
* @return Attachments
3177+
* @return File
31843178
* @throws IOException if an error occurs while attempting to invoke the API
31853179
**/
3186-
public Attachments getContactAttachmentByFileName(UUID contactID, String fileName, String contentType) throws IOException {
3180+
public ByteArrayInputStream getContactAttachmentByFileName(UUID contactID, String fileName, String contentType) throws IOException {
31873181
try {
31883182
String strBody = null;
31893183
Map<String, String> params = null;
@@ -3203,11 +3197,9 @@ public Attachments getContactAttachmentByFileName(UUID contactID, String fileNam
32033197
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
32043198
String url = uriBuilder.buildFromMap(uriVariables).toString();
32053199

3200+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
3201+
return response;
32063202

3207-
String response = this.DATA(url, strBody, params, "GET", contentType);
3208-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
3209-
return apiClient.getObjectMapper().readValue(response, typeRef);
3210-
32113203
} catch (IOException e) {
32123204
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
32133205
} catch (XeroApiException e) {
@@ -3553,10 +3545,10 @@ public ByteArrayInputStream getCreditNoteAsPdf(UUID creditNoteID, String content
35533545
* @param creditNoteID The creditNoteID parameter
35543546
* @param fileName The fileName parameter
35553547
* @param contentType The contentType parameter
3556-
* @return Attachments
3548+
* @return File
35573549
* @throws IOException if an error occurs while attempting to invoke the API
35583550
**/
3559-
public Attachments getCreditNoteAttachmentByFileName(UUID creditNoteID, String fileName, String contentType) throws IOException {
3551+
public ByteArrayInputStream getCreditNoteAttachmentByFileName(UUID creditNoteID, String fileName, String contentType) throws IOException {
35603552
try {
35613553
String strBody = null;
35623554
Map<String, String> params = null;
@@ -3576,11 +3568,9 @@ public Attachments getCreditNoteAttachmentByFileName(UUID creditNoteID, String f
35763568
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
35773569
String url = uriBuilder.buildFromMap(uriVariables).toString();
35783570

3571+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
3572+
return response;
35793573

3580-
String response = this.DATA(url, strBody, params, "GET", contentType);
3581-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
3582-
return apiClient.getObjectMapper().readValue(response, typeRef);
3583-
35843574
} catch (IOException e) {
35853575
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
35863576
} catch (XeroApiException e) {
@@ -4023,10 +4013,10 @@ public ByteArrayInputStream getInvoiceAsPdf(UUID invoiceID, String contentType)
40234013
* @param invoiceID The invoiceID parameter
40244014
* @param fileName The fileName parameter
40254015
* @param contentType The contentType parameter
4026-
* @return Attachments
4016+
* @return File
40274017
* @throws IOException if an error occurs while attempting to invoke the API
40284018
**/
4029-
public Attachments getInvoiceAttachmentByFileName(UUID invoiceID, String fileName, String contentType) throws IOException {
4019+
public ByteArrayInputStream getInvoiceAttachmentByFileName(UUID invoiceID, String fileName, String contentType) throws IOException {
40304020
try {
40314021
String strBody = null;
40324022
Map<String, String> params = null;
@@ -4046,11 +4036,9 @@ public Attachments getInvoiceAttachmentByFileName(UUID invoiceID, String fileNam
40464036
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
40474037
String url = uriBuilder.buildFromMap(uriVariables).toString();
40484038

4039+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
4040+
return response;
40494041

4050-
String response = this.DATA(url, strBody, params, "GET", contentType);
4051-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
4052-
return apiClient.getObjectMapper().readValue(response, typeRef);
4053-
40544042
} catch (IOException e) {
40554043
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
40564044
} catch (XeroApiException e) {
@@ -4549,10 +4537,10 @@ public ManualJournals getManualJournal(UUID manualJournalID) throws IOException
45494537
* @param manualJournalID The manualJournalID parameter
45504538
* @param fileName The fileName parameter
45514539
* @param contentType The contentType parameter
4552-
* @return Attachments
4540+
* @return File
45534541
* @throws IOException if an error occurs while attempting to invoke the API
45544542
**/
4555-
public Attachments getManualJournalAttachmentByFileName(UUID manualJournalID, String fileName, String contentType) throws IOException {
4543+
public ByteArrayInputStream getManualJournalAttachmentByFileName(UUID manualJournalID, String fileName, String contentType) throws IOException {
45564544
try {
45574545
String strBody = null;
45584546
Map<String, String> params = null;
@@ -4572,11 +4560,9 @@ public Attachments getManualJournalAttachmentByFileName(UUID manualJournalID, St
45724560
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
45734561
String url = uriBuilder.buildFromMap(uriVariables).toString();
45744562

4563+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
4564+
return response;
45754565

4576-
String response = this.DATA(url, strBody, params, "GET", contentType);
4577-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
4578-
return apiClient.getObjectMapper().readValue(response, typeRef);
4579-
45804566
} catch (IOException e) {
45814567
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
45824568
} catch (XeroApiException e) {
@@ -5304,10 +5290,10 @@ public Receipts getReceipt(UUID receiptID) throws IOException {
53045290
* @param receiptID The receiptID parameter
53055291
* @param fileName The fileName parameter
53065292
* @param contentType The contentType parameter
5307-
* @return Attachments
5293+
* @return File
53085294
* @throws IOException if an error occurs while attempting to invoke the API
53095295
**/
5310-
public Attachments getReceiptAttachmentByFileName(UUID receiptID, String fileName, String contentType) throws IOException {
5296+
public ByteArrayInputStream getReceiptAttachmentByFileName(UUID receiptID, String fileName, String contentType) throws IOException {
53115297
try {
53125298
String strBody = null;
53135299
Map<String, String> params = null;
@@ -5327,11 +5313,9 @@ public Attachments getReceiptAttachmentByFileName(UUID receiptID, String fileNam
53275313
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
53285314
String url = uriBuilder.buildFromMap(uriVariables).toString();
53295315

5316+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
5317+
return response;
53305318

5331-
String response = this.DATA(url, strBody, params, "GET", contentType);
5332-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
5333-
return apiClient.getObjectMapper().readValue(response, typeRef);
5334-
53355319
} catch (IOException e) {
53365320
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
53375321
} catch (XeroApiException e) {
@@ -5526,10 +5510,10 @@ public RepeatingInvoices getRepeatingInvoice(UUID repeatingInvoiceID) throws IOE
55265510
* @param repeatingInvoiceID The repeatingInvoiceID parameter
55275511
* @param fileName The fileName parameter
55285512
* @param contentType The contentType parameter
5529-
* @return Attachments
5513+
* @return File
55305514
* @throws IOException if an error occurs while attempting to invoke the API
55315515
**/
5532-
public Attachments getRepeatingInvoiceAttachmentByFileName(UUID repeatingInvoiceID, String fileName, String contentType) throws IOException {
5516+
public ByteArrayInputStream getRepeatingInvoiceAttachmentByFileName(UUID repeatingInvoiceID, String fileName, String contentType) throws IOException {
55335517
try {
55345518
String strBody = null;
55355519
Map<String, String> params = null;
@@ -5549,11 +5533,9 @@ public Attachments getRepeatingInvoiceAttachmentByFileName(UUID repeatingInvoice
55495533
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
55505534
String url = uriBuilder.buildFromMap(uriVariables).toString();
55515535

5536+
ByteArrayInputStream response = this.FILE(url, strBody, params, "GET", contentType);
5537+
return response;
55525538

5553-
String response = this.DATA(url, strBody, params, "GET", contentType);
5554-
TypeReference<Attachments> typeRef = new TypeReference<Attachments>() {};
5555-
return apiClient.getObjectMapper().readValue(response, typeRef);
5556-
55575539
} catch (IOException e) {
55585540
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
55595541
} catch (XeroApiException e) {

0 commit comments

Comments
 (0)