Skip to content

Commit a54f87b

Browse files
committed
Update missing Enums and Prepayment routes
Added CountryCode, CurrencyCode and Timezone, PaymentTermType components Updated 37 string properties with appropriate Enums Added Allocations and History for Prepayments
1 parent f395ccf commit a54f87b

36 files changed

Lines changed: 2411 additions & 728 deletions

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.0</version>
77+
<version>2.2.1</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.0</version>
7+
<version>2.2.1</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
@@ -131,7 +131,7 @@ public String getAccessTokenUrl() {
131131

132132
@Override
133133
public String getUserAgent() {
134-
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.0]";
134+
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.1]";
135135
}
136136

137137
@Override

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

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import com.xero.models.accounting.Account;
66
import com.xero.models.accounting.Accounts;
7-
import com.xero.models.accounting.Allocation;
87
import com.xero.models.accounting.Allocations;
98
import com.xero.models.accounting.Attachments;
109
import com.xero.models.accounting.BankTransactions;
@@ -1630,11 +1629,11 @@ public Prepayments createPrepayment(Prepayments prepayments) throws IOException
16301629
* <p><b>200</b> - A successful request
16311630
* <p><b>400</b> - A failed request due to validation error
16321631
* @param prepaymentID The prepaymentID parameter
1633-
* @param allocation The allocation parameter
1634-
* @return Allocation
1632+
* @param allocations The allocations parameter
1633+
* @return Allocations
16351634
* @throws IOException if an error occurs while attempting to invoke the API
16361635
**/
1637-
public Allocation createPrepaymentAllocation(UUID prepaymentID, Allocation allocation) throws IOException {
1636+
public Allocations createPrepaymentAllocation(UUID prepaymentID, Allocations allocations) throws IOException {
16381637
try {
16391638
String strBody = null;
16401639
Map<String, String> params = null;
@@ -1654,11 +1653,53 @@ public Allocation createPrepaymentAllocation(UUID prepaymentID, Allocation alloc
16541653
String url = uriBuilder.buildFromMap(uriVariables).toString();
16551654

16561655
ApiClient apiClient = new ApiClient();
1657-
strBody = apiClient.getObjectMapper().writeValueAsString(allocation);
1656+
strBody = apiClient.getObjectMapper().writeValueAsString(allocations);
16581657

16591658
String response = this.DATA(url, strBody, params, "PUT");
16601659

1661-
TypeReference<Allocation> typeRef = new TypeReference<Allocation>() {};
1660+
TypeReference<Allocations> typeRef = new TypeReference<Allocations>() {};
1661+
return apiClient.getObjectMapper().readValue(response, typeRef);
1662+
1663+
} catch (IOException e) {
1664+
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
1665+
} catch (XeroApiException e) {
1666+
throw xeroExceptionHandler.handleBadRequest(e.getMessage(), e.getResponseCode(),JSONUtils.isJSONValid(e.getMessage()));
1667+
}
1668+
}
1669+
/**
1670+
* Allows you to retrieve a history records of an Overpayment
1671+
* <p><b>200</b> - A successful request
1672+
* <p><b>400</b> - A failed request due to validation error
1673+
* @param prepaymentID The prepaymentID parameter
1674+
* @param historyRecords The historyRecords parameter
1675+
* @return HistoryRecords
1676+
* @throws IOException if an error occurs while attempting to invoke the API
1677+
**/
1678+
public HistoryRecords createPrepaymentHistory(UUID prepaymentID, HistoryRecords historyRecords) throws IOException {
1679+
try {
1680+
String strBody = null;
1681+
Map<String, String> params = null;
1682+
String correctPath = "/Prepayments/{PrepaymentID}/History";
1683+
// Hacky path manipulation to support different return types from same endpoint
1684+
String path = "/Prepayments/{PrepaymentID}/History";
1685+
String type = "/pdf";
1686+
if(path.toLowerCase().contains(type.toLowerCase()))
1687+
{
1688+
correctPath = path.replace("/pdf","");
1689+
}
1690+
1691+
// create a map of path variables
1692+
final Map<String, String> uriVariables = new HashMap<String, String>();
1693+
uriVariables.put("PrepaymentID", prepaymentID.toString());
1694+
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
1695+
String url = uriBuilder.buildFromMap(uriVariables).toString();
1696+
1697+
ApiClient apiClient = new ApiClient();
1698+
strBody = apiClient.getObjectMapper().writeValueAsString(historyRecords);
1699+
1700+
String response = this.DATA(url, strBody, params, "PUT");
1701+
1702+
TypeReference<HistoryRecords> typeRef = new TypeReference<HistoryRecords>() {};
16621703
return apiClient.getObjectMapper().readValue(response, typeRef);
16631704

16641705
} catch (IOException e) {
@@ -5305,6 +5346,46 @@ public Prepayments getPrepayment(UUID prepaymentID) throws IOException {
53055346
}
53065347
}
53075348
/**
5349+
* Allows you to retrieve a history records of an Prepayment
5350+
* <p><b>200</b> - A successful request
5351+
* @param prepaymentID The prepaymentID parameter
5352+
* @return HistoryRecords
5353+
* @throws IOException if an error occurs while attempting to invoke the API
5354+
**/
5355+
public HistoryRecords getPrepaymentHistory(UUID prepaymentID) throws IOException {
5356+
try {
5357+
String strBody = null;
5358+
Map<String, String> params = null;
5359+
String correctPath = "/Prepayments/{PrepaymentID}/History";
5360+
// Hacky path manipulation to support different return types from same endpoint
5361+
String path = "/Prepayments/{PrepaymentID}/History";
5362+
String type = "/pdf";
5363+
if(path.toLowerCase().contains(type.toLowerCase()))
5364+
{
5365+
correctPath = path.replace("/pdf","");
5366+
}
5367+
5368+
// create a map of path variables
5369+
final Map<String, String> uriVariables = new HashMap<String, String>();
5370+
uriVariables.put("PrepaymentID", prepaymentID.toString());
5371+
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
5372+
String url = uriBuilder.buildFromMap(uriVariables).toString();
5373+
5374+
ApiClient apiClient = new ApiClient();
5375+
5376+
5377+
String response = this.DATA(url, strBody, params, "GET");
5378+
5379+
TypeReference<HistoryRecords> typeRef = new TypeReference<HistoryRecords>() {};
5380+
return apiClient.getObjectMapper().readValue(response, typeRef);
5381+
5382+
} catch (IOException e) {
5383+
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
5384+
} catch (XeroApiException e) {
5385+
throw xeroExceptionHandler.handleBadRequest(e.getMessage(), e.getResponseCode(),JSONUtils.isJSONValid(e.getMessage()));
5386+
}
5387+
}
5388+
/**
53085389
* Allows you to retrieve prepayments
53095390
* <p><b>200</b> - A successful response
53105391
* @param ifModifiedSince Only records created or modified since this timestamp will be returned

0 commit comments

Comments
 (0)