Skip to content

Commit

Permalink
Update missing Enums and Prepayment routes
Browse files Browse the repository at this point in the history
Added CountryCode, CurrencyCode and Timezone, PaymentTermType components
Updated 37 string properties with appropriate Enums
Added Allocations and History for Prepayments
  • Loading branch information
SidneyAllen committed Dec 10, 2018
1 parent f395ccf commit a54f87b
Show file tree
Hide file tree
Showing 36 changed files with 2,411 additions and 728 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Add the dependency to your pom.xml. Gradle, sbt and other build tools can be fo
<dependency>
<groupId>com.github.xeroapi</groupId>
<artifactId>xero-java</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
</dependency>


Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.github.xeroapi</groupId>
<artifactId>xero-java</artifactId>
<packaging>jar</packaging>
<version>2.2.0</version>
<version>2.2.1</version>
<name>Xero-Java SDK</name>
<description>This is the official Java SDK for Xero API</description>
<url>https://github.com/XeroAPI/Xero-Java</url>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/xero/api/JsonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public String getAccessTokenUrl() {

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

@Override
Expand Down
93 changes: 87 additions & 6 deletions src/main/java/com/xero/api/client/AccountingApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.xero.models.accounting.Account;
import com.xero.models.accounting.Accounts;
import com.xero.models.accounting.Allocation;
import com.xero.models.accounting.Allocations;
import com.xero.models.accounting.Attachments;
import com.xero.models.accounting.BankTransactions;
Expand Down Expand Up @@ -1630,11 +1629,11 @@ public Prepayments createPrepayment(Prepayments prepayments) throws IOException
* <p><b>200</b> - A successful request
* <p><b>400</b> - A failed request due to validation error
* @param prepaymentID The prepaymentID parameter
* @param allocation The allocation parameter
* @return Allocation
* @param allocations The allocations parameter
* @return Allocations
* @throws IOException if an error occurs while attempting to invoke the API
**/
public Allocation createPrepaymentAllocation(UUID prepaymentID, Allocation allocation) throws IOException {
public Allocations createPrepaymentAllocation(UUID prepaymentID, Allocations allocations) throws IOException {
try {
String strBody = null;
Map<String, String> params = null;
Expand All @@ -1654,11 +1653,53 @@ public Allocation createPrepaymentAllocation(UUID prepaymentID, Allocation alloc
String url = uriBuilder.buildFromMap(uriVariables).toString();

ApiClient apiClient = new ApiClient();
strBody = apiClient.getObjectMapper().writeValueAsString(allocation);
strBody = apiClient.getObjectMapper().writeValueAsString(allocations);

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

TypeReference<Allocation> typeRef = new TypeReference<Allocation>() {};
TypeReference<Allocations> typeRef = new TypeReference<Allocations>() {};
return apiClient.getObjectMapper().readValue(response, typeRef);

} catch (IOException e) {
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
} catch (XeroApiException e) {
throw xeroExceptionHandler.handleBadRequest(e.getMessage(), e.getResponseCode(),JSONUtils.isJSONValid(e.getMessage()));
}
}
/**
* Allows you to retrieve a history records of an Overpayment
* <p><b>200</b> - A successful request
* <p><b>400</b> - A failed request due to validation error
* @param prepaymentID The prepaymentID parameter
* @param historyRecords The historyRecords parameter
* @return HistoryRecords
* @throws IOException if an error occurs while attempting to invoke the API
**/
public HistoryRecords createPrepaymentHistory(UUID prepaymentID, HistoryRecords historyRecords) throws IOException {
try {
String strBody = null;
Map<String, String> params = null;
String correctPath = "/Prepayments/{PrepaymentID}/History";
// Hacky path manipulation to support different return types from same endpoint
String path = "/Prepayments/{PrepaymentID}/History";
String type = "/pdf";
if(path.toLowerCase().contains(type.toLowerCase()))
{
correctPath = path.replace("/pdf","");
}

// create a map of path variables
final Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("PrepaymentID", prepaymentID.toString());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
String url = uriBuilder.buildFromMap(uriVariables).toString();

ApiClient apiClient = new ApiClient();
strBody = apiClient.getObjectMapper().writeValueAsString(historyRecords);

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

TypeReference<HistoryRecords> typeRef = new TypeReference<HistoryRecords>() {};
return apiClient.getObjectMapper().readValue(response, typeRef);

} catch (IOException e) {
Expand Down Expand Up @@ -5305,6 +5346,46 @@ public Prepayments getPrepayment(UUID prepaymentID) throws IOException {
}
}
/**
* Allows you to retrieve a history records of an Prepayment
* <p><b>200</b> - A successful request
* @param prepaymentID The prepaymentID parameter
* @return HistoryRecords
* @throws IOException if an error occurs while attempting to invoke the API
**/
public HistoryRecords getPrepaymentHistory(UUID prepaymentID) throws IOException {
try {
String strBody = null;
Map<String, String> params = null;
String correctPath = "/Prepayments/{PrepaymentID}/History";
// Hacky path manipulation to support different return types from same endpoint
String path = "/Prepayments/{PrepaymentID}/History";
String type = "/pdf";
if(path.toLowerCase().contains(type.toLowerCase()))
{
correctPath = path.replace("/pdf","");
}

// create a map of path variables
final Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("PrepaymentID", prepaymentID.toString());
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
String url = uriBuilder.buildFromMap(uriVariables).toString();

ApiClient apiClient = new ApiClient();


String response = this.DATA(url, strBody, params, "GET");

TypeReference<HistoryRecords> typeRef = new TypeReference<HistoryRecords>() {};
return apiClient.getObjectMapper().readValue(response, typeRef);

} catch (IOException e) {
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
} catch (XeroApiException e) {
throw xeroExceptionHandler.handleBadRequest(e.getMessage(), e.getResponseCode(),JSONUtils.isJSONValid(e.getMessage()));
}
}
/**
* Allows you to retrieve prepayments
* <p><b>200</b> - A successful response
* @param ifModifiedSince Only records created or modified since this timestamp will be returned
Expand Down
Loading

0 comments on commit a54f87b

Please sign in to comment.