rest-client-sdk
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -19,3 +19,3 @@ Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _urijs=require('urijs');var _urijs2=_interopRequireDefault(_urijs); | ||
{ | ||
{var pathParameters=arguments.length<=0||arguments[0]===undefined?{}:arguments[0]; | ||
throw new Error('AbstractClient::getPathBase can not be called directly.\n You must implement "getPathBase" method.');}},{key:'getName',value:function getName() | ||
@@ -30,4 +30,4 @@ | ||
id){var queryParam=arguments.length<=1||arguments[1]===undefined?{}:arguments[1]; | ||
var url=this._generateUrlFromParams(queryParam,id); | ||
id){var queryParam=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];var pathParameters=arguments.length<=2||arguments[2]===undefined?{}:arguments[2]; | ||
var url=this._generateUrlFromParams(queryParam,pathParameters,id); | ||
@@ -37,4 +37,4 @@ return this.createEntityFromJsonResponse(this.authorizedFetch(url),'item');}},{key:'findBy',value:function findBy( | ||
criteria){ | ||
var url=this._generateUrlFromParams(criteria); | ||
criteria){var pathParameters=arguments.length<=1||arguments[1]===undefined?{}:arguments[1]; | ||
var url=this._generateUrlFromParams(criteria,pathParameters); | ||
@@ -44,8 +44,8 @@ return this.createEntityFromJsonResponse(this.authorizedFetch(url),'list');}},{key:'findAll',value:function findAll() | ||
{ | ||
return this.findBy({});}},{key:'create',value:function create( | ||
{var pathParameters=arguments.length<=0||arguments[0]===undefined?{}:arguments[0]; | ||
return this.findBy({},pathParameters);}},{key:'create',value:function create( | ||
entity){ | ||
var url=this.getPathBase(); | ||
entity){var pathParameters=arguments.length<=1||arguments[1]===undefined?{}:arguments[1]; | ||
var url=this.getPathBase(pathParameters); | ||
@@ -100,2 +100,8 @@ return this.createEntityFromJsonResponse( | ||
if(this.sdk.config.prefix){ | ||
var segments=url.segment(); | ||
segments.unshift(this.sdk.config.prefix); | ||
url.segment(segments);} | ||
return url;}},{key:'authorizedFetch',value:function authorizedFetch( | ||
@@ -110,3 +116,3 @@ | ||
queryParam){var id=arguments.length<=1||arguments[1]===undefined?null:arguments[1]; | ||
queryParam){var pathParameters=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];var id=arguments.length<=2||arguments[2]===undefined?null:arguments[2]; | ||
var params=queryParam; | ||
@@ -117,3 +123,3 @@ if(this.sdk.config.useDefaultParameters){ | ||
var url=new _urijs2.default(!!id?this.getPathBase()+'/'+id:this.getPathBase()); | ||
var url=new _urijs2.default(!!id?this.getPathBase(pathParameters)+'/'+id:this.getPathBase(pathParameters)); | ||
if(params){ | ||
@@ -120,0 +126,0 @@ url.addSearch(params);} |
{ | ||
"name": "rest-client-sdk", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Rest Client SDK for API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -53,2 +53,4 @@ Mapado Rest Client JS SDK [![Build Status](https://travis-ci.org/mapado/rest-client-js-sdk.svg?branch=master)](https://travis-ci.org/mapado/rest-client-js-sdk) | ||
port: 443, | ||
segment: '/my-api', | ||
useDefaultParameters: true, | ||
}; // path and scheme are mandatory | ||
@@ -55,0 +57,0 @@ |
35607
399
94