-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjsonrpc.min.js
7 lines (7 loc) · 1.11 KB
/
jsonrpc.min.js
1
2
3
4
5
6
7
/**!
* angular-jsonrpc v0.1.4 [build 2015-10-04]
* @copyright 2015 Arunjit Singh <[email protected]>. All Rights Reserved.
* @license MIT; see LICENCE.
* [https://github.com/ajsd/angular-jsonrpc.git]
*/
"use strict";angular.module("jsonrpc",["uuid"]).provider("jsonrpc",function(){var a=this.defaults={};a.basePath="/rpc",this.$get=["$http","$q","uuid4",function(b,c,d){function e(e,f){var g=d.generate(),h={jsonrpc:"2.0",method:e.method,id:g};return angular.isDefined(e.data)&&(h.params=e.data),b.post(e.path||a.basePath,h,f).then(function(a){return a.data.hasOwnProperty("error")?c.reject(a.data.error):a.data.result})}function f(a,b){this.serviceName=a,this.path=b}return e.request=function(a,b,c,d){return arguments.length<4&&(d=c,c=b,b=a,a=null),e({path:a,method:b,data:c},d)},f.prototype.createMethod=function(a,b){var c=this.path,d=a;return this.serviceName&&(d=this.serviceName+"."+d),function(a){return e.request(c,d,a,b)}},e.newService=function(a,b){return new f(a,b)},e.setBasePath=function(b){return a.basePath=b,this},e.getBasePath=function(){return a.basePath},e}],this.setBasePath=function(b){return a.basePath=b,this}});