angular
    .module('citizenos')
    .factory('VoteDelegation', ['$log', '$resource', 'sLocation', function ($log, $resource, sLocation) {
        $log.debug('citizenos.factory.VoteDelegation');

        var VoteDelegation = $resource(
            sLocation.getAbsoluteUrlApi('/api/users/self/topics/:topicId/votes/:voteId/delegations'),
            {topicId: '@topicId', voteId: '@voteId'},
            {
                save: {
                    method: 'POST',
                    transformResponse: function (data) {
                        if (status > 0 && status < 400) {
                            return angular.fromJson(data).data;
                        } else {
                            return angular.fromJson(data);
                        }
                    }
                },
                delete: {
                    method: 'DELETE'
                }
            }
        );

        return VoteDelegation;
    }]);

{'avg_line_length': 33.964285714285715, 'max_line_length': 105, 'alphanum_fraction': 0.43112513144058884, 'licenses': ['Apache-2.0'], 'repository_name': 'el-tu/citizenos-fe', 'path': 'public/js/factories/VoteDelegation.js', 'size': 951, 'lang': 'JavaScript'}