/* global angular, api_url */

angular.module("app").service("RolesService", [
    '$uhttp',
    function ($uhttp) {
        var controller = "roles/";
        // ----- GET -----
        this.getAllRoles = function () {
            return $uhttp({
                url: api_url + controller + 'get_all_roles'
            });
        };
        this.getAllRolesActivos = function () {
            return $uhttp({
                url: api_url + controller + 'get_all_roles_activos'
            });
        };
        this.getRolById = function (rol_id) {
            return $uhttp({
                url: api_url + controller + 'get_rol_by_id',
                params: {id: rol_id}
            });
        };
        // ----- POST -----
        this.create = function (data) {
            return $uhttp({
                url: api_url + controller + 'create',
                method: "POST",
                data: data
            });
        };
        this.update = function (rol_id, data) {
            return $uhttp({
                url: api_url + controller + 'update',
                method: "POST",
                data: data,
                params: {id: rol_id}
            });
        };
    }
]);