From 9c2a68076dbe0eaceb86d53478ac02d84cfc5155 Mon Sep 17 00:00:00 2001 From: Vignesh Kennadi Date: Fri, 20 Sep 2024 14:59:55 +0530 Subject: [PATCH] fixed final issue findings --- src/main/java/com/xero/api/client/AccountingApi.java | 7 +++++++ src/main/java/com/xero/api/client/BankFeedsApi.java | 4 ++-- .../com/xero/api/client/AccountingApiAccountsTest.java | 10 +++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/xero/api/client/AccountingApi.java b/src/main/java/com/xero/api/client/AccountingApi.java index bf771059..62781eba 100644 --- a/src/main/java/com/xero/api/client/AccountingApi.java +++ b/src/main/java/com/xero/api/client/AccountingApi.java @@ -526,6 +526,7 @@ public HttpResponse createAccountAttachmentByFileNameForHttpResponse( HttpHeaders headers = new HttpHeaders(); headers.set("xero-tenant-id", xeroTenantId); headers.set("Idempotency-Key", idempotencyKey); + headers.setContentType("application/octet-stream"); headers.setAccept("application/json"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables @@ -815,6 +816,7 @@ public HttpResponse createBankTransactionAttachmentByFileNameForHttpResponse( headers.set("xero-tenant-id", xeroTenantId); headers.set("Idempotency-Key", idempotencyKey); headers.setAccept("application/json"); + headers.setContentType("application/octet-stream"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables final Map uriVariables = new HashMap(); @@ -1508,6 +1510,7 @@ public HttpResponse createBankTransferAttachmentByFileNameForHttpResponse( headers.set("xero-tenant-id", xeroTenantId); headers.set("Idempotency-Key", idempotencyKey); headers.setAccept("application/json"); + headers.setContentType("application/octet-stream"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables final Map uriVariables = new HashMap(); @@ -2327,6 +2330,7 @@ public HttpResponse createContactAttachmentByFileNameForHttpResponse( headers.set("xero-tenant-id", xeroTenantId); headers.set("Idempotency-Key", idempotencyKey); headers.setAccept("application/json"); + headers.setContentType("application/octet-stream"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables final Map uriVariables = new HashMap(); @@ -5468,6 +5472,7 @@ public HttpResponse createManualJournalAttachmentByFileNameForHttpResponse( headers.set("xero-tenant-id", xeroTenantId); headers.set("Idempotency-Key", idempotencyKey); headers.setAccept("application/json"); + headers.setContentType("application/octet-stream"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables final Map uriVariables = new HashMap(); @@ -8354,6 +8359,7 @@ public HttpResponse createReceiptAttachmentByFileNameForHttpResponse( headers.set("xero-tenant-id", xeroTenantId); headers.set("Idempotency-Key", idempotencyKey); headers.setAccept("application/json"); + headers.setContentType("application/octet-stream"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables final Map uriVariables = new HashMap(); @@ -8778,6 +8784,7 @@ public HttpResponse createRepeatingInvoiceAttachmentByFileNameForHttpResponse( headers.set("xero-tenant-id", xeroTenantId); headers.set("Idempotency-Key", idempotencyKey); headers.setAccept("application/json"); + headers.setContentType("application/octet-stream"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables final Map uriVariables = new HashMap(); diff --git a/src/main/java/com/xero/api/client/BankFeedsApi.java b/src/main/java/com/xero/api/client/BankFeedsApi.java index d2451d1e..ccb52485 100644 --- a/src/main/java/com/xero/api/client/BankFeedsApi.java +++ b/src/main/java/com/xero/api/client/BankFeedsApi.java @@ -327,7 +327,7 @@ public HttpResponse createStatementsForHttpResponse( HttpHeaders headers = new HttpHeaders(); headers.set("Xero-Tenant-Id", xeroTenantId); headers.set("Idempotency-Key", idempotencyKey); - headers.setAccept("application/jsonapplication/problem+json"); + headers.setAccept("application/json;application/problem+json"); headers.setUserAgent(this.getUserAgent()); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Statements"); String url = uriBuilder.build().toString(); @@ -872,7 +872,7 @@ public HttpResponse getStatementsForHttpResponse( headers.set("Xero-Tenant-Id", xeroTenantId); headers.set("Xero-Application-Id", xeroApplicationId); headers.set("Xero-User-Id", xeroUserId); - headers.setAccept("application/jsonapplication/problem+json"); + headers.setAccept("application/json;application/problem+json"); headers.setUserAgent(this.getUserAgent()); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Statements"); if (page != null) { diff --git a/src/test/java/com/xero/api/client/AccountingApiAccountsTest.java b/src/test/java/com/xero/api/client/AccountingApiAccountsTest.java index 8df6b567..01f7b24a 100644 --- a/src/test/java/com/xero/api/client/AccountingApiAccountsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiAccountsTest.java @@ -127,17 +127,13 @@ public void testGetAccountAttachments() throws Exception { public void testCreateAccountAttachmentByFileName() throws Exception { System.out.println("@Test - createAccountAttachmentByFileName"); - Accounts accounts = accountingApi.getAccounts(accessToken,xeroTenantId,null, null, null); - UUID accountID = accounts.getAccounts().get(0).getAccountID(); - // UUID accountID = UUID.fromString("297c2dc5-cc47-4afd-8ec8-74990b8761e9"); + UUID accountID = UUID.fromString("297c2dc5-cc47-4afd-8ec8-74990b8761e9"); ClassLoader classLoader = getClass().getClassLoader(); File bytes = new File(classLoader.getResource("helo-heros.jpg").getFile()); - String newFileName = bytes.getName(); - String idempotencyKey = null; - // String idempotencyKey = "KEY_VALUE"; - Attachments createAccountsAttachments = accountingApi.createAccountAttachmentByFileName(accessToken,xeroTenantId,accountID, newFileName, bytes, idempotencyKey); + String newFileName = "sample5.jpg"; + Attachments createAccountsAttachments = accountingApi.createAccountAttachmentByFileName(accessToken,xeroTenantId,accountID, newFileName, bytes, null); assertThat(createAccountsAttachments.getAttachments().get(0).getAttachmentID().toString(), is(equalTo("ab95b276-9dce-4925-9077-439818ba270f"))); assertThat(createAccountsAttachments.getAttachments().get(0).getFileName().toString(), is(equalTo("sample5.jpg")));