public static MetadataTemplate createMetadataTemplate ( BoxAPIConnection api , String scope , String templateKey , String displayName , boolean hidden , List < Field > fields ) { JsonObject jsonObject = new JsonObject ( ) ; jsonObject . add ( "scope" , scope ) ; jsonObject . add ( "displayName" , displayName ) ; jsonObject . add ( "hidden" , hidden ) ; if ( templateKey != null ) { jsonObject . add ( "templateKey" , templateKey ) ; } JsonArray fieldsArray = new JsonArray ( ) ; if ( fields != null && ! fields . isEmpty ( ) ) { for ( Field field : fields ) { JsonObject fieldObj = getFieldJsonObject ( field ) ; fieldsArray . add ( fieldObj ) ; } jsonObject . add ( "fields" , fieldsArray ) ; } URL url = METADATA_TEMPLATE_SCHEMA_URL_TEMPLATE . build ( api . getBaseURL ( ) ) ; BoxJSONRequest request = new BoxJSONRequest ( api , url , "POST" ) ; request . setBody ( jsonObject . toString ( ) ) ; BoxJSONResponse response = ( BoxJSONResponse ) request . send ( ) ; JsonObject responseJSON = JsonObject . readFrom ( response . getJSON ( ) ) ; return new MetadataTemplate ( responseJSON ) ; }
Creates new metadata template .