/** * Voids (cancels) an Order. * * @param apiContext {@link APIContext} used for the API call. * @return Order * @throws PayPalRESTException */ public Order doVoid(APIContext apiContext) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/orders/{0}/do-void"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Order.class); }
/** * Obtain the Order resource for the given identifier. * * @param apiContext {@link APIContext} used for the API call. * @param orderId String * @return Order * @throws PayPalRESTException */ public static Order get(APIContext apiContext, String orderId) throws PayPalRESTException { if (orderId == null) { throw new IllegalArgumentException("orderId cannot be null"); } Object[] parameters = new Object[] {orderId}; String pattern = "v1/payments/orders/{0}"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = ""; return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Order.class); }
/** * Creates (and processes) a new Capture Transaction added as a related resource. * * @param apiContext {@link APIContext} used for the API call. * @param capture Capture * @return Capture * @throws PayPalRESTException */ public Capture capture(APIContext apiContext, Capture capture) throws PayPalRESTException { if (this.getId() == null) { throw new IllegalArgumentException("Id cannot be null"); } if (capture == null) { throw new IllegalArgumentException("capture cannot be null"); } Object[] parameters = new Object[] {this.getId()}; String pattern = "v1/payments/orders/{0}/capture"; String resourcePath = RESTUtil.formatURIPath(pattern, parameters); String payLoad = capture.toJSON(); return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Capture.class); }
/** * Adds the dependent files * * @param store the store * @param uri the URI * @param monitor may be null * @throws CoreException on failure */ public void addDependentFiles(ISemanticFileStore store, String uri, IProgressMonitor monitor) throws CoreException { InputStream is = store.openInputStream(EFS.NONE, monitor); List<String> uris; try { StringBuffer buf = RESTUtil.readStreamIntoStringBuffer(is, "UTF-8"); // $NON-NLS-1$ uris = this.findRelativeURLs(buf); } catch (IOException e) { // $JL-EXC$ ignore throw new CoreException( new Status( IStatus.ERROR, SemanticResourcesPluginExamplesCore.PLUGIN_ID, e.getMessage(), e)); } finally { Util.safeClose(is); } String rootURI = uri.substring(0, uri.lastIndexOf("/")); // $NON-NLS-1$ for (String uriString : uris) { if (uriString.contains(":")) { // $NON-NLS-1$ // this is an absolute URI; ignore continue; } if (uriString.contains("?")) { // $NON-NLS-1$ // this is an invalid file name; ignore continue; } if (uriString.startsWith("/")) { // $NON-NLS-1$ // this is an URI that is not relative to the document; ignore continue; } String[] parts = uriString.split("/"); // $NON-NLS-1$ addDependentFiles((ISemanticFileStore) store.getParent(), rootURI, parts, 0, monitor); } }