Skip to content

Commit e965fc8

Browse files
committed
Add unit tests and update some missing properties and data types
- Removed create prepayment - method performed by banktransactions endpoint - Add attachment array to Manual Journal - Add Edition ENUM to Organisation Overpayment - Change remainingCredit property changed from String to Double - Add attachment array Payment - Change isReconciled property from String to boolean - Add attachment array to Prepayment - Add attachment array to Purchase Order - Add attachments and validationerrors array to Receipt - Add attachment array to Repeating Invoice Unit tests added - CreditNotes - Employees - ExpenseClaims - Invoices - Items - Journals - LinkedTransactions - ManualJournals - Organisation - Overpayments - PaymentServices - Payments - Prepayments - PurchaseOrders - Receipts - RepeatingInvoices - TrackingCategories - Users
1 parent 8f95fcb commit e965fc8

29 files changed

Lines changed: 3940 additions & 841 deletions

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

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,36 +1627,6 @@ public PaymentServices createPaymentService(PaymentServices paymentServices) thr
16271627
}
16281628
}
16291629
/**
1630-
* Allows you to create prepayments
1631-
* <p><b>200</b> - Success - return response of type Prepayments array for newly created Prepayment
1632-
* <p><b>400</b> - A failed request due to validation error
1633-
* @param prepayments The prepayments parameter
1634-
* @return Prepayments
1635-
* @throws IOException if an error occurs while attempting to invoke the API
1636-
**/
1637-
public Prepayments createPrepayment(Prepayments prepayments) throws IOException {
1638-
try {
1639-
String strBody = null;
1640-
Map<String, String> params = null;
1641-
String correctPath = "/Prepayments";
1642-
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
1643-
String url = uriBuilder.build().toString();
1644-
1645-
1646-
strBody = apiClient.getObjectMapper().writeValueAsString(prepayments);
1647-
1648-
String response = this.DATA(url, strBody, params, "PUT");
1649-
1650-
TypeReference<Prepayments> typeRef = new TypeReference<Prepayments>() {};
1651-
return apiClient.getObjectMapper().readValue(response, typeRef);
1652-
1653-
} catch (IOException e) {
1654-
throw xeroExceptionHandler.handleBadRequest(e.getMessage());
1655-
} catch (XeroApiException e) {
1656-
throw xeroExceptionHandler.handleBadRequest(e.getMessage(), e.getResponseCode(),JSONUtils.isJSONValid(e.getMessage()));
1657-
}
1658-
}
1659-
/**
16601630
* Allows you to create an Allocation for prepayments
16611631
* <p><b>200</b> - Success - return response of type Allocations array of Allocation for all Prepayment
16621632
* <p><b>400</b> - A failed request due to validation error
@@ -1891,8 +1861,8 @@ public Attachments createReceiptAttachmentByFileName(UUID receiptID, String file
18911861
}
18921862
/**
18931863
* Allows you to retrieve a history records of an Receipt
1894-
* <p><b>200</b> - Success - return response of type HistoryRecords array for newly created HistoryRecord for Receipt
1895-
* <p><b>400</b> - A failed request due to validation error
1864+
* <p><b>200</b> - Unsupported - return response incorrect exception, API is not able to create HistoryRecord for Receipts
1865+
* <p><b>400</b> - Unsupported - return response incorrect exception, API is not able to create HistoryRecord for Receipts
18961866
* @param receiptID Unique identifier for a Receipt
18971867
* @param historyRecords The historyRecords parameter
18981868
* @return HistoryRecords

src/main/java/com/xero/models/accounting/ManualJournal.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.fasterxml.jackson.annotation.JsonProperty;
1919
import com.fasterxml.jackson.annotation.JsonCreator;
2020
import com.fasterxml.jackson.annotation.JsonValue;
21+
import com.xero.models.accounting.Attachment;
2122
import com.xero.models.accounting.LineAmountTypes;
2223
import com.xero.models.accounting.ManualJournalLine;
2324
import com.xero.models.accounting.ValidationError;
@@ -123,6 +124,10 @@ public static StatusEnum fromValue(String text) {
123124
@JsonProperty("ValidationErrors")
124125
private List<ValidationError> validationErrors = null;
125126

127+
128+
@JsonProperty("Attachments")
129+
private List<Attachment> attachments = null;
130+
126131
public ManualJournal narration(String narration) {
127132
this.narration = narration;
128133
return this;
@@ -342,6 +347,32 @@ public void setValidationErrors(List<ValidationError> validationErrors) {
342347
this.validationErrors = validationErrors;
343348
}
344349

350+
public ManualJournal attachments(List<Attachment> attachments) {
351+
this.attachments = attachments;
352+
return this;
353+
}
354+
355+
public ManualJournal addAttachmentsItem(Attachment attachmentsItem) {
356+
if (this.attachments == null) {
357+
this.attachments = new ArrayList<Attachment>();
358+
}
359+
this.attachments.add(attachmentsItem);
360+
return this;
361+
}
362+
363+
/**
364+
* Displays array of attachments from the API
365+
* @return attachments
366+
**/
367+
@ApiModelProperty(value = "Displays array of attachments from the API")
368+
public List<Attachment> getAttachments() {
369+
return attachments;
370+
}
371+
372+
public void setAttachments(List<Attachment> attachments) {
373+
this.attachments = attachments;
374+
}
375+
345376

