baasic-sdk-angular
Version:
Angular (v5+) SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
719 lines • 78.3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var core_1 = require("@angular/core");
var index_1 = require("../index");
var UserProfileService = /** @class */ (function () {
function UserProfileService(baasicApp) {
this.baasicApp = baasicApp;
}
Object.defineProperty(UserProfileService.prototype, "profile", {
get: function () {
var baasicApp = this.baasicApp;
return {
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of user profile resources matching the given criteria.
* @method
* @param options Query resource options object.
* @returns A promise that is resolved once the find action has been performed.
* @example UserProfileService.profile.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
search : '<search-phrase>'
})
.then(function (collection) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
find: function (options) {
return baasicApp.userProfileModule.profile.find(options);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the user profile resource.
* @method
* @param id User profile id which uniquely identifies user profile resource that needs to be retrieved.
* @param options Query resource options object.
* @returns A promise that is resolved once the get action has been performed.
* @example UserProfileService.profile.get()
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.userProfileModule.profile.get(id, options);
},
/**
* Returns a promise that is resolved once the create user profile action has been performed; this action creates a new user profile resource.
* @method
* @param data An user profile object that needs to be inserted into the system.
* @returns A promise that is resolved once the create user profile action has been performed.
* @example UserProfileService.profile.create({
firstName : '<first-name>',
lastName : '<last-name>',
displayName: '<nick-name>'
}.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
create: function (data) {
return baasicApp.userProfileModule.profile.create(data);
},
/**
* Returns a promise that is resolved once the update user profile action has been performed; this action updates a user profile resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicUserProfileRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.removeParams(userProfile);
* let uri = params['model'].links('put').href;
* ```
* @method
* @param data An user profile object used to update specified user profile resource.
* @returns A promise that is resolved once the update user profile action has been performed.
* @example // userProfile is a resource previously fetched using get action.
userProfile.displayName = '<nick-name>';
UserProfileService.profile.update(userProfile)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data) {
return baasicApp.userProfileModule.profile.update(data);
},
/**
* Returns a promise that is resolved once the remove action has been performed. This action will remove a user profile resource from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicUserProfileRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.removeParams(userProfile);
* let uri = params['model'].links('delete').href;
* ```
* @method
* @param data An user profile object used to delete specified user profile resource.
* @returns A promise that is resolved once the remove action has been performed.
* @example // userProfile is a resource previously fetched using get action.
UserProfileService.profile.remove(userProfile)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
remove: function (data) {
return baasicApp.userProfileModule.profile.remove(data);
},
acl: {
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns a list of ACL policies established for the specified user profile resource.
* @method
* @param options Query resource options object.
* @returns A promise that is resolved once the get action has been performed.
* @example UserProfileService.profile.acl.get({id: '<profile-id>'})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (options) {
return baasicApp.userProfileModule.profile.acl.get(options);
},
/**
* Returns a promise that is resolved once the update acl action has been performed, this action creates new ACL policy for the specified user profile resource.
* @method
* @param options ACL options object.
* @returns A promise that is resolved once the update acl action has been performed.
* @example let options = {id : '<profile-id>'};
let aclObj = { actionId: '<action-id'>, roleId: '<roleId>', userId: '<userId>' };
options[baasicConstants.modelPropertyName] = aclObj;
UserProfileService.profile.acl.update(options)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (options) {
return baasicApp.userProfileModule.profile.acl.update(options);
},
/**
* Returns a promise that is resolved once the removeByUser action has been performed. This action deletes ACL policy assigned to the specified user and user profile resource.
* @method
* @param profileId User profile id which uniquely identifies user profile resource whose security privileges need to be retrieved and updated.
* @param action Action abbreviation which identifies ACL policy assigned to the specified user and user profile resource.
* Supported Values:
* "Create"
* "Delete"
* "Read"
* "Update"
* @param user A value that uniquely identifies user for which ACL policy needs to be removed.
* @param data ACL policy object used to delete specified ACL policy resource.
* @returns A promise that is resolved once the removeByUser action has been performed.
* @example UserProfileService.profile.acl.removeByUser('<profile-id>', '<access-action>', '<username>')
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
removeByUser: function (profileId, action, user, data) {
return baasicApp.userProfileModule.profile.acl.removeByUser(profileId, action, user, data);
},
/**
* Returns a promise that is resolved once the removeByRole action has been performed. This action deletes ACL policy assigned to the specified role and user profile resource.
* @method
* @param profileId User profile id which uniquely identifies user profile resource whose security privileges need to be retrieved and updated.
* @param action Action abbreviation which identifies ACL policy assigned to the specified user and user profile resource.
* Supported Values:
* "Create"
* "Delete"
* "Read"
* "Update"
* @param role A value that uniquely identifies role for which ACL policy needs to be removed.
* @param data ACL policy object used to delete specified ACL policy resource.
* @returns A promise that is resolved once the removeByRole action has been performed.
* @example UserProfileService.profile.acl.removeByRole('<profile-id>', '<access-action>', '<role-name>')
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
removeByRole: function (profileId, action, role, data) {
return baasicApp.userProfileModule.profile.acl.removeByRole(profileId, action, role, data);
}
},
education: {
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of user education resources matching the given criteria.
* @method
* @param options Query resource options object.
* @returns A promise that is resolved once the find action has been performed.
* @example UserProfileService.profile.education.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
search : '<search-phrase>'
})
.then(function (collection) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
find: function (options) {
return baasicApp.userProfileModule.profile.education.find(options);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the user education resource.
* @method
* @example UserProfileService.profile.education.get(id)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.userProfileModule.profile.education.get(id, options);
},
/**
* Returns a promise that is resolved once the create user education action has been performed; this action creates a new user education resource.
* @method
* @param data An user education object that needs to be inserted into the system.
* @returns A promise that is resolved once the create user education action has been performed.
* @example UserProfileService.profile.education.create({
organizationName : '<organization-name>',
summary: '<summary>',
userId: '<user-id>'
})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
create: function (data) {
return baasicApp.userProfileModule.profile.education.create(data);
},
/**
* Returns a promise that is resolved once the update user education action has been performed; this action updates a user education resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicUserEducationRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.removeParams(education);
* let uri = params['model'].links('put').href;
* ```
* @method
* @param data An user education object used to update specified user education resource.
* @returns A promise that is resolved once the update user education action has been performed.
* @example // education is a resource previously fetched using get action.
education.degree = '<degree>';
UserProfileService.profile.education.update(education)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data) {
return baasicApp.userProfileModule.profile.education.update(data);
},
/**
* Returns a promise that is resolved once the remove action has been performed. This action will remove a user education resource from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicUserEducationRoutDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.removeParams(education);
* let uri = params['model'].links('delete').href;
* ```
* @method
* @example // education is a resource previously fetched using get action.
UserProfileService.profile.education.remove(education)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
remove: function (data) {
return baasicApp.userProfileModule.profile.education.remove(data);
}
},
avatar: {
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns requested file resource.
* @method
* @param id User Profile id which uniquely identifies user avatar resource that needs to be retrieved.
* @param options Query resource options object.
* @returns A promise that is resolved once the get action has been performed.
* @example UserProfileService.profile.avatar.get('<file-id>')
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.userProfileModule.profile.avatar.get(id, 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 `baasicUserProfileAvatarRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.updateParams(fileEntry);
* let uri = params['model'].links('put').href;
* ```
* @method
* @param data Avatar file object that need to be updated in the system.
* @returns A promise that is resolved once the update file action has been performed.
* @example // fileEntry is a file resource previously fetched using get action.
fileEntry.description = '<description>';
UserProfileService.profile.avatar.update(fileEntry)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
});
// perform error handling here
**/
update: function (data) {
return baasicApp.userProfileModule.profile.avatar.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 Profile Files module (For example: file resources from the Media Vault module can be linked directly into the Profile Files module).
* @method
* @param id User Profile id which uniquely identifies user avatar resource that needs to be retrieved.
* @param data A profile avatar file object that need to be inserted into the system.
* @returns A promise that is resolved once the link action has been performed.
* @example UserProfileService.profile.avatar.link(fileObject)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
link: function (id, data) {
return baasicApp.userProfileModule.profile.avatar.link(id, data);
},
/**
* 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. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicUserProfileAvatarRouteDefinition route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.removeParams(fileEntry);
* let uri = params['model'].links('unlink').href;
* ```
* @method
* @param data A profile avatar file object used to remove specific profile avatar from the system.
* @param options Query resource options object.
* @returns A promise that is resolved once the unlink action has been performed.
* @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.
UserProfileService.profile.avatar.remove(fileEntry)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
unlink: function (data, options) {
return baasicApp.userProfileModule.profile.avatar.unlink(data, options);
},
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
* @param data User unique identifier.
* @returns A promise that is resolved once the get action has been performed.
* @example // Request the original file stream
UserProfileService.profile.avatar.streams.get({id: '<file-id>'})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
// Request derived file stream
UserProfileService.profile.avatar.streams.get({id: '<file-id>', width: <width>, height: <height>})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (data) {
return baasicApp.userProfileModule.profile.avatar.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
* @example // Request the original blob
UserProfileService.profile.avatar.streams.getBlob('<file-id>')
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
// Request derived blob
UserProfileService.profile.avatar.streams.getBlob({id: '<file-id>', width: <width>, height: <height>})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
getBlob: function (data) {
return baasicApp.userProfileModule.profile.avatar.streams.getBlob(data);
},
/**
* Returns a promise that is resolved once the create file stream action has been performed; this action will upload the specified blob. For more information on Blob objects please see [Blob Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
* @method
* @param id
* @param data
* @param stream
* @returns A promise that is resolved once the create file stream action has been performed.
* @example UserProfileService.profile.avatar.streams.create('<file-id>', '<filename'>, <blob>)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
create: function (id, data, stream) {
return baasicApp.userProfileModule.profile.avatar.streams.create(id, data, stream);
},
/**
* 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
* @param data
* @param stream
* @returns A promise that is resolved once the update file stream action has been performed.
* @example // Update original file stream
UserProfileService.profile.avatar.streams.update('<file-id>', <file-stream>)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
// Update derived file stream
UserProfileService.profile.avatar.streams.update({id: '<file-id>', width: <width>, height: <height>}, <file-stream>)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data, stream) {
return baasicApp.userProfileModule.profile.avatar.streams.update(data, stream);
}
}
},
skill: {
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of user skill resources matching the given criteria.
* @method
* @param options Query resource options object.
* @returns A promise that is resolved once the find action has been performed.
* @example UserProfileService.profile.skill.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
search : '<search-phrase>'
})
.then(function (collection) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
find: function (options) {
return baasicApp.userProfileModule.profile.skill.find(options);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the user skill resource.
* @method
* @param id User profile id or display name which uniquely identifies user profile whose skill resources need to be retrieved.
* @param options Query resource options object.
* @returns A promise that is resolved once the get action has been performed.
* @example UserProfileService.profile.skill.get()
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.userProfileModule.profile.skill.get(id, options);
},
/**
* Returns a promise that is resolved once the create user skill action has been performed; this action creates a new user skill resource.
* @method
* @param data An user skill object that needs to be inserted into the system.
* @returns A promise that is resolved once the create user skill action has been performed.
* @example UserProfileService.profile.skill.create({ skillName : '<skill-name>', userId: '<user-id>' })
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
create: function (data) {
return baasicApp.userProfileModule.profile.skill.create(data);
},
/**
* Returns a promise that is resolved once the update user skill action has been performed; this action updates a user skill resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicUserSkillRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.removeParams(skill);
* let uri = params['model'].links('put').href;
* ```
* @method
* @param data An user skill object used to update specified user skill resource.
* @returns A promise that is resolved once the update user skill action has been performed.
* @example // skill is a resource previously fetched using get action.
skill.description = '<description>';
UserProfileService.profile.skill.update(skill)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data) {
return baasicApp.userProfileModule.profile.skill.update(data);
},
/**
* Returns a promise that is resolved once the remove action has been performed. This action will remove a user skill resource from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicUserSkillRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.removeParams(skill);
* let uri = params['model'].links('delete').href;
* ```
* @method
* @param data An user skill object used to delete specific user skill resource in the system.
* @returns A promise that is resolved once the remove action has been performed.
* @example // skill is a resource previously fetched using get action.
UserProfileService.profile.skill.remove(skill)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
remove: function (data) {
return baasicApp.userProfileModule.profile.skill.remove(data);
}
},
work: {
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of user work resources matching the given criteria.
* @method
* @param options Query resource options object.
* @returns A promise that is resolved once the find action has been performed.
* @example UserProfileService.profile.work.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
search : '<search-phrase>'
})
.then(function (collection) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
find: function (options) {
return baasicApp.userProfileModule.profile.work.find(options);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the user work resource.
* @method
* @param id User work id which uniquely identifies resource that needs to be retrieved.
* @param options Query resource options object.
* @example UserProfileService.profile.work.get()
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.userProfileModule.profile.work.get(id, options);
},
/**
* Returns a promise that is resolved once the create user work action has been performed; this action creates a new user work resource.
* @method
* @param data An user work object that needs to be inserted into the system.
* @returns A promise that is resolved once the create user work action has been performed.
* @example UserProfileService.profile.work.create({ companyName : '<company-name>', userId: '<user-id>' })
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
create: function (data) {
return baasicApp.userProfileModule.profile.work.create(data);
},
/**
* Returns a promise that is resolved once the update user work action has been performed; this action updates a user work resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicUserWorkRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.updateParams(work);
* let uri = params['model'].links('put').href;
* ```
* @method
* @param data An user work object used to update specified user work resource.
* @returns A promise that is resolved once the update user work action has been performed.
* @example // work is a resource previously fetched using get action.
work.companyName = '<company-name>';
UserProfileService.profile.work.update(work)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
update: function (data) {
return baasicApp.userProfileModule.profile.work.update(data);
},
/**
* Returns a promise that is resolved once the remove action has been performed. This action will remove a user work resource from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicUserWorkRouteDefinition` route template. Here is an example of how a route can be obtained from HAL enabled objects:
* ```
* let params = modelMapper.removeParams(work);
* let uri = params['model'].links('delete').href;
* ```
* @method
* @example // work is a resource previously fetched using get action.
UserProfileService.profile.work.remove(work)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
remove: function (data) {
return baasicApp.userProfileModule.profile.work.remove(data);
}
}
};
},
enumerable: true,
configurable: true
});
Object.defineProperty(UserProfileService.prototype, "company", {
get: function () {
var baasicApp = this.baasicApp;
return {
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of company resources matching the given criteria.
* @method
* @param options Query resource options object.
* @returns A promise that is resolved once the find action has been performed.
* @example UserProfileService.company.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
search : '<search-phrase>'
})
.then(function (collection) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
find: function (options) {
return baasicApp.userProfileModule.company.find(options);
},
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the company resource.
* @method
* @param id Company id which uniquely identifies resource that needs to be retrieved.
* @returns A promise that is resolved once the get action has been performed.
* @param options Query resource options object.
* @example UserProfileService.company.get()
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get: function (id, options) {
return baasicApp.userProfileModule.company.get(id, options);
},
/**
* Returns a promise that is resolved once the create company action has b