Skip to content

Commit 85f7a18

Browse files
docs info description
1 parent 45ce040 commit 85f7a18

30 files changed

+514
-292
lines changed

src/main/java/com/contentstack/cms/core/CMSRuntimeException.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* @version 1.0.0
88
* @since 2022-05-19
99
*/
10-
public class CMSRuntimeException extends Exception {
11-
public CMSRuntimeException(String message) {
10+
public class CMSRuntimeException extends Exception { public CMSRuntimeException(String message) {
1211
super(message);
13-
}
14-
}
12+
}}

src/main/java/com/contentstack/cms/core/ContentstackResponse.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class ContentstackResponse<T> {
1919

2020
Call<ResponseBody> response;
2121

22-
2322
public Response<ResponseBody> fetch(Call<ResponseBody> response) {
2423
try {
2524
return response.execute();

src/main/java/com/contentstack/cms/core/ObjectModel.java

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/main/java/com/contentstack/cms/core/Util.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
/**
11-
* The Utility class that contains utility common functions
11+
* The utility class that contains utility common functions
1212
*
1313
* @author ***REMOVED***
1414
* @version 1.0.0
@@ -80,8 +80,7 @@ public static void assertionError() {
8080
}
8181

8282
public static RequestBody toRequestBody(String bodyString) {
83-
return RequestBody.create(MediaType.parse("application/json; charset=UTF-8"),
84-
bodyString);
83+
return RequestBody.create(MediaType.parse("application/json; charset=UTF-8"), bodyString);
8584
}
8685

8786
}

src/main/java/com/contentstack/cms/stack/Environment.java

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.contentstack.cms.stack;
22

3+
import com.contentstack.cms.core.Util;
34
import okhttp3.ResponseBody;
45
import org.jetbrains.annotations.NotNull;
56
import org.json.simple.JSONObject;
@@ -26,7 +27,7 @@ public class Environment {
2627
protected Environment(Retrofit instance, @NotNull Map<String, Object> stackHeaders) {
2728
this.headers = new HashMap<>();
2829
this.params = new HashMap<>();
29-
this.headers.put("Content-Type", "application/json");
30+
this.headers.put(Util.CONTENT_TYPE, Util.CONTENT_TYPE_VALUE);
3031
this.headers.putAll(stackHeaders);
3132
this.service = instance.create(EnvironmentService.class);
3233
}
@@ -90,6 +91,13 @@ protected void clearParams() {
9091
* </pre>
9192
*
9293
* @return Call
94+
* @see <a
95+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#environment-collection">Get all
96+
* environments
97+
* </a>
98+
* @see #addHeader(String, Object) to add headers
99+
* @see #addParam(String, Object) to add query parameters
100+
* @since 1.0.0
93101
*/
94102
public Call<ResponseBody> fetch() {
95103
return this.service.fetch(this.headers, this.params);
@@ -103,10 +111,17 @@ public Call<ResponseBody> fetch() {
103111
* logging into your account.
104112
*
105113
* @param environment
106-
* name of the environment
114+
* The name of the environment
107115
* @return Call
116+
* @see <a
117+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#get-a-single-environment">Get a
118+
* single environments
119+
* </a>
120+
* @see #addHeader(String, Object) to add headers
121+
* @see #addParam(String, Object) to add query parameters
122+
* @since 1.0.0
108123
*/
109-
public Call<ResponseBody> get(@NotNull String environment) {
124+
public Call<ResponseBody> single(@NotNull String environment) {
110125
return this.service.getEnv(this.headers, environment);
111126
}
112127

@@ -120,12 +135,24 @@ public Call<ResponseBody> get(@NotNull String environment) {
120135
* In the 'Body' section, mention the environment name, server names that are part of the environment, the urls
121136
* (which include the language code and the URL of the server), and the option to deploy content to a server.
122137
*
123-
* @param requestBody
124-
* request body of type @{@link JSONObject}
138+
* @param body
139+
* The {@link JSONObject} request body<br>
140+
* <b>Example:</b>
141+
* <pre
125142
* @return Call
143+
* @code{ { "environment": { "name": "development", "servers": [ { "name": "default" } ], "urls": [ { "locale":
144+
* "en-us", "url": "http://example.com/" } ], "deploy_content": true } }}
145+
* </pre>
146+
* @see <a
147+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#environment-collection">Get all
148+
* environments
149+
* </a>
150+
* @see #addHeader(String, Object) to add headers
151+
* @see #addParam(String, Object) to add query parameters
152+
* @since 1.0.0
126153
*/
127-
public Call<ResponseBody> add(@NotNull JSONObject requestBody) {
128-
return this.service.add(this.headers, requestBody);
154+
public Call<ResponseBody> create(@NotNull JSONObject body) {
155+
return this.service.add(this.headers, body);
129156
}
130157

131158

@@ -140,10 +167,15 @@ public Call<ResponseBody> add(@NotNull JSONObject requestBody) {
140167
* the option to deploy content to a server.
141168
*
142169
* @param environmentName
143-
* name of the environment
170+
* The name of the environment
144171
* @param requestBody
145172
* request body of type @{@link JSONObject}
146173
* @return Call
174+
* @see <a
175+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#update-environment">Update
176+
* Environment
177+
* @see #addHeader(String, Object) to add headers to the request
178+
* @since 1.0.0
147179
*/
148180
public Call<ResponseBody> update(@NotNull String environmentName, @NotNull JSONObject requestBody) {
149181
return this.service.update(this.headers, environmentName, requestBody);
@@ -157,8 +189,13 @@ public Call<ResponseBody> update(@NotNull String environmentName, @NotNull JSONO
157189
* authtoken that you receive after logging into your account.
158190
*
159191
* @param environmentName
160-
* name of the environment
192+
* The name of the environment
161193
* @return Call
194+
* @see <a
195+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-environment">Delete
196+
* Environment
197+
* @see #addHeader(String, Object) to add headers to the request
198+
* @since 1.0.0
162199
*/
163200
public Call<ResponseBody> delete(@NotNull String environmentName) {
164201
return this.service.delete(this.headers, environmentName);

src/main/java/com/contentstack/cms/stack/Extensions.java

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ protected Extensions(Retrofit retrofit, HashMap<String, Object> stackHeaders) {
3838
this.service = retrofit.create(ExtensionsService.class);
3939
}
4040

41-
public Extensions addHeader(@NotNull String key, @NotNull String value) {
42-
this.headers.put(key, value);
43-
return this;
44-
}
45-
4641
/**
4742
* Sets header for the request
4843
*
@@ -59,58 +54,75 @@ public void addHeader(@NotNull String key, @NotNull Object value) {
5954
* Sets header for the request
6055
*
6156
* @param key
62-
* header key for the request
57+
* query param key for the request
6358
* @param value
64-
* header value for the request
59+
* query param value for the request
6560
*/
6661
public void addParam(@NotNull String key, @NotNull Object value) {
6762
this.params.put(key, value);
6863
}
6964

7065

7166
/**
72-
* Sets header for the request
67+
* Set header for the request
7368
*
7469
* @param key
75-
* header key for the request
70+
* Removes query param using key of request
7671
*/
7772
public void removeParam(@NotNull String key) {
7873
this.params.remove(key);
7974
}
8075

8176

8277
/**
83-
* To clear all the params
78+
* To clear all the query params
8479
*/
8580
protected void clearParams() {
8681
this.params.clear();
8782
}
8883

84+
8985
/**
9086
* The Get all custom fields request is used to get the information of all custom fields created in a stack.
9187
*
92-
* @param query
93-
* For custom fields <b>Example:"type":"field"</b>
94-
* @param isIncludeBranch
95-
* Set this to 'true' to include the '_branch' top-level key in the response. This key states the unique ID
96-
* of the branch where the concerned Contentstack module resides.
97-
* <b>Example:false</b>
88+
* <dl>
89+
* <dt>query</dt>
90+
* <dd>For custom fields <b>Example:"type":"field"</b></dd>
91+
* <dt>include_branch</dt>
92+
* <dd>Set this to 'true' to include the '_branch' top-level key in the response. This key states the unique ID
93+
* of the branch where the concerned Contentstack module resides</dd>
94+
* </dl>
95+
*
9896
* @return Call
97+
* @see <a
98+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#get-all-custom-fields">Get all
99+
* Custom Field
100+
* </a>
101+
* @see #addHeader(String, Object) to add headers
102+
* @see #addParam(String, Object) to add query parameters
103+
* @since 1.0.0
99104
*/
100-
public Call<ResponseBody> fetch(@NotNull String query, boolean isIncludeBranch) {
101-
return this.service.getAll(this.headers, query, isIncludeBranch);
105+
public Call<ResponseBody> fetch() {
106+
return this.service.getAll(this.headers, this.params);
102107
}
103108

104109

105110
/**
106111
* @param customFieldUid
107-
* Enter the UID of the custom field of which you want to retrieve the details.
108-
* <br><br>
109-
* {@link #addParam(String, Object)} Set this to 'true' to include the '_branch' top-level key in the
110-
* response. This key states the unique ID of the branch where the concerned Contentstack module resides.
111-
* <p>
112-
* <b>Example:false</b>
112+
* Enter the UID of the custom field of which you want to retrieve the details.<br>
113+
* <dl>
114+
* <dt>include_branch</dt>
115+
* <dd>Set this to 'true' to include the '_branch' top-level key in the response.
116+
* This key states the unique ID of the branch where the concerned Contentstack module resides.</dd>
117+
* </dl>
113118
* @return Call
119+
* @see <a
120+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#get-a-single-custom-field">Get a
121+
* Single Custom Field
122+
* </a>
123+
* @see #addHeader(String, Object) to add headers
124+
* @see #addParam(String, Object) to add query parameters
125+
* @since 1.0.0
114126
*/
115127
public Call<ResponseBody> single(@NotNull String customFieldUid) {
116128
this.headers.put(Util.CONTENT_TYPE, "multipart/form-data");
@@ -135,6 +147,13 @@ public Call<ResponseBody> single(@NotNull String customFieldUid) {
135147
* @param body
136148
* the request body
137149
* @return Call
150+
* @see <a
151+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#upload-a-custom-field">Upload a
152+
* custom field
153+
* </a>
154+
* @see #addHeader(String, Object) to add headers
155+
* @see #addParam(String, Object) to add query parameters
156+
* @since 1.0.0
138157
*/
139158
public Call<ResponseBody> uploadCustomField(Map<String, RequestBody> body) {
140159
this.headers.put(Util.CONTENT_TYPE, "multipart/form-data");
@@ -158,6 +177,13 @@ public Call<ResponseBody> uploadCustomField(Map<String, RequestBody> body) {
158177
* @param body
159178
* the request body
160179
* @return Call
180+
* @see <a
181+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#upload-a-custom-field">Upload a
182+
* custom field
183+
* </a>
184+
* @see #addHeader(String, Object) to add headers
185+
* @see #addParam(String, Object) to add query parameters
186+
* @since 1.0.0
161187
*/
162188
public Call<ResponseBody> uploadCustomField(JSONObject body) {
163189
this.headers.put(Util.CONTENT_TYPE, "application/json");
@@ -175,6 +201,12 @@ public Call<ResponseBody> uploadCustomField(JSONObject body) {
175201
* @param body
176202
* JSON requestBody
177203
* @return Call
204+
* @see <a
205+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#update-a-custom-field">Update a
206+
* custom field
207+
* </a>
208+
* @see #addHeader(String, Object) to add headers
209+
* @since 1.0.0
178210
*/
179211
public Call<ResponseBody> update(@NotNull String customFieldUid, JSONObject body) {
180212
if (body == null) {
@@ -194,6 +226,12 @@ public Call<ResponseBody> update(@NotNull String customFieldUid, JSONObject body
194226
* @param customFieldUid
195227
* UID of the custom field that you want to update
196228
* @return Call
229+
* @see <a
230+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-custom-field">Delete a
231+
* custom field
232+
* </a>
233+
* @see #addHeader(String, Object) to add headers
234+
* @since 1.0.0
197235
*/
198236
public Call<ResponseBody> delete(@NotNull String customFieldUid) {
199237
return this.service.delete(this.headers, customFieldUid);

src/main/java/com/contentstack/cms/stack/ExtensionsService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public interface ExtensionsService {
1414
@GET("extensions")
1515
Call<ResponseBody> getAll(
1616
@HeaderMap Map<String, Object> headers,
17-
@Query("query") String query,
18-
@Query("include_branch") Boolean isIncludeBranch);
17+
@QueryMap(encoded = true) Map<String, Object> query);
1918

2019
@GET("extensions/{custom_field_uid}")
2120
Call<ResponseBody> getSingle(

0 commit comments

Comments
 (0)