346377
@Override
347378
public boolean equals(java.lang.Object o) {
@@ -363,12 +394,13 @@ public boolean equals(java.lang.Object o) {
363394
Objects.equals(this.updatedDateUTC, manualJournal.updatedDateUTC) &&
364395
Objects.equals(this.manualJournalID, manualJournal.manualJournalID) &&
365396
Objects.equals(this.warnings, manualJournal.warnings) &&
366-
Objects.equals(this.validationErrors, manualJournal.validationErrors);
397+
Objects.equals(this.validationErrors, manualJournal.validationErrors) &&
398+
Objects.equals(this.attachments, manualJournal.attachments);
367399
}
368400

369401
@Override
370402
public int hashCode() {
371-
return Objects.hash(narration, journalLines, date, lineAmountTypes, status, url, showOnCashBasisReports, hasAttachments, updatedDateUTC, manualJournalID, warnings, validationErrors);
403+
return Objects.hash(narration, journalLines, date, lineAmountTypes, status, url, showOnCashBasisReports, hasAttachments, updatedDateUTC, manualJournalID, warnings, validationErrors, attachments);
372404
}
373405

374406

@@ -389,6 +421,7 @@ public String toString() {
389421
sb.append(" manualJournalID: ").append(toIndentedString(manualJournalID)).append("\n");
390422
sb.append(" warnings: ").append(toIndentedString(warnings)).append("\n");
391423
sb.append(" validationErrors: ").append(toIndentedString(validationErrors)).append("\n");
424+
sb.append(" attachments: ").append(toIndentedString(attachments)).append("\n");
392425
sb.append("}");
393426
return sb.toString();
394427
}

src/main/java/com/xero/models/accounting/Organisation.java

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,45 @@ public static PropertyClassEnum fromValue(String text) {
448448
@JsonProperty("Class")
449449
private PropertyClassEnum propertyClass;
450450

451+
/**
452+
* BUSINESS or PARTNER. Partner edition organisations are sold exclusively through accounting partners and have restricted functionality (e.g. no access to invoicing)
453+
*/
454+
public enum EditionEnum {
455+
BUSINESS("BUSINESS"),
456+
457+
PARTNER("PARTNER");
458+
459+
private String value;
460+
461+
EditionEnum(String value) {
462+
this.value = value;
463+
}
464+
465+
@JsonValue
466+
public String getValue() {
467+
return value;
468+
}
469+
470+
@Override
471+
public String toString() {
472+
return String.valueOf(value);
473+
}
474+
475+
@JsonCreator
476+
public static EditionEnum fromValue(String text) {
477+
for (EditionEnum b : EditionEnum.values()) {
478+
if (String.valueOf(b.value).equals(text)) {
479+
return b;
480+
}
481+
}
482+
throw new IllegalArgumentException("Unexpected value '" + text + "'");
483+
}
484+
}
485+
486+
487+
@JsonProperty("Edition")
488+
private EditionEnum edition;
489+
451490

452491
@JsonProperty("LineOfBusiness")
453492
private String lineOfBusiness;
@@ -936,6 +975,24 @@ public void setPropertyClass(PropertyClassEnum propertyClass) {
936975
this.propertyClass = propertyClass;
937976
}
938977

978+
public Organisation edition(EditionEnum edition) {
979+
this.edition = edition;
980+
return this;
981+
}
982+
983+
/**
984+
* BUSINESS or PARTNER. Partner edition organisations are sold exclusively through accounting partners and have restricted functionality (e.g. no access to invoicing)
985+
* @return edition
986+
**/
987+
@ApiModelProperty(value = "BUSINESS or PARTNER. Partner edition organisations are sold exclusively through accounting partners and have restricted functionality (e.g. no access to invoicing)")
988+
public EditionEnum getEdition() {
989+
return edition;
990+
}
991+
992+
public void setEdition(EditionEnum edition) {
993+
this.edition = edition;
994+
}
995+
939996
public Organisation lineOfBusiness(String lineOfBusiness) {
940997
this.lineOfBusiness = lineOfBusiness;
941998
return this;
@@ -1086,6 +1143,7 @@ public boolean equals(java.lang.Object o) {
10861143
Objects.equals(this.organisationEntityType, organisation.organisationEntityType) &&
10871144
Objects.equals(this.shortCode, organisation.shortCode) &&
10881145
Objects.equals(this.propertyClass, organisation.propertyClass) &&
1146+
Objects.equals(this.edition, organisation.edition) &&
10891147
Objects.equals(this.lineOfBusiness, organisation.lineOfBusiness) &&
10901148
Objects.equals(this.addresses, organisation.addresses) &&
10911149
Objects.equals(this.phones, organisation.phones) &&
@@ -1095,7 +1153,7 @@ public boolean equals(java.lang.Object o) {
10951153

10961154
@Override
10971155
public int hashCode() {
1098-
return Objects.hash(organisationID, apIKey, name, legalName, paysTax, version, organisationType, baseCurrency, countryCode, isDemoCompany, organisationStatus, registrationNumber, taxNumber, financialYearEndDay, financialYearEndMonth, salesTaxBasis, salesTaxPeriod, defaultSalesTax, defaultPurchasesTax, periodLockDate, endOfYearLockDate, createdDateUTC, timezone, organisationEntityType, shortCode, propertyClass, lineOfBusiness, addresses, phones, externalLinks, paymentTerms);
1156+
return Objects.hash(organisationID, apIKey, name, legalName, paysTax, version, organisationType, baseCurrency, countryCode, isDemoCompany, organisationStatus, registrationNumber, taxNumber, financialYearEndDay, financialYearEndMonth, salesTaxBasis, salesTaxPeriod, defaultSalesTax, defaultPurchasesTax, periodLockDate, endOfYearLockDate, createdDateUTC, timezone, organisationEntityType, shortCode, propertyClass, edition, lineOfBusiness, addresses, phones, externalLinks, paymentTerms);
10991157
}
11001158

11011159

@@ -1130,6 +1188,7 @@ public String toString() {
11301188
sb.append(" organisationEntityType: ").append(toIndentedString(organisationEntityType)).append("\n");
11311189
sb.append(" shortCode: ").append(toIndentedString(shortCode)).append("\n");
11321190
sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n");
1191+
sb.append(" edition: ").append(toIndentedString(edition)).append("\n");
11331192
sb.append(" lineOfBusiness: ").append(toIndentedString(lineOfBusiness)).append("\n");
11341193
sb.append(" addresses: ").append(toIndentedString(addresses)).append("\n");
11351194
sb.append(" phones: ").append(toIndentedString(phones)).append("\n");

src/main/java/com/xero/models/accounting/Overpayment.java

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.fasterxml.jackson.annotation.JsonCreator;
2020
import com.fasterxml.jackson.annotation.JsonValue;
2121
import com.xero.models.accounting.Allocation;
22+
import com.xero.models.accounting.Attachment;
2223
import com.xero.models.accounting.Contact;
2324
import com.xero.models.accounting.CurrencyCode;
2425
import com.xero.models.accounting.LineAmountTypes;
@@ -165,7 +166,7 @@ public static StatusEnum fromValue(String text) {
165166

166167

167168
@JsonProperty("RemainingCredit")
168-
private String remainingCredit;
169+
private Double remainingCredit;
169170

170171

171172
@JsonProperty("Allocations")
@@ -179,6 +180,10 @@ public static StatusEnum fromValue(String text) {
179180
@JsonProperty("HasAttachments")
180181
private Boolean hasAttachments;
181182

183+
184+
@JsonProperty("Attachments")
185+
private List<Attachment> attachments = null;
186+
182187
public Overpayment type(TypeEnum type) {
183188
this.type = type;
184189
return this;
@@ -421,7 +426,7 @@ public void setCurrencyRate(Double currencyRate) {
421426
this.currencyRate = currencyRate;
422427
}
423428

424-
public Overpayment remainingCredit(String remainingCredit) {
429+
public Overpayment remainingCredit(Double remainingCredit) {
425430
this.remainingCredit = remainingCredit;
426431
return this;
427432
}
@@ -431,11 +436,11 @@ public Overpayment remainingCredit(String remainingCredit) {
431436
* @return remainingCredit
432437
**/
433438
@ApiModelProperty(value = "The remaining credit balance on the overpayment")
434-
public String getRemainingCredit() {
439+
public Double getRemainingCredit() {
435440
return remainingCredit;
436441
}
437442

438-
public void setRemainingCredit(String remainingCredit) {
443+
public void setRemainingCredit(Double remainingCredit) {
439444
this.remainingCredit = remainingCredit;
440445
}
441446

@@ -509,6 +514,32 @@ public void setHasAttachments(Boolean hasAttachments) {
509514
this.hasAttachments = hasAttachments;
510515
}
511516

517+
public Overpayment attachments(List<Attachment> attachments) {
518+
this.attachments = attachments;
519+
return this;
520+
}
521+
522+
public Overpayment addAttachmentsItem(Attachment attachmentsItem) {
523+
if (this.attachments == null) {
524+
this.attachments = new ArrayList<Attachment>();
525+
}
526+
this.attachments.add(attachmentsItem);
527+
return this;
528+
}
529+
530+
/**
531+
* See Attachments
532+
* @return attachments
533+
**/
534+
@ApiModelProperty(value = "See Attachments")
535+
public List<Attachment> getAttachments() {
536+
return attachments;
537+
}
538+
539+
public void setAttachments(List<Attachment> attachments) {
540+
this.attachments = attachments;
541+
}
542+
512543

513544
@Override
514545
public boolean equals(java.lang.Object o) {
@@ -535,12 +566,13 @@ public boolean equals(java.lang.Object o) {
535566
Objects.equals(this.remainingCredit, overpayment.remainingCredit) &&
536567
Objects.equals(this.allocations, overpayment.allocations) &&
537568
Objects.equals(this.payments, overpayment.payments) &&
538-
Objects.equals(this.hasAttachments, overpayment.hasAttachments);
569+
Objects.equals(this.hasAttachments, overpayment.hasAttachments) &&
570+
Objects.equals(this.attachments, overpayment.attachments);
539571
}
540572

541573
@Override
542574
public int hashCode() {
543-
return Objects.hash(type, contact, date, status, lineAmountTypes, lineItems, subTotal, totalTax, total, updatedDateUTC, currencyCode, overpaymentID, currencyRate, remainingCredit, allocations, payments, hasAttachments);
575+
return Objects.hash(type, contact, date, status, lineAmountTypes, lineItems, subTotal, totalTax, total, updatedDateUTC, currencyCode, overpaymentID, currencyRate, remainingCredit, allocations, payments, hasAttachments, attachments);
544576
}
545577

546578

@@ -566,6 +598,7 @@ public String toString() {
566598
sb.append(" allocations: ").append(toIndentedString(allocations)).append("\n");
567599
sb.append(" payments: ").append(toIndentedString(payments)).append("\n");
568600
sb.append(" hasAttachments: ").append(toIndentedString(hasAttachments)).append("\n");
601+
sb.append(" attachments: ").append(toIndentedString(attachments)).append("\n");
569602
sb.append("}");
570603
return sb.toString();
571604
}

src/main/java/com/xero/models/accounting/Payment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public class Payment {
8989

9090

9191
@JsonProperty("IsReconciled")
92-
private String isReconciled;
92+
private Boolean isReconciled;
9393

9494
/**
9595
* The status of the payment.
@@ -429,7 +429,7 @@ public void setReference(String reference) {
429429
this.reference = reference;
430430
}
431431

432-
public Payment isReconciled(String isReconciled) {
432+
public Payment isReconciled(Boolean isReconciled) {
433433
this.isReconciled = isReconciled;
434434
return this;
435435
}
@@ -439,11 +439,11 @@ public Payment isReconciled(String isReconciled) {
439439
* @return isReconciled
440440
**/
441441
@ApiModelProperty(value = "An optional parameter for the payment. A boolean indicating whether you would like the payment to be created as reconciled when using PUT, or whether a payment has been reconciled when using GET")
442-
public String getIsReconciled() {
442+
public Boolean getIsReconciled() {
443443
return isReconciled;
444444
}
445445

446-
public void setIsReconciled(String isReconciled) {
446+
public void setIsReconciled(Boolean isReconciled) {
447447
this.isReconciled = isReconciled;
448448
}
449449

0 commit comments

Comments
 (0)