Squiz Matrix JS API Enhanced Mode
Wed, Aug. 3, 2011The new Squiz Matrix JS API asset was just released with a great new option, Enhanced Mode. This allows for jQuery like methods for a much more object oriented style of doing things. The great thing is that you don't have to pass all of the parameters like the old version of the API, only the ones that are required and ones you want.
Test Functions
Console Output
$test:
Javascript
// Code goes here
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); // Call api method js_api.getGeneral({ asset_id: '1272', dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val+'
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); // Call api method js_api.getAssetTypes({ dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+'
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); // Call api method js_api.getWebPath({ asset_id: '1272', dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val+'
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); // Call api method js_api.getPermissions({ asset_id: '1272', level: 1, dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val['7'].name); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); // Call api method js_api.createAsset({ asset_name: 'Test Record', parent_id: '1272', type_code: 'data_record', link_type: 2, dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val+'
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); // Call api method js_api.getAttributes({ asset_id: '1272', dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val+'
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); // Call api method js_api.getLocksInfo({ asset_id: '1272', screen_name: 'all', dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val+'
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); // Keywords Array var keywords = ['%asset_name%', '%asset_short_name%', '%asset_assetid%', '%asset_type%', '%asset_url%', '%asset_type_icon%', '%asset_version%', '%asset_created%', '%asset_created_short%', '%asset_created_readable%', '%asset_created_relative%', '%asset_created_relative-dow%', '%asset_created_ical%', '%asset_created_by_first_name%', '%asset_created_by_last_name%', '%asset_updated%', '%asset_updated_relative%', '%asset_status_changed%', '%asset_read_permission%']; // Call api method js_api.getKeywordsReplacements({ asset_id: 1272, keywords_array: keywords, dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val+'
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); js_api.getChildren({ asset_id: 86, levels: 1, type_codes: ['page_standard'], dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val.name+' ['+val.id+']
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); js_api.getParents({ asset_id: 1272, levels: 1, dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val.name+' ['+val.type_code+']
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); js_api.getLineage({ asset_url: 1272, dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val.name+' ['+val.type_code+']
'); });//end }//end });//end
// Create new api object and set key var js_api = new Squiz_Matrix_API({key: '1348815761'}); js_api.getMetadata({ asset_id: 1272, dataCallback: function(data) { $('code.shell').html(''); $.each(data, function(key, val) { $('code.shell').append('$test: '+key+' => '+val+'
'); });//end }//end });//end
There are many more API methods that require more than read access, but those are out of the scope of this post.
Nicholas Hubbard
Owner
Comments