11package com .contentstack .cms .stack ;
22
3+ import com .contentstack .cms .BaseImplementation ;
34import okhttp3 .ResponseBody ;
45import org .jetbrains .annotations .NotNull ;
56import org .json .simple .JSONObject ;
1819 * @author ***REMOVED***
1920 * @version v0.1.0
2021 * @see <a href=
21- * "https://www.contentstack.com/docs/developers/apis/content-management-api/#aliases">About
22- * Aliases
23- * </a>
22+ * "https://www.contentstack.com/docs/developers/apis/content-management-api/#aliases">About
23+ * Aliases
24+ * </a>
2425 * @since 2022-10-20
2526 */
26- public class Alias {
27+ public class Alias implements BaseImplementation < Alias > {
2728
2829 protected final Map <String , Object > headers ;
2930 protected Map <String , Object > params ;
@@ -57,36 +58,70 @@ protected Alias(Retrofit instance, String aliasUid) {
5758
5859 /**
5960 * The addHeader function adds a key-value pair to the headers map.
60- *
61+ *
6162 * @param key A string representing the key of the header. This is used to
6263 * identify the header when
6364 * retrieving or modifying it.
6465 * @param value The value parameter is of type Object, which means it can accept
6566 * any type of object as
6667 * its value.
68+ * @return instance of the `Alias` class
6769 */
68- public void addHeader (@ NotNull String key , @ NotNull Object value ) {
70+ @ Override
71+ public Alias addHeader (@ NotNull String key , @ NotNull String value ) {
6972 this .headers .put (key , value );
73+ return this ;
7074 }
7175
7276 /**
7377 * The addParam function adds a key-value pair to a map.
74- *
78+ *
7579 * @param key A string representing the key for the parameter. It is annotated
7680 * with @NotNull,
7781 * indicating that it cannot be null.
7882 * @param value The value parameter is of type Object, which means it can accept
7983 * any type of object as
8084 * its value.
8185 */
82- public void addParam (@ NotNull String key , @ NotNull Object value ) {
86+ @ Override
87+ public Alias addParam (@ NotNull String key , @ NotNull Object value ) {
8388 this .params .put (key , value );
89+ return this ;
90+ }
91+
92+ /**
93+ * The addParam function adds a key-value pair to Alias
94+ *
95+ * @param params The "params" parameter is a HashMap that maps String keys to
96+ * Object values. It is
97+ * annotated with @NotNull, indicating that it cannot be null.
98+ * @return instance of {@link Alias}
99+ */
100+ @ Override
101+ public Alias addParams (@ NotNull HashMap <String , Object > params ) {
102+ this .params .putAll (params );
103+ return this ;
104+ }
105+
106+ /**
107+ * The removeParam function removes a key-value pair from
108+ *
109+ * @param headers A HashMap containing key-value pairs of headers, where the key
110+ * is a String
111+ * representing the header name and the value is a String
112+ * representing the header value.
113+ * @return instance of Alias
114+ */
115+ @ Override
116+ public Alias addHeaders (@ NotNull HashMap <String , String > headers ) {
117+ this .headers .putAll (headers );
118+ return this ;
84119 }
85120
86121 /**
87122 * The removeParam function removes a parameter from a map using the specified
88123 * key.
89- *
124+ *
90125 * @param key The parameter "key" is of type String and is used to specify the
91126 * key of the parameter
92127 * that needs to be removed from the "params" collection.
@@ -107,9 +142,9 @@ protected void clearParams() {
107142 * @return Call
108143 * @author ***REMOVED***
109144 * @see <a href=
110- * "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-all-aliases">Get
111- * all
112- * aliases</a>
145+ * "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-all-aliases">Get
146+ * all
147+ * aliases</a>
113148 * @since 2022-10-20
114149 */
115150 public Call <ResponseBody > find () {
@@ -122,12 +157,12 @@ public Call<ResponseBody> find() {
122157 * @return Call
123158 * @author ***REMOVED***
124159 * @see <a href=
125- * "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-a-single-branch">
126- * Get a single branch</a>
160+ * "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-a-single-branch">
161+ * Get a single branch</a>
127162 * @since 2022-10-20
128163 */
129164 public Call <ResponseBody > fetch () {
130- Objects .requireNonNull (this .uid ,"Global Field Uid can not be null or empty" );
165+ Objects .requireNonNull (this .uid , "Global Field Uid can not be null or empty" );
131166 return this .service .single (this .headers , this .uid );
132167 }
133168
@@ -142,15 +177,14 @@ public Call<ResponseBody> fetch() {
142177 * “Body” section, you need to provide
143178 * the UID of the new target branch that will be associated with the alias.
144179 *
145- * @param body
146- * the request body
180+ * @param body the request body
147181 * @return Call
148182 * @author ***REMOVED***
149183 * @see <a href=
150- * "https://www.contentstack.com/docs/developers/apis/content-management-api/#assign-or-update-an-alias">Update
151- * a
152- * branch</a>
153- * @see #addHeader(String, Object ) to add headers
184+ * "https://www.contentstack.com/docs/developers/apis/content-management-api/#assign-or-update-an-alias">Update
185+ * a
186+ * branch</a>
187+ * @see #addHeader(String, String ) to add headers
154188 * @since 2022-10-20
155189 */
156190 public Call <ResponseBody > update (@ NotNull JSONObject body ) {
@@ -169,14 +203,14 @@ public Call<ResponseBody> update(@NotNull JSONObject body) {
169203 * @return Call
170204 * @author ***REMOVED***
171205 * @see <a href=
172- * "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-an-alias">Delete
173- * a branch</a>
174- * @see #addHeader(String, Object ) to add headers
206+ * "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-an-alias">Delete
207+ * a branch</a>
208+ * @see #addHeader(String, String ) to add headers
175209 * @see #addParam(String, Object) to add query params
176210 * @since 2022-10-20
177211 */
178212 public Call <ResponseBody > delete () {
179- Objects .requireNonNull (this .uid ,"Global Field Uid can not be null or empty" );
213+ Objects .requireNonNull (this .uid , "Global Field Uid can not be null or empty" );
180214 return this .service .delete (this .headers , this .uid , this .params );
181215 }
182216
0 commit comments