datocms-client
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -37,3 +37,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.DatoCmsClient = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
},{"./EntitiesRepo":11,"./Item":13,"pluralize":5}],15:[function(require,module,exports){ | ||
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_request=require("./request"),_queryString=require("query-string"),_queryString2=_interopRequireDefault(_queryString),Session=function(){function e(t,r,n){_classCallCheck(this,e),this.baseUrl=t,this.domain=r,this.token=n,this.defaultHeaders={"X-Site-Domain":r,Authorization:"Bearer "+n}}return _createClass(e,[{key:"getSite",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return this.get("/site",e,t)}},{key:"getItems",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return this.get("/items",e,t)}},{key:"get",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=Object.keys(t).length?"?"+_queryString2["default"].stringify(t):"";return(0,_request.get)(""+this.baseUrl+e+n,Object.assign({headers:this.defaultHeaders},r))}}]),e}();exports["default"]=Session,module.exports=exports["default"]; | ||
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_request=require("./request"),_queryString=require("query-string"),_queryString2=_interopRequireDefault(_queryString),Session=function(){function e(t,r,n){_classCallCheck(this,e),this.baseUrl=t,this.domain=r,this.token=n,this.defaultHeaders={"X-Site-Domain":r,Authorization:"Bearer "+n}}return _createClass(e,[{key:"getSite",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return this.get("/site",e,t)}},{key:"getItems",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return this.get("/items",e,t)}},{key:"getItem",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return this.get("/items/"+e,t,r)}},{key:"updateItem",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];return this.put("/items/"+e,t,r,n)}},{key:"get",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=Object.keys(t).length?"?"+_queryString2["default"].stringify(t):"";return(0,_request.get)(""+this.baseUrl+e+n,Object.assign({headers:this.defaultHeaders},r))}},{key:"put",value:function(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],i=Object.keys(r).length?"?"+_queryString2["default"].stringify(r):"";return(0,_request.put)(""+this.baseUrl+e+i,t,Object.assign({headers:this.defaultHeaders},n))}}]),e}();exports["default"]=Session,module.exports=exports["default"]; | ||
@@ -40,0 +40,0 @@ },{"./request":20,"query-string":6}],16:[function(require,module,exports){ |
@@ -50,2 +50,18 @@ 'use strict'; | ||
}, { | ||
key: 'getItem', | ||
value: function getItem(id) { | ||
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
return this.get('/items/' + id, params, options); | ||
} | ||
}, { | ||
key: 'updateItem', | ||
value: function updateItem(id, body) { | ||
var params = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
return this.put('/items/' + id, body, params, options); | ||
} | ||
}, { | ||
key: 'get', | ||
@@ -60,2 +76,12 @@ value: function get(url) { | ||
} | ||
}, { | ||
key: 'put', | ||
value: function put(url, body) { | ||
var params = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
var query = Object.keys(params).length ? '?' + _queryString2.default.stringify(params) : ''; | ||
return (0, _request.put)('' + this.baseUrl + url + query, body, Object.assign({ headers: this.defaultHeaders }, options)); | ||
} | ||
}]); | ||
@@ -62,0 +88,0 @@ |
{ | ||
"name": "datocms-client", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "DatoCMS API client", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
284286
2348