Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unsplash-js

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unsplash-js - npm Package Compare versions

Comparing version 6.0.0 to 6.2.0

32

CHANGELOG.md
# Changelog
## 6.2.0
### Changes
- Adds support for [the languages beta](https://changelog.unsplash.com/update/2020/08/21/languages-beta.html) on search
```js
unsplash.search.photos("nature", 1, 10, { lang: "en" });
```
- Adds support for the [new search filters and ordering](https://changelog.unsplash.com/update/2020/03/04/new-filters.html)
```js
unsplash.search.photos("nature", 1, 10, {
orientation: "landscape",
color: "brown", // new
orderBy: "relevant" // new
});
```
- Adds support for [content filtering on search](https://changelog.unsplash.com/update/2020/03/15/content-filtering.html)
```js
unsplash.search.photos("nature", 1, 10, { contentFilter: "high" });
```
- Removes any references to 'popular' ordering ([due to deprecation](https://changelog.unsplash.com/update/2020/07/09/deprecate-popular.html))
## 6.1.0
Enables Brotli compression by default.
## 6.0

@@ -4,0 +36,0 @@

2

dist/unsplash.min.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Unsplash=t():e.Unsplash=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){return"function"==typeof e.json?e.json():e}Object.defineProperty(t,"__esModule",{value:!0});var u=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}}();t.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 e(t){o(this,e),this._apiUrl=t.apiUrl||s.API_URL,this._apiVersion=t.apiVersion||s.API_VERSION,this._accessKey=t.accessKey,this._secret=t.secret,this._callbackUrl=t.callbackUrl,this._bearerToken=t.bearerToken,this._headers=t.headers||{},this._timeout=t.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(e,[{key:"request",value:function(e){var t=a.buildFetchOptions.bind(this)(e),r=t.url,n=t.options;return fetch(r,n)}}]),e}();t["default"]=O},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.API_URL="https://api.unsplash.com",t.API_VERSION="v1",t.OAUTH_AUTHORIZE_URL="https://unsplash.com/oauth/authorize",t.OAUTH_TOKEN_URL="https://unsplash.com/oauth/token"},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e){return(0,l["default"])(e)}function i(e){return(0,h["default"])(e,{},!0)}function u(e){var t=e.method,r=e.query,n=e.oauth,i=e.body,u=n===!0?e.url:""+this._apiUrl+e.url,c=s({},this._headers,e.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:t,headers:c,timeout:l,body:"GET"!==t&&i?o(i):void 0}}}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.formUrlEncode=o,t.getUrlComponents=i,t.buildFetchOptions=u;var a=r(3),c=r(11),l=n(c),f=r(17),h=n(f)},function(e,t,r){"use strict";t.decode=t.parse=r(13),t.encode=t.stringify=r(14)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=this;return{getAuthenticationUrl:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["public"],r=u["default"].stringify({client_id:e._accessKey,redirect_uri:e._callbackUrl,response_type:"code",scope:t.length>1?t.join("+"):t.toString()});return decodeURIComponent(s.OAUTH_AUTHORIZE_URL+"?"+r)},userAuthentication:function(t){var r=s.OAUTH_TOKEN_URL;return e.request({url:r,method:"POST",body:{client_id:e._accessKey,client_secret:e._secret,redirect_uri:e._callbackUrl,grant_type:"authorization_code",code:t},oauth:!0})},setBearerToken:function(t){t&&(e._bearerToken=t)}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var i=r(3),u=n(i),s=r(1)},function(e,t){"use strict";function r(){var e=this;return{listCollections:function(){var t=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:t,per_page:r};return e.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(t){var r="/collections/"+t;return e.request({url:r,method:"DELETE"})},addPhotoToCollection:function(t,r){var n="/collections/"+t+"/add";return e.request({url:n,method:"POST",body:{photo_id:r}})},removePhotoFromCollection:function(t,r){var n="/collections/"+t+"/remove?photo_id="+r;return e.request({url:n,method:"DELETE"})},listRelatedCollections:function(t){var r="/collections/"+t+"/related";return e.request({url:r,method:"GET"})}}}function n(e){return this.request({url:"/collections/"+e,method:"GET"})}function o(e){var t=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={page:t,per_page:r,order_by:n};return this.request({url:"/collections/"+e+"/photos",method:"GET",query:o})}function i(e,t,r,n){var o=e?"/collections/"+e:"/collections",i={title:t,description:r,"private":n};return this.request({url:o,method:e?"PUT":"POST",body:i})}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{profile:function(){var t="/me";return e.request({url:t,method:"GET"})},updateProfile:function(t){var r="/me",n=t.username,o=t.firstName,i=t.lastName,u=t.email,s=t.url,a=t.location,c=t.bio,l=t.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(e){f[e]||delete f[e]}),e.request({url:r,method:"PUT",body:f})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=this;return{listPhotos:function(){var t=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:t,per_page:r,order_by:n};return e.request({url:o,method:"GET",query:i})},getPhoto:function(t){var r="/photos/"+t;return e.request({url:r,method:"GET"})},getPhotoStats:function(t){var r="/photos/"+t+"/statistics";return e.request({url:r,method:"GET"})},getRandomPhoto:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="/photos/random",n=t.collections||[],o={featured:t.featured,username:t.username,orientation:t.orientation,collections:n.join(),query:t.query,c:t.cacheBuster||(new Date).getTime(),count:t.count};return Object.keys(o).forEach(function(e){o[e]||delete o[e]}),e.request({url:r,method:"GET",query:o})},likePhoto:function(t){if(!e._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+t+"/like";return e.request({url:r,method:"POST"})},unlikePhoto:function(t){if(!e._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos/"+t+"/like";return e.request({url:r,method:"DELETE"})},downloadPhoto:function(t){var r=(0,s["default"])(t,"links.download_location",void 0);if(void 0===r)throw new Error("Object received is not a photo. "+t);var n=(0,i.getUrlComponents)(r);return e.request({url:n.pathname,method:"GET",query:n.query})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var i=r(2),u=r(12),s=n(u)},function(e,t){"use strict";function r(){var e=this;return{photos:function(){var t=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(t),per_page:n,orientation:o.orientation,collections:i.join(),page:r};return Object.keys(u).forEach(function(e){u[e]||"query"==e||delete u[e]}),e.request({url:"/search/photos",method:"GET",query:u})},users:function(){var t=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(t),per_page:n,page:r};return e.request({url:"/search/users",method:"GET",query:o})},collections:function(){var t=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(t),per_page:n,page:r};return e.request({url:"/search/collections",method:"GET",query:o})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{total:function(){var t="/stats/total";return e.request({url:t,method:"GET"})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";function r(){var e=this;return{profile:function(t){var r="/users/"+t;return e.request({url:r,method:"GET"})},photos:function(t){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/"+t+"/photos",s={page:r,per_page:n,order_by:o,stats:i};return e.request({url:u,method:"GET",query:s})},likes:function(t){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="/users/"+t+"/likes",u={page:r,per_page:n,order_by:o};return e.request({url:i,method:"GET",query:u})},collections:function(t){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/"+t+"/collections",u={page:r,per_page:n,order_by:o};return e.request({url:i,method:"GET",query:u})},statistics:function(t){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/"+t+"/statistics",i={resolution:r,quantity:n};return e.request({url:o,method:"GET",query:i})}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){e.exports=function(e,t){function r(e){return String(e).replace(/[^ !'()~\*]*/g,encodeURIComponent).replace(/ /g,"+").replace(/[!'()~\*]/g,function(e){return"%"+e.charCodeAt().toString(16).slice(-2).toUpperCase()})}function n(e){var r=Object.keys(e);return t.sorted?r.sort():r}function o(e){return e.filter(function(e){return e}).join("&")}function i(e,t){return o(n(t).map(function(r){return s(e+"["+r+"]",t[r])}))}function u(e,t){return o(t.map(function(t){return s(e+"[]",t)}))}function s(e,n){var o=typeof n,s=null;return n===s?s=t.ignorenull?s:r(e)+"="+s:/string|number|boolean/.test(o)?s=r(e)+"="+r(n):Array.isArray(n)?s=u(e,n):"object"===o&&(s=i(e,n)),s}return t="object"==typeof t?t:{},o(n(e).map(function(t){return s(t,e[t])}))}},function(e,t){(function(t){function r(e,t){return null==e?void 0:e[t]}function n(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(r){}return t}function o(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function i(){this.__data__=ye?ye(null):{}}function u(e){return this.has(e)&&delete this.__data__[e]}function s(e){var t=this.__data__;if(ye){var r=t[e];return r===z?void 0:r}return le.call(t,e)?t[e]:void 0}function a(e){var t=this.__data__;return ye?void 0!==t[e]:le.call(t,e)}function c(e,t){var r=this.__data__;return r[e]=ye&&void 0===t?z:t,this}function l(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function f(){this.__data__=[]}function h(e){var t=this.__data__,r=j(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():de.call(t,r,1),!0}function p(e){var t=this.__data__,r=j(t,e);return r<0?void 0:t[r][1]}function d(e){return j(this.__data__,e)>-1}function v(e,t){var r=this.__data__,n=j(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}function y(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function _(){this.__data__={hash:new o,map:new(ve||l),string:new o}}function g(e){return U(this,e)["delete"](e)}function m(e){return U(this,e).get(e)}function b(e){return U(this,e).has(e)}function q(e,t){return U(this,e).set(e,t),this}function j(e,t){for(var r=e.length;r--;)if(G(e[r][0],t))return r;return-1}function O(e,t){t=P(t,e)?[t]:E(t);for(var r=0,n=t.length;null!=e&&r<n;)e=e[A(t[r++])];return r&&r==n?e:void 0}function T(e){if(!M(e)||R(e))return!1;var t=S(e)||n(e)?he:ee;return t.test(x(e))}function w(e){if("string"==typeof e)return e;if(N(e))return ge?ge.call(e):"";var t=e+"";return"0"==t&&1/e==-H?"-0":t}function E(e){return be(e)?e:me(e)}function U(e,t){var r=e.__data__;return k(t)?r["string"==typeof t?"string":"hash"]:r.map}function C(e,t){var n=r(e,t);return T(n)?n:void 0}function P(e,t){if(be(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!N(e))||(J.test(e)||!B.test(e)||null!=t&&e in Object(t))}function k(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function R(e){return!!ae&&ae in e}function A(e){if("string"==typeof e||N(e))return e;var t=e+"";return"0"==t&&1/e==-H?"-0":t}function x(e){if(null!=e){try{return ce.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function I(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(F);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=e.apply(this,n);return r.cache=i.set(o,u),u};return r.cache=new(I.Cache||y),r}function G(e,t){return e===t||e!==e&&t!==t}function S(e){var t=M(e)?fe.call(e):"";return t==V||t==D}function M(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function L(e){return!!e&&"object"==typeof e}function N(e){return"symbol"==typeof e||L(e)&&fe.call(e)==Z}function $(e){return null==e?"":w(e)}function K(e,t,r){var n=null==e?void 0:O(e,t);return void 0===n?r:n}var F="Expected a function",z="__lodash_hash_undefined__",H=1/0,V="[object Function]",D="[object GeneratorFunction]",Z="[object Symbol]",B=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,Q=/^\./,W=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,X=/[\\^$.*+?()[\]{}|]/g,Y=/\\(\\)?/g,ee=/^\[object .+?Constructor\]$/,te="object"==typeof t&&t&&t.Object===Object&&t,re="object"==typeof self&&self&&self.Object===Object&&self,ne=te||re||Function("return this")(),oe=Array.prototype,ie=Function.prototype,ue=Object.prototype,se=ne["__core-js_shared__"],ae=function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ce=ie.toString,le=ue.hasOwnProperty,fe=ue.toString,he=RegExp("^"+ce.call(le).replace(X,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),pe=ne.Symbol,de=oe.splice,ve=C(ne,"Map"),ye=C(Object,"create"),_e=pe?pe.prototype:void 0,ge=_e?_e.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 me=I(function(e){e=$(e);var t=[];return Q.test(e)&&t.push(""),e.replace(W,function(e,r,n,o){t.push(n?o.replace(Y,"$1"):r||e)}),t});I.Cache=y;var be=Array.isArray;e.exports=K}).call(t,function(){return this}())},function(e,t){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,n,o){t=t||"&",n=n||"=";var i={};if("string"!=typeof e||0===e.length)return i;var u=/\+/g;e=e.split(t);var s=1e3;o&&"number"==typeof o.maxKeys&&(s=o.maxKeys);var a=e.length;s>0&&a>s&&(a=s);for(var c=0;c<a;++c){var l,f,h,p,d=e[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(e,t){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,n,o){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(o){var i=encodeURIComponent(r(o))+n;return Array.isArray(e[o])?e[o].map(function(e){return i+encodeURIComponent(r(e))}).join(t):i+encodeURIComponent(r(e[o]))}).join(t):o?encodeURIComponent(r(o))+n+encodeURIComponent(r(e)):""}},function(e,t){"use strict";function r(e){return decodeURIComponent(e.replace(/\+/g," "))}function n(e){for(var t,n=/([^=?&]+)=?([^&]*)/g,o={};t=n.exec(e);){var i=r(t[1]),u=r(t[2]);i in o||(o[i]=u)}return o}function o(e,t){t=t||"";var r,n,o=[];"string"!=typeof t&&(t="?");for(n in e)u.call(e,n)&&(r=e[n],r||null!==r&&r!==i&&!isNaN(r)||(r=""),o.push(encodeURIComponent(n)+"="+encodeURIComponent(r)));return o.length?t+o.join("&"):""}var i,u=Object.prototype.hasOwnProperty;t.stringify=o,t.parse=n},function(e,t){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],e=+e,!e)return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},function(e,t,r){(function(t){"use strict";function n(e){var r;r="undefined"!=typeof window?window:"undefined"!=typeof t?t:"undefined"!=typeof self?self:{};var n=r.location||{};e=e||n;var o,i={},s=typeof e;if("blob:"===e.protocol)i=new u(unescape(e.pathname),{});else if("string"===s){i=new u(e,{});for(o in d)delete i[o]}else if("object"===s){for(o in e)o in d||(i[o]=e[o]);void 0===i.slashes&&(i.slashes=h.test(e.href))}return i}function o(e){var t=f.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function i(e,t){for(var r=(t||"/").split("/").slice(0,-1).concat(e.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 u(e,t,r){if(!(this instanceof u))return new u(e,t,r);var s,a,f,h,d,v,y=p.slice(),_=typeof t,g=this,m=0;for("object"!==_&&"string"!==_&&(r=t,t=null),r&&"function"!=typeof r&&(r=l.parse),t=n(t),a=o(e||""),s=!a.protocol&&!a.slashes,g.slashes=a.slashes||s&&t.slashes,g.protocol=a.protocol||t.protocol||"",e=a.rest,a.slashes||(y[3]=[/(.*)/,"pathname"]);m<y.length;m++)h=y[m],"function"!=typeof h?(f=h[0],v=h[1],f!==f?g[v]=e:"string"==typeof f?~(d=e.indexOf(f))&&("number"==typeof h[2]?(g[v]=e.slice(0,d),e=e.slice(d+h[2])):(g[v]=e.slice(d),e=e.slice(0,d))):(d=f.exec(e))&&(g[v]=d[1],e=e.slice(0,d.index)),g[v]=g[v]||(s&&h[3]?t[v]||"":""),h[4]&&(g[v]=g[v].toLowerCase())):e=h(e);r&&(g.query=r(g.query)),s&&t.slashes&&"/"!==g.pathname.charAt(0)&&(""!==g.pathname||""!==t.pathname)&&(g.pathname=i(g.pathname,t.pathname)),c(g.port,g.protocol)||(g.host=g.hostname,g.port=""),g.username=g.password="",g.auth&&(h=g.auth.split(":"),g.username=h[0]||"",g.password=h[1]||""),g.origin=g.protocol&&g.host&&"file:"!==g.protocol?g.protocol+"//"+g.host:"null",g.href=g.toString()}function s(e,t,r){var n=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(r||l.parse)(t)),n[e]=t;break;case"port":n[e]=t,c(t,n.protocol)?t&&(n.host=n.hostname+":"+t):(n.host=n.hostname,n[e]="");break;case"hostname":n[e]=t,n.port&&(t+=":"+n.port),n.host=t;break;case"host":n[e]=t,/:\d+$/.test(t)?(t=t.split(":"),n.port=t.pop(),n.hostname=t.join(":")):(n.hostname=t,n.port="");break;case"protocol":n.protocol=t.toLowerCase(),n.slashes=!r;break;case"pathname":case"hash":if(t){var o="pathname"===e?"/":"#";n[e]=t.charAt(0)!==o?o+t:t}else n[e]=t;break;default:n[e]=t}for(var i=0;i<p.length;i++){var u=p[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 a(e){e&&"function"==typeof e||(e=l.stringify);var t,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,t="object"==typeof r.query?e(r.query):r.query,t&&(o+="?"!==t.charAt(0)?"?"+t:t),r.hash&&(o+=r.hash),o}var c=r(16),l=r(15),f=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,h=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,p=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],d={hash:1,query:1};u.prototype={set:s,toString:a},u.extractProtocol=o,u.location=n,u.qs=l,e.exports=u}).call(t,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),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}())}])});

@@ -5,47 +5,9 @@ import config from 'universal-config';

const unsplash = new Unsplash({
accessKey: config.get('ACCESS_KEY'),
secret: config.get('SECRET'),
callbackUrl: config.get('CALLBACK_URL')
accessKey: config.get('ACCESS_KEY')
});
let authenticationUrl = unsplash.auth.getAuthenticationUrl([
"public",
"read_user",
"write_user",
"read_photos",
"write_photos",
"write_likes",
"read_collections",
"write_collections"
]);
console.log(userAuthentication(code));
currentUser();
users();
photos();
collections();
stats();
function userAuthentication(code) {
return unsplash.auth.userAuthentication(code)
.then(toJson)
.then(json => json.access_token);
}
function currentUser() {
console.log("\nCurrent User");
unsplash.currentUser.profile()
.then(toJson)
.then(json => {
console.log('profile', json);
});
unsplash.currentUser.updateProfile({ location: "¯\_(ツ)_/¯" })
.then(toJson)
.then(json => {
console.log('updateProfile', json);
});
}
function users() {

@@ -93,14 +55,2 @@ console.log("\nUsers")

});
unsplash.photos.likePhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.unlikePhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
}

@@ -128,42 +78,2 @@

});
unsplash.collections.createCollection("Birds", "Wild birds from 'round the world", true)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.updateCollection(152645, "Wild", "Wild")
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.deleteCollection(152645)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.addPhotoToCollection(151165, '-yPg8cusGD8')
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.removePhotoFromCollection(151165, '-yPg8cusGD8')
.then(toJson)
.then(json => {
console.log(json);
});
}
function stats() {
console.log("\nStats");
unsplash.stats.total()
.then(toJson)
.then(json => {
console.log(json);
});
}
var unsplash = new Unsplash({
accessKey: "{YOUR_ACCESS_KEY}",
secret: "{YOUR_SECRET}",
callbackUrl: "{YOUR_CALLBACK_URL}"
secret: "{YOUR_SECRET}"
});

@@ -6,0 +5,0 @@

@@ -5,4 +5,3 @@ import Unsplash, { toJson } from "unsplash-js";

accessKey: "{YOUR_ACCESS_KEY}",
secret: "{YOUR_SECRET}",
callbackUrl: "{YOUR_CALLBACK_URL}"
secret: "{YOUR_SECRET}"
});

