Created
April 24, 2015 04:36
-
-
Save fastcodecoq/c486ce461263e1b7ed5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function apiFactory($http){ | |
| this.uri = ''; | |
| this.base_url = "api/url/metodo"; | |
| // console.log(this.base_url, 'base api url'); | |
| this.usuario = function(id){ (id) ? this.uri += '/usuario/'+id : this.uri += '/usuario'; return this; } | |
| this.empresa = function(id){ (id) ? this.uri += '/empresa/'+id : this.uri += '/empresa'; return this; } | |
| this.ordenServicio = function(id){ (id) ? this.uri += '/orden_servicio/'+id : this.uri += '/orden_servicio'; return this; } | |
| this.solicitudServicio = function(id){ (id) ? this.uri += '/solicitud_servicio/'+id : this.uri += '/solicitud_servicio'; return this; } | |
| this.perfilLaboral = function(id){ (id) ? this.uri += '/perfil_laboral/'+id : this.uri += '/perfil_laboral'; return this; } | |
| this.candidato = function(id){ (id) ? this.uri += '/usuario/'+ id : this.uri += '/usuario/type/candidato'; return this; } | |
| this.contacto = function(id){ (id) ? this.uri += '/contacts/' + id : this.uri += '/contacts'; return this; } | |
| this.consultor = function(id){ (id) ? this.uri += '/usuario/' + id : this.uri += '/usuario/type/consultor'; return this; } | |
| this.coordinador = function(id){ (id) ? this.uri += '/usuario/' + id : this.uri += '/usuario/type/coordinador'; return this; } | |
| this.cargo = function(id){ (id) ? this.uri += '/cargo/' + id : this.uri += '/cargo'; return this; } | |
| this.notificacion = function(id){ (id) ? this.uri += '/notifi3r/' + id : this.uri += '/notifi3r'; return this; } | |
| this.event = function(id){ (id) ? this.uri += '/event/' + id : this.uri += '/event'; return this; } | |
| this.reset = this.destroy = function(){this.uri = ''}; | |
| this.get = function(){ if (this.uri) { var req = $http.get(this.base_url + this.uri); this.reset(); return req; } } | |
| this.create = function(data){ if (this.uri) { var req = $http.post(this.base_url + this.uri, data || {}); this.reset(); return req; } } | |
| this.del = function(){ if (this.uri) { var req = $http.delete(this.base_url + this.uri); this.reset(); return req; } } | |
| this.update = function(data){ if (this.uri) { var req = $http.put(this.base_url + this.uri, data || {}); this.reset(); return req; } } | |
| return this; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment