From 9152fd3d5cc916386dd612e0a3f0b483ba9c924a Mon Sep 17 00:00:00 2001 From: manisha1997 Date: Mon, 5 May 2025 17:10:46 +0530 Subject: [PATCH] chore: Add doc --- .../BearerTokenTwilioRestClient.java | 32 ++++++++++++++++--- .../http/noauth/NoAuthTwilioRestClient.java | 31 +++++++++++++++--- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/twilio/http/bearertoken/BearerTokenTwilioRestClient.java b/src/main/java/com/twilio/http/bearertoken/BearerTokenTwilioRestClient.java index 0562c72534..72a1a5fd7d 100644 --- a/src/main/java/com/twilio/http/bearertoken/BearerTokenTwilioRestClient.java +++ b/src/main/java/com/twilio/http/bearertoken/BearerTokenTwilioRestClient.java @@ -17,8 +17,32 @@ import java.util.function.Predicate; -/* - * Use this BearerToken Rest Client if no authentication is involved in an API. +/** + * The `BearerTokenTwilioRestClient` class is a specialized REST client for interacting with Twilio's API + * using JWT token-based authentication. It handles token management, request retries, and logging. + * + *

Features:

+ * + * + *

Usage:

+ *
+ * BearerTokenTwilioRestClient client = new BearerTokenTwilioRestClient.Builder()
+ *     .region("us1")
+ *     .edge("ashburn")
+ *     .tokenManager(new CustomTokenManager())
+ *     .build();
+ *
+ * BearerTokenRequest request = new BearerTokenRequest("GET", "/path");
+ * Response response = client.request(request);
+ * 
+ * + *

Thread Safety:

+ * This class is thread-safe for concurrent use. */ public class BearerTokenTwilioRestClient { public static final int HTTP_STATUS_CODE_CREATED = 201; @@ -54,7 +78,7 @@ private BearerTokenTwilioRestClient(BearerTokenTwilioRestClient.Builder b) { // generates warnings from the module system on Java 9+ objectMapper.registerModule(new JavaTimeModule()); } - + public static class Builder { private String region; private String edge; @@ -111,7 +135,7 @@ public Response request(BearerTokenRequest request) { } } } - + request.setAuth(accessToken); if (region != null) request.setRegion(region); diff --git a/src/main/java/com/twilio/http/noauth/NoAuthTwilioRestClient.java b/src/main/java/com/twilio/http/noauth/NoAuthTwilioRestClient.java index 84ef657419..77f66f5975 100644 --- a/src/main/java/com/twilio/http/noauth/NoAuthTwilioRestClient.java +++ b/src/main/java/com/twilio/http/noauth/NoAuthTwilioRestClient.java @@ -15,13 +15,36 @@ import java.util.function.Predicate; -/* - * Use this NoAuth Rest Client if no authentication is involved in an API. +/** + * The `NoAuthTwilioRestClient` class is a specialized REST client for interacting with Twilio's API + * when no authentication is required. It provides functionality for making API requests, logging, + * and customizing request parameters such as region, edge, and user-agent extensions. + * + *

Features:

+ * + * + *

Usage:

+ *
+ * NoAuthTwilioRestClient client = new NoAuthTwilioRestClient.Builder()
+ *     .region("us1")
+ *     .edge("ashburn")
+ *     .build();
+ *
+ * NoAuthRequest request = new NoAuthRequest("GET", "/path");
+ * Response response = client.request(request);
+ * 
+ * + *

Thread Safety:

+ * This class is thread-safe for concurrent use as it does not maintain mutable shared state. */ public class NoAuthTwilioRestClient { @Getter private final ObjectMapper objectMapper; - + @Getter private final String region; @Getter @@ -47,7 +70,7 @@ private NoAuthTwilioRestClient(NoAuthTwilioRestClient.Builder b) { // generates warnings from the module system on Java 9+ objectMapper.registerModule(new JavaTimeModule()); } - + public static class Builder { private String region; private String edge;