@@ -9,0 +8,0 @@

@@ -89,2 +89,3 @@ "use strict";

var orderBy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "latest";
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};

@@ -94,3 +95,4 @@ var query = {

per_page: perPage,
order_by: orderBy
order_by: orderBy,
orientation: options.orientation
};

@@ -97,0 +99,0 @@

@@ -20,4 +20,7 @@ "use strict";

updateProfile: function updateProfile(options) {
updateProfile: function updateProfile() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var endpointUrl = "/me";
var username = options.username,

@@ -32,2 +35,3 @@ firstName = options.firstName,

var body = {

@@ -34,0 +38,0 @@ username: username,

@@ -15,9 +15,13 @@ "use strict";

var perPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
var filters = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var collections = filters.collections || [];
var collections = options.collections || [];
var query = {
query: encodeURIComponent(keyword),
per_page: perPage,
orientation: filters.orientation,
orientation: options.orientation,
content_filter: options.contentFilter,
color: options.color,
order_by: options.orderBy,
lang: options.lang,
collections: collections.join(),

@@ -24,0 +28,0 @@ page: page

@@ -24,4 +24,5 @@ "use strict";

var orderBy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "latest";
var stats = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var stats = options.stats || false;
var url = "/users/" + username + "/photos";

@@ -32,2 +33,3 @@ var query = {

order_by: orderBy,
orientation: options.orientation,
stats: stats

@@ -47,2 +49,3 @@ };

var orderBy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "latest";
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};

@@ -53,3 +56,4 @@ var url = "/users/" + username + "/likes";

per_page: perPage,
order_by: orderBy
order_by: orderBy,
orientation: options.orientation
};

@@ -56,0 +60,0 @@

@@ -48,3 +48,5 @@ "use strict";

var Unsplash = function () {
function Unsplash(options) {
function Unsplash() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, Unsplash);

@@ -51,0 +53,0 @@

@@ -33,3 +33,4 @@ "use strict";

function buildFetchOptions(options) {
function buildFetchOptions() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var method = options.method,

@@ -36,0 +37,0 @@ query = options.query,

{
"name": "unsplash-js",
"version": "6.0.0",
"description": "A Universal JavaScript wrapper for the Unsplash API",
"version": "6.2.0",
"description": "A JavaScript wrapper for the Unsplash API",
"main": "lib/unsplash.js",

@@ -14,4 +14,3 @@ "scripts": {

"lint": "eslint src",
"flow": "flow status",
"test": "npm run lint && npm run flow && npm run test:node",
"test": "npm run lint && npm run test:node",
"test:node": "mocha --compilers js:babel-core/register --require test/setup --recursive",

@@ -54,7 +53,6 @@ "test:watch": "npm test -- --watch",

"expect": "1.12.2",
"flow-bin": "0.40.0",
"istanbul": "0.4.2",
"mocha": "2.3.3",
"mockery": "1.4.0",
"node-fetch": "1.5.0",
"node-fetch": "2.6.0",
"webpack": "1.12.14"

@@ -66,4 +64,4 @@ },

"querystring": "0.2.0",
"url-parse": "1.4.4"
"url-parse": "1.4.5"
}
}

@@ -46,2 +46,4 @@ # Unsplash

Note: we recommend using a version of `node-fetch` higher than `2.4.0` to benefit from Brotli compression.
## Usage

@@ -56,10 +58,11 @@

// ES Modules syntax
import Unsplash from 'unsplash-js';
import Unsplash, { toJson } from 'unsplash-js';
// require syntax
const Unsplash = require('unsplash-js').default;
const toJson = require('unsplash-js').toJson;
const unsplash = new Unsplash({ accessKey: "{APP_ACCESS_KEY}" });
const unsplash = new Unsplash({ accessKey: APP_ACCESS_KEY });
const unsplash = new Unsplash({
accessKey: "{APP_ACCESS_KEY}",
accessKey: APP_ACCESS_KEY,
// Optionally you can also configure a custom header to be sent with every request

@@ -78,11 +81,2 @@ headers: {

### React Native
For use with React Native, import from `unsplash-js/native` instead.
```js
import Unsplash from 'unsplash-js/native';
```
---
### Error handling

@@ -104,4 +98,3 @@ ```js

- [Collections](https://github.com/unsplash/unsplash-js#collections)
- [Stats](https://github.com/unsplash/unsplash-js#stats)
- [Authorization](https://github.com/unsplash/unsplash-js#authorization)
- [User Authorization](https://github.com/unsplash/unsplash-js#user-authorization)
- [Current User](https://github.com/unsplash/unsplash-js#current-user)

@@ -117,8 +110,8 @@

### search.photos(keyword, page, per_page, filters)
Get a list of photos matching the keyword.
### search.photos(keyword, page, per_page, options)
Get a list of photos matching the keyword. [See endpoint docs 🚀](https://unsplash.com/documentation#search-photos)
__Arguments__
| Argument | Type | Opt/Required | Default |
| Argument | Type | Optional/Required | Default |
|---|---|---|---|

@@ -128,9 +121,15 @@ |__`keyword`__|_string_|Required||

|__`per_page`__|_number_|Optional|10|
|__`filters`__|_object_|Optional||
|__`filters.orientation`__|_string_|Optional||
|__`filters.collections`__|_array_|Optional||
|__`options`__|_object_|Optional||
|__`options.orientation`__|_string_|Optional||
|__`options.contentFilter`__|_string_|Optional||
|__`options.color`__|_string_|Optional||
|__`options.orderBy`__|_string_|Optional||
|__`options.collections`__|_array_|Optional||
|__`options.lang`__|_string_|Optional||
See the [API documentation for the possible option values](https://unsplash.com/documentation#parameters-16).
__Example__
```js
unsplash.search.photos("dogs", 1, 10, { orientation: "portrait" })
unsplash.search.photos("dogs", 1, 10, { orientation: "portrait", color: "brown" })
.then(toJson)

@@ -143,3 +142,3 @@ .then(json => {

### search.users(keyword, page, per_page)
Get a list of users matching the keyword.
Get a list of users matching the keyword. [See endpoint docs 🚀](https://unsplash.com/documentation#search-users)

@@ -165,3 +164,3 @@ __Arguments__

### search.collections(keyword, page, per_page)
Get a list of collections matching the keyword.
Get a list of collections matching the keyword. [See endpoint docs 🚀](https://unsplash.com/documentation#search-collections)

@@ -193,3 +192,3 @@ __Arguments__

### photos.listPhotos(page, perPage, orderBy)
Get a single page from the list of all photos.
Get a single page from the list of all photos. [See endpoint docs 🚀](https://unsplash.com/documentation#list-photos)

@@ -202,3 +201,3 @@ __Arguments__

|__`perPage`__|_number_|Optional|
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|
|__`orderBy`__|_string_|Optional|`latest`, `oldest`|

@@ -216,3 +215,3 @@ __Example__

### photos.getPhoto(id)
Retrieve a single photo.
Retrieve a single photo. [See endpoint docs 🚀](https://unsplash.com/documentation#get-a-photo)

@@ -236,3 +235,3 @@ __Arguments__

### photos.getPhotoStats(id)
Retrieve a single photo's stats.
Retrieve a single photo's stats. [See endpoint docs 🚀](https://unsplash.com/documentation#get-a-photos-statistics)

@@ -258,3 +257,3 @@ __Arguments__

### photos.getRandomPhoto({ query, username, featured })
Retrieve a single random photo, given optional filters.
Retrieve a single random photo, given optional filters. [See endpoint docs 🚀](https://unsplash.com/documentation#get-a-random-photo)

@@ -290,3 +289,3 @@ When using this function, It is recommended to double check the types of the parameters,

### photos.likePhoto(id)
Like a photo on behalf of the logged-in user. This requires the `write_likes` scope.
Like a photo on behalf of the logged-in user. This requires the `write_likes` scope. [See endpoint docs 🚀](https://unsplash.com/documentation#like-a-photo)

@@ -310,3 +309,3 @@ __Arguments__

### photos.unlikePhoto(id)
Remove a user’s like of a photo.
Remove a user’s like of a photo. [See endpoint docs 🚀](https://unsplash.com/documentation#unlike-a-photo)

@@ -332,3 +331,3 @@ __Arguments__

### photos.downloadPhoto(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).
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)

@@ -364,3 +363,3 @@ *Note*: this accepts a photo JSON object, not a URL string or photo ID. See the example below for how to pair it with other calls to trigger it.

### users.profile(username)
Retrieve public details on a given user.
Retrieve public details on a given user. [See endpoint docs 🚀](https://unsplash.com/documentation#get-a-users-public-profile)

@@ -384,3 +383,3 @@ __Arguments__

### users.statistics(username, resolution, quantity)
Retrieve statistics for a given user.
Retrieve statistics for a given user. [See endpoint docs 🚀](https://unsplash.com/documentation#get-a-users-statistics)

@@ -406,4 +405,4 @@ __Arguments__

### users.photos(username, page, perPage, orderBy, stats)
Get a list of photos uploaded by a user.
### users.photos(username, page, perPage, orderBy, options)
Get a list of photos uploaded by a user. [See endpoint docs 🚀](https://unsplash.com/documentation#list-a-users-photos)

@@ -417,8 +416,10 @@ __Arguments__

|__`perPage`__|_number_|Optional||10|
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|`latest`|
|__`stats`__|_boolean_|Optional||`false`|
|__`orderBy`__|_string_|Optional|`latest`, `oldest`|`latest`|
|__`options`__|_object_|Optional|
|__`options.stats`__|_boolean_|Optional||`false`|
|__`options.orientation`__|_string_|Optional|`landscape`, `portrait`, `squarish`|
__Example__
```js
unsplash.users.photos("naoufal", 1, 10, "popular", false)
unsplash.users.photos("naoufal", 1, 10, "latest", { orientation: "landscape" })
.then(toJson)

@@ -431,4 +432,4 @@ .then(json => {

### users.likes(username, page, perPage, orderBy)
Get a list of photos liked by a user.
### users.likes(username, page, perPage, orderBy, options)
Get a list of photos liked by a user. [See endpoint docs 🚀](https://unsplash.com/documentation#list-a-users-liked-photos)

@@ -442,7 +443,9 @@ __Arguments__

|__`perPage`__|_number_|Optional||
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|
|__`orderBy`__|_string_|Optional|`latest`, `oldest`|
|__`options`__|_object_|Optional|
|__`options.orientation`__|_string_|Optional|`landscape`, `portrait`, `squarish`|
__Example__
```js
unsplash.users.likes("naoufal", 2, 15, "popular")
unsplash.users.likes("naoufal", 2, 15, "latest", { orientation: "landscape" })
.then(toJson)

@@ -456,3 +459,3 @@ .then(json => {

### users.collections(username, page, perPage, orderBy)
Get a list of collections created by the user.
Get a list of collections created by the user. [See endpoint docs 🚀](https://unsplash.com/documentation#list-a-users-collections)

@@ -481,3 +484,3 @@ __Arguments__

### collections.listCollections(page, perPage, orderBy)
Get a single page from the list of all collections.
Get a single page from the list of all collections. [See endpoint docs 🚀](https://unsplash.com/documentation#list-collections)

@@ -490,7 +493,7 @@ __Arguments__

|__`perPage`__|_number_|Optional||
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|
|__`orderBy`__|_string_|Optional|`latest`, `oldest`|
__Example__
```js
unsplash.collections.listCollections(1, 10, "popular")
unsplash.collections.listCollections(1, 10, "latest")
.then(toJson)

@@ -504,3 +507,3 @@ .then(json => {

### collections.getCollection(id)
Retrieve a single collection. To view a user’s private collections, the `read_collections` scope is required.
Retrieve a single collection. To view a user’s private collections, the `read_collections` scope is required. [See endpoint docs 🚀](https://unsplash.com/documentation#get-a-collection)

@@ -524,4 +527,4 @@ __Arguments__

### collections.getCollectionPhotos(id, orderBy)
Retrieve a collection’s photos.
### collections.getCollectionPhotos(id, page, perPage, orderBy, options)
Retrieve a collection’s photos. [See endpoint docs 🚀](https://unsplash.com/documentation#get-a-collections-photos)

@@ -535,9 +538,9 @@ __Arguments__

|__`perPage`__|_number_|Optional|
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|
|__`orderBy`__|_string_|Optional|`latest`, `oldest`|
|__`options`__|_object_|Optional|
|__`options.orientation`__|_string_|Optional| `landscape`, `portrait`, `squarish`|
__Example__
```js
unsplash.collections.getCollectionPhotos(123456, 1, 10, "popular")
unsplash.collections.getCollectionPhotos(123456, 1, 10, "latest")
.then(toJson)

@@ -551,3 +554,3 @@ .then(json => {

### collections.createCollection(title, description, private)
Create a new collection. This requires the `write_collections` scope.
Create a new collection. This requires the `write_collections` scope. [See endpoint docs 🚀](https://unsplash.com/documentation#create-a-new-collection)

@@ -573,3 +576,3 @@ __Arguments__

### collections.updateCollection(id, title, description, private)
Update an existing collection belonging to the logged-in user. This requires the `write_collections` scope.
Update an existing collection belonging to the logged-in user. This requires the `write_collections` scope. [See endpoint docs 🚀](https://unsplash.com/documentation#update-an-existing-collection)

@@ -596,3 +599,3 @@ __Arguments__

### collections.deleteCollection(id)
Delete a collection belonging to the logged-in user. This requires the `write_collections` scope.
Delete a collection belonging to the logged-in user. This requires the `write_collections` scope. [See endpoint docs 🚀](https://unsplash.com/documentation#delete-a-collection)

@@ -617,3 +620,3 @@ __Arguments__

### collections.addPhotoToCollection(collectionId, photoId)
Add a photo to one of the logged-in user’s collections. Requires the `write_collections` scope.
Add a photo to one of the logged-in user’s collections. Requires the `write_collections` scope. [See endpoint docs 🚀](https://unsplash.com/documentation#add-a-photo-to-a-collection)

@@ -638,3 +641,3 @@ __Arguments__

### collections.removePhotoFromCollection(collectionId, photoId)
Remove a photo from one of the logged-in user’s collections. Requires the `write_collections` scope.
Remove a photo from one of the logged-in user’s collections. Requires the `write_collections` scope. [See endpoint docs 🚀](https://unsplash.com/documentation#remove-a-photo-from-a-collection)

@@ -659,3 +662,3 @@ __Arguments__

### collections.listRelatedCollections(collectionId)
Lists collections related to the provided one.
Lists collections related to the provided one. [See endpoint docs 🚀](https://unsplash.com/documentation#list-a-collections-related-collections)

@@ -676,29 +679,12 @@ __Arguments__

```
---
<div id="stats" />
<div id="user-authorization" />
### stats.total()
Get a list of download counts for all of Unsplash.
Note: Most endpoints do not need to be authenticated by an individual user to be accessed and can instead be accessed with [public authentication](https://unsplash.com/documentation#public-authentication). Endpoints that require user authentication will be explicitly marked with the required scopes.
__Arguments__
When initializing an instance of Unsplash, you'll need to include your application's `secretKey` and `callbackUrl` as defined in the [API documentation](https://unsplash.com/documentation/user-authentication-workflow):
_N/A_
__Example__
```js
unsplash.stats.total()
.then(toJson)
.then(json => {
// Your code
});
```
---
<div id="authorization" />
When initializing an instance of Unsplash, you'll need to include your application's `secretKey` and `callbackUrl` as defined in the [API documentation](https://unsplash.com/documentation#authorization-workflow):
```js
const unsplash = new Unsplash({

@@ -752,3 +738,3 @@ accessKey: "{APP_ACCESS_KEY}",

_For more information on the authroization workflow, consult the [Unsplash Documentation](https://unsplash.com/documentation#authorization-workflow)._
_For more information on the authroization workflow, consult the [Unsplash API Documentation](https://unsplash.com/documentation/user-authentication-workflow)._

@@ -755,0 +741,0 @@ ---

@@ -1,7 +0,5 @@

/* @flow */
import querystring from "querystring";
import { OAUTH_AUTHORIZE_URL, OAUTH_TOKEN_URL } from "../constants";
export default function auth(): Object {
export default function auth() {
return {

@@ -21,3 +19,3 @@ getAuthenticationUrl: (scope = ["public"]) => {

userAuthentication: (code: string) => {
userAuthentication: (code) => {
const url = OAUTH_TOKEN_URL;

@@ -39,3 +37,3 @@

setBearerToken: (accessToken: string) => {
setBearerToken: (accessToken) => {
if (accessToken) {

@@ -42,0 +40,0 @@ this._bearerToken = accessToken;

@@ -1,6 +0,4 @@

/* @flow */
export default function collections(): Object {
export default function collections() {
return {
listCollections: (page: number = 1, perPage: number = 10) => {
listCollections: (page = 1, perPage = 10) => {
const url = "/collections";

@@ -28,3 +26,3 @@

deleteCollection: (id: string) => {
deleteCollection: (id) => {
const url = `/collections/${id}`;

@@ -38,3 +36,3 @@

addPhotoToCollection: (collectionId: string, photoId: string) => {
addPhotoToCollection: (collectionId, photoId) => {
const url = `/collections/${collectionId}/add`;

@@ -71,3 +69,3 @@

function collection(id: string) {
function collection(id) {
return this.request({

@@ -80,6 +78,7 @@ url: `/collections/${id}`,

function collectionPhotos(
id: string,
page: number = 1,
perPage: number = 10,
orderBy: string = "latest"
id,
page = 1,
perPage = 10,
orderBy = "latest",
options = {},
) {

@@ -89,3 +88,4 @@ const query = {

per_page: perPage,
order_by: orderBy
order_by: orderBy,
orientation: options.orientation
};

@@ -100,8 +100,3 @@

function createUpdateCollection(
id: ?string,
title: string,
description: string,
isPrivate: bool
) {
function createUpdateCollection(id, title, description, isPrivate) {
const url = id

@@ -108,0 +103,0 @@ ? `/collections/${id}`

@@ -1,4 +0,2 @@

/* @flow */
export default function currentUser(): Object {
export default function currentUser() {
return {

@@ -14,15 +12,5 @@ profile: () => {

updateProfile: (
options: {
username?: string,
firstName?: string,
lastName?: string,
email?: string,
url?: string,
location?: string,
bio?: string,
instagramUsername?: string
}
) => {
updateProfile: (options = {}) => {
const endpointUrl = "/me";
let {

@@ -38,2 +26,3 @@ username,

} = options;
let body = {

@@ -40,0 +29,0 @@ username,

@@ -1,6 +0,5 @@

/* @flow */
import { getUrlComponents } from "../utils";
import get from "lodash.get";
export default function photos(): Object {
export default function photos() {
return {

@@ -7,0 +6,0 @@ listPhotos: (page = 1, perPage = 10, orderBy = "latest") => {

@@ -1,11 +0,13 @@

/* @flow */
export default function search(): Object {
export default function search() {
return {
photos: (keyword = "", page = 1, perPage = 10, filters = {}) => {
const collections = filters.collections || [];
photos: (keyword = "", page = 1, perPage = 10, options = {}) => {
const collections = options.collections || [];
const query = {
query: encodeURIComponent(keyword),
per_page: perPage,
orientation: filters.orientation,
orientation: options.orientation,
content_filter: options.contentFilter,
color: options.color,
order_by: options.orderBy,
lang: options.lang,
collections: collections.join(),

@@ -12,0 +14,0 @@ page

@@ -1,4 +0,2 @@

/* @flow */
export default function stats(): Object {
export default function stats() {
return {

@@ -5,0 +3,0 @@ total: () => {

@@ -1,6 +0,4 @@

/* @flow */
export default function users(): Object {
export default function users() {
return {
profile: (username: string) => {
profile: (username) => {
const url = `/users/${username}`;

@@ -15,8 +13,9 @@

photos: (
username: string,
page: number = 1,
perPage: number = 10,
orderBy: string = "latest",
stats: bool = false,
username,
page = 1,
perPage = 10,
orderBy = "latest",
options = {}
) => {
const stats = options.stats || false;
const url = `/users/${username}/photos`;

@@ -27,2 +26,3 @@ const query = {

order_by: orderBy,
orientation: options.orientation,
stats

@@ -38,3 +38,3 @@ };

likes: (username: string, page: number = 1, perPage: number = 10, orderBy: string = "latest") => {
likes: (username, page = 1, perPage = 10, orderBy = "latest", options = {}) => {
const url = `/users/${username}/likes`;

@@ -44,3 +44,4 @@ const query = {

per_page: perPage,
order_by: orderBy
order_by: orderBy,
orientation: options.orientation
};

@@ -55,3 +56,3 @@

collections: (username: string, page: number = 1, perPage: number = 10, orderBy: string = "published") => {
collections: (username, page = 1, perPage = 10, orderBy = "published") => {
const url = `/users/${username}/collections`;

@@ -71,3 +72,3 @@ const query = {

statistics: (username: string, resolution: string = "days", quantity: number = 30) => {
statistics: (username, resolution = "days", quantity = 30) => {
const url = `/users/${username}/statistics`;

@@ -74,0 +75,0 @@ const query = {

@@ -1,3 +0,1 @@

/* @flow */
declare var fetch: any;

@@ -17,32 +15,3 @@

export default class Unsplash {
_apiUrl: string;
_apiVersion: string;
_accessKey: string;
_secret: ?string;
_callbackUrl: ?string;
_bearerToken: ?string;
_headers: ?Object;
_timeout: ?number;
auth: Object;
currentUser: Object;
users: Object;
photos: Object;
collections: Object;
search: Object;
stats: Object;
toJson: Function;
constructor(
options: {
apiUrl: string,
apiVersion: string,
accessKey: string,
secret?: string,
callbackUrl?: string,
bearerToken?: string,
headers?: Object,
timeout?: number
}
) {
constructor(options = {}) {
this._apiUrl = options.apiUrl || API_URL;

@@ -66,12 +35,3 @@ this._apiVersion = options.apiVersion || API_VERSION;

request(
requestOptions: {
url: string,
method: string,
query: Object,
headers: Object,
body: Object,
oauth: boolean
}
):Promise<any> {
request(requestOptions: {}) {
var { url, options } = buildFetchOptions.bind(this)(requestOptions);

@@ -83,4 +43,4 @@

export function toJson(res: Object): Object {
export function toJson(res) {
return typeof res.json === "function" ? res.json() : res;
}

@@ -1,2 +0,1 @@

/* @flow */
import { stringify as qsStringify } from "querystring";

@@ -6,20 +5,11 @@ import formurlencoded from "form-urlencoded";

export function formUrlEncode(body: Object): Object {
export function formUrlEncode(body) {
return formurlencoded(body);
}
export function getUrlComponents(uri: String): Object {
export function getUrlComponents(uri) {
return parse(uri, {}, true);
}
export function buildFetchOptions(
options: {
url: string,
method: string,
query: Object,
headers: Object,
body: Object,
oauth: boolean
}
): Object {
export function buildFetchOptions(options = {}) {
let { method, query, oauth, body } = options;

@@ -26,0 +16,0 @@ let url = (oauth === true)

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc