1717import com .signnow .core .provider .ApiServiceProvider ;
1818import com .signnow .core .token .BearerToken ;
1919
20+ /**
21+ * Main class for the signNow SDK.
22+ */
2023public class Sdk {
2124
2225 private static final String API_VERSION = "2024-08-30" ;
@@ -25,13 +28,23 @@ public class Sdk {
2528 private static final String EMPTY_CODE = "" ;
2629 private static final String GRANT_TYPE_BY_PASSWORD = "password" ;
2730
28- /** signNow SDK Service Provider * */
31+ /**
32+ * signNow SDK Service Provider
33+ */
2934 private final ApiServiceProvider apiServiceProvider ;
3035
36+ /**
37+ * Default constructor that initializes the ApiServiceProvider with the default configuration.
38+ */
3139 public Sdk () {
3240 this .apiServiceProvider = new ApiServiceProvider (DEFAULT_CONFIG );
3341 }
3442
43+ /**
44+ * Constructor that initializes the ApiServiceProvider with the provided configuration path.
45+ *
46+ * @param configPath the path to the configuration file
47+ */
3548 public Sdk (String configPath ) {
3649 if (configPath == null || configPath .isEmpty ()) {
3750 configPath = DEFAULT_CONFIG ;
@@ -40,18 +53,36 @@ public Sdk(String configPath) {
4053 this .apiServiceProvider = new ApiServiceProvider (configPath );
4154 }
4255
56+ /**
57+ * Builds the SDK by registering the services.
58+ *
59+ * @return the built SDK
60+ * @throws SignNowApiException if an error occurs during the registration of services
61+ */
4362 public Sdk build () throws SignNowApiException {
4463 this .apiServiceProvider .register ();
4564 return this ;
4665 }
4766
67+ /**
68+ * Retrieves the ApiClient from the services.
69+ *
70+ * @return the ApiClient
71+ * @throws SignNowApiException if an error occurs during the retrieval of the ApiClient
72+ */
4873 public ApiClient getApiClient () throws SignNowApiException {
4974 if (this .apiServiceProvider .services ().isEmpty ()) {
5075 this .build ();
5176 }
5277 return (ApiClient ) this .apiServiceProvider .services ().get ("client" );
5378 }
5479
80+ /**
81+ * Authenticates the SDK by sending a TokenPostRequest and setting the BearerToken.
82+ *
83+ * @return the authenticated SDK
84+ * @throws SignNowApiException if an error occurs during the authentication
85+ */
5586 public Sdk authenticate () throws SignNowApiException {
5687 ConfigRepository config = (ConfigRepository ) this .apiServiceProvider .services ().get ("config" );
5788 ApiClient client = (ApiClient ) this .apiServiceProvider .services ().get ("client" );
@@ -70,17 +101,34 @@ public Sdk authenticate() throws SignNowApiException {
70101 return this ;
71102 }
72103
104+ /**
105+ * Sets the BearerToken for the ApiClient.
106+ *
107+ * @param bearerToken the BearerToken to be set
108+ * @return the SDK with the set BearerToken
109+ */
73110 public Sdk withBearerToken (BearerToken bearerToken ) {
74111 ApiClient client = (ApiClient ) this .apiServiceProvider .services ().get ("client" );
75112 client .setBearerToken (bearerToken );
76113 this .apiServiceProvider .services ().set ("client" , client );
77114 return this ;
78115 }
79116
117+ /**
118+ * Retrieves the actual BearerToken of the ApiClient.
119+ *
120+ * @return the actual BearerToken
121+ * @throws SignNowApiException if an error occurs during the retrieval of the BearerToken
122+ */
80123 public BearerToken getActualBearerToken () throws SignNowApiException {
81124 return this .getApiClient ().getBearerToken ();
82125 }
83126
127+ /**
128+ * Retrieves the version of the API.
129+ *
130+ * @return the version of the API
131+ */
84132 public String version () {
85133 return API_VERSION ;
86134 }
0 commit comments