unsplash-js
Advanced tools
Comparing version 6.2.0 to 6.3.0
# Changelog | ||
## 6.3.0 | ||
### Changes | ||
- Deprecate `photos.photoDownload` in favor of `photos.trackDownload` to better clarify method usage. `photoDownload` will continue to be supported until version 7.0. | ||
## 6.2.0 | ||
@@ -18,3 +24,3 @@ | ||
orientation: "landscape", | ||
color: "brown", // new | ||
color: "green", // new | ||
orderBy: "relevant" // new | ||
@@ -21,0 +27,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Unsplash=e():t.Unsplash=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return"function"==typeof t.json?t.json():t}Object.defineProperty(e,"__esModule",{value:!0});var u=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();e.toJson=i;var s=r(1),a=r(2),c=r(4),l=n(c),f=r(6),h=n(f),p=r(10),d=n(p),v=r(7),y=n(v),_=r(5),g=n(_),m=r(8),b=n(m),q=r(9),j=n(q),O=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this._apiUrl=e.apiUrl||s.API_URL,this._apiVersion=e.apiVersion||s.API_VERSION,this._accessKey=e.accessKey,this._secret=e.secret,this._callbackUrl=e.callbackUrl,this._bearerToken=e.bearerToken,this._headers=e.headers||{},this._timeout=e.timeout||0,this.auth=l["default"].bind(this)(),this.currentUser=h["default"].bind(this)(),this.users=d["default"].bind(this)(),this.photos=y["default"].bind(this)(),this.collections=g["default"].bind(this)(),this.search=b["default"].bind(this)(),this.stats=j["default"].bind(this)()}return u(t,[{key:"request",value:function(t){var e=a.buildFetchOptions.bind(this)(t),r=e.url,n=e.options;return fetch(r,n)}}]),t}();e["default"]=O},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.API_URL="https://api.unsplash.com",e.API_VERSION="v1",e.OAUTH_AUTHORIZE_URL="https://unsplash.com/oauth/authorize",e.OAUTH_TOKEN_URL="https://unsplash.com/oauth/token"},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t){return(0,l["default"])(t)}function i(t){return(0,h["default"])(t,{},!0)}function u(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.method,r=t.query,n=t.oauth,i=t.body,u=n===!0?t.url:""+this._apiUrl+t.url,c=s({},this._headers,t.headers,{"Accept-Version":this._apiVersion,Authorization:this._bearerToken?"Bearer "+this._bearerToken:"Client-ID "+this._accessKey}),l=this._timeout;return i&&(c["Content-Type"]="application/x-www-form-urlencoded"),r&&(u=decodeURIComponent(u+"?"+(0,a.stringify)(r))),{url:u,options:{method:e,headers:c,timeout:l,body:"GET"!==e&&i?o(i):void 0}}}Object.defineProperty(e,"__esModule",{value:!0});var s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.formUrlEncode=o,e.getUrlComponents=i,e.buildFetchOptions=u;var a=r(3),c=r(11),l=n(c),f=r(17),h=n(f)},function(t,e,r){"use strict";e.decode=e.parse=r(13),e.encode=e.stringify=r(14)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=this;return{getAuthenticationUrl:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["public"],r=u["default"].stringify({client_id:t._accessKey,redirect_uri:t._callbackUrl,response_type:"code",scope:e.length>1?e.join("+"):e.toString()});return decodeURIComponent(s.OAUTH_AUTHORIZE_URL+"?"+r)},userAuthentication:function(e){var r=s.OAUTH_TOKEN_URL;return t.request({url:r,method:"POST",body:{client_id:t._accessKey,client_secret:t._secret,redirect_uri:t._callbackUrl,grant_type:"authorization_code",code:e},oauth:!0})},setBearerToken:function(e){e&&(t._bearerToken=e)}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=o;var i=r(3),u=n(i),s=r(1)},function(t,e){"use strict";function r(){var t=this;return{listCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n="/collections",o={page:e,per_page:r};return t.request({url:n,method:"GET",query:o})},getCollection:n.bind(this),getCollectionPhotos:o.bind(this),createCollection:i.bind(this,null),updateCollection:i.bind(this),deleteCollection:function(e){var r="/collections/"+e;return t.request({url:r,method:"DELETE"})},addPhotoToCollection:function(e,r){var n="/collections/"+e+"/add";return t.request({url:n,method:"POST",body:{photo_id:r}})},removePhotoFromCollection:function(e,r){var n="/collections/"+e+"/remove?photo_id="+r;return t.request({url:n,method:"DELETE"})},listRelatedCollections:function(e){var r="/collections/"+e+"/related";return t.request({url:r,method:"GET"})}}}function n(t){return this.request({url:"/collections/"+t,method:"GET"})}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i={page:e,per_page:r,order_by:n,orientation:o.orientation};return this.request({url:"/collections/"+t+"/photos",method:"GET",query:i})}function i(t,e,r,n){var o=t?"/collections/"+t:"/collections",i={title:e,description:r,"private":n};return this.request({url:o,method:t?"PUT":"POST",body:i})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{profile:function(){var e="/me";return t.request({url:e,method:"GET"})},updateProfile:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="/me",n=e.username,o=e.firstName,i=e.lastName,u=e.email,s=e.url,a=e.location,c=e.bio,l=e.instagramUsername,f={username:n,first_name:o,last_name:i,email:u,url:s,location:a,bio:c,instagram_username:l};return Object.keys(f).forEach(function(t){f[t]||delete f[t]}),t.request({url:r,method:"PUT",body:f})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=this;return{listPhotos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"latest",o="/photos",i={page:e,per_page:r,order_by:n};return t.request({url:o,method:"GET",query:i})},getPhoto:function(e){var r="/photos/"+e;return t.request({url:r,method:"GET"})},getPhotoStats:function(e){var r="/photos/"+e+"/statistics";return t.request({url:r,method:"GET"})},getRandomPhoto:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="/photos/random",n=e.collections||[],o={featured:e.featured,username:e.username,orientation:e.orientation,collections:n.join(),query:e.query,c:e.cacheBuster||(new Date).getTime(),count:e.count};return Object.keys(o).forEach(function(t){o[t]||delete o[t]}),t.request({url:r,method:"GET",query:o})},likePhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+e+"/like";return t.request({url:r,method:"POST"})},unlikePhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+e+"/like";return t.request({url:r,method:"DELETE"})},downloadPhoto:function(e){var r=(0,s["default"])(e,"links.download_location",void 0);if(void 0===r)throw new Error("Object received is not a photo. "+e);var n=(0,i.getUrlComponents)(r);return t.request({url:n.pathname,method:"GET",query:n.query})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=o;var i=r(2),u=r(12),s=n(u)},function(t,e){"use strict";function r(){var t=this;return{photos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=o.collections||[],u={query:encodeURIComponent(e),per_page:n,orientation:o.orientation,content_filter:o.contentFilter,color:o.color,order_by:o.orderBy,lang:o.lang,collections:i.join(),page:r};return Object.keys(u).forEach(function(t){u[t]||"query"==t||delete u[t]}),t.request({url:"/search/photos",method:"GET",query:u})},users:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o={query:encodeURIComponent(e),per_page:n,page:r};return t.request({url:"/search/users",method:"GET",query:o})},collections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o={query:encodeURIComponent(e),per_page:n,page:r};return t.request({url:"/search/collections",method:"GET",query:o})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{total:function(){var e="/stats/total";return t.request({url:e,method:"GET"})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{profile:function(e){var r="/users/"+e;return t.request({url:r,method:"GET"})},photos:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},u=i.stats||!1,s="/users/"+e+"/photos",a={page:r,per_page:n,order_by:o,orientation:i.orientation,stats:u};return t.request({url:s,method:"GET",query:a})},likes:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},u="/users/"+e+"/likes",s={page:r,per_page:n,order_by:o,orientation:i.orientation};return t.request({url:u,method:"GET",query:s})},collections:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"published",i="/users/"+e+"/collections",u={page:r,per_page:n,order_by:o};return t.request({url:i,method:"GET",query:u})},statistics:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"days",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,o="/users/"+e+"/statistics",i={resolution:r,quantity:n};return t.request({url:o,method:"GET",query:i})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){t.exports=function(t,e){function r(t){return String(t).replace(/[^ !'()~\*]*/g,encodeURIComponent).replace(/ /g,"+").replace(/[!'()~\*]/g,function(t){return"%"+t.charCodeAt().toString(16).slice(-2).toUpperCase()})}function n(t){var r=Object.keys(t);return e.sorted?r.sort():r}function o(t){return t.filter(function(t){return t}).join("&")}function i(t,e){return o(n(e).map(function(r){return s(t+"["+r+"]",e[r])}))}function u(t,e){return o(e.map(function(e){return s(t+"[]",e)}))}function s(t,n){var o=typeof n,s=null;return n===s?s=e.ignorenull?s:r(t)+"="+s:/string|number|boolean/.test(o)?s=r(t)+"="+r(n):Array.isArray(n)?s=u(t,n):"object"===o&&(s=i(t,n)),s}return e="object"==typeof e?e:{},o(n(t).map(function(e){return s(e,t[e])}))}},function(t,e){(function(e){function r(t,e){return null==t?void 0:t[e]}function n(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(r){}return e}function o(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function i(){this.__data__=yt?yt(null):{}}function u(t){return this.has(t)&&delete this.__data__[t]}function s(t){var e=this.__data__;if(yt){var r=e[t];return r===z?void 0:r}return lt.call(e,t)?e[t]:void 0}function a(t){var e=this.__data__;return yt?void 0!==e[t]:lt.call(e,t)}function c(t,e){var r=this.__data__;return r[t]=yt&&void 0===e?z:e,this}function l(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function f(){this.__data__=[]}function h(t){var e=this.__data__,r=j(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():dt.call(e,r,1),!0}function p(t){var e=this.__data__,r=j(e,t);return r<0?void 0:e[r][1]}function d(t){return j(this.__data__,t)>-1}function v(t,e){var r=this.__data__,n=j(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}function y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function _(){this.__data__={hash:new o,map:new(vt||l),string:new o}}function g(t){return U(this,t)["delete"](t)}function m(t){return U(this,t).get(t)}function b(t){return U(this,t).has(t)}function q(t,e){return U(this,t).set(t,e),this}function j(t,e){for(var r=t.length;r--;)if(G(t[r][0],e))return r;return-1}function O(t,e){e=P(e,t)?[e]:w(e);for(var r=0,n=e.length;null!=t&&r<n;)t=t[A(e[r++])];return r&&r==n?t:void 0}function T(t){if(!M(t)||x(t))return!1;var e=S(t)||n(t)?ht:tt;return e.test(R(t))}function E(t){if("string"==typeof t)return t;if(L(t))return gt?gt.call(t):"";var e=t+"";return"0"==e&&1/t==-D?"-0":e}function w(t){return bt(t)?t:mt(t)}function U(t,e){var r=t.__data__;return k(e)?r["string"==typeof e?"string":"hash"]:r.map}function C(t,e){var n=r(t,e);return T(n)?n:void 0}function P(t,e){if(bt(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!L(t))||(J.test(t)||!Z.test(t)||null!=e&&t in Object(e))}function k(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function x(t){return!!at&&at in t}function A(t){if("string"==typeof t||L(t))return t;var e=t+"";return"0"==e&&1/t==-D?"-0":e}function R(t){if(null!=t){try{return ct.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function I(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(K);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u),u};return r.cache=new(I.Cache||y),r}function G(t,e){return t===e||t!==t&&e!==e}function S(t){var e=M(t)?ft.call(t):"";return e==H||e==V}function M(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function F(t){return!!t&&"object"==typeof t}function L(t){return"symbol"==typeof t||F(t)&&ft.call(t)==B}function N(t){return null==t?"":E(t)}function $(t,e,r){var n=null==t?void 0:O(t,e);return void 0===n?r:n}var K="Expected a function",z="__lodash_hash_undefined__",D=1/0,H="[object Function]",V="[object GeneratorFunction]",B="[object Symbol]",Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,Q=/^\./,W=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,X=/[\\^$.*+?()[\]{}|]/g,Y=/\\(\\)?/g,tt=/^\[object .+?Constructor\]$/,et="object"==typeof e&&e&&e.Object===Object&&e,rt="object"==typeof self&&self&&self.Object===Object&&self,nt=et||rt||Function("return this")(),ot=Array.prototype,it=Function.prototype,ut=Object.prototype,st=nt["__core-js_shared__"],at=function(){var t=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ct=it.toString,lt=ut.hasOwnProperty,ft=ut.toString,ht=RegExp("^"+ct.call(lt).replace(X,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),pt=nt.Symbol,dt=ot.splice,vt=C(nt,"Map"),yt=C(Object,"create"),_t=pt?pt.prototype:void 0,gt=_t?_t.toString:void 0;o.prototype.clear=i,o.prototype["delete"]=u,o.prototype.get=s,o.prototype.has=a,o.prototype.set=c,l.prototype.clear=f,l.prototype["delete"]=h,l.prototype.get=p,l.prototype.has=d,l.prototype.set=v,y.prototype.clear=_,y.prototype["delete"]=g,y.prototype.get=m,y.prototype.has=b,y.prototype.set=q;var mt=I(function(t){t=N(t);var e=[];return Q.test(t)&&e.push(""),t.replace(W,function(t,r,n,o){e.push(n?o.replace(Y,"$1"):r||t)}),e});I.Cache=y;var bt=Array.isArray;t.exports=$}).call(e,function(){return this}())},function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,o){e=e||"&",n=n||"=";var i={};if("string"!=typeof t||0===t.length)return i;var u=/\+/g;t=t.split(e);var s=1e3;o&&"number"==typeof o.maxKeys&&(s=o.maxKeys);var a=t.length;s>0&&a>s&&(a=s);for(var c=0;c<a;++c){var l,f,h,p,d=t[c].replace(u,"%20"),v=d.indexOf(n);v>=0?(l=d.substr(0,v),f=d.substr(v+1)):(l=d,f=""),h=decodeURIComponent(l),p=decodeURIComponent(f),r(i,h)?Array.isArray(i[h])?i[h].push(p):i[h]=[i[h],p]:i[h]=p}return i}},function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,n,o){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(o){var i=encodeURIComponent(r(o))+n;return Array.isArray(t[o])?t[o].map(function(t){return i+encodeURIComponent(r(t))}).join(e):i+encodeURIComponent(r(t[o]))}).join(e):o?encodeURIComponent(r(o))+n+encodeURIComponent(r(t)):""}},function(t,e){"use strict";function r(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return null}}function n(t){for(var e,n=/([^=?&]+)=?([^&]*)/g,o={};e=n.exec(t);){var i=r(e[1]),u=r(e[2]);null===i||null===u||i in o||(o[i]=u)}return o}function o(t,e){e=e||"";var r,n,o=[];"string"!=typeof e&&(e="?");for(n in t)if(u.call(t,n)){if(r=t[n],r||null!==r&&r!==i&&!isNaN(r)||(r=""),n=encodeURIComponent(n),r=encodeURIComponent(r),null===n||null===r)continue;o.push(n+"="+r)}return o.length?e+o.join("&"):""}var i,u=Object.prototype.hasOwnProperty;e.stringify=o,e.parse=n},function(t,e){"use strict";t.exports=function(t,e){if(e=e.split(":")[0],t=+t,!t)return!1;switch(e){case"http":case"ws":return 80!==t;case"https":case"wss":return 443!==t;case"ftp":return 21!==t;case"gopher":return 70!==t;case"file":return!1}return 0!==t}},function(t,e,r){(function(e){"use strict";function n(t){return(t||"").replace(v,"")}function o(t){var r;r="undefined"!=typeof window?window:"undefined"!=typeof e?e:"undefined"!=typeof self?self:{};var n=r.location||{};t=t||n;var o,i={},u=typeof t;if("blob:"===t.protocol)i=new s(unescape(t.pathname),{});else if("string"===u){i=new s(t,{});for(o in _)delete i[o]}else if("object"===u){for(o in t)o in _||(i[o]=t[o]);void 0===i.slashes&&(i.slashes=h.test(t.href))}return i}function i(t){t=n(t);var e=p.exec(t);return{protocol:e[1]?e[1].toLowerCase():"",slashes:!!e[2],rest:e[3]}}function u(t,e){if(""===t)return e;for(var r=(e||"/").split("/").slice(0,-1).concat(t.split("/")),n=r.length,o=r[n-1],i=!1,u=0;n--;)"."===r[n]?r.splice(n,1):".."===r[n]?(r.splice(n,1),u++):u&&(0===n&&(i=!0),r.splice(n,1),u--);return i&&r.unshift(""),"."!==o&&".."!==o||r.push(""),r.join("/")}function s(t,e,r){if(t=n(t),!(this instanceof s))return new s(t,e,r);var a,c,h,p,d,v,_=y.slice(),g=typeof e,m=this,b=0;for("object"!==g&&"string"!==g&&(r=e,e=null),r&&"function"!=typeof r&&(r=f.parse),e=o(e),c=i(t||""),a=!c.protocol&&!c.slashes,m.slashes=c.slashes||a&&e.slashes,m.protocol=c.protocol||e.protocol||"",t=c.rest,c.slashes||(_[3]=[/(.*)/,"pathname"]);b<_.length;b++)p=_[b],"function"!=typeof p?(h=p[0],v=p[1],h!==h?m[v]=t:"string"==typeof h?~(d=t.indexOf(h))&&("number"==typeof p[2]?(m[v]=t.slice(0,d),t=t.slice(d+p[2])):(m[v]=t.slice(d),t=t.slice(0,d))):(d=h.exec(t))&&(m[v]=d[1],t=t.slice(0,d.index)),m[v]=m[v]||(a&&p[3]?e[v]||"":""),p[4]&&(m[v]=m[v].toLowerCase())):t=p(t);r&&(m.query=r(m.query)),a&&e.slashes&&"/"!==m.pathname.charAt(0)&&(""!==m.pathname||""!==e.pathname)&&(m.pathname=u(m.pathname,e.pathname)),l(m.port,m.protocol)||(m.host=m.hostname,m.port=""),m.username=m.password="",m.auth&&(p=m.auth.split(":"),m.username=p[0]||"",m.password=p[1]||""),m.origin=m.protocol&&m.host&&"file:"!==m.protocol?m.protocol+"//"+m.host:"null",m.href=m.toString()}function a(t,e,r){var n=this;switch(t){case"query":"string"==typeof e&&e.length&&(e=(r||f.parse)(e)),n[t]=e;break;case"port":n[t]=e,l(e,n.protocol)?e&&(n.host=n.hostname+":"+e):(n.host=n.hostname,n[t]="");break;case"hostname":n[t]=e,n.port&&(e+=":"+n.port),n.host=e;break;case"host":n[t]=e,/:\d+$/.test(e)?(e=e.split(":"),n.port=e.pop(),n.hostname=e.join(":")):(n.hostname=e,n.port="");break;case"protocol":n.protocol=e.toLowerCase(),n.slashes=!r;break;case"pathname":case"hash":if(e){var o="pathname"===t?"/":"#";n[t]=e.charAt(0)!==o?o+e:e}else n[t]=e;break;default:n[t]=e}for(var i=0;i<y.length;i++){var u=y[i];u[4]&&(n[u[1]]=n[u[1]].toLowerCase())}return n.origin=n.protocol&&n.host&&"file:"!==n.protocol?n.protocol+"//"+n.host:"null",n.href=n.toString(),n}function c(t){t&&"function"==typeof t||(t=f.stringify);var e,r=this,n=r.protocol;n&&":"!==n.charAt(n.length-1)&&(n+=":");var o=n+(r.slashes?"//":"");return r.username&&(o+=r.username,r.password&&(o+=":"+r.password),o+="@"),o+=r.host+r.pathname,e="object"==typeof r.query?t(r.query):r.query,e&&(o+="?"!==e.charAt(0)?"?"+e:e),r.hash&&(o+=r.hash),o}var l=r(16),f=r(15),h=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,p=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,d="[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]",v=new RegExp("^"+d+"+"),y=[["#","hash"],["?","query"],function(t){return t.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],_={hash:1,query:1};s.prototype={set:a,toString:c},s.extractProtocol=i,s.location=o,s.trimLeft=n,s.qs=f,t.exports=s}).call(e,function(){return this}())}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Unsplash=e():t.Unsplash=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return"function"==typeof t.json?t.json():t}Object.defineProperty(e,"__esModule",{value:!0});var u=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();e.toJson=i;var s=r(1),a=r(2),c=r(4),l=n(c),h=r(6),f=n(h),p=r(10),d=n(p),v=r(7),y=n(v),_=r(5),g=n(_),m=r(8),b=n(m),j=r(9),q=n(j),O=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this._apiUrl=e.apiUrl||s.API_URL,this._apiVersion=e.apiVersion||s.API_VERSION,this._accessKey=e.accessKey,this._secret=e.secret,this._callbackUrl=e.callbackUrl,this._bearerToken=e.bearerToken,this._headers=e.headers||{},this._timeout=e.timeout||0,this.auth=l["default"].bind(this)(),this.currentUser=f["default"].bind(this)(),this.users=d["default"].bind(this)(),this.photos=y["default"].bind(this)(),this.collections=g["default"].bind(this)(),this.search=b["default"].bind(this)(),this.stats=q["default"].bind(this)()}return u(t,[{key:"request",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=a.buildFetchOptions.bind(this)(t),r=e.url,n=e.options;return fetch(r,n)}}]),t}();e["default"]=O},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.API_URL="https://api.unsplash.com",e.API_VERSION="v1",e.OAUTH_AUTHORIZE_URL="https://unsplash.com/oauth/authorize",e.OAUTH_TOKEN_URL="https://unsplash.com/oauth/token"},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t){return(0,l["default"])(t)}function i(t){return(0,f["default"])(t,{},!0)}function u(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.method,r=t.query,n=t.oauth,i=t.body,u=n===!0?t.url:""+this._apiUrl+t.url,c=s({},this._headers,t.headers,{"Accept-Version":this._apiVersion,Authorization:this._bearerToken?"Bearer "+this._bearerToken:"Client-ID "+this._accessKey}),l=this._timeout;return i&&(c["Content-Type"]="application/x-www-form-urlencoded"),r&&(u=decodeURIComponent(u+"?"+(0,a.stringify)(r))),{url:u,options:{method:e,headers:c,timeout:l,body:"GET"!==e&&i?o(i):void 0}}}Object.defineProperty(e,"__esModule",{value:!0});var s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.formUrlEncode=o,e.getUrlComponents=i,e.buildFetchOptions=u;var a=r(3),c=r(11),l=n(c),h=r(17),f=n(h)},function(t,e,r){"use strict";e.decode=e.parse=r(13),e.encode=e.stringify=r(14)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=this;return{getAuthenticationUrl:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["public"],r=u["default"].stringify({client_id:t._accessKey,redirect_uri:t._callbackUrl,response_type:"code",scope:e.length>1?e.join("+"):e.toString()});return decodeURIComponent(s.OAUTH_AUTHORIZE_URL+"?"+r)},userAuthentication:function(e){var r=s.OAUTH_TOKEN_URL;return t.request({url:r,method:"POST",body:{client_id:t._accessKey,client_secret:t._secret,redirect_uri:t._callbackUrl,grant_type:"authorization_code",code:e},oauth:!0})},setBearerToken:function(e){e&&(t._bearerToken=e)}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=o;var i=r(3),u=n(i),s=r(1)},function(t,e){"use strict";function r(){var t=this;return{listCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n="/collections",o={per_page:r,page:e};return t.request({url:n,method:"GET",query:o})},getCollection:n.bind(this),getCollectionPhotos:o.bind(this),createCollection:i.bind(this,null),updateCollection:i.bind(this),deleteCollection:function(e){var r="/collections/"+e;return t.request({url:r,method:"DELETE"})},addPhotoToCollection:function(e,r){var n="/collections/"+e+"/add";return t.request({url:n,method:"POST",body:{photo_id:r}})},removePhotoFromCollection:function(e,r){var n="/collections/"+e+"/remove?photo_id="+r;return t.request({url:n,method:"DELETE"})},listRelatedCollections:function(e){var r="/collections/"+e+"/related";return t.request({url:r,method:"GET"})}}}function n(t){return this.request({url:"/collections/"+t,method:"GET"})}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i={per_page:r,order_by:n,orientation:o.orientation,page:e};return Object.keys(i).forEach(function(t){i[t]||delete i[t]}),this.request({url:"/collections/"+t+"/photos",method:"GET",query:i})}function i(t,e,r,n){var o=t?"/collections/"+t:"/collections",i={title:e,description:r,"private":n};return this.request({url:o,method:t?"PUT":"POST",body:i})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{profile:function(){var e="/me";return t.request({url:e,method:"GET"})},updateProfile:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="/me",n=e.username,o=e.firstName,i=e.lastName,u=e.email,s=e.url,a=e.location,c=e.bio,l=e.instagramUsername,h={username:n,first_name:o,last_name:i,email:u,url:s,location:a,bio:c,instagram_username:l};return Object.keys(h).forEach(function(t){h[t]||delete h[t]}),t.request({url:r,method:"PUT",body:h})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(){var t=this;return{listPhotos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"latest",o="/photos",i={page:e,per_page:r,order_by:n};return t.request({url:o,method:"GET",query:i})},getPhoto:function(e){var r="/photos/"+e;return t.request({url:r,method:"GET"})},getPhotoStats:function(e){var r="/photos/"+e+"/statistics";return t.request({url:r,method:"GET"})},getRandomPhoto:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="/photos/random",n=e.collections||[],o={featured:e.featured,username:e.username,orientation:e.orientation,collections:n.join(),query:e.query,c:e.cacheBuster||(new Date).getTime(),count:e.count};return Object.keys(o).forEach(function(t){o[t]||delete o[t]}),t.request({url:r,method:"GET",query:o})},likePhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+e+"/like";return t.request({url:r,method:"POST"})},unlikePhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+e+"/like";return t.request({url:r,method:"DELETE"})},downloadPhoto:i.bind(this),trackDownload:i.bind(this)}}function i(t){var e=(0,a["default"])(t,"links.download_location",void 0);if(void 0===e)throw new Error("Object received is not a photo. "+t);var r=(0,u.getUrlComponents)(e);return this.request({url:r.pathname,method:"GET",query:r.query})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=o;var u=r(2),s=r(12),a=n(s)},function(t,e){"use strict";function r(){var t=this;return{photos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=o.collections||[],u={query:encodeURIComponent(e),per_page:n,orientation:o.orientation,content_filter:o.contentFilter,color:o.color,order_by:o.orderBy,lang:o.lang,collections:i.join(),page:r};return Object.keys(u).forEach(function(t){u[t]||"query"==t||delete u[t]}),t.request({url:"/search/photos",method:"GET",query:u})},users:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o={query:encodeURIComponent(e),per_page:n,page:r};return t.request({url:"/search/users",method:"GET",query:o})},collections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o={query:encodeURIComponent(e),per_page:n,page:r};return t.request({url:"/search/collections",method:"GET",query:o})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{total:function(){var e="/stats/total";return t.request({url:e,method:"GET"})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){"use strict";function r(){var t=this;return{profile:function(e){var r="/users/"+e;return t.request({url:r,method:"GET"})},photos:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},u=i.stats||!1,s="/users/"+e+"/photos",a={page:r,per_page:n,order_by:o,orientation:i.orientation,stats:u};return Object.keys(a).forEach(function(t){a[t]||delete a[t]}),t.request({url:s,method:"GET",query:a})},likes:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},u="/users/"+e+"/likes",s={page:r,per_page:n,order_by:o,orientation:i.orientation};return Object.keys(s).forEach(function(t){s[t]||delete s[t]}),t.request({url:u,method:"GET",query:s})},collections:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"published",i="/users/"+e+"/collections",u={page:r,per_page:n,order_by:o};return t.request({url:i,method:"GET",query:u})},statistics:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"days",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,o="/users/"+e+"/statistics",i={resolution:r,quantity:n};return t.request({url:o,method:"GET",query:i})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},function(t,e){t.exports=function(t,e){function r(t){return String(t).replace(/[^ !'()~\*]*/g,encodeURIComponent).replace(/ /g,"+").replace(/[!'()~\*]/g,function(t){return"%"+t.charCodeAt().toString(16).slice(-2).toUpperCase()})}function n(t){var r=Object.keys(t);return e.sorted?r.sort():r}function o(t){return t.filter(function(t){return t}).join("&")}function i(t,e){return o(n(e).map(function(r){return s(t+"["+r+"]",e[r])}))}function u(t,e){return o(e.map(function(e){return s(t+"[]",e)}))}function s(t,n){var o=typeof n,s=null;return n===s?s=e.ignorenull?s:r(t)+"="+s:/string|number|boolean/.test(o)?s=r(t)+"="+r(n):Array.isArray(n)?s=u(t,n):"object"===o&&(s=i(t,n)),s}return e="object"==typeof e?e:{},o(n(t).map(function(e){return s(e,t[e])}))}},function(t,e){(function(e){function r(t,e){return null==t?void 0:t[e]}function n(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(r){}return e}function o(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function i(){this.__data__=yt?yt(null):{}}function u(t){return this.has(t)&&delete this.__data__[t]}function s(t){var e=this.__data__;if(yt){var r=e[t];return r===z?void 0:r}return lt.call(e,t)?e[t]:void 0}function a(t){var e=this.__data__;return yt?void 0!==e[t]:lt.call(e,t)}function c(t,e){var r=this.__data__;return r[t]=yt&&void 0===e?z:e,this}function l(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function h(){this.__data__=[]}function f(t){var e=this.__data__,r=q(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():dt.call(e,r,1),!0}function p(t){var e=this.__data__,r=q(e,t);return r<0?void 0:e[r][1]}function d(t){return q(this.__data__,t)>-1}function v(t,e){var r=this.__data__,n=q(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}function y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function _(){this.__data__={hash:new o,map:new(vt||l),string:new o}}function g(t){return U(this,t)["delete"](t)}function m(t){return U(this,t).get(t)}function b(t){return U(this,t).has(t)}function j(t,e){return U(this,t).set(t,e),this}function q(t,e){for(var r=t.length;r--;)if(G(t[r][0],e))return r;return-1}function O(t,e){e=C(e,t)?[e]:w(e);for(var r=0,n=e.length;null!=t&&r<n;)t=t[A(e[r++])];return r&&r==n?t:void 0}function E(t){if(!M(t)||x(t))return!1;var e=S(t)||n(t)?ft:tt;return e.test(R(t))}function T(t){if("string"==typeof t)return t;if(L(t))return gt?gt.call(t):"";var e=t+"";return"0"==e&&1/t==-D?"-0":e}function w(t){return bt(t)?t:mt(t)}function U(t,e){var r=t.__data__;return P(e)?r["string"==typeof e?"string":"hash"]:r.map}function k(t,e){var n=r(t,e);return E(n)?n:void 0}function C(t,e){if(bt(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!L(t))||(J.test(t)||!Z.test(t)||null!=e&&t in Object(e))}function P(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function x(t){return!!at&&at in t}function A(t){if("string"==typeof t||L(t))return t;var e=t+"";return"0"==e&&1/t==-D?"-0":e}function R(t){if(null!=t){try{return ct.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function I(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(K);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u),u};return r.cache=new(I.Cache||y),r}function G(t,e){return t===e||t!==t&&e!==e}function S(t){var e=M(t)?ht.call(t):"";return e==H||e==V}function M(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function F(t){return!!t&&"object"==typeof t}function L(t){return"symbol"==typeof t||F(t)&&ht.call(t)==B}function N(t){return null==t?"":T(t)}function $(t,e,r){var n=null==t?void 0:O(t,e);return void 0===n?r:n}var K="Expected a function",z="__lodash_hash_undefined__",D=1/0,H="[object Function]",V="[object GeneratorFunction]",B="[object Symbol]",Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,Q=/^\./,W=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,X=/[\\^$.*+?()[\]{}|]/g,Y=/\\(\\)?/g,tt=/^\[object .+?Constructor\]$/,et="object"==typeof e&&e&&e.Object===Object&&e,rt="object"==typeof self&&self&&self.Object===Object&&self,nt=et||rt||Function("return this")(),ot=Array.prototype,it=Function.prototype,ut=Object.prototype,st=nt["__core-js_shared__"],at=function(){var t=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ct=it.toString,lt=ut.hasOwnProperty,ht=ut.toString,ft=RegExp("^"+ct.call(lt).replace(X,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),pt=nt.Symbol,dt=ot.splice,vt=k(nt,"Map"),yt=k(Object,"create"),_t=pt?pt.prototype:void 0,gt=_t?_t.toString:void 0;o.prototype.clear=i,o.prototype["delete"]=u,o.prototype.get=s,o.prototype.has=a,o.prototype.set=c,l.prototype.clear=h,l.prototype["delete"]=f,l.prototype.get=p,l.prototype.has=d,l.prototype.set=v,y.prototype.clear=_,y.prototype["delete"]=g,y.prototype.get=m,y.prototype.has=b,y.prototype.set=j;var mt=I(function(t){t=N(t);var e=[];return Q.test(t)&&e.push(""),t.replace(W,function(t,r,n,o){e.push(n?o.replace(Y,"$1"):r||t)}),e});I.Cache=y;var bt=Array.isArray;t.exports=$}).call(e,function(){return this}())},function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,o){e=e||"&",n=n||"=";var i={};if("string"!=typeof t||0===t.length)return i;var u=/\+/g;t=t.split(e);var s=1e3;o&&"number"==typeof o.maxKeys&&(s=o.maxKeys);var a=t.length;s>0&&a>s&&(a=s);for(var c=0;c<a;++c){var l,h,f,p,d=t[c].replace(u,"%20"),v=d.indexOf(n);v>=0?(l=d.substr(0,v),h=d.substr(v+1)):(l=d,h=""),f=decodeURIComponent(l),p=decodeURIComponent(h),r(i,f)?Array.isArray(i[f])?i[f].push(p):i[f]=[i[f],p]:i[f]=p}return i}},function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,n,o){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(o){var i=encodeURIComponent(r(o))+n;return Array.isArray(t[o])?t[o].map(function(t){return i+encodeURIComponent(r(t))}).join(e):i+encodeURIComponent(r(t[o]))}).join(e):o?encodeURIComponent(r(o))+n+encodeURIComponent(r(t)):""}},function(t,e){"use strict";function r(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return null}}function n(t){for(var e,n=/([^=?&]+)=?([^&]*)/g,o={};e=n.exec(t);){var i=r(e[1]),u=r(e[2]);null===i||null===u||i in o||(o[i]=u)}return o}function o(t,e){e=e||"";var r,n,o=[];"string"!=typeof e&&(e="?");for(n in t)if(u.call(t,n)){if(r=t[n],r||null!==r&&r!==i&&!isNaN(r)||(r=""),n=encodeURIComponent(n),r=encodeURIComponent(r),null===n||null===r)continue;o.push(n+"="+r)}return o.length?e+o.join("&"):""}var i,u=Object.prototype.hasOwnProperty;e.stringify=o,e.parse=n},function(t,e){"use strict";t.exports=function(t,e){if(e=e.split(":")[0],t=+t,!t)return!1;switch(e){case"http":case"ws":return 80!==t;case"https":case"wss":return 443!==t;case"ftp":return 21!==t;case"gopher":return 70!==t;case"file":return!1}return 0!==t}},function(t,e,r){(function(e){"use strict";function n(t){return(t||"").replace(v,"")}function o(t){var r;r="undefined"!=typeof window?window:"undefined"!=typeof e?e:"undefined"!=typeof self?self:{};var n=r.location||{};t=t||n;var o,i={},u=typeof t;if("blob:"===t.protocol)i=new s(unescape(t.pathname),{});else if("string"===u){i=new s(t,{});for(o in _)delete i[o]}else if("object"===u){for(o in t)o in _||(i[o]=t[o]);void 0===i.slashes&&(i.slashes=f.test(t.href))}return i}function i(t){t=n(t);var e=p.exec(t);return{protocol:e[1]?e[1].toLowerCase():"",slashes:!!e[2],rest:e[3]}}function u(t,e){if(""===t)return e;for(var r=(e||"/").split("/").slice(0,-1).concat(t.split("/")),n=r.length,o=r[n-1],i=!1,u=0;n--;)"."===r[n]?r.splice(n,1):".."===r[n]?(r.splice(n,1),u++):u&&(0===n&&(i=!0),r.splice(n,1),u--);return i&&r.unshift(""),"."!==o&&".."!==o||r.push(""),r.join("/")}function s(t,e,r){if(t=n(t),!(this instanceof s))return new s(t,e,r);var a,c,f,p,d,v,_=y.slice(),g=typeof e,m=this,b=0;for("object"!==g&&"string"!==g&&(r=e,e=null),r&&"function"!=typeof r&&(r=h.parse),e=o(e),c=i(t||""),a=!c.protocol&&!c.slashes,m.slashes=c.slashes||a&&e.slashes,m.protocol=c.protocol||e.protocol||"",t=c.rest,c.slashes||(_[3]=[/(.*)/,"pathname"]);b<_.length;b++)p=_[b],"function"!=typeof p?(f=p[0],v=p[1],f!==f?m[v]=t:"string"==typeof f?~(d=t.indexOf(f))&&("number"==typeof p[2]?(m[v]=t.slice(0,d),t=t.slice(d+p[2])):(m[v]=t.slice(d),t=t.slice(0,d))):(d=f.exec(t))&&(m[v]=d[1],t=t.slice(0,d.index)),m[v]=m[v]||(a&&p[3]?e[v]||"":""),p[4]&&(m[v]=m[v].toLowerCase())):t=p(t);r&&(m.query=r(m.query)),a&&e.slashes&&"/"!==m.pathname.charAt(0)&&(""!==m.pathname||""!==e.pathname)&&(m.pathname=u(m.pathname,e.pathname)),l(m.port,m.protocol)||(m.host=m.hostname,m.port=""),m.username=m.password="",m.auth&&(p=m.auth.split(":"),m.username=p[0]||"",m.password=p[1]||""),m.origin=m.protocol&&m.host&&"file:"!==m.protocol?m.protocol+"//"+m.host:"null",m.href=m.toString()}function a(t,e,r){var n=this;switch(t){case"query":"string"==typeof e&&e.length&&(e=(r||h.parse)(e)),n[t]=e;break;case"port":n[t]=e,l(e,n.protocol)?e&&(n.host=n.hostname+":"+e):(n.host=n.hostname,n[t]="");break;case"hostname":n[t]=e,n.port&&(e+=":"+n.port),n.host=e;break;case"host":n[t]=e,/:\d+$/.test(e)?(e=e.split(":"),n.port=e.pop(),n.hostname=e.join(":")):(n.hostname=e,n.port="");break;case"protocol":n.protocol=e.toLowerCase(),n.slashes=!r;break;case"pathname":case"hash":if(e){var o="pathname"===t?"/":"#";n[t]=e.charAt(0)!==o?o+e:e}else n[t]=e;break;default:n[t]=e}for(var i=0;i<y.length;i++){var u=y[i];u[4]&&(n[u[1]]=n[u[1]].toLowerCase())}return n.origin=n.protocol&&n.host&&"file:"!==n.protocol?n.protocol+"//"+n.host:"null",n.href=n.toString(),n}function c(t){t&&"function"==typeof t||(t=h.stringify);var e,r=this,n=r.protocol;n&&":"!==n.charAt(n.length-1)&&(n+=":");var o=n+(r.slashes?"//":"");return r.username&&(o+=r.username,r.password&&(o+=":"+r.password),o+="@"),o+=r.host+r.pathname,e="object"==typeof r.query?t(r.query):r.query,e&&(o+="?"!==e.charAt(0)?"?"+e:e),r.hash&&(o+=r.hash),o}var l=r(16),h=r(15),f=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,p=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,d="[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]",v=new RegExp("^"+d+"+"),y=[["#","hash"],["?","query"],function(t){return t.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],_={hash:1,query:1};s.prototype={set:a,toString:c},s.extractProtocol=i,s.location=o,s.trimLeft=n,s.qs=h,t.exports=s}).call(e,function(){return this}())}])}); |
@@ -18,4 +18,4 @@ "use strict"; | ||
var query = { | ||
page: page, | ||
per_page: perPage | ||
per_page: perPage, | ||
page: page | ||
}; | ||
@@ -93,8 +93,14 @@ | ||
var query = { | ||
page: page, | ||
per_page: perPage, | ||
order_by: orderBy, | ||
orientation: options.orientation | ||
orientation: options.orientation, | ||
page: page | ||
}; | ||
Object.keys(query).forEach(function (key) { | ||
if (!query[key]) { | ||
delete query[key]; | ||
} | ||
}); | ||
return this.request({ | ||
@@ -101,0 +107,0 @@ url: "/collections/" + id + "/photos", |
@@ -112,18 +112,23 @@ "use strict"; | ||
downloadPhoto: function downloadPhoto(photo) { | ||
var downloadLocation = (0, _lodash2.default)(photo, "links.download_location", undefined); | ||
// Deprecated in 6.2 | ||
downloadPhoto: track.bind(this), | ||
if (downloadLocation === undefined) { | ||
throw new Error("Object received is not a photo. " + photo); | ||
} | ||
trackDownload: track.bind(this) | ||
}; | ||
} | ||
var urlComponents = (0, _utils.getUrlComponents)(downloadLocation); | ||
function track(photo) { | ||
var downloadLocation = (0, _lodash2.default)(photo, "links.download_location", undefined); | ||
return _this.request({ | ||
url: urlComponents.pathname, | ||
method: "GET", | ||
query: urlComponents.query | ||
}); | ||
} | ||
}; | ||
if (downloadLocation === undefined) { | ||
throw new Error("Object received is not a photo. " + photo); | ||
} | ||
var urlComponents = (0, _utils.getUrlComponents)(downloadLocation); | ||
return this.request({ | ||
url: urlComponents.pathname, | ||
method: "GET", | ||
query: urlComponents.query | ||
}); | ||
} |
@@ -36,2 +36,8 @@ "use strict"; | ||
Object.keys(query).forEach(function (key) { | ||
if (!query[key]) { | ||
delete query[key]; | ||
} | ||
}); | ||
return _this.request({ | ||
@@ -58,2 +64,8 @@ url: url, | ||
Object.keys(query).forEach(function (key) { | ||
if (!query[key]) { | ||
delete query[key]; | ||
} | ||
}); | ||
return _this.request({ | ||
@@ -60,0 +72,0 @@ url: url, |
@@ -73,3 +73,5 @@ "use strict"; | ||
key: "request", | ||
value: function request(requestOptions) { | ||
value: function request() { | ||
var requestOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _buildFetchOptions$bi = _utils.buildFetchOptions.bind(this)(requestOptions), | ||
@@ -76,0 +78,0 @@ url = _buildFetchOptions$bi.url, |
{ | ||
"name": "unsplash-js", | ||
"version": "6.2.0", | ||
"version": "6.3.0", | ||
"description": "A JavaScript wrapper for the Unsplash API", | ||
@@ -47,3 +47,2 @@ "main": "lib/unsplash.js", | ||
"babel-plugin-transform-class-properties": "6.4.0", | ||
"babel-plugin-transform-flow-strip-types": "6.4.0", | ||
"babel-plugin-transform-object-assign": "6.3.13", | ||
@@ -50,0 +49,0 @@ "babel-preset-es2015": "6.3.13", |
@@ -16,3 +16,3 @@ # Unsplash | ||
- [Get a random photo](#photo-random) 🎑 | ||
- [Trigger a photo download](#photo-download) 📡 | ||
- [Trigger a photo download](#track-download) 📡 | ||
- [Search for a photo by keyword](#search-photos) 🕵️♂️ | ||
@@ -115,11 +115,11 @@ | ||
|__`keyword`__|_string_|Required|| | ||
|__`page`__|_number_|Optional|| | ||
|__`page`__|_number_|Optional|1| | ||
|__`per_page`__|_number_|Optional|10| | ||
|__`options`__|_object_|Optional|| | ||
|__`options.orientation`__|_string_|Optional|| | ||
|__`options.contentFilter`__|_string_|Optional|| | ||
|__`options.contentFilter`__|_string_|Optional|"low"| | ||
|__`options.color`__|_string_|Optional|| | ||
|__`options.orderBy`__|_string_|Optional|| | ||
|__`options.orderBy`__|_string_|Optional|"relevant"| | ||
|__`options.collections`__|_array_|Optional|| | ||
|__`options.lang`__|_string_|Optional|| | ||
|__`options.lang`__|_string_|Optional|"en"| | ||
@@ -130,3 +130,3 @@ See the [API documentation for the possible option values](https://unsplash.com/documentation#parameters-16). | ||
```js | ||
unsplash.search.photos("dogs", 1, 10, { orientation: "portrait", color: "brown" }) | ||
unsplash.search.photos("dogs", 1, 10, { orientation: "portrait", color: "green" }) | ||
.then(toJson) | ||
@@ -146,3 +146,3 @@ .then(json => { | ||
|__`keyword`__|_string_|Required|| | ||
|__`page`__|_number_|Optional|| | ||
|__`page`__|_number_|Optional|1| | ||
|__`per_page`__|_number_|Optional|10| | ||
@@ -168,3 +168,3 @@ | ||
|__`keyword`__|_string_|Required|| | ||
|__`page`__|_number_|Optional|| | ||
|__`page`__|_number_|Optional|1| | ||
|__`per_page`__|_number_|Optional|10| | ||
@@ -193,7 +193,7 @@ | ||
| Argument | Type | Opt/Required | | ||
| Argument | Type | Opt/Required | Default | | ||
|---|---|---| | ||
|__`page`__|_number_|Optional| | ||
|__`perPage`__|_number_|Optional| | ||
|__`orderBy`__|_string_|Optional|`latest`, `oldest`| | ||
|__`page`__|_number_|Optional|1| | ||
|__`perPage`__|_number_|Optional|10| | ||
|__`orderBy`__|_string_|Optional|`latest`| | ||
@@ -319,5 +319,5 @@ __Example__ | ||
<div id="photo-download" /> | ||
<div id="track-download" /> | ||
### photos.downloadPhoto(photo) | ||
### photos.trackDownload(photo) | ||
Trigger a download of a photo as per the [download tracking requirement of API Guidelines](https://medium.com/unsplash/unsplash-api-guidelines-triggering-a-download-c39b24e99e02). [See endpoint docs 🚀](https://unsplash.com/documentation#track-a-photo-download) | ||
@@ -338,3 +338,3 @@ | ||
.then(json => { | ||
unsplash.photos.downloadPhoto(json); | ||
unsplash.photos.trackDownload(json); | ||
}); | ||
@@ -346,3 +346,3 @@ | ||
.then(json => { | ||
unsplash.photos.downloadPhoto(json["results"][0]); | ||
unsplash.photos.trackDownload(json["results"][0]); | ||
}); | ||
@@ -426,10 +426,10 @@ ``` | ||
| Argument | Type | Opt/Required | Notes | | ||
| Argument | Type | Opt/Required | Notes | Default | | ||
|---|---|---|---| | ||
|__`username`__|_string_|Required|| | ||
|__`page`__|_number_|Optional|| | ||
|__`perPage`__|_number_|Optional|| | ||
|__`orderBy`__|_string_|Optional|`latest`, `oldest`| | ||
|__`options`__|_object_|Optional| | ||
|__`options.orientation`__|_string_|Optional|`landscape`, `portrait`, `squarish`| | ||
|__`page`__|_number_|Optional||1| | ||
|__`perPage`__|_number_|Optional||10| | ||
|__`orderBy`__|_string_|Optional|`latest`, `oldest`|`latest`| | ||
|__`options`__|_object_|Optional|| | ||
|__`options.orientation`__|_string_|Optional|`landscape`, `portrait`, `squarish`|| | ||
@@ -451,8 +451,8 @@ __Example__ | ||
| Argument | Type | Opt/Required | Notes | | ||
| Argument | Type | Opt/Required | Notes | Default | | ||
|---|---|---|---| | ||
|__`username`__|_string_|Required|| | ||
|__`page`__|_number_|Optional|| | ||
|__`perPage`__|_number_|Optional|| | ||
|__`orderBy`__|_string_|Optional|`published` or `updated`| | ||
|__`username`__|_string_|Required||| | ||
|__`page`__|_number_|Optional||1| | ||
|__`perPage`__|_number_|Optional||10| | ||
|__`orderBy`__|_string_|Optional|`published` or `updated`|`updated`| | ||
@@ -476,7 +476,7 @@ __Example__ | ||
| Argument | Type | Opt/Required |Notes| | ||
| Argument | Type | Opt/Required | Notes | Default | | ||
|---|---|---|---| | ||
|__`page`__|_number_|Optional|| | ||
|__`perPage`__|_number_|Optional|| | ||
|__`orderBy`__|_string_|Optional|`latest`, `oldest`| | ||
|__`page`__|_number_|Optional||1| | ||
|__`perPage`__|_number_|Optional||10| | ||
|__`orderBy`__|_string_|Optional|`latest`, `oldest`|`latest`| | ||
@@ -518,8 +518,8 @@ __Example__ | ||
| Argument | Type | Opt/Required | Notes | | ||
| Argument | Type | Opt/Required | Notes | Default | | ||
|---|---|---|---| | ||
|__`id`__|_number_|Required|| | ||
|__`page`__|_number_|Optional| | ||
|__`perPage`__|_number_|Optional| | ||
|__`orderBy`__|_string_|Optional|`latest`, `oldest`| | ||
|__`id`__|_number_|Required||| | ||
|__`page`__|_number_|Optional||1| | ||
|__`perPage`__|_number_|Optional||10| | ||
|__`orderBy`__|_string_|Optional|`latest`, `oldest`|`latest`| | ||
|__`options`__|_object_|Optional| | ||
@@ -836,4 +836,4 @@ |__`options.orientation`__|_string_|Optional| `landscape`, `portrait`, `squarish`| | ||
const unsplash = new Unsplash({ | ||
accessKey: "{YOUR_ACCESS_KEY}", | ||
secret: "{YOUR_SECRET_KEY}" | ||
accessKey: YOUR_ACCESS_KEY, | ||
secret: YOUR_SECRET_KEY | ||
}); | ||
@@ -840,0 +840,0 @@ |
@@ -7,4 +7,4 @@ export default function collections() { | ||
const query = { | ||
page, | ||
per_page: perPage | ||
per_page: perPage, | ||
page | ||
}; | ||
@@ -83,8 +83,14 @@ | ||
const query = { | ||
page, | ||
per_page: perPage, | ||
order_by: orderBy, | ||
orientation: options.orientation | ||
orientation: options.orientation, | ||
page | ||
}; | ||
Object.keys(query).forEach(key => { | ||
if (!query[key]) { | ||
delete query[key]; | ||
} | ||
}); | ||
return this.request({ | ||
@@ -91,0 +97,0 @@ url: `/collections/${id}/photos`, |
@@ -92,18 +92,23 @@ import { getUrlComponents } from "../utils"; | ||
downloadPhoto: (photo) => { | ||
const downloadLocation = get(photo, "links.download_location", undefined); | ||
// Deprecated in 6.2 | ||
downloadPhoto: track.bind(this), | ||
if (downloadLocation === undefined) { | ||
throw new Error(`Object received is not a photo. ${photo}`); | ||
} | ||
trackDownload: track.bind(this) | ||
}; | ||
} | ||
const urlComponents = getUrlComponents(downloadLocation); | ||
function track(photo) { | ||
const downloadLocation = get(photo, "links.download_location", undefined); | ||
return this.request({ | ||
url: urlComponents.pathname, | ||
method: "GET", | ||
query: urlComponents.query | ||
}); | ||
} | ||
}; | ||
if (downloadLocation === undefined) { | ||
throw new Error(`Object received is not a photo. ${photo}`); | ||
} | ||
const urlComponents = getUrlComponents(downloadLocation); | ||
return this.request({ | ||
url: urlComponents.pathname, | ||
method: "GET", | ||
query: urlComponents.query | ||
}); | ||
} |
@@ -29,2 +29,8 @@ export default function users() { | ||
Object.keys(query).forEach(key => { | ||
if (!query[key]) { | ||
delete query[key]; | ||
} | ||
}); | ||
return this.request({ | ||
@@ -46,2 +52,8 @@ url, | ||
Object.keys(query).forEach(key => { | ||
if (!query[key]) { | ||
delete query[key]; | ||
} | ||
}); | ||
return this.request({ | ||
@@ -48,0 +60,0 @@ url, |
@@ -1,3 +0,1 @@ | ||
declare var fetch: any; | ||
import { API_URL, API_VERSION } from "./constants"; | ||
@@ -34,3 +32,3 @@ import { buildFetchOptions } from "./utils"; | ||
request(requestOptions: {}) { | ||
request(requestOptions = {}) { | ||
var { url, options } = buildFetchOptions.bind(this)(requestOptions); | ||
@@ -37,0 +35,0 @@ |
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
287456
15
3522