"use strict"; (function () { 'use strict'; angular.module('userModule') .service('userService', ['$resource', function ($resource) { var resource = $resource('', {}, { getFullUserData: { url: '/smartit/restapi/person/supportgroupperson/:userId', method: 'GET', isArray: true }, getUpdatesFeed: { url: '/smartit/rest/v2/following/stream', method: 'GET', isArray: true }, getUserPreferences: { url: '/smartit/rest/v2/preference/details/search', method: 'GET', isArray: true }, setUserPreferences: { url: '/smartit/rest/preference/update', method: 'POST', isArray: true }, removeUserPreferences: { url: '/smartit/rest/preference/delete/:id', method: 'DELETE', isArray: true }, searchUserByName: { url: '/smartit/rest/person/search?name=:searchStr&thumbnail=true', method: 'GET', isArray: true }, getBCMIntegrationConfig: { url: '/smartit/rest/bcm/configuration', method: 'GET', isArray: false }, doBCMLogin: { url: '/smartit/rest/bcm/admin/connectivity', method: 'POST', isArray: false } }), defaultPreferenceParams = { clientType: 'UC' }; this.getFullUserData = function (id) { return resource.getFullUserData({ userId: id }).$promise.then(function (responce) { return new UserVO().build(responce[0].items[0]); }); }; this.getUpdatesFeed = function (criteria) { return resource.getUpdatesFeed(criteria).$promise.then(function (data) { var result = {}; result.feedItems = data[0].items.map(function (item) { return new FeedItemVO().build(item); }); if (data[0].followCount) { result.followCount = data[0].followCount; } return result; }); }; this.getUserPreferences = function (params) { return resource.getUserPreferences(angular.extend(params, defaultPreferenceParams)).$promise; }; this.updateUserPreferences = function (params) { return resource.setUserPreferences(angular.extend(params, defaultPreferenceParams)).$promise; }; this.removeUserPreferences = function (id) { return resource.removeUserPreferences({ id: id }).$promise; }; this.doBCMLogin = function (username, password) { return resource.doBCMLogin({ 'username': username, 'password': password }).$promise; }; this.getBCMIntegrationConfig = function () { return resource.getBCMIntegrationConfig().$promise; }; this.searchUserByName = function (str) { return resource.searchUserByName({ searchStr: str }).$promise .then(function (response) { console.log('searchUserByName', response); return response[0].items; }); }; }]); }());