-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0a6fcf
commit d085c5b
Showing
2 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters