@mariolazzari/rijks
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -1,2 +0,2 @@ | ||
import ArtObjectDetails from "../types/ArtObjectDetails"; | ||
import ArtObjectDetails from "./ArtObjectDetails"; | ||
interface CollectionDetailsResponse { | ||
@@ -3,0 +3,0 @@ elapsedMilliseconds: number; |
@@ -1,2 +0,2 @@ | ||
import ArtObject from "../types/ArtObject"; | ||
import ArtObject from "./ArtObject"; | ||
import CountFacets from "../types/CountFacets"; | ||
@@ -3,0 +3,0 @@ interface CollectionResponse { |
@@ -407,22 +407,21 @@ 'use strict'; | ||
var _getCollection = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) { | ||
var url; | ||
var _params$searchTerm, searchTerm, _params$page, page, _params$perPage, perPage, involvedMaker, imageOnly, url; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
url = this.baseUrl + "?key=" + this.apiKey; | ||
if (params.searchTerm) { | ||
url += "&q=" + params.searchTerm; | ||
// request params | ||
_params$searchTerm = params.searchTerm, searchTerm = _params$searchTerm === void 0 ? "vermeer" : _params$searchTerm, _params$page = params.page, page = _params$page === void 0 ? 1 : _params$page, _params$perPage = params.perPage, perPage = _params$perPage === void 0 ? 10 : _params$perPage, involvedMaker = params.involvedMaker, imageOnly = params.imageOnly; // build api endpoint | ||
url = this.baseUrl + "?key=" + this.apiKey + "&q=" + searchTerm; | ||
if (page) { | ||
url += "&p=" + page; | ||
} | ||
if (params.involvedMaker) { | ||
url += "&involvedMaker=" + params.involvedMaker; | ||
if (perPage) { | ||
url += "&ps=" + perPage; | ||
} | ||
if (params.imageOnly) { | ||
url += "&imgonly=" + params.imageOnly; | ||
if (involvedMaker) { | ||
url += "&involvedMaker=" + involvedMaker; | ||
} | ||
if (params.page) { | ||
url += "&p=" + params.page; | ||
if (imageOnly) { | ||
url += "&imgonly=" + imageOnly; | ||
} | ||
if (params.perPage) { | ||
url += "&ps=" + params.perPage; | ||
} | ||
_context.next = 8; | ||
@@ -429,0 +428,0 @@ return fetchData(url); |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(){t=function(){return e};var r,e={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(r){f=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var o=Object.create((r&&r.prototype instanceof g?r:g).prototype),a=new T(n||[]);return i(o,"_invoke",{value:O(t,e,a)}),o}function l(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var p="suspendedStart",v="executing",y="completed",d={};function g(){}function m(){}function w(){}var b={};f(b,c,(function(){return this}));var x=Object.getPrototypeOf,L=x&&x(x(G([])));L&&L!==n&&o.call(L,c)&&(b=L);var k=w.prototype=g.prototype=Object.create(b);function E(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function j(t,r){function e(n,i,a,c){var u=l(t[n],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function O(t,e,n){var o=p;return function(i,a){if(o===v)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=l(t,e,n);if("normal"===s.type){if(o=n.done?y:"suspendedYield",s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function _(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,_(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=l(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,d):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function P(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function N(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function G(t){if(t||""===t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(o.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=r,e.done=!0,e};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=w,i(k,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:m,configurable:!0}),m.displayName=f(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===m||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,s,"GeneratorFunction")),t.prototype=Object.create(k),t},e.awrap=function(t){return{__await:t}},E(j.prototype),f(j.prototype,u,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new j(h(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(k),f(k,s,"Generator"),f(k,c,(function(){return this})),f(k,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=G,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(N),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return c.type="throw",c.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),d},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),N(e),d}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;N(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:G(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),d}},e}function r(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function e(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))}}function n(t){return o.apply(this,arguments)}function o(){return(o=e(t().mark((function r(e){var n,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={success:!1,status:500,data:void 0,error:void 0},t.prev=1,t.next=4,fetch(e);case 4:if(n.status=(o=t.sent).status,!o.ok){t.next=13;break}return n.success=!0,t.next=10,o.json();case 10:n.data=t.sent,t.next=14;break;case 13:n.error=o.statusText;case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(1),n.error=t.t0 instanceof Error?t.t0.message:JSON.stringify(t.t0);case 19:return t.prev=19,t.abrupt("return",n);case 22:case"end":return t.stop()}}),r,null,[[1,16,19,22]])})))).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var i=function(){function r(t,r){void 0===r&&(r="en"),this.apiKey="",this.baseUrl="https://www.rijksmuseum.nl/api/",this.apiKey=t,this.baseUrl+=r+"/collection"}var o=r.prototype;return o.getCollection=function(){var r=e(t().mark((function r(e){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=this.baseUrl+"?key="+this.apiKey,e.searchTerm&&(o+="&q="+e.searchTerm),e.involvedMaker&&(o+="&involvedMaker="+e.involvedMaker),e.imageOnly&&(o+="&imgonly="+e.imageOnly),e.page&&(o+="&p="+e.page),e.perPage&&(o+="&ps="+e.perPage),t.next=8,n(o);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),r,this)})));return function(t){return r.apply(this,arguments)}}(),o.getCollectionDetails=function(){var r=e(t().mark((function r(e){var o,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this.baseUrl+"/"+e.objectNumber+"?key="+this.apiKey+"&format="+(void 0===(o=e.format)?"json":o),t.next=4,n(i);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})));return function(t){return r.apply(this,arguments)}}(),o.getCollectionImage=function(){var r=e(t().mark((function r(e){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=this.baseUrl+"/"+e.objectNumber+"/tiles?key="+this.apiKey,t.next=4,n(o);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})));return function(t){return r.apply(this,arguments)}}(),r}();exports.Rijks=i,exports.default=i; | ||
"use strict";function t(){t=function(){return e};var r,e={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(r){f=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var o=Object.create((r&&r.prototype instanceof g?r:g).prototype),a=new G(n||[]);return i(o,"_invoke",{value:O(t,e,a)}),o}function l(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var p="suspendedStart",v="executing",y="completed",d={};function g(){}function m(){}function w(){}var b={};f(b,c,(function(){return this}));var x=Object.getPrototypeOf,L=x&&x(x(T([])));L&&L!==n&&o.call(L,c)&&(b=L);var E=w.prototype=g.prototype=Object.create(b);function k(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function j(t,r){function e(n,i,a,c){var u=l(t[n],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function O(t,e,n){var o=p;return function(i,a){if(o===v)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=l(t,e,n);if("normal"===s.type){if(o=n.done?y:"suspendedYield",s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function _(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,_(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=l(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,d):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function N(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function P(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function G(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function T(t){if(t||""===t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(o.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=r,e.done=!0,e};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=w,i(E,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:m,configurable:!0}),m.displayName=f(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===m||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,s,"GeneratorFunction")),t.prototype=Object.create(E),t},e.awrap=function(t){return{__await:t}},k(j.prototype),f(j.prototype,u,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new j(h(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(E),f(E,s,"Generator"),f(E,c,(function(){return this})),f(E,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,G.prototype={constructor:G,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return c.type="throw",c.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),d},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),P(e),d}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;P(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:T(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),d}},e}function r(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function e(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))}}function n(t){return o.apply(this,arguments)}function o(){return(o=e(t().mark((function r(e){var n,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={success:!1,status:500,data:void 0,error:void 0},t.prev=1,t.next=4,fetch(e);case 4:if(n.status=(o=t.sent).status,!o.ok){t.next=13;break}return n.success=!0,t.next=10,o.json();case 10:n.data=t.sent,t.next=14;break;case 13:n.error=o.statusText;case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(1),n.error=t.t0 instanceof Error?t.t0.message:JSON.stringify(t.t0);case 19:return t.prev=19,t.abrupt("return",n);case 22:case"end":return t.stop()}}),r,null,[[1,16,19,22]])})))).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var i=function(){function r(t,r){void 0===r&&(r="en"),this.apiKey="",this.baseUrl="https://www.rijksmuseum.nl/api/",this.apiKey=t,this.baseUrl+=r+"/collection"}var o=r.prototype;return o.getCollection=function(){var r=e(t().mark((function r(e){var o,i,a,c,u,s,f,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return h=this.baseUrl+"?key="+this.apiKey+"&q="+(void 0===(o=e.searchTerm)?"vermeer":o),(a=void 0===(i=e.page)?1:i)&&(h+="&p="+a),(u=void 0===(c=e.perPage)?10:c)&&(h+="&ps="+u),(s=e.involvedMaker)&&(h+="&involvedMaker="+s),(f=e.imageOnly)&&(h+="&imgonly="+f),t.next=8,n(h);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),r,this)})));return function(t){return r.apply(this,arguments)}}(),o.getCollectionDetails=function(){var r=e(t().mark((function r(e){var o,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this.baseUrl+"/"+e.objectNumber+"?key="+this.apiKey+"&format="+(void 0===(o=e.format)?"json":o),t.next=4,n(i);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})));return function(t){return r.apply(this,arguments)}}(),o.getCollectionImage=function(){var r=e(t().mark((function r(e){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=this.baseUrl+"/"+e.objectNumber+"/tiles?key="+this.apiKey,t.next=4,n(o);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})));return function(t){return r.apply(this,arguments)}}(),r}();exports.Rijks=i,exports.default=i; | ||
//# sourceMappingURL=rijks.cjs.production.min.js.map |
@@ -403,22 +403,21 @@ function _regeneratorRuntime() { | ||
var _getCollection = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) { | ||
var url; | ||
var _params$searchTerm, searchTerm, _params$page, page, _params$perPage, perPage, involvedMaker, imageOnly, url; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
url = this.baseUrl + "?key=" + this.apiKey; | ||
if (params.searchTerm) { | ||
url += "&q=" + params.searchTerm; | ||
// request params | ||
_params$searchTerm = params.searchTerm, searchTerm = _params$searchTerm === void 0 ? "vermeer" : _params$searchTerm, _params$page = params.page, page = _params$page === void 0 ? 1 : _params$page, _params$perPage = params.perPage, perPage = _params$perPage === void 0 ? 10 : _params$perPage, involvedMaker = params.involvedMaker, imageOnly = params.imageOnly; // build api endpoint | ||
url = this.baseUrl + "?key=" + this.apiKey + "&q=" + searchTerm; | ||
if (page) { | ||
url += "&p=" + page; | ||
} | ||
if (params.involvedMaker) { | ||
url += "&involvedMaker=" + params.involvedMaker; | ||
if (perPage) { | ||
url += "&ps=" + perPage; | ||
} | ||
if (params.imageOnly) { | ||
url += "&imgonly=" + params.imageOnly; | ||
if (involvedMaker) { | ||
url += "&involvedMaker=" + involvedMaker; | ||
} | ||
if (params.page) { | ||
url += "&p=" + params.page; | ||
if (imageOnly) { | ||
url += "&imgonly=" + imageOnly; | ||
} | ||
if (params.perPage) { | ||
url += "&ps=" + params.perPage; | ||
} | ||
_context.next = 8; | ||
@@ -425,0 +424,0 @@ return fetchData(url); |
{ | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
277
README.md
@@ -1,54 +0,52 @@ | ||
[![npm version](https://badge.fury.io/js/angular2-expandable-list.svg)](https://badge.fury.io/js/angular2-expandable-list) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
- [Rijks](#rijks) | ||
- [Gettting started](#gettting-started) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Rijks class](#rijks-class) | ||
- [Constructor](#constructor) | ||
- [Result](#result) | ||
- [Types](#types) | ||
- [Culture type](#culture-type) | ||
- [Sort type](#sort-type) | ||
- [CountFacets](#countfacets) | ||
- [ArtObject](#artobject) | ||
- [Methods](#methods) | ||
- [getCollection](#getcollection) | ||
- [CollectionRequest](#collectionrequest) | ||
- [CollectionResponse](#collectionresponse) | ||
- [getCollectionDetails](#getcollectiondetails) | ||
- [Authors](#authors) | ||
- [Links](#links) | ||
# Rijks | ||
> Rijks museum APIs client | ||
# Rijks | ||
___ | ||
## Prerequisites | ||
This package is a wrapper around the public REST APIs of Rijksmuseum (Amsterdam). | ||
Before you can use this wrapper or the API, you need a api-key. You can read more on how to obtain the API key and the parameters you can use from this page: [Rijks museum APIs](http://nodejs.org/) | ||
**Prerequisites** | ||
This project requires NodeJS (version 18 or later) and NPM. | ||
[Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install. | ||
To make sure you have them available on your machine, | ||
try running the following command. | ||
In order to use this package, you need an api key: You can read more on how to obtain the API key on [this page](http://rijksmuseum.github.io). | ||
This package requires [NodeJS](https://nodejs.org) (version 18 or later) and a node package manager (Npm, Yarn, Pnpm or Bun). | ||
To make sure you have them available on your machine, try running the following command. | ||
```sh | ||
$ npm -v && node -v | ||
6.4.1 | ||
v8.16.0 | ||
v10.1.0 | ||
v18.18.0 | ||
``` | ||
___ | ||
## Table of contents | ||
- [Rijks](#rijks) | ||
- [Prerequisites](#prerequisites) | ||
- [Table of contents](#table-of-contents) | ||
- [Getting Started](#getting-started) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Serving the app](#serving-the-app) | ||
- [Running the tests](#running-the-tests) | ||
- [Building a distribution version](#building-a-distribution-version) | ||
- [API](#api) | ||
- [Rijks](#rijks-1) | ||
- [Options](#options) | ||
- [getCollection](#getcollection) | ||
- [getCollectionDetails](#getcollectiondetails) | ||
- [getCollectionImage](#getcollectionimage) | ||
- [Contributing](#contributing) | ||
- [Credits](#credits) | ||
- [Built With](#built-with) | ||
- [Versioning](#versioning) | ||
- [Authors](#authors) | ||
- [License](#license) | ||
## Gettting started | ||
## Getting Started | ||
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. | ||
___ | ||
## Installation | ||
**BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites) | ||
**BEFORE YOU INSTALL**: please read the prerequisites. | ||
@@ -65,118 +63,199 @@ Start with cloning this repo on your local machine: | ||
```sh | ||
$ npm install @mariolazzari/rijks | ||
npm install @mariolazzari/rijks | ||
``` | ||
___ | ||
Or if you prefer using Yarn: | ||
## Usage | ||
```sh | ||
$ yarn add @mariolazzari/rijks | ||
**Import package** | ||
```js | ||
import Rijks from "@mariolazzari/rijks" | ||
``` | ||
## Usage | ||
### Serving the app | ||
**Watch mode** | ||
```sh | ||
$ npm start | ||
npm test | ||
``` | ||
### Running the tests | ||
**Unit testing** | ||
```sh | ||
$ npm test | ||
npm test | ||
``` | ||
### Building a distribution version | ||
**Bulding new version** | ||
```sh | ||
$ npm run build | ||
npm build | ||
``` | ||
This task will create a distribution version of the project | ||
inside your local `dist/` folder | ||
This task will create a distribution version of the project inside your local dist/ folder | ||
## API | ||
## Rijks class | ||
### Rijks | ||
Rijks **class++ content handles all the requests and the responses to the thrre main Rijks museum REST APIs. | ||
### Constructor | ||
In order to initialize Rijks **client**: | ||
```js | ||
const rijks = new Rijks(apiKey: string, culture: Culture = "en") | ||
const rijks = new Rijks(API_KEY, culture?) | ||
``` | ||
Supported options for the `Rijks` class are listed below. | ||
Constructor parameters | ||
#### Options | ||
| Parameter | Type | Required | Default | | ||
| --------- | ------- | :------: | ------- | | ||
| apiKey | string | Yes | | | ||
| culture | Culture | No | en | | ||
`apiKey` | ||
### Result | ||
| Type | Default value | | ||
| --- | --- | | ||
| string | '' | | ||
This **interface** handles all REST APIs responses. | ||
`culture` | ||
```ts | ||
interface Result<T> { | ||
success: boolean; | ||
status: number; | ||
data?: T; | ||
error?: string; | ||
} | ||
``` | ||
| Type | Default value | | ||
| --- | --- | | ||
| string | 'en' | | ||
### Types | ||
In order to implement all features, the following common types have been implemended: | ||
### getCollection | ||
#### Culture type | ||
```js | ||
const collection: CollectionResponse = await rijks.getCollection(params: CollectionRequest) | ||
**Culture** type contains all supported cultures. | ||
```ts | ||
type Culture = "en | nl" | ||
``` | ||
Perform an asynchronous http request against Rijks collection api. | ||
#### Sort type | ||
### getCollectionDetails | ||
**Sort** type contains all supported sorting criterias. | ||
```js | ||
const collectionDetails: CollectionDetailsResponse= await rijks.getCollectionDetails(params:CollectionDetailsRequest) | ||
```ts | ||
type Sort = | "relevance" | ||
| "objectYype" | ||
| "chronologic" | ||
| "achronologic" | ||
| "artist" | ||
| "artistDesc" | ||
``` | ||
Perform an asynchronous http request against Rijks collection details api. | ||
#### CountFacets | ||
### getCollectionImage | ||
This **type** has the following definition: | ||
```ts | ||
type CountFacets = { | ||
hasimage: number; | ||
ondisplay: number; | ||
}; | ||
``` | ||
#### ArtObject | ||
```js | ||
const collectionImage: CollectionImageResponse = await rijks.getCollectionImage(params: CollectionImageRequest) | ||
This **interface** has the following structure: | ||
```ts | ||
interface ArtObject { | ||
links: Link; | ||
id: string; | ||
objectNumber: string; | ||
title: string; | ||
hasImage: boolean; | ||
principalOrFirstMaker: string; | ||
longTitle: string; | ||
showImage: boolean; | ||
permitDownload: boolean; | ||
webImage?: Image; | ||
headerImage?: Image; | ||
productionPlaces: string[]; | ||
}; | ||
``` | ||
Perform an asynchronous http request against Rijks collection image api. | ||
### Methods | ||
## Contributing | ||
Rijks client includes the following three methonds: | ||
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. | ||
#### getCollection | ||
1. Fork it! | ||
2. Create your feature branch: `git checkout -b my-new-feature` | ||
3. Add your changes: `git add .` | ||
4. Commit your changes: `git commit -am 'Add some feature'` | ||
5. Push to the branch: `git push origin my-new-feature` | ||
6. Submit a pull request :sunglasses: | ||
*Description* | ||
## Credits | ||
This asynchronous **method** handles `GET /api/[culture]/collection` REST API. | ||
TODO: Write credits | ||
*Prototype* | ||
## Built With | ||
```ts | ||
async getCollection(params: CollectionRequest): Promise<Result<CollectionResponse>> | ||
``` | ||
* Typescript | ||
* Visual Studio Code | ||
* Vitest | ||
*Sample code* | ||
## Versioning | ||
```ts | ||
const params: CollectionRequest = {searchTerm: "Vermeer"} | ||
const collection: CollectionResponse = await rijks.getCollection(params) | ||
``` | ||
##### CollectionRequest | ||
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/mariolazzari/tags). | ||
This **interface** contains all the possible parameters handled by **getCollection** method. | ||
| Parameter | Type | Required | Default | | ||
| ------------- | ------- | :------: | ------- | | ||
| searchTerm | string | Yes | | | ||
| page | number | Yes | 1 | | ||
| perPage | number | Yes | 10 | | ||
| format | Format | | json | | ||
| culture | Culture | | en | | ||
| involvedMaker | string | | | | ||
| type | string | | | | ||
| material | string | | | | ||
| technique | string | | | | ||
| period | string | | | | ||
| hex | string | | | | ||
| imageOnly | string | | true | | ||
| topPieces | string | | true | | ||
| sort | Sort | | | | ||
##### CollectionResponse | ||
This **interface** contains all the values returned by **getCollection** method | ||
| Parameter | Type | Required | Default | | ||
| ------------------- | ------------ | :------: | ------- | | ||
| elapsedMilliseconds | number | Yes | 0 | | ||
| count | number | Yes | 0 | | ||
| countFacets | CountFacets | | | | ||
| artObjects | ArtObjects[] | | [] | | ||
**** | ||
#### getCollectionDetails | ||
*Description* | ||
This **method** handles `GET /api/[culture]/collection/[object-number]` REST API. | ||
*Prototype* | ||
```ts | ||
async getCollectionDetails(params:CollectionDetailsRequst) : Promise<Result<CollectionDetailsResponse>> | ||
``` | ||
## Authors | ||
* **Mario Lazzari** - *Initial work* - [mariolazzari](https://github.com/mariolazzari) | ||
* **Mario Lazzari** - *Initial work* | ||
See also the list of [contributors](https://github.com/mariolazzari/rijks/contributors) who participated in this project. | ||
## Links | ||
## License | ||
* Demo [app](https://www.mariolazzari.it/hobbies/art/rijks) | ||
* My personal [site](https://mariolazzari.it) | ||
* My [github](https://github.com/mariolazzari) profile | ||
[MIT License](https://andreasonny.mit-license.org/2019) |
@@ -1,2 +0,2 @@ | ||
import ArtObjectDetails from "../types/ArtObjectDetails"; | ||
import ArtObjectDetails from "./ArtObjectDetails"; | ||
@@ -3,0 +3,0 @@ interface CollectionDetailsResponse { |
@@ -1,2 +0,2 @@ | ||
import ArtObject from "../types/ArtObject"; | ||
import ArtObject from "./ArtObject"; | ||
import CountFacets from "../types/CountFacets"; | ||
@@ -3,0 +3,0 @@ |
@@ -20,19 +20,25 @@ import Culture from "./types/Culture"; | ||
public async getCollection(params: CollectionRequest) { | ||
let url = `${this.baseUrl}?key=${this.apiKey}`; | ||
// request params | ||
const { | ||
searchTerm = "vermeer", | ||
page = 1, | ||
perPage = 10, | ||
involvedMaker, | ||
imageOnly, | ||
} = params; | ||
if (params.searchTerm) { | ||
url += `&q=${params.searchTerm}`; | ||
// build api endpoint | ||
let url = `${this.baseUrl}?key=${this.apiKey}&q=${searchTerm}`; | ||
if (page) { | ||
url += `&p=${page}`; | ||
} | ||
if (params.involvedMaker) { | ||
url += `&involvedMaker=${params.involvedMaker}`; | ||
if (perPage) { | ||
url += `&ps=${perPage}`; | ||
} | ||
if (params.imageOnly) { | ||
url += `&imgonly=${params.imageOnly}`; | ||
if (involvedMaker) { | ||
url += `&involvedMaker=${involvedMaker}`; | ||
} | ||
if (params.page) { | ||
url += `&p=${params.page}`; | ||
if (imageOnly) { | ||
url += `&imgonly=${imageOnly}`; | ||
} | ||
if (params.perPage) { | ||
url += `&ps=${params.perPage}`; | ||
} | ||
@@ -39,0 +45,0 @@ return await fetchData<CollectionResponse>(url); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
87277
1447
261