baasic-sdk-angularjs
Version:
AngularJS SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
863 lines (850 loc) • 604 kB
JavaScript
/*
Baasic AngularJS SDK v2.0.0
(c) 2014-2017 Mono Ltd. http://baasic.com
License: MIT
*/
(function (angular, undefined) { /* exported module */
/**
* @description The angular.module is a global place for creating, registering or retrieving modules. All modules should be registered in an application using this mechanism. An angular module is a container for the different parts of your app - services, directives etc. In order to use `baasic.appSettings` module functionality it must be added as a dependency to your app.
* @copyright (c) 2017 Mono Ltd
* @license MIT
* @author Mono Ltd
* @module baasic.appSettings
* @example
(function (Main) {
"use strict";
var dependencies = [
"baasic.api",
"baasic.membership",
"baasic.security",
"baasic.appSettings",
"baasic.article",
"baasic.dynamicResource",
"baasic.keyValue",
"baasic.valueSet"
];
Main.module = angular.module("myApp.Main", dependencies);
}
(MyApp.Modules.Main = {}));
*/
var module = angular.module('baasic.appSettings', ['baasic.api']);
/* globals module */
/**
* @module baasicApplicationSettingsService
* @description Baasic Application Settings Service provides an easy way to consume Baasic Application Settings REST API end-points. In order to obtain needed routes `baasicApplicationSettingsService` uses `baasicApplicationSettingsRouteService`.
*/
(function (angular, module, undefined) {
'use strict';
module.service('baasicApplicationSettingsService', ['baasicApp', function (baasicApps) {
var baasicApp = baasicApps.get();
return {
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the application settings resource.
* @method
* @example
baasicApplicationSettingsService.get()
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (options) {
return baasicApp.applicationSettingModule.get(options).success(function (appSettings) {
appSettings.origins = appSettings.origins || [];
});
},
/**
* Returns a promise that is resolved once the update application settings action has been performed. This action updates the application setting resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't use `baasicApplicationSettingsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.removeParams(appSettings);
var uri = params['model'].links('put').href;
```
* @method
* @example
// appSettings is a resource previously fetched using get action.
appSettings.allowAnyOrigin = true;
baasicApplicationSettingsService.update(appSettings)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data) {
return baasicApp.applicationSettingModule.update(data);
},
routeService: baasicApp.applicationSettingModule.routeDefinition
};
}]);
}(angular, module));
/**
* @copyright (c) 2017 Mono Ltd
* @license MIT
* @author Mono Ltd
* @overview
***Notes:**
- Refer to the [Baasic REST API](http://dev.baasic.com/api/reference/home) for detailed information about available Baasic REST API end-points.
- All end-point objects are transformed by the associated route service.
*/
/* exported module */
/**
* @description The angular.module is a global place for creating, registering or retrieving modules. All modules should be registered in an application using this mechanism. An angular module is a container for the different parts of your app - services, directives etc. In order to use `baasic.article` module functionality it must be added as a dependency to your app.
* @copyright (c) 2017 Mono Ltd
* @license MIT
* @author Mono Ltd
* @module baasic.article
* @example
(function (Main) {
'use strict';
var dependencies = [
'baasic.api',
'baasic.membership',
'baasic.security',
'baasic.appSettings',
'baasic.article',
'baasic.dynamicResource',
'baasic.keyValue',
'baasic.valueSet'
];
Main.module = angular.module('myApp.Main', dependencies);
}
(MyApp.Modules.Main = {}));
*/
var module = angular.module('baasic.article', ['baasic.api']);
/* globals module */
/**
* @module baasicArticleCommentRepliesService
* @description Baasic Article Comment Replies Service provides an easy way to consume Baasic Article Comment Replies REST API end-points. `baasicArticleCommentRepliesService` functions enable performing standard CRUD operations directly on article comment reply resources, whereas the `baasicArticleService` functions allow management between article and article comment reply. In order to obtain needed routes `baasicArticleCommentRepliesService` uses `baasicArticleCommentRepliesRouteService`.
*/
(function (angular, module, undefined) {
'use strict';
module.service('baasicArticleCommentRepliesService', ['baasicApp', function (baasicApps) {
var baasicApp = baasicApps.get();
return {
/**
* Contains a reference to valid list of article comment reply states. It returns an object containing all article comment reply states.
* @method
* @example baasicArticleCommentRepliesService.statuses.approved;
**/
statuses: baasicApp.articleModule.comments.replies.statuses,
/**
* Returns a promise that is resolved once the approve article comment reply action has been performed. This action sets the state of an article comment reply to "approved". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('comment-approve').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.approve(articleCommentReply, commentOptions)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
approve: function (data, options) {
return baasicApp.articleModule.comments.replies.approve(data, options);
},
/**
* Returns a promise that is resolved once the unapprove article comment reply action has been performed. This action sets the state of an article comment reply to "unapproved". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('comment-unapprove').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.unapprove(articleCommentReply)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unapprove: function (data) {
return baasicApp.articleModule.comments.replies.unapprove(data);
},
/**
* Returns a promise that is resolved once the create article comment reply action has been performed; this action creates a new comment reply for an article.
* @method
* @example
baasicArticleCommentRepliesService.create('<article-id>', {
commentId : '<comment-id>',
comment : <comment>,
userId : '<user-id>'
})
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
create: function (data) {
return baasicApp.articleModule.comments.replies.create(data);
},
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of article comment reply resources matching the given criteria.
* @method
* @example
baasicArticleCommentRepliesService.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
search : '<search-phrase>'
})
.success(function (collection) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
find: function (options) {
return baasicApp.articleModule.comments.replies.find(options);
},
/**
* Returns a promise that is resolved once the flag article comment reply action has been performed. This action sets the state of an article comment reply to "flagged". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('comment-flag').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.flag(articleCommentReply)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
flag: function (data) {
var params = baasicApiService.updateParams(data);
return baasicApp.articleModule.comments.replies.flag(data);
},
/**
* Returns a promise that is resolved once the unflag article comment reply action has been performed. This action removes the "flagged" comment reply state. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('comment-unflag').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.unflag(articleCommentReply)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unflag: function (data) {
return baasicApp.articleModule.comments.replies.unflag(data);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the specified article comment reply resource.
* @method
* @example
baasicArticleCommentRepliesService.get('<comment-reply-id>')
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.articleModule.comments.replies.get(id, options);
},
/**
* Returns a promise that is resolved once the remove article comment reply action has been performed. If the action is successfully completed, the article comment reply resource will be permanently removed from the system. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.removeParams(articleCommentReply);
var uri = params['model'].links('delete').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.remove(articleCommentReply)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
remove: function (data) {
return baasicApp.articleModule.comments.replies.remove(data);
},
/**
* Returns a promise that is resolved once the report article comment reply action has been performed. This action sets the state of an article comment reply to "reported". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('comment-report').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.report(articleCommentReply, commentOptions)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
report: function (data, options) {
return baasicApp.articleModule.comments.replies.report(data, options);
},
/**
* Returns a promise that is resolved once the unreport article comment reply action has been performed. This action removes the "reported" comment reply state. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('comment-unreport').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.unreport(articleCommentReply)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unreport: function (data) {
return baasicApp.articleModule.comments.replies.unreport(data);
},
/**
* Returns a promise that is resolved once the mark as spam article comment reply action has been performed. This action sets the state of an article comment reply to "spam". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('comment-spam').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.spam(articleCommentReply)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
spam: function (data) {
return baasicApp.articleModule.comments.replies.spam(data);
},
/**
* Returns a promise that is resolved once the unspam article comment reply action has been performed. This action removes the "spam" comment reply state. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('comment-unspam').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.unspam(articleCommentReply)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unspam: function (data) {
return baasicApp.articleModule.comments.replies.unspam(data);
},
/**
* Returns a promise that is resolved once the update article comment reply action has been performed; this action updates an article comment reply resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentRepliesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleCommentReply);
var uri = params['model'].links('put').href;
```
* @method
* @example
// articleCommentReply is a resource previously fetched using get action.
baasicArticleCommentRepliesService.update(articleCommentReply)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data) {
return baasicApp.articleModule.comments.replies.update(data);
},
/**
* Provides direct access to `baasicArticleCommentRepliesRouteService`.
* @method
* @example baasicArticleCommentRepliesService.routeService.get(expandObject);
**/
routeService: baasicApp.articleModule.comments.replies.routeDefinition
};
}]);
}(angular, module));
/**
* @overview
***Notes:**
- Refer to the [REST API documentation](https://github.com/Baasic/baasic-rest-api/wiki) for detailed information about available Baasic REST API end-points.
- All end-point objects are transformed by the associated route service.
*/
/* globals module */
/**
* @module baasicArticleCommentsService
* @description Baasic Article Comments Service provides an easy way to consume Baasic Article Comments REST API end-points. `baasicArticleCommentsService` functions enable performing standard CRUD operations directly on article comment resources, whereas the `baasicArticleService` functions allow management between article and article comments. In order to obtain needed routes `baasicArticleCommentsService` uses `baasicArticleCommentsRouteService`.
*/
(function (angular, module, undefined) {
'use strict';
module.service('baasicArticleCommentsService', ['baasicApp', function (baasicApps) {
var baasicApp = baasicApps.get();
return {
/**
* Contains a reference to valid list of article comment states. It returns an object containing all article comment states.
* @method
* @example baasicArticleCommentsService.statuses.approved;
**/
statuses: baasicApp.articleModule.comments.statuses,
/**
* Returns a promise that is resolved once the approve article comment action has been performed. This action sets the state of an article comment to "approved". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('comment-approve').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.approve(articleComment, commentOptions)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
approve: function (data, options) {
return baasicApp.articleModule.comments.approve(data, options);
},
/**
* Returns a promise that is resolved once the unapprove article comment action has been performed. This action sets the state of an article comment to "unapproved". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('comment-unapprove').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.unapprove(articleComment)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unapprove: function (data) {
return baasicApp.articleModule.comments.unapprove(data);
},
/**
* Returns a promise that is resolved once the create article comment action has been performed; this action creates a new comment for an article.
* @method
* @example
baasicArticleCommentsService.create({
articleId : '<article-id>',
comment : <comment>,
userId : '<user-id>'
})
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
create: function (data) {
return baasicApp.articleModule.comments.create(data);
},
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of article comment resources matching the given criteria.
* @method
* @example
baasicArticleCommentsService.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
search : '<search-phrase>'
})
.success(function (collection) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
find: function (options) {
return baasicApp.articleModule.comments.find(options);
},
/**
* Returns a promise that is resolved once the flag article comment action has been performed. This action sets the state of an article comment to "flagged". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('comment-flag').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.flag(articleComment)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
flag: function (data) {
return baasicApp.articleModule.comments.flag(data);
},
/**
* Returns a promise that is resolved once the unflag article comment action has been performed. This action removes the "flagged" comment mark. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('comment-unflag').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.unflag(articleComment)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unflag: function (data) {
return baasicApp.articleModule.comments.unflag(data);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the specified article comment resource.
* @method
* @example
baasicArticleCommentsService.get('<article-id>', '<comment-id>')
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.articleModule.comments.get(id, options);
},
/**
* Returns a promise that is resolved once the remove article comment action has been performed. If the action is successfully completed, the article comment resource and its replies will be permanently removed from the system. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.removeParams(articleComment);
var uri = params['model'].links('delete').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.remove(articleComment)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
remove: function (data) {
return baasicApp.articleModule.comments.remove(data);
},
/**
* Returns a promise that is resolved once the report article comment action has been performed. This action sets the state of an article comment to "reported". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('comment-report').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.report(articleComment, commentOptions)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
report: function (data, options) {
return baasicApp.articleModule.comments.report(data, options);
},
/**
* Returns a promise that is resolved once the unreport article comment action has been performed. This action removes the "reported" comment mark. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('comment-unreport').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.unreport(articleComment)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unreport: function (data) {
return baasicApp.articleModule.comments.unreport(data);
},
/**
* Returns a promise that is resolved once the mark as spam article comment action has been performed. This action sets the state of an article comment to "spam". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('comment-spam').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.spam(articleComment)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
spam: function (data) {
return baasicApp.articleModule.comments.spam(data);
},
/**
* Returns a promise that is resolved once the unspam article comment action has been performed. This action removes the "spam" comment mark. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('comment-unspam').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.unspam(articleComment)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unspam: function (data) {
return baasicApp.articleModule.comments.unspam(data);
},
/**
* Returns a promise that is resolved once the update article comment action has been performed; this action updates an article comment resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicarticleCommentsRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(articleComment);
var uri = params['model'].links('put').href;
```
* @method
* @example
// articleComment is a resource previously fetched using get action.
baasicArticleCommentsService.update(articleComment)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data) {
return baasicApp.articleModule.comments.update(data);
},
/**
* Provides direct access to `baasicArticleCommentsRouteService`.
* @method
* @example baasicArticleCommentsService.routeService.get(expandObject);
**/
routeService: baasicApp.articleModule.comments.routeDefinition
};
}]);
}(angular, module));
/**
* @overview
***Notes:**
- Refer to the [REST API documentation](https://github.com/Baasic/baasic-rest-api/wiki) for detailed information about available Baasic REST API end-points.
- All end-point objects are transformed by the associated route service.
*/
/* globals module */
/**
* @module baasicArticleFilesService
* @description Baasic Files Service provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Files Route Service to obtain needed routes while other routes will be obtained through HAL. By convention, all route services use the same function names as their corresponding services.
*/
(function (angular, module, undefined) {
'use strict';
module.service('baasicArticleFilesService', ['baasicApp', function (baasicApps) {
var baasicApp = baasicApps.get();
return {
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of file resources matching the given criteria.
* @method
* @example
baasicArticleFilesService.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
search : '<search-phrase>'
})
.success(function (collection) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
find: function (options) {
return baasicApp.articleModule.files.find(options);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns requested file resource.
* @method
* @example
baasicArticleFilesService.get('<file-id>')
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.articleModule.files.get(id, options);
},
/**
* Returns a promise that is resolved once the unlink action has been performed. This action will remove one or many file resources from the system if successfully completed. Specified file and all its accompanying derived resources will be removed from the system. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicArticleFilesRouteService route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.removeParams(fileEntry);
var uri = params['model'].links('unlink').href;
```
* @method
* @example
// fileEntry is a file resource previously fetched using get action. The following action will remove the original file resource and all accompanying derived file resources.
baasicArticleFilesRouteService.remove(fileEntry)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
unlink: function (data, options) {
return baasicApp.articleModule.files.unlink(data, options);
},
/**
* Returns a promise that is resolved once the update file action has been performed; this action will update a file resource if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleFilesRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects:
```
var params = baasicApiService.updateParams(fileEntry);
var uri = params['model'].links('put').href;
```
* @method
* @example
// fileEntry is a file resource previously fetched using get action.
fileEntry.description = '<description>';
baasicArticleFilesService.update(fileEntry)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data) {
return baasicApp.articleModule.files.update(data);
},
/**
* Returns a promise that is resolved once the link action has been performed; this action links file resource from other modules into the Article Files module (For example: file resources from the Media Vault module can be linked directly into the Article Files module).
* @method
* @example
baasicArticleFilesService.link(fileObject)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
link: function (data) {
return baasicApp.articleModule.files.link(data);
},
streams: {
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the file stream if successfully completed. If derived resource's format is passed, such as `width` and `height` for the image type of file resource, the operation will return a stream of the derived resource. Otherwise, stream of the original file resource will be retrieved.
* @method streams.get
* @example
// Request the original file stream
baasicArticleFilesService.stream.get({id: '<file-id>'})
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
// Request derived file stream
baasicArticleFilesService.stream.get({id: '<file-id>', width: <width>, height: <height>})
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (data) {
return baasicApp.articleModule.files.streams.get(data);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the file stream as a blob. If derived resource's format is passed, such as `width` and `height` for the image type of file resource, the operation will return a blob of the derived file resource. Otherwise, blob of the original file resource will be retrieved. For more information on Blob objects please see [Blob Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
* @method streams.getBlob
* @example
// Request the original blob
baasicArticleFilesService.stream.getBlob('<file-id>')
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
// Request derived blob
baasicArticleFilesService.stream.getBlob({id: '<file-id>', width: <width>, height: <height>})
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
**/
getBlob: function (data) {
return baasicApp.articleModule.files.streams.getBlob(data);
},
/**
* Returns a promise that is resolved once the update file stream action has been performed; this action will replace the existing stream with a new one. Alternatively, if a derived stream is being updated it will either create a new derived stream or replace the existing one. In order to update a derived stream, format needs to be passed (For example: `width` and `height` for the image type of file stream data type).
* @method streams.update
* @example
// Update original file stream
baasicArticleFilesService.streams.update('<file-id>', <file-stream>)
.success(function (data) {
// perform success action here
})
.error(function (response, stat