Skip to content

Commit

Permalink
Added getInvoice() method
Browse files Browse the repository at this point in the history
  • Loading branch information
benedwards44 committed Aug 10, 2016
1 parent a0a6fcf commit d085c5b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
27 changes: 27 additions & 0 deletions src/classes/XeroAccountingApi.cls
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,33 @@ public with sharing class XeroAccountingApi {
return xeroInvoices;
}

/**
* @author Ben Edwards ([email protected])
* @description Method to return a single invoice for your Xero environment for a given Xero Invoice
* @return Single Xero Invoice
**/
public static XeroInvoice getInvoice (String invoiceId) {

XeroInvoice xeroInvoice = new XeroInvoice();

// Execute the callout to the Invoice resource
HttpResponse response = XeroCalloutUtility.executeCallout('GET', 'Invoices/' + invoiceId, null);

// If successful response
if (response.getStatusCode() == 200) {

// Use the parser to convert the response into Xero objects
xeroInvoice = XeroCalloutResponseParser.parseInvoices(response.getBody())[0];
}
else {

// Raise error
throw new XeroAccountingApiException(response.getStatusCode() + ': ' + response.getBody());
}

return xeroInvoice;
}

/**
* @author Ben Edwards ([email protected])
* @description Method to return all invoices for a given Contact Id
Expand Down
9 changes: 5 additions & 4 deletions src/classes/XeroInvoice.cls
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ public class XeroInvoice {
class cls_ContactPersons {
}
class LineItem {
public String ItemCode;
public String Description; //Consulting services as agreed
public Integer UnitAmount; //120
public Decimal UnitAmount; //120
public String TaxType; //NONE
public Integer TaxAmount; //0
public Integer LineAmount; //600
public Decimal TaxAmount; //0
public Decimal LineAmount; //600
public String AccountCode; //200
public cls_Tracking[] Tracking;
public Integer Quantity; //5
public Decimal Quantity; //5
public String LineItemID; //0d129d0d-4b3a-4567-afc5-0453f3457175
public cls_ValidationErrors[] ValidationErrors;
}
Expand Down

0 comments on commit d085c5b

Please sign in to comment.