diff --git a/src/main/java/com/twilio/base/Patcher.java b/src/main/java/com/twilio/base/Patcher.java new file mode 100644 index 0000000000..e981e7601d --- /dev/null +++ b/src/main/java/com/twilio/base/Patcher.java @@ -0,0 +1,50 @@ +package com.twilio.base; + +import com.twilio.Twilio; +import com.twilio.http.TwilioRestClient; + +import java.util.concurrent.CompletableFuture; + +/** + * Executor for updates of a resource. + * + * @param type of the resource + */ +public abstract class Patcher { + + /** + * Execute an async request using default client. + * + * @return future that resolves to requested object + */ + public CompletableFuture patchAsync() { + return patchAsync(Twilio.getRestClient()); + } + + /** + * Execute an async request using specified client. + * + * @param client client used to make request + * @return future that resolves to requested object + */ + public CompletableFuture patchAsync(final TwilioRestClient client) { + return CompletableFuture.supplyAsync(() -> patch(client), Twilio.getExecutorService()); + } + + /** + * Execute a request using default client. + * + * @return Requested object + */ + public T patch() { + return patch(Twilio.getRestClient()); + } + + /** + * Execute a request using specified client. + * + * @param client client used to make request + * @return Requested object + */ + public abstract T patch(final TwilioRestClient client); +}