55import okhttp3 .RequestBody ;
66import okhttp3 .ResponseBody ;
77import org .jetbrains .annotations .NotNull ;
8- import org .jetbrains .annotations .Nullable ;
98import org .json .simple .JSONObject ;
109import retrofit2 .Call ;
1110import retrofit2 .Retrofit ;
@@ -28,12 +27,14 @@ public class Asset {
2827 protected final Map <String , Object > headers ;
2928 protected Map <String , Object > params ;
3029 protected final AssetService service ;
30+ private final Retrofit instance ;
3131
3232 protected Asset (Retrofit instance , @ NotNull Map <String , Object > stackHeaders ) {
3333 this .headers = new HashMap <>();
3434 this .headers .put ("Content-Type" , "application/json" );
3535 this .headers .putAll (stackHeaders );
3636 params = new HashMap <>();
37+ this .instance = instance ;
3738 this .service = instance .create (AssetService .class );
3839 }
3940
@@ -81,6 +82,10 @@ protected void clearParams() {
8182 }
8283
8384
85+ public Folder folder () {
86+ return new Folder (this .instance , this .headers );
87+ }
88+
8489 /**
8590 * The Get all assets request returns comprehensive information on all assets available in a stack.
8691 * <p>
@@ -305,7 +310,7 @@ public Call<ResponseBody> generatePermanentUrl(String uid, JSONObject body) {
305310 * <br>
306311 *
307312 * @param uid
308- * The UID of the asset you want to download. Use the Get All Assets request to get the UID of the asset..
313+ * The UID of the asset you want to download. Use the Get All Assets request to get the UID of the asset.
309314 * @param slugUrl
310315 * The unique identifier of the asset.
311316 * @return Call
@@ -555,28 +560,6 @@ public Call<ResponseBody> unpublish(
555560 return this .service .unpublish (this .headers , assetUid , requestBody );
556561 }
557562
558- /**
559- * The Get a single folder call gets the comprehensive details of a specific asset folder by means of folder UID.
560- * <p>
561- * When executing the API call to search for a subfolder, you need to provide the parent folder UID.
562- *
563- * @param folderUid
564- * folder uid provide query using <p>#addParam query parameters - include_path(optional) Set this parameter
565- * to ‘true’ to retrieve the complete path of the folder. The path will be displayed as an array of objects
566- * which includes the names and UIDs of each parent folder.
567- * <p>
568- * Example:false
569- * @return Call
570- * @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#unpublish-an-asset">
571- * Unpublish An Asset</a>
572- * @see #addHeader(String, Object) to add headers
573- * @see #addParam(String, Object) to add query params
574- * @since 1.0.0
575- */
576- public Call <ResponseBody > singleFolder (
577- @ NotNull String folderUid ) {
578- return this .service .singleFolder (this .headers , folderUid , this .params );
579- }
580563
581564 /**
582565 * The Get a single folder by name call retrieves a specific asset folder based on the name provided.
@@ -617,81 +600,5 @@ public Call<ResponseBody> getSubfolder() {
617600 return this .service .getSubfolder (this .headers , this .params );
618601 }
619602
620- /**
621- * The Create a folder call is used to create an asset folder and/or add a parent folder to it (if required).
622- * <p>
623- * In the ‘Body’ section, you need to provide a name for the new folder.
624- * <p>
625- * If you want to place this folder within another folder, provide the UID of the parent folder in the Request body
626- * as follows:
627- * <p>
628- * { "asset": { "name": "asset_folder_name", "parent_uid": "asset_parent_folder_uid" } }
629- *
630- * <b>Note:</b> Here are some points that needs to be considered when executing
631- * this API request:
632- * <p>
633- * A maximum of 300 folders can be created. The maximum level of folder nesting is 5. When nesting folder, you
634- * cannot nest a folder within the same folder or within its child folders
635- *
636- * @param requestBody
637- * JSONObject request body
638- * @return Call
639- * @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#create-a-folder"> Create
640- * a folder</a>
641- * @see #addHeader(String, Object) to add headers
642- * @see #addParam(String, Object) to add query params
643- * @since 1.0.0
644- */
645- public Call <ResponseBody > createFolder (@ Nullable JSONObject requestBody ) {
646- return this .service .createFolder (this .headers , this .params , requestBody );
647- }
648-
649- /**
650- * The Update or move folder request can be used either to update the details of a folder or set the parent folder
651- * if you want to move a folder under another folder.
652- * <p>
653- * When executing the API request, provide the UID of the folder that you want to move/update.
654- * <p>
655- * In the ‘Body’ section, you need to provide a new name for your folder, and if you want to move your folder within
656- * another folder, then you need provide the UID of the parent folder.
657- *
658- * <b>Note:</b> Here are some points that needs to be considered when executing
659- * this API request:
660- * <p>
661- * A maximum of 300 folders can be created. The maximum level of folder nesting is 5. When nesting folder, you
662- * cannot nest a folder within the same folder or within its child folders.
663- *
664- * @param folderUid
665- * The UID of the folder that you want to either update or move
666- * @param requestBody
667- * JSONObject request body { "asset": { "name": "Demo" } }
668- * @return Call
669- * @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#update-or-move-folder">
670- * Update ORr Move Folder</a>
671- * @see #addHeader(String, Object) to add headers
672- * @see #addParam(String, Object) to add query params
673- * @since 1.0.0
674- */
675- public Call <ResponseBody > updateFolder (@ NotNull String folderUid , @ Nullable JSONObject requestBody ) {
676- return this .service .updateFolder (this .headers , folderUid , this .params , requestBody );
677- }
678-
679- /**
680- * Delete a folder call is used to delete an asset folder along with all the assets within that folder.
681- * <p>
682- * When executing the API call, provide the parent folder UID.
683- *
684- * @param folderUid
685- * The UID of the asset folder that you want to delete
686- * @return Call
687- * @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-a-folder">
688- * Delete A Folder</a>
689- * @see #addHeader(String, Object) to add headers
690- * @see #addParam(String, Object) to add query params
691- * @since 1.0.0
692- */
693- public Call <ResponseBody > deleteFolder (@ NotNull String folderUid ) {
694- return this .service .deleteFolder (this .headers , folderUid );
695- }
696603
697604}
0 commit comments