@@ -93,7 +93,7 @@ public class AccountingApi {
9393 private ApiClient apiClient;
9494 private static AccountingApi instance = null;
9595 private String userAgent = "Default";
96- private String version = "4.0.1 ";
96+ private String version = "4.0.2 ";
9797 final static Logger logger = LoggerFactory.getLogger(AccountingApi.class);
9898
9999 public AccountingApi() {
@@ -6783,6 +6783,68 @@ public HttpResponse getContactAttachmentsForHttpResponse(String accessToken, St
67836783 .setReadTimeout(apiClient.getReadTimeout()).execute();
67846784 }
67856785
6786+ /**
6787+ * Allows you to retrieve a single contact by Contact Number in a Xero organisation
6788+ * <p><b>200</b> - Success - return response of type Contacts array with a unique Contact
6789+ * @param xeroTenantId Xero identifier for Tenant
6790+ * @param contactNumber This field is read only on the Xero contact screen, used to identify contacts in external systems (max length = 50).
6791+ * @param accessToken Authorization token for user set in header of each request
6792+ * @return Contacts
6793+ * @throws IOException if an error occurs while attempting to invoke the API
6794+ **/
6795+ public Contacts getContactByContactNumber(String accessToken, String xeroTenantId, String contactNumber) throws IOException {
6796+ try {
6797+ TypeReference<Contacts> typeRef = new TypeReference<Contacts>() {};
6798+ HttpResponse response = getContactByContactNumberForHttpResponse(accessToken, xeroTenantId, contactNumber);
6799+ return apiClient.getObjectMapper().readValue(response.getContent(), typeRef);
6800+ } catch (HttpResponseException e) {
6801+ if (logger.isDebugEnabled()) {
6802+ logger.debug("------------------ HttpResponseException " + e.getStatusCode() + " : getContactByContactNumber -------------------");
6803+ logger.debug(e.toString());
6804+ }
6805+ XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
6806+ handler.execute(e);
6807+ } catch (IOException ioe) {
6808+ throw ioe;
6809+ }
6810+ return null;
6811+ }
6812+
6813+ public HttpResponse getContactByContactNumberForHttpResponse(String accessToken, String xeroTenantId, String contactNumber) throws IOException {
6814+ // verify the required parameter 'xeroTenantId' is set
6815+ if (xeroTenantId == null) {
6816+ throw new IllegalArgumentException("Missing the required parameter 'xeroTenantId' when calling getContactByContactNumber");
6817+ }// verify the required parameter 'contactNumber' is set
6818+ if (contactNumber == null) {
6819+ throw new IllegalArgumentException("Missing the required parameter 'contactNumber' when calling getContactByContactNumber");
6820+ }
6821+ if (accessToken == null) {
6822+ throw new IllegalArgumentException("Missing the required parameter 'accessToken' when calling getContactByContactNumber");
6823+ }
6824+ HttpHeaders headers = new HttpHeaders();
6825+ headers.set("xero-tenant-id", xeroTenantId);
6826+ headers.setAccept("application/json");
6827+ headers.setUserAgent(this.getUserAgent());
6828+ // create a map of path variables
6829+ final Map<String, Object> uriVariables = new HashMap<String, Object>();
6830+ uriVariables.put("ContactNumber", contactNumber);
6831+
6832+ UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Contacts/{ContactNumber}");
6833+ String url = uriBuilder.buildFromMap(uriVariables).toString();
6834+ GenericUrl genericUrl = new GenericUrl(url);
6835+ if (logger.isDebugEnabled()) {
6836+ logger.debug("GET " + genericUrl.toString());
6837+ }
6838+
6839+ HttpContent content = null;
6840+ Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
6841+ HttpTransport transport = apiClient.getHttpTransport();
6842+ HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
6843+ return requestFactory.buildRequest(HttpMethods.GET, genericUrl, content).setHeaders(headers)
6844+ .setConnectTimeout(apiClient.getConnectionTimeout())
6845+ .setReadTimeout(apiClient.getReadTimeout()).execute();
6846+ }
6847+
67866848 /**
67876849 * Allows you to retrieve CISSettings for a contact in a Xero organisation
67886850 * <p><b>200</b> - Success - return response of type CISSettings for a specific Contact
@@ -10375,70 +10437,6 @@ public HttpResponse getPrepaymentForHttpResponse(String accessToken, String xer
1037510437 .setReadTimeout(apiClient.getReadTimeout()).execute();
1037610438 }
1037710439
10378- /**
10379- * Allows you to retrieve prepayments as PDF files
10380- * <p><b>200</b> - Success - return response of byte array pdf version of specified Prepayments
10381- * @param xeroTenantId Xero identifier for Tenant
10382- * @param prepaymentID Unique identifier for a PrePayment
10383- * @param accessToken Authorization token for user set in header of each request
10384- * @return File
10385- * @throws IOException if an error occurs while attempting to invoke the API
10386- **/
10387- public ByteArrayInputStream getPrepaymentAsPdf(String accessToken, String xeroTenantId, UUID prepaymentID) throws IOException {
10388- try {
10389- TypeReference<File> typeRef = new TypeReference<File>() {};
10390- HttpResponse response = getPrepaymentAsPdfForHttpResponse(accessToken, xeroTenantId, prepaymentID);
10391- InputStream is = response.getContent();
10392- return convertInputToByteArray(is);
10393-
10394- } catch (HttpResponseException e) {
10395- if (logger.isDebugEnabled()) {
10396- logger.debug("------------------ HttpResponseException " + e.getStatusCode() + " : getPrepaymentAsPdf -------------------");
10397- logger.debug(e.toString());
10398- }
10399- XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
10400- handler.execute(e);
10401- } catch (IOException ioe) {
10402- throw ioe;
10403- }
10404- return null;
10405- }
10406-
10407- public HttpResponse getPrepaymentAsPdfForHttpResponse(String accessToken, String xeroTenantId, UUID prepaymentID) throws IOException {
10408- // verify the required parameter 'xeroTenantId' is set
10409- if (xeroTenantId == null) {
10410- throw new IllegalArgumentException("Missing the required parameter 'xeroTenantId' when calling getPrepaymentAsPdf");
10411- }// verify the required parameter 'prepaymentID' is set
10412- if (prepaymentID == null) {
10413- throw new IllegalArgumentException("Missing the required parameter 'prepaymentID' when calling getPrepaymentAsPdf");
10414- }
10415- if (accessToken == null) {
10416- throw new IllegalArgumentException("Missing the required parameter 'accessToken' when calling getPrepaymentAsPdf");
10417- }
10418- HttpHeaders headers = new HttpHeaders();
10419- headers.set("xero-tenant-id", xeroTenantId);
10420- headers.setAccept("application/pdf");
10421- headers.setUserAgent(this.getUserAgent());
10422- // create a map of path variables
10423- final Map<String, Object> uriVariables = new HashMap<String, Object>();
10424- uriVariables.put("PrepaymentID", prepaymentID);
10425-
10426- UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Prepayments/{PrepaymentID}");
10427- String url = uriBuilder.buildFromMap(uriVariables).toString();
10428- GenericUrl genericUrl = new GenericUrl(url);
10429- if (logger.isDebugEnabled()) {
10430- logger.debug("GET " + genericUrl.toString());
10431- }
10432-
10433- HttpContent content = null;
10434- Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
10435- HttpTransport transport = apiClient.getHttpTransport();
10436- HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
10437- return requestFactory.buildRequest(HttpMethods.GET, genericUrl, content).setHeaders(headers)
10438- .setConnectTimeout(apiClient.getConnectionTimeout())
10439- .setReadTimeout(apiClient.getReadTimeout()).execute();
10440- }
10441-
1044210440 /**
1044310441 * Allows you to retrieve a history records of an Prepayment
1044410442 * <p><b>200</b> - Success - return response of HistoryRecords array of 0 to N HistoryRecord
0 commit comments