Skip to content

Commit

Permalink
fixed final issue findings
Browse files Browse the repository at this point in the history
  • Loading branch information
Vignesh Kennadi committed Sep 20, 2024
1 parent 1b5bbdd commit 9c2a680
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/xero/api/client/AccountingApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String, Object> uriVariables = new HashMap<String, Object>();
Expand Down Expand Up @@ -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<String, Object> uriVariables = new HashMap<String, Object>();
Expand Down Expand Up @@ -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<String, Object> uriVariables = new HashMap<String, Object>();
Expand Down Expand Up @@ -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<String, Object> uriVariables = new HashMap<String, Object>();
Expand Down Expand Up @@ -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<String, Object> uriVariables = new HashMap<String, Object>();
Expand Down Expand Up @@ -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<String, Object> uriVariables = new HashMap<String, Object>();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/xero/api/client/BankFeedsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 3 additions & 7 deletions src/test/java/com/xero/api/client/AccountingApiAccountsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
Expand Down

0 comments on commit 9c2a680

Please sign in to comment.