@@ -91,7 +91,7 @@ public class AccountingApi {
9191 private ApiClient apiClient;
9292 private static AccountingApi instance = null;
9393 private String userAgent = "Default";
94- private String version = "3.5.1 ";
94+ private String version = "3.5.2 ";
9595
9696 public AccountingApi() {
9797 this(new ApiClient());
@@ -9699,6 +9699,74 @@ public HttpResponse getPurchaseOrderForHttpResponse(String accessToken, String
96999699 GenericUrl genericUrl = new GenericUrl(url);
97009700
97019701
9702+ HttpContent content = null;
9703+ Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
9704+ HttpTransport transport = apiClient.getHttpTransport();
9705+ HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
9706+ return requestFactory.buildRequest(HttpMethods.GET, genericUrl, content).setHeaders(headers)
9707+ .setConnectTimeout(apiClient.getConnectionTimeout())
9708+ .setReadTimeout(apiClient.getReadTimeout()).execute();
9709+ }
9710+
9711+ /**
9712+ * Allows you to retrieve purchase orders as PDF files
9713+ * <p><b>200</b> - Success - return response of byte array pdf version of specified Purchase Orders
9714+ * @param xeroTenantId Xero identifier for Tenant
9715+ * @param purchaseOrderID Unique identifier for an Purchase Order
9716+ * @param accessToken Authorization token for user set in header of each request
9717+ * @return File
9718+ * @throws IOException if an error occurs while attempting to invoke the API
9719+ **/
9720+ public ByteArrayInputStream getPurchaseOrderAsPdf(String accessToken, String xeroTenantId, UUID purchaseOrderID) throws IOException {
9721+ try {
9722+ TypeReference<File> typeRef = new TypeReference<File>() {};
9723+ HttpResponse response = getPurchaseOrderAsPdfForHttpResponse(accessToken, xeroTenantId, purchaseOrderID);
9724+ InputStream is = response.getContent();
9725+ return convertInputToByteArray(is);
9726+
9727+ } catch (HttpResponseException e) {
9728+ XeroApiExceptionHandler handler = new XeroApiExceptionHandler();
9729+ handler.execute(e,apiClient);
9730+ } catch (IOException ioe) {
9731+ throw ioe;
9732+ }
9733+ return null;
9734+ }
9735+
9736+ public HttpResponse getPurchaseOrderAsPdfForHttpResponse(String accessToken, String xeroTenantId, UUID purchaseOrderID) throws IOException {
9737+ // verify the required parameter 'xeroTenantId' is set
9738+ if (xeroTenantId == null) {
9739+ throw new IllegalArgumentException("Missing the required parameter 'xeroTenantId' when calling getPurchaseOrderAsPdf");
9740+ }// verify the required parameter 'purchaseOrderID' is set
9741+ if (purchaseOrderID == null) {
9742+ throw new IllegalArgumentException("Missing the required parameter 'purchaseOrderID' when calling getPurchaseOrderAsPdf");
9743+ }
9744+ if (accessToken == null) {
9745+ throw new IllegalArgumentException("Missing the required parameter 'accessToken' when calling getPurchaseOrderAsPdf");
9746+ }
9747+ HttpHeaders headers = new HttpHeaders();
9748+ headers.set("xero-tenant-id", xeroTenantId);
9749+ headers.setAccept("application/json");
9750+ headers.setUserAgent(this.getUserAgent());
9751+
9752+ String correctPath = "/PurchaseOrders/{PurchaseOrderID}/pdf";
9753+
9754+ // Hacky path manipulation to support different return types from same endpoint
9755+ String path = "/PurchaseOrders/{PurchaseOrderID}/pdf";
9756+ String type = "/pdf";
9757+ if(path.toLowerCase().contains(type.toLowerCase())) {
9758+ correctPath = path.replace("/pdf","");
9759+ headers.setAccept("application/pdf");
9760+ }
9761+ // create a map of path variables
9762+ final Map<String, Object> uriVariables = new HashMap<String, Object>();
9763+ uriVariables.put("PurchaseOrderID", purchaseOrderID);
9764+
9765+ UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + correctPath);
9766+ String url = uriBuilder.buildFromMap(uriVariables).toString();
9767+ GenericUrl genericUrl = new GenericUrl(url);
9768+
9769+
97029770 HttpContent content = null;
97039771 Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken);
97049772 HttpTransport transport = apiClient.getHttpTransport();
0 commit comments