-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add domain and noauth base classes (#838)
* added domain and noauth base files
- Loading branch information
Showing
6 changed files
with
122 additions
and
14 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
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.twilio.base.noauth; | ||
|
||
import com.twilio.Twilio; | ||
import com.twilio.TwilioNoAuth; | ||
import com.twilio.http.noauth.NoAuthTwilioRestClient; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Executor for deletes of a resource. | ||
* | ||
* @param <T> type of the resource | ||
*/ | ||
public abstract class Deleter<T extends Resource> { | ||
|
||
/** | ||
* Execute an async request using default client. | ||
* | ||
* @return future that resolves to true if the object was deleted | ||
*/ | ||
public CompletableFuture<Boolean> deleteAsync() { | ||
return deleteAsync(TwilioNoAuth.getRestClient()); | ||
} | ||
|
||
/** | ||
* Execute an async request using specified client. | ||
* | ||
* @param client client used to make request | ||
* @return future that resolves to true if the object was deleted | ||
*/ | ||
public CompletableFuture<Boolean> deleteAsync(final NoAuthTwilioRestClient client) { | ||
return CompletableFuture.supplyAsync(() -> delete(client), Twilio.getExecutorService()); | ||
} | ||
|
||
/** | ||
* Execute a request using default client. | ||
* | ||
* @return true if the object was deleted | ||
*/ | ||
public boolean delete() { | ||
return delete(TwilioNoAuth.getRestClient()); | ||
} | ||
|
||
/** | ||
* Execute a request using specified client. | ||
* | ||
* @param client client used to make request | ||
* @return true if the object was deleted | ||
*/ | ||
public abstract boolean delete(final NoAuthTwilioRestClient client); | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.twilio.base.noauth; | ||
|
||
import com.twilio.Twilio; | ||
import com.twilio.TwilioNoAuth; | ||
import com.twilio.http.noauth.NoAuthTwilioRestClient; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Executor for updates of a resource. | ||
* | ||
* @param <T> type of the resource | ||
*/ | ||
public abstract class Updater<T extends Resource> { | ||
|
||
/** | ||
* Execute an async request using default client. | ||
* | ||
* @return future that resolves to requested object | ||
*/ | ||
public CompletableFuture<T> updateAsync() { | ||
return updateAsync(TwilioNoAuth.getRestClient()); | ||
} | ||
|
||
/** | ||
* Execute an async request using specified client. | ||
* | ||
* @param client client used to make request | ||
* @return future that resolves to requested object | ||
*/ | ||
public CompletableFuture<T> updateAsync(final NoAuthTwilioRestClient client) { | ||
return CompletableFuture.supplyAsync(() -> update(client), Twilio.getExecutorService()); | ||
} | ||
|
||
/** | ||
* Execute a request using default client. | ||
* | ||
* @return Requested object | ||
*/ | ||
public T update() { | ||
return update(TwilioNoAuth.getRestClient()); | ||
} | ||
|
||
/** | ||
* Execute a request using specified client. | ||
* | ||
* @param client client used to make request | ||
* @return Requested object | ||
*/ | ||
public abstract T update(final NoAuthTwilioRestClient client); | ||
} |
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