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 5.0.0 to 6.0.0

CHANGELOG.md

2

dist/unsplash.min.js

@@ -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(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(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 o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,r,o){return r&&t(e.prototype,r),o&&t(e,o),e}}();e.toJson=i;var s=r(1),a=r(2),c=r(4),l=o(c),h=r(7),f=o(h),p=r(11),d=o(p),v=r(8),y=o(v),_=r(5),g=o(_),b=r(6),m=o(b),q=r(9),T=o(q),j=r(10),O=o(j),w=function(){function t(e){n(this,t),this._apiUrl=e.apiUrl||s.API_URL,this._apiVersion=e.apiVersion||s.API_VERSION,this._applicationId=e.applicationId,this._secret=e.secret,this._callbackUrl=e.callbackUrl,this._bearerToken=e.bearerToken,this._headers=e.headers||{},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.categories=g["default"].bind(this)(),this.collections=m["default"].bind(this)(),this.search=T["default"].bind(this)(),this.stats=O["default"].bind(this)()}return u(t,[{key:"request",value:function(t){var e=a.buildFetchOptions.bind(this)(t),r=e.url,o=e.options;return fetch(r,o)}}]),t}();e["default"]=w},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 o(t){return t&&t.__esModule?t:{"default":t}}function n(t){return(0,l["default"])(t)}function i(t){return(0,f["default"])(t,{},!0)}function u(t){var e=t.method,r=t.query,o=t.oauth,i=t.body,u=o===!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._applicationId});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,body:"GET"!==e&&i?n(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 o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};e.formUrlEncode=n,e.getUrlComponents=i,e.buildFetchOptions=u;var a=r(3),c=r(12),l=o(c),h=r(18),f=o(h)},function(t,e,r){"use strict";e.decode=e.parse=r(14),e.encode=e.stringify=r(15)},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function n(){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._applicationId,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._applicationId,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"]=n;var i=r(3),u=o(i),s=r(1)},function(t,e){"use strict";function r(){var t=this;return{listCategories:function(){var e="/categories";return t.request({url:e,method:"GET"})},category:function(e){var r="/categories/"+e;return t.request({url:r,method:"GET"})},categoryPhotos:function(e,r,o){var n="/categories/"+e+"/photos",i={page:r,per_page:o};return t.request({url:n,method:"GET",query:i})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r},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,o="/collections",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},listCuratedCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o="/collections/curated",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},listFeaturedCollections:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o="/collections/featured",n={page:e,per_page:r};return t.request({url:o,method:"GET",query:n})},getCollection:o.bind(this,!1),getCuratedCollection:o.bind(this,!0),getCuratedCollectionPhotos:n.bind(this,!0),getCollectionPhotos:n.bind(this,!1),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 o="/collections/"+e+"/add";return t.request({url:o,method:"POST",body:{photo_id:r}})},removePhotoFromCollection:function(e,r){var o="/collections/"+e+"/remove?photo_id="+r;return t.request({url:o,method:"DELETE"})},listRelatedCollections:function(e){var r="/collections/"+e+"/related";return t.request({url:r,method:"GET"})}}}function o(t,e){var r=t?"/collections/curated/"+e:"/collections/"+e;return this.request({url:r,method:"GET"})}function n(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"latest",i=t?"/collections/curated/"+e+"/photos":"/collections/"+e+"/photos",u={page:r,per_page:o,order_by:n};return this.request({url:i,method:"GET",query:u})}function i(t,e,r,o){var n=t?"/collections/"+t:"/collections",i={title:e,description:r,"private":o};return this.request({url:n,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(e){var r="/me",o=e.username,n=e.firstName,i=e.lastName,u=e.email,s=e.url,a=e.location,c=e.bio,l=e.instagramUsername,h={username:o,first_name:n,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 o(t){return t&&t.__esModule?t:{"default":t}}function n(){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,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"latest",n="/photos",i={page:e,per_page:r,order_by:o};return t.request({url:n,method:"GET",query:i})},listCuratedPhotos:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"latest",n="/photos/curated",i={page:e,per_page:r,order_by:o};return t.request({url:n,method:"GET",query:i})},searchPhotos:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[""],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,i="/photos/search",u={query:e,category:r.length>1?r.join(","):r.toString(),page:o,per_page:n};return t.request({url:i,method:"GET",query:u})},getPhoto:function(e,r,o,n){var i="/photos/"+e,u={w:r,h:o,rect:n};return t.request({url:i,method:"GET",query:u})},getPhotoStats:function(e){var r="/photos/"+e+"/stats";return t.request({url:r,method:"GET"})},getRandomPhoto:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="/photos/random",o=e.category||[],n=e.collections||[],i={featured:e.featured,username:e.username,orientation:e.orientation,category:o.join(),collections:n.join(),query:e.query,w:e.width,h:e.height,c:e.cacheBuster||(new Date).getTime(),count:e.count};return Object.keys(i).forEach(function(t){i[t]||delete i[t]}),t.request({url:r,method:"GET",query:i})},uploadPhoto:function(e){if(!t._bearerToken)throw new Error("Requires a bearerToken to be set.");var r="/photos";return t.request({url:r,method:"POST",body:{photo:e}})},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 o=(0,i.getUrlComponents)(r);return t.request({url:o.pathname,method:"GET",query:o.query})}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(2),u=r(13),s=o(u)},function(t,e){"use strict";function r(){return{all:o.bind(this,"/search"),photos:o.bind(this,"/search/photos"),users:o.bind(this,"/search/users"),collections:o.bind(this,"/search/collections")}}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,n={query:e,page:r,per_page:o};return this.request({url:t,method:"GET",query:n})}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,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],u="/users/"+e+"/photos",s={page:r,per_page:o,order_by:n,stats:i};return t.request({url:u,method:"GET",query:s})},likes:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"latest",i="/users/"+e+"/likes",u={page:r,per_page:o,order_by:n};return t.request({url:i,method:"GET",query:u})},collections:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"published",i="/users/"+e+"/collections",u={page:r,per_page:o,order_by:n};return t.request({url:i,method:"GET",query:u})},statistics:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"days",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,n="/users/"+e+"/statistics",i={resolution:r,quantity:o};return t.request({url:n,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 o(t){var r=Object.keys(t);return e.sorted?r.sort():r}function n(t){return t.filter(function(t){return t}).join("&")}function i(t,e){return n(o(e).map(function(r){return s(t+"["+r+"]",e[r])}))}function u(t,e){return n(e.map(function(e){return s(t+"[]",e)}))}function s(t,o){var n=typeof o,s=null;return o===s?s=e.ignorenull?s:r(t)+"="+s:/string|number|boolean/.test(n)?s=r(t)+"="+r(o):Array.isArray(o)?s=u(t,o):"object"===n&&(s=i(t,o)),s}return e="object"==typeof e?e:{},n(o(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 o(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(r){}return e}function n(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[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===H?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?H:e,this}function l(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function h(){this.__data__=[]}function f(t){var e=this.__data__,r=T(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():dt.call(e,r,1),!0}function p(t){var e=this.__data__,r=T(e,t);return r<0?void 0:e[r][1]}function d(t){return T(this.__data__,t)>-1}function v(t,e){var r=this.__data__,o=T(r,t);return o<0?r.push([t,e]):r[o][1]=e,this}function y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function _(){this.__data__={hash:new n,map:new(vt||l),string:new n}}function g(t){return P(this,t)["delete"](t)}function b(t){return P(this,t).get(t)}function m(t){return P(this,t).has(t)}function q(t,e){return P(this,t).set(t,e),this}function T(t,e){for(var r=t.length;r--;)if(G(t[r][0],e))return r;return-1}function j(t,e){e=U(e,t)?[e]:E(e);for(var r=0,o=e.length;null!=t&&r<o;)t=t[R(e[r++])];return r&&r==o?t:void 0}function O(t){if(!M(t)||A(t))return!1;var e=S(t)||o(t)?ft:tt;return e.test(x(t))}function w(t){if("string"==typeof t)return t;if(N(t))return gt?gt.call(t):"";var e=t+"";return"0"==e&&1/t==-V?"-0":e}function E(t){return mt(t)?t:bt(t)}function P(t,e){var r=t.__data__;return k(e)?r["string"==typeof e?"string":"hash"]:r.map}function C(t,e){var o=r(t,e);return O(o)?o:void 0}function U(t,e){if(mt(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!N(t))||(J.test(t)||!B.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 A(t){return!!at&&at in t}function R(t){if("string"==typeof t||N(t))return t;var e=t+"";return"0"==e&&1/t==-V?"-0":e}function x(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(z);var r=function(){var o=arguments,n=e?e.apply(this,o):o[0],i=r.cache;if(i.has(n))return i.get(n);var u=t.apply(this,o);return r.cache=i.set(n,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==D||e==K}function M(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function L(t){return!!t&&"object"==typeof t}function N(t){return"symbol"==typeof t||L(t)&&ht.call(t)==Z}function $(t){return null==t?"":w(t)}function F(t,e,r){var o=null==t?void 0:j(t,e);return void 0===o?r:o}var z="Expected a function",H="__lodash_hash_undefined__",V=1/0,D="[object Function]",K="[object GeneratorFunction]",Z="[object Symbol]",B=/\.|\[(?:[^[\]]*|(["'])(?:(?!\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,ot=et||rt||Function("return this")(),nt=Array.prototype,it=Function.prototype,ut=Object.prototype,st=ot["__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=ot.Symbol,dt=nt.splice,vt=C(ot,"Map"),yt=C(Object,"create"),_t=pt?pt.prototype:void 0,gt=_t?_t.toString:void 0;n.prototype.clear=i,n.prototype["delete"]=u,n.prototype.get=s,n.prototype.has=a,n.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=b,y.prototype.has=m,y.prototype.set=q;var bt=I(function(t){t=$(t);var e=[];return Q.test(t)&&e.push(""),t.replace(W,function(t,r,o,n){e.push(o?n.replace(Y,"$1"):r||t)}),e});I.Cache=y;var mt=Array.isArray;t.exports=F}).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,o,n){e=e||"&",o=o||"=";var i={};if("string"!=typeof t||0===t.length)return i;var u=/\+/g;t=t.split(e);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.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(o);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,o,n){return e=e||"&",o=o||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(n){var i=encodeURIComponent(r(n))+o;return Array.isArray(t[n])?t[n].map(function(t){return i+encodeURIComponent(r(t))}).join(e):i+encodeURIComponent(r(t[n]))}).join(e):n?encodeURIComponent(r(n))+o+encodeURIComponent(r(t)):""}},function(t,e){"use strict";function r(t){return decodeURIComponent(t.replace(/\+/g," "))}function o(t){for(var e,o=/([^=?&]+)=?([^&]*)/g,n={};e=o.exec(t);){var i=r(e[1]),u=r(e[2]);i in n||(n[i]=u)}return n}function n(t,e){e=e||"";var r,o,n=[];"string"!=typeof e&&(e="?");for(o in t)u.call(t,o)&&(r=t[o],r||null!==r&&r!==i&&!isNaN(r)||(r=""),n.push(encodeURIComponent(o)+"="+encodeURIComponent(r)));return n.length?e+n.join("&"):""}var i,u=Object.prototype.hasOwnProperty;e.stringify=n,e.parse=o},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 o(t){var r;r="undefined"!=typeof window?window:"undefined"!=typeof e?e:"undefined"!=typeof self?self:{};var o=r.location||{};t=t||o;var n,i={},s=typeof t;if("blob:"===t.protocol)i=new u(unescape(t.pathname),{});else if("string"===s){i=new u(t,{});for(n in d)delete i[n]}else if("object"===s){for(n in t)n in d||(i[n]=t[n]);void 0===i.slashes&&(i.slashes=f.test(t.href))}return i}function n(t){var e=h.exec(t);return{protocol:e[1]?e[1].toLowerCase():"",slashes:!!e[2],rest:e[3]}}function i(t,e){for(var r=(e||"/").split("/").slice(0,-1).concat(t.split("/")),o=r.length,n=r[o-1],i=!1,u=0;o--;)"."===r[o]?r.splice(o,1):".."===r[o]?(r.splice(o,1),u++):u&&(0===o&&(i=!0),r.splice(o,1),u--);return i&&r.unshift(""),"."!==n&&".."!==n||r.push(""),r.join("/")}function u(t,e,r){if(!(this instanceof u))return new u(t,e,r);var s,a,h,f,d,v,y=p.slice(),_=typeof e,g=this,b=0;for("object"!==_&&"string"!==_&&(r=e,e=null),r&&"function"!=typeof r&&(r=l.parse),e=o(e),a=n(t||""),s=!a.protocol&&!a.slashes,g.slashes=a.slashes||s&&e.slashes,g.protocol=a.protocol||e.protocol||"",t=a.rest,a.slashes||(y[3]=[/(.*)/,"pathname"]);b<y.length;b++)f=y[b],"function"!=typeof f?(h=f[0],v=f[1],h!==h?g[v]=t:"string"==typeof h?~(d=t.indexOf(h))&&("number"==typeof f[2]?(g[v]=t.slice(0,d),t=t.slice(d+f[2])):(g[v]=t.slice(d),t=t.slice(0,d))):(d=h.exec(t))&&(g[v]=d[1],t=t.slice(0,d.index)),g[v]=g[v]||(s&&f[3]?e[v]||"":""),f[4]&&(g[v]=g[v].toLowerCase())):t=f(t);r&&(g.query=r(g.query)),s&&e.slashes&&"/"!==g.pathname.charAt(0)&&(""!==g.pathname||""!==e.pathname)&&(g.pathname=i(g.pathname,e.pathname)),c(g.port,g.protocol)||(g.host=g.hostname,g.port=""),g.username=g.password="",g.auth&&(f=g.auth.split(":"),g.username=f[0]||"",g.password=f[1]||""),g.origin=g.protocol&&g.host&&"file:"!==g.protocol?g.protocol+"//"+g.host:"null",g.href=g.toString()}function s(t,e,r){var o=this;switch(t){case"query":"string"==typeof e&&e.length&&(e=(r||l.parse)(e)),o[t]=e;break;case"port":o[t]=e,c(e,o.protocol)?e&&(o.host=o.hostname+":"+e):(o.host=o.hostname,o[t]="");break;case"hostname":o[t]=e,o.port&&(e+=":"+o.port),o.host=e;break;case"host":o[t]=e,/:\d+$/.test(e)?(e=e.split(":"),o.port=e.pop(),o.hostname=e.join(":")):(o.hostname=e,o.port="");break;case"protocol":o.protocol=e.toLowerCase(),o.slashes=!r;break;case"pathname":case"hash":if(e){var n="pathname"===t?"/":"#";o[t]=e.charAt(0)!==n?n+e:e}else o[t]=e;break;default:o[t]=e}for(var i=0;i<p.length;i++){var u=p[i];u[4]&&(o[u[1]]=o[u[1]].toLowerCase())}return o.origin=o.protocol&&o.host&&"file:"!==o.protocol?o.protocol+"//"+o.host:"null",o.href=o.toString(),o}function a(t){t&&"function"==typeof t||(t=l.stringify);var e,r=this,o=r.protocol;o&&":"!==o.charAt(o.length-1)&&(o+=":");var n=o+(r.slashes?"//":"");return r.username&&(n+=r.username,r.password&&(n+=":"+r.password),n+="@"),n+=r.host+r.pathname,e="object"==typeof r.query?t(r.query):r.query,e&&(n+="?"!==e.charAt(0)?"?"+e:e),r.hash&&(n+=r.hash),n}var c=r(17),l=r(16),h=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,f=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,p=[["#","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]],d={hash:1,query:1};u.prototype={set:s,toString:a},u.extractProtocol=n,u.location=o,u.qs=l,t.exports=u}).call(e,function(){return this}())}])});
!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}())}])});

@@ -5,3 +5,3 @@ import config from 'universal-config';

const unsplash = new Unsplash({
applicationId: config.get('APPLICATION_ID'),
accessKey: config.get('ACCESS_KEY'),
secret: config.get('SECRET'),

@@ -82,8 +82,2 @@ callbackUrl: config.get('CALLBACK_URL')

unsplash.photos.searchPhotos("bear", undefined, 1, 1)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.photos.getPhoto("kZ8dyUT0h30")

@@ -114,24 +108,2 @@ .then(toJson)

function categories() {
console.log("\nCategories");
unsplash.categories.listCategories()
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.categories.category(4)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.categories.categoryPhotos(4, 1, 1)
.then(toJson)
.then(json => {
console.log(json);
});
}
function collections() {

@@ -146,8 +118,2 @@ console.log("\nCollections");

unsplash.collections.listCuratedCollections(1, 10)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCollection(151165)

@@ -159,9 +125,2 @@ .then(toJson)

unsplash.collections.getCuratedCollection(94)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.getCollectionPhotos(151165)

@@ -173,8 +132,2 @@ .then(toJson)

unsplash.collections.getCuratedCollectionPhotos(94)
.then(toJson)
.then(json => {
console.log(json);
});
unsplash.collections.createCollection("Birds", "Wild birds from 'round the world", true)

@@ -181,0 +134,0 @@ .then(toJson)

module.exports = {
APPLICATION_ID: process.env.APPLICATION_ID || '5f82c78e3722e13421afa7674623013d3c7bc0673f114e08d8f0aa12eeec9373',
ACCESS_KEY: process.env.ACCESS_KEY || '5f82c78e3722e13421afa7674623013d3c7bc0673f114e08d8f0aa12eeec9373',
SECRET: process.env.SECRET || 'b5906a7297749a82b7aead883d14468bb9368c84a2ee3733946a919d71d2c24b',
CALLBACK_URL: process.env.CALLBACK_URL || 'http://unsplash-js.herokuapp.com'
};
var unsplash = new Unsplash({
applicationId: "{YOUR_APPLICATION_ID}",
accessKey: "{YOUR_ACCESS_KEY}",
secret: "{YOUR_SECRET}",

@@ -4,0 +4,0 @@ callbackUrl: "{YOUR_CALLBACK_URL}"

import Unsplash, { toJson } from "unsplash-js";
let unsplash = new Unsplash({
applicationId: "{YOUR_APPLICATION_ID}",
accessKey: "{YOUR_ACCESS_KEY}",
secret: "{YOUR_SECRET}",

@@ -6,0 +6,0 @@ callbackUrl: "{YOUR_CALLBACK_URL}"

@@ -24,3 +24,3 @@ "use strict";

var querystrings = _querystring2.default.stringify({
client_id: _this._applicationId,
client_id: _this._accessKey,
redirect_uri: _this._callbackUrl,

@@ -41,3 +41,3 @@ response_type: "code",

body: {
client_id: _this._applicationId,
client_id: _this._accessKey,
client_secret: _this._secret,

@@ -44,0 +44,0 @@ redirect_uri: _this._callbackUrl,

@@ -29,44 +29,6 @@ "use strict";

listCuratedCollections: function listCuratedCollections() {
var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var perPage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
getCollection: collection.bind(this),
var url = "/collections/curated";
var query = {
page: page,
per_page: perPage
};
getCollectionPhotos: collectionPhotos.bind(this),
return _this.request({
url: url,
method: "GET",
query: query
});
},
listFeaturedCollections: function listFeaturedCollections() {
var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var perPage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
var url = "/collections/featured";
var query = {
page: page,
per_page: perPage
};
return _this.request({
url: url,
method: "GET",
query: query
});
},
getCollection: collection.bind(this, false),
getCuratedCollection: collection.bind(this, true),
getCuratedCollectionPhotos: collectionPhotos.bind(this, true),
getCollectionPhotos: collectionPhotos.bind(this, false),
createCollection: createUpdateCollection.bind(this, null),

@@ -114,11 +76,8 @@

}
};
}
function collection(isCurated, id) {
var url = isCurated ? "/collections/curated/" + id : "/collections/" + id;
function collection(id) {
return this.request({
url: url,
url: "/collections/" + id,
method: "GET"

@@ -128,9 +87,7 @@ });

function collectionPhotos(isCurated, id) {
var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var perPage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
var orderBy = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "latest";
function collectionPhotos(id) {
var page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var perPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
var orderBy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "latest";
var url = isCurated ? "/collections/curated/" + id + "/photos" : "/collections/" + id + "/photos";
var query = {

@@ -143,3 +100,3 @@ page: page,

return this.request({
url: url,
url: "/collections/" + id + "/photos",
method: "GET",

@@ -146,0 +103,0 @@ query: query

@@ -39,53 +39,8 @@ "use strict";

listCuratedPhotos: function listCuratedPhotos() {
var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var perPage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
var orderBy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "latest";
var url = "/photos/curated";
var query = {
page: page,
per_page: perPage,
order_by: orderBy
};
return _this.request({
url: url,
method: "GET",
query: query
});
},
searchPhotos: function searchPhotos(q) {
var category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [""];
var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var perPage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
var url = "/photos/search";
var query = {
query: q,
category: category.length > 1 ? category.join(",") : category.toString(),
page: page,
per_page: perPage
};
return _this.request({
url: url,
method: "GET",
query: query
});
},
getPhoto: function getPhoto(id, width, height, rectangle) {
getPhoto: function getPhoto(id) {
var url = "/photos/" + id;
var query = {
w: width,
h: height,
rect: rectangle
};
return _this.request({
url: url,
method: "GET",
query: query
method: "GET"
});

@@ -95,3 +50,3 @@ },

getPhotoStats: function getPhotoStats(id) {
var url = "/photos/" + id + "/stats";
var url = "/photos/" + id + "/statistics";

@@ -108,3 +63,2 @@ return _this.request({

var url = "/photos/random";
var category = options.category || [];
var collections = options.collections || [];

@@ -116,7 +70,4 @@

orientation: options.orientation,
category: category.join(),
collections: collections.join(),
query: options.query,
w: options.width,
h: options.height,
c: options.cacheBuster || new Date().getTime(), // Avoid ajax response caching

@@ -139,18 +90,2 @@ count: options.count

uploadPhoto: function uploadPhoto(photo) {
if (!_this._bearerToken) {
throw new Error("Requires a bearerToken to be set.");
}
var url = "/photos";
return _this.request({
url: url,
method: "POST",
body: {
photo: photo
}
});
},
likePhoto: function likePhoto(id) {

@@ -157,0 +92,0 @@ if (!_this._bearerToken) {

@@ -8,29 +8,69 @@ "use strict";

function search() {
var _this = this;
return {
all: searcher.bind(this, "/search"),
photos: function photos() {
var keyword = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
var page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var perPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
var filters = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
photos: searcher.bind(this, "/search/photos"),
var collections = filters.collections || [];
var query = {
query: encodeURIComponent(keyword),
per_page: perPage,
orientation: filters.orientation,
collections: collections.join(),
page: page
};
users: searcher.bind(this, "/search/users"),
Object.keys(query).forEach(function (key) {
if (!query[key] && key != "query") {
delete query[key];
}
});
collections: searcher.bind(this, "/search/collections")
};
}
return _this.request({
url: "/search/photos",
method: "GET",
query: query
});
},
function searcher(url) {
var keyword = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var per_page = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
users: function users() {
var keyword = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
var page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var perPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
var query = {
query: keyword,
page: page,
per_page: per_page
var query = {
query: encodeURIComponent(keyword),
per_page: perPage,
page: page
};
return _this.request({
url: "/search/users",
method: "GET",
query: query
});
},
collections: function collections() {
var keyword = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
var page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var perPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
var query = {
query: encodeURIComponent(keyword),
per_page: perPage,
page: page
};
return _this.request({
url: "/search/collections",
method: "GET",
query: query
});
}
};
return this.request({
url: url,
method: "GET",
query: query
});
}

@@ -31,6 +31,2 @@ "use strict";

var _categories = require("./methods/categories");
var _categories2 = _interopRequireDefault(_categories);
var _collections = require("./methods/collections");

@@ -58,3 +54,3 @@

this._apiVersion = options.apiVersion || _constants.API_VERSION;
this._applicationId = options.applicationId;
this._accessKey = options.accessKey;
this._secret = options.secret;

@@ -64,2 +60,3 @@ this._callbackUrl = options.callbackUrl;

this._headers = options.headers || {};
this._timeout = options.timeout || 0; // 0 defaults to the OS timeout behaviour.

@@ -70,3 +67,2 @@ this.auth = _auth2.default.bind(this)();

this.photos = _photos2.default.bind(this)();
this.categories = _categories2.default.bind(this)();
this.collections = _collections2.default.bind(this)();

@@ -73,0 +69,0 @@ this.search = _search2.default.bind(this)();

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

"Accept-Version": this._apiVersion,
"Authorization": this._bearerToken ? "Bearer " + this._bearerToken : "Client-ID " + this._applicationId
"Authorization": this._bearerToken ? "Bearer " + this._bearerToken : "Client-ID " + this._accessKey
});
var timeout = this._timeout;

@@ -59,2 +60,3 @@ if (body) {

headers: headers,
timeout: timeout,
body: method !== "GET" && body ? formUrlEncode(body) : undefined

@@ -61,0 +63,0 @@ }

{
"name": "unsplash-js",
"version": "5.0.0",
"version": "6.0.0",
"description": "A Universal JavaScript wrapper for the Unsplash API",

@@ -15,6 +15,3 @@ "main": "lib/unsplash.js",

"flow": "flow status",
"test": "npm run lint && npm run flow && npm run test:node && npm run test:browser",
"test:browser": "karma start",
"test:ci": "npm run lint && npm run flow && npm run test:browser && npm run test:coverage",
"test:coverage": "babel-node ./node_modules/.bin/isparta cover _mocha -- --require test/setup",
"test": "npm run lint && npm run flow && npm run test:node",
"test:node": "mocha --compilers js:babel-core/register --require test/setup --recursive",

@@ -47,4 +44,4 @@ "test:watch": "npm test -- --watch",

"babel": "6.3.26",
"babel-cli": "6.4.0",
"babel-core": "6.4.0",
"babel-cli": "6.26.0",
"babel-core": "6.26.3",
"babel-eslint": "5.0.0-beta10",

@@ -56,16 +53,6 @@ "babel-loader": "6.2.1",

"babel-preset-es2015": "6.3.13",
"coveralls": "2.11.4",
"eslint": "1.10.2",
"expect": "1.12.2",
"flow-bin": "0.40.0",
"isparta": "4.0.0",
"istanbul": "0.4.2",
"karma": "0.13.21",
"karma-browserstack-launcher": "0.1.10",
"karma-chrome-launcher": "0.2.2",
"karma-firefox-launcher": "0.1.7",
"karma-mocha": "0.2.2",
"karma-safari-launcher": "0.1.1",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "1.7.0",
"mocha": "2.3.3",

@@ -72,0 +59,0 @@ "mockery": "1.4.0",

@@ -5,15 +5,7 @@ # Unsplash

[![Travis](https://img.shields.io/travis/unsplash/unsplash-js/master.svg?style=flat-square)](https://travis-ci.org/unsplash/unsplash-js/branches)
[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=RzJud09PSXV6TCtRWTY3V0czQUxrUVN5eWZJVDYvTmpGRUFCNEpuQ2Mzcz0tLVZaenhaUlM4RTRtdEZxaEhOblZLNWc9PQ==--a90a25acdadf06f74cf787ed47eb08cedd6f3935%)](https://www.browserstack.com/automate/public-build/RzJud09PSXV6TCtRWTY3V0czQUxrUVN5eWZJVDYvTmpGRUFCNEpuQ2Mzcz0tLVZaenhaUlM4RTRtdEZxaEhOblZLNWc9PQ==--a90a25acdadf06f74cf787ed47eb08cedd6f3935%)
[![Coveralls](https://img.shields.io/coveralls/unsplash/unsplash-js/master.svg?style=flat-square)](https://coveralls.io/github/unsplash/unsplash-js?branch=master)
A [Universal JavaScript](https://medium.com/@mjackson/universal-javascript-4761051b7ae9) wrapper for the [Unsplash API](https://unsplash.com/developers).
A server-side Javascript wrapper for working with the [Unsplash API](https://unsplash.com/developers).
Before using the Unsplash API, you need to [register as a developer](https://unsplash.com/developers) and read the [API Guidelines](https://help.unsplash.com/api-guidelines/unsplash-api-guidelines).
## Browser Support
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |
--- | --- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 10+ ✔ |
## Quick start

@@ -36,4 +28,2 @@

- [Helpers](https://github.com/unsplash/unsplash-js#helpers)
- [Shoutouts](https://github.com/unsplash/unsplash-js#shoutouts)
- [License](https://github.com/unsplash/unsplash-js#license)

@@ -46,7 +36,20 @@ ## Installation

## Dependencies
This library depends on [fetch](https://fetch.spec.whatwg.org/) to make requests to the Unsplash API. For environments that don't support fetch, you'll need to provide a [poly](https://github.com/github/fetch)[fill](https://github.com/bitinn/node-fetch).
This library depends on [fetch](https://fetch.spec.whatwg.org/) to make requests to the Unsplash API. For environments that don't support fetch, you'll need to provide a [polyfill](https://github.com/bitinn/node-fetch).
```js
// ES Modules syntax
import fetch from 'node-fetch';
global.fetch = fetch;
// require syntax
const fetch = require('node-fetch');
global.fetch = fetch;
```
## Usage
If you're using `unsplash-js` publicly in the browser, you'll need to proxy your requests through your server to sign the requests with the Access Key and/or Secret Key to abide by the [API Guideline](https://help.unsplash.com/articles/2511245-unsplash-api-guidelines) to keep keys confidential.
### Creating an instance
To create an instance, simply provide an _Object_ with your `access key` and `secret`.
To create an instance, simply provide an _Object_ with your `accessKey`:

@@ -56,32 +59,15 @@ ```js

import Unsplash from 'unsplash-js';
// require syntax
const Unsplash = require('unsplash-js').default;
const unsplash = new Unsplash({
applicationId: "{APP_ACCESS_KEY}",
secret: "{APP_SECRET}"
});
```
const unsplash = new Unsplash({ accessKey: "{APP_ACCESS_KEY}" });
If you already have a bearer token, you can also provide it to the constructor.
```js
const unsplash = new Unsplash({
applicationId: "{APP_ACCESS_KEY}",
secret: "{APP_SECRET}",
callbackUrl: "{CALLBACK_URL}",
bearerToken: "{USER_BEARER_TOKEN}"
});
```
You can also provide headers that will be set on every request by providing them to the constructor.
```js
const unsplash = new Unsplash({
applicationId: "{APP_ACCESS_KEY}",
secret: "{APP_SECRET}",
accessKey: "{APP_ACCESS_KEY}",
// Optionally you can also configure a custom header to be sent with every request
headers: {
"X-Custom-Header": "foo"
}
},
// Optionally if using a node-fetch polyfill or a version of fetch which supports the timeout option, you can configure the request timeout for all requests
timeout: 500 // values set in ms
});

@@ -92,2 +78,4 @@ ```

---
### React Native

@@ -102,37 +90,2 @@ For use with React Native, import from `unsplash-js/native` instead.

### Authorization workflow
Generate an authentication url with the scopes your app requires.
```js
const authenticationUrl = unsplash.auth.getAuthenticationUrl([
"public",
"read_user",
"write_user",
"read_photos",
"write_photos"
]);
```
Now that you have an authentication url, you'll want to redirect the user to it.
```js
location.assign(authenticationUrl);
```
After the user authorizes your app she'll be redirected to your callback url with a `code` querystring present. Request an access token using that code.
```js
// The OAuth code will be passed to your callback url as a querystring
unsplash.auth.userAuthentication(query.code)
.then(toJson)
.then(json => {
unsplash.auth.setBearerToken(json.access_token);
});
```
_For more information on the authroization workflow, consult the [Unsplash Documentation](https://unsplash.com/documentation#authorization-workflow)._
---
### Error handling

@@ -148,86 +101,37 @@ ```js

### Sidenote
## Instance Methods
All the instance methods below make use of the `toJson` helper method described [below](https://github.com/unsplash/unsplash-js#tojsonres)
---
## Instance Methods
- [Authorization](https://github.com/unsplash/unsplash-js#authorization)
- [Current User](https://github.com/unsplash/unsplash-js#current-user)
- [Search](https://github.com/unsplash/unsplash-js#search)
- [Photos](https://github.com/unsplash/unsplash-js#photos)
- [Users](https://github.com/unsplash/unsplash-js#users)
- [Photos](https://github.com/unsplash/unsplash-js#photos)
- [Collections](https://github.com/unsplash/unsplash-js#collections)
- [Search](https://github.com/unsplash/unsplash-js#search)
- [Stats](https://github.com/unsplash/unsplash-js#stats)
- [Authorization](https://github.com/unsplash/unsplash-js#authorization)
- [Current User](https://github.com/unsplash/unsplash-js#current-user)
<div id="authorization" />
All the instance methods below make use of the `toJson` helper method described [below](https://github.com/unsplash/unsplash-js#tojsonres)
### auth.getAuthenticationUrl(scopes)
Build an OAuth url with requested scopes.
__Arguments__
| Argument | Type | Opt/Required | Default |
|---|---|---|---|
|__`scopes`__|_Array<string>_|Optional| `["public"]` |
__Example__
```js
const authenticationUrl = unsplash.auth.getAuthenticationUrl([
"public",
"read_user",
"write_user",
"read_photos",
"write_photos"
]);
```
---
### auth.userAuthentication(code)
Retrieve a user's access token.
<div id="search" />
__Arguments__
<div id="search-photos" />
| Argument | Type | Opt/Required |
|---|---|---|
|__`code`__|_string_|Required|
### search.photos(keyword, page, per_page, filters)
Get a list of photos matching the keyword.
__Example__
```js
unsplash.auth.userAuthentication("{OAUTH_CODE}")
.then(toJson)
.then(json => {
// Your code
});
```
---
### auth.setBearerToken(accessToken)
Set a bearer token on the instance.
__Arguments__
| Argument | Type | Opt/Required |
|---|---|---|
|__`accessToken`__|_string_|Required|
| Argument | Type | Opt/Required | Default |
|---|---|---|---|
|__`keyword`__|_string_|Required||
|__`page`__|_number_|Optional||
|__`per_page`__|_number_|Optional|10|
|__`filters`__|_object_|Optional||
|__`filters.orientation`__|_string_|Optional||
|__`filters.collections`__|_array_|Optional||
__Example__
```js
unsplash.auth.setBearerToken("{BEARER_TOKEN}");
```
---
<div id="current-user" />
### currentUser.profile()
Get the user’s profile.
__Arguments__
_N/A_
__Example__
```js
unsplash.currentUser.profile()
unsplash.search.photos("dogs", 1, 10, { orientation: "portrait" })
.then(toJson)

@@ -238,46 +142,18 @@ .then(json => {

```
---
### currentUser.updateProfile(options)
Update the current user’s profile.
### search.users(keyword, page, per_page)
Get a list of users matching the keyword.
__Arguments__
| Argument | Type | Opt/Required |Notes|
| Argument | Type | Opt/Required | Default |
|---|---|---|---|
|__`options`__|_Object_|Required|Object with the following optional keys: `username`, `firstName`, `lastName`, `email`, `url`, `location`, `bio`, `instagramUsername`|
|__`keyword`__|_string_|Required||
|__`page`__|_number_|Optional||
|__`per_page`__|_number_|Optional|10|
__Example__
```js
unsplash.currentUser.updateProfile({
username: "drizzy",
firstName: "Aubrey",
lastName: "Graham",
email: "drizzy@octobersveryown.com",
url: "http://octobersveryown.com",
location: "Toronto, Ontario, Canada",
bio: "Views from the 6",
instagramUsername: "champagnepapi"
})
.then(toJson)
.then(json => {
// Your code
});
```
---
<div id="users" />
### users.profile(username)
Retrieve public details on a given user.
__Arguments__
| Argument | Type | Opt/Required |
|---|---|---|
|__`username`__|_string_|Required|
__Example__
```js
unsplash.users.profile("naoufal")
unsplash.search.users("steve", 1)
.then(toJson)

@@ -288,64 +164,18 @@ .then(json => {

```
---
### users.statistics(username, resolution, quantity)
Retrieve statistics for a given user.
### search.collections(keyword, page, per_page)
Get a list of collections matching the keyword.
__Arguments__
| Argument | Type | Opt/Required | Notes | Default
|---|---|---|---|---|
|__`username`__|_string_|Required|
|__`resolution`__|_string_|Optional|Currently only `days`|`days`|
|__`quantity`__|_string_|Optional||30|
__Example__
```js
unsplash.users.statistics("naoufal", "days", 30)
.then(toJson)
.then(json => {
// Your code
});
```
---
### users.photos(username, page, perPage, orderBy, stats)
Get a list of photos uploaded by a user.
__Arguments__
| Argument | Type | Opt/Required | Notes | Default |
|---|---|---|---|---|
|__`username`__|_string_|Required|||
|__`page`__|_number_|Optional||1|
|__`perPage`__|_number_|Optional||10|
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|`latest`|
|__`stats`__|_boolean_|Optional||`false`|
__Example__
```js
unsplash.users.photos("naoufal", 1, 10, "popular", false)
.then(toJson)
.then(json => {
// Your code
});
```
---
### users.likes(username, page, perPage, orderBy)
Get a list of photos liked by a user.
__Arguments__
| Argument | Type | Opt/Required | Notes |
| Argument | Type | Opt/Required | Default |
|---|---|---|---|
|__`username`__|_string_|Required||
|__`keyword`__|_string_|Required||
|__`page`__|_number_|Optional||
|__`perPage`__|_number_|Optional||
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|
|__`per_page`__|_number_|Optional|10|
__Example__
```js
unsplash.users.likes("naoufal", 2, 15, "popular")
unsplash.search.collections("dogs", 1)
.then(toJson)

@@ -356,24 +186,3 @@ .then(json => {

```
---
### users.collections(username, page, perPage, orderBy)
Get a list of collections created by the user.
__Arguments__
| Argument | Type | Opt/Required | Notes |
|---|---|---|---|
|__`username`__|_string_|Required||
|__`page`__|_number_|Optional||
|__`perPage`__|_number_|Optional||
|__`orderBy`__|_string_|Optional|`published` or `updated`|
__Example__
```js
unsplash.users.collections("naoufal", 2, 15, "updated")
.then(toJson)
.then(json => {
// Your code
});
```
---

@@ -406,3 +215,3 @@

### photos.getPhoto(id, width, height, rectangle)
### photos.getPhoto(id)
Retrieve a single photo.

@@ -415,9 +224,6 @@

|__`id`__|_string_|Required|
|__`width`__|_number_|Optional|
|__`height`__|_number_|Optional|
|__`rectangle`__|_Array<number>_|Optional|
__Example__
```js
unsplash.photos.getPhoto("mtNweauBsMQ", 1920, 1080, [0, 0, 1920, 1080])
unsplash.photos.getPhoto("mtNweauBsMQ")
.then(toJson)

@@ -451,3 +257,3 @@ .then(json => {

### photos.getRandomPhoto({ width, height, query, username, featured })
### photos.getRandomPhoto({ query, username, featured })
Retrieve a single random photo, given optional filters.

@@ -465,4 +271,2 @@

|---|---|---|
|__`width`__|_number_|Optional|
|__`height`__|_number_|Optional|
|__`query`__|_string_|Optional|

@@ -555,11 +359,76 @@ |__`username`__|_string_|Optional|

<div id="collections" />
<div id="users" />
### collections.listCollections(page, perPage, orderBy)
Get a single page from the list of all collections.
### users.profile(username)
Retrieve public details on a given user.
__Arguments__
| Argument | Type | Opt/Required |Notes|
| Argument | Type | Opt/Required |
|---|---|---|
|__`username`__|_string_|Required|
__Example__
```js
unsplash.users.profile("naoufal")
.then(toJson)
.then(json => {
// Your code
});
```
---
### users.statistics(username, resolution, quantity)
Retrieve statistics for a given user.
__Arguments__
| Argument | Type | Opt/Required | Notes | Default
|---|---|---|---|---|
|__`username`__|_string_|Required|
|__`resolution`__|_string_|Optional|Currently only `days`|`days`|
|__`quantity`__|_string_|Optional||30|
__Example__
```js
unsplash.users.statistics("naoufal", "days", 30)
.then(toJson)
.then(json => {
// Your code
});
```
---
### users.photos(username, page, perPage, orderBy, stats)
Get a list of photos uploaded by a user.
__Arguments__
| Argument | Type | Opt/Required | Notes | Default |
|---|---|---|---|---|
|__`username`__|_string_|Required|||
|__`page`__|_number_|Optional||1|
|__`perPage`__|_number_|Optional||10|
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|`latest`|
|__`stats`__|_boolean_|Optional||`false`|
__Example__
```js
unsplash.users.photos("naoufal", 1, 10, "popular", false)
.then(toJson)
.then(json => {
// Your code
});
```
---
### users.likes(username, page, perPage, orderBy)
Get a list of photos liked by a user.
__Arguments__
| Argument | Type | Opt/Required | Notes |
|---|---|---|---|
|__`username`__|_string_|Required||
|__`page`__|_number_|Optional||

@@ -571,3 +440,3 @@ |__`perPage`__|_number_|Optional||

```js
unsplash.collections.listCollections(1, 10, "popular")
unsplash.users.likes("naoufal", 2, 15, "popular")
.then(toJson)

@@ -580,15 +449,17 @@ .then(json => {

### collections.listFeaturedCollections(page, perPage)
Get a single page from the list of featured collections.
### users.collections(username, page, perPage, orderBy)
Get a list of collections created by the user.
__Arguments__
| Argument | Type | Opt/Required |
|---|---|---|
|__`page`__|_number_|Optional|
|__`perPage`__|_number_|Optional|
| Argument | Type | Opt/Required | Notes |
|---|---|---|---|
|__`username`__|_string_|Required||
|__`page`__|_number_|Optional||
|__`perPage`__|_number_|Optional||
|__`orderBy`__|_string_|Optional|`published` or `updated`|
__Example__
```js
unsplash.collections.listFeaturedCollections(1, 10)
unsplash.users.collections("naoufal", 2, 15, "updated")
.then(toJson)

@@ -601,2 +472,25 @@ .then(json => {

<div id="collections" />
### collections.listCollections(page, perPage, orderBy)
Get a single page from the list of all collections.
__Arguments__
| Argument | Type | Opt/Required |Notes|
|---|---|---|---|
|__`page`__|_number_|Optional||
|__`perPage`__|_number_|Optional||
|__`orderBy`__|_string_|Optional|`latest`, `popular` or `oldest`|
__Example__
```js
unsplash.collections.listCollections(1, 10, "popular")
.then(toJson)
.then(json => {
// Your code
});
```
---
### collections.getCollection(id)

@@ -768,21 +662,14 @@ Retrieve a single collection. To view a user’s private collections, the `read_collections` scope is required.

<div id="search" />
<div id="stats" />
<div id="search-photos" />
### stats.total()
Get a list of download counts for all of Unsplash.
### search.photos(keyword, page, per_page)
Get a list of photos matching the keyword.
__Arguments__
| Argument | Type | Opt/Required | Default |
|---|---|---|---|
|__`keyword`__|_string_|Required||
|__`page`__|_number_|Optional||
|__`per_page`__|_number_|Optional|10|
_N/A_
__Example__
```js
unsplash.search.photos("dogs", 1)
unsplash.stats.total()
.then(toJson)

@@ -794,26 +681,64 @@ .then(json => {

### search.users(keyword, page, per_page)
Get a list of users matching the keyword.
---
__Arguments__
<div id="authorization" />
| Argument | Type | Opt/Required | Default |
|---|---|---|---|
|__`keyword`__|_string_|Required||
|__`page`__|_number_|Optional||
|__`per_page`__|_number_|Optional|10|
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({
accessKey: "{APP_ACCESS_KEY}",
secret: "{APP_SECRET}",
callbackUrl: "{CALLBACK_URL}"
});
```
__Example__
If you already have a bearer token, you can also provide it to the constructor:
```js
unsplash.search.users("steve", 1)
const unsplash = new Unsplash({
accessKey: "{APP_ACCESS_KEY}",
secret: "{APP_SECRET}",
callbackUrl: "{CALLBACK_URL}",
bearerToken: "{USER_BEARER_TOKEN}"
});
```
Generate an authentication url with the scopes your app requires.
```js
const authenticationUrl = unsplash.auth.getAuthenticationUrl([
"public",
"read_user",
"write_user",
"read_photos",
"write_photos"
]);
```
Now that you have an authentication url, you'll want to redirect the user to it.
```js
location.assign(authenticationUrl);
```
After the user authorizes your app she'll be redirected to your callback url with a `code` querystring present. Request an access token using that code.
```js
// The OAuth code will be passed to your callback url as a querystring
unsplash.auth.userAuthentication(query.code)
.then(toJson)
.then(json => {
// Your code
unsplash.auth.setBearerToken(json.access_token);
});
```
### search.collections(keyword, page, per_page)
Get a list of collections matching the keyword.
_For more information on the authroization workflow, consult the [Unsplash Documentation](https://unsplash.com/documentation#authorization-workflow)._
---
### auth.getAuthenticationUrl(scopes)
Build an OAuth url with requested scopes.
__Arguments__

@@ -823,10 +748,28 @@

|---|---|---|---|
|__`keyword`__|_string_|Required||
|__`page`__|_number_|Optional||
|__`per_page`__|_number_|Optional|10|
|__`scopes`__|_Array<string>_|Optional| `["public"]` |
__Example__
```js
const authenticationUrl = unsplash.auth.getAuthenticationUrl([
"public",
"read_user",
"write_user",
"read_photos",
"write_photos"
]);
```
---
### auth.userAuthentication(code)
Retrieve a user's access token.
__Arguments__
| Argument | Type | Opt/Required |
|---|---|---|
|__`code`__|_string_|Required|
__Example__
```js
unsplash.search.collections("dogs", 1)
unsplash.auth.userAuthentication("{OAUTH_CODE}")
.then(toJson)

@@ -837,9 +780,23 @@ .then(json => {

```
---
### auth.setBearerToken(accessToken)
Set a bearer token on the instance.
__Arguments__
| Argument | Type | Opt/Required |
|---|---|---|
|__`accessToken`__|_string_|Required|
__Example__
```js
unsplash.auth.setBearerToken("{BEARER_TOKEN}");
```
---
<div id="stats" />
<div id="current-user" />
### stats.total()
Get a list of download counts for all of Unsplash.
### currentUser.profile()
Get the user’s profile.

@@ -852,3 +809,3 @@ __Arguments__

```js
unsplash.stats.total()
unsplash.currentUser.profile()
.then(toJson)

@@ -861,2 +818,30 @@ .then(json => {

### currentUser.updateProfile(options)
Update the current user’s profile.
__Arguments__
| Argument | Type | Opt/Required |Notes|
|---|---|---|---|
|__`options`__|_Object_|Required|Object with the following optional keys: `username`, `firstName`, `lastName`, `email`, `url`, `location`, `bio`, `instagramUsername`|
__Example__
```js
unsplash.currentUser.updateProfile({
username: "drizzy",
firstName: "Aubrey",
lastName: "Graham",
email: "drizzy@octobersveryown.com",
url: "http://octobersveryown.com",
location: "Toronto, Ontario, Canada",
bio: "Views from the 6",
instagramUsername: "champagnepapi"
})
.then(toJson)
.then(json => {
// Your code
});
```
---
## Helpers

@@ -876,3 +861,3 @@

const unsplash = new Unsplash({
applicationId: "{YOUR_ACCESS_KEY}",
accessKey: "{YOUR_ACCESS_KEY}",
secret: "{YOUR_SECRET_KEY}"

@@ -887,27 +872,1 @@ });

```
---
## Shoutouts
- Shoutout to all the [contributors](https://github.com/unsplash/unsplash-js/graphs/contributors) for lending a helping hand.
- Shoutout to [BrowserStack](https://www.browserstack.com/) for letting us use their service to run automated browser tests.
## License
Copyright (c) 2019, [Unsplash](https://unsplash.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@@ -10,3 +10,3 @@ /* @flow */

let querystrings = querystring.stringify({
client_id: this._applicationId,
client_id: this._accessKey,
redirect_uri: this._callbackUrl,

@@ -29,3 +29,3 @@ response_type: "code",

body: {
client_id: this._applicationId,
client_id: this._accessKey,
client_secret: this._secret,

@@ -32,0 +32,0 @@ redirect_uri: this._callbackUrl,

@@ -20,38 +20,6 @@ /* @flow */

listCuratedCollections: (page: number = 1, perPage: number = 10) => {
const url = "/collections/curated";
const query = {
page,
per_page: perPage
};
getCollection: collection.bind(this),
return this.request({
url: url,
method: "GET",
query
});
},
getCollectionPhotos: collectionPhotos.bind(this),
listFeaturedCollections: (page: number = 1, perPage: number = 10) => {
const url = "/collections/featured";
const query = {
page,
per_page: perPage
};
return this.request({
url: url,
method: "GET",
query
});
},
getCollection: collection.bind(this, false),
getCuratedCollection: collection.bind(this, true),
getCuratedCollectionPhotos: collectionPhotos.bind(this, true),
getCollectionPhotos: collectionPhotos.bind(this, false),
createCollection: createUpdateCollection.bind(this, null),

@@ -99,13 +67,8 @@

}
};
}
function collection(isCurated: bool, id: string) {
const url = isCurated
? `/collections/curated/${id}`
: `/collections/${id}`;
function collection(id: string) {
return this.request({
url: url,
url: `/collections/${id}`,
method: "GET"

@@ -116,3 +79,2 @@ });

function collectionPhotos(
isCurated: bool,
id: string,

@@ -123,6 +85,2 @@ page: number = 1,

) {
const url = isCurated
? `/collections/curated/${id}/photos`
: `/collections/${id}/photos`;
const query = {

@@ -135,3 +93,3 @@ page,

return this.request({
url: url,
url: `/collections/${id}/photos`,
method: "GET",

@@ -138,0 +96,0 @@ query

@@ -22,47 +22,8 @@ /* @flow */

listCuratedPhotos: (page = 1, perPage = 10, orderBy = "latest") => {
const url = "/photos/curated";
const query = {
page,
per_page: perPage,
order_by: orderBy
};
return this.request({
url,
method: "GET",
query
});
},
searchPhotos: (q, category = [""], page = 1, perPage = 10) => {
const url = "/photos/search";
const query = {
query: q,
category: category.length > 1
? category.join(",")
: category.toString(),
page,
per_page: perPage
};
return this.request({
url,
method: "GET",
query
});
},
getPhoto: (id, width, height, rectangle) => {
getPhoto: (id) => {
const url = `/photos/${id}`;
const query = {
w: width,
h: height,
rect: rectangle
};
return this.request({
url,
method: "GET",
query
method: "GET"
});

@@ -72,3 +33,3 @@ },

getPhotoStats: (id) => {
const url = `/photos/${id}/stats`;
const url = `/photos/${id}/statistics`;

@@ -83,3 +44,2 @@ return this.request({

const url = "/photos/random";
const category = options.category || [];
const collections = options.collections || [];

@@ -91,7 +51,4 @@

orientation: options.orientation,
category: category.join(),
collections: collections.join(),
query: options.query,
w: options.width,
h: options.height,
c: options.cacheBuster || new Date().getTime(), // Avoid ajax response caching

@@ -114,18 +71,2 @@ count: options.count

uploadPhoto: (photo) => {
if (!this._bearerToken) {
throw new Error("Requires a bearerToken to be set.");
}
const url = "/photos";
return this.request({
url,
method: "POST",
body: {
photo: photo
}
});
},
likePhoto: (id) => {

@@ -132,0 +73,0 @@ if (!this._bearerToken) {

@@ -5,24 +5,53 @@ /* @flow */

return {
all: searcher.bind(this, "/search"),
photos: (keyword = "", page = 1, perPage = 10, filters = {}) => {
const collections = filters.collections || [];
const query = {
query: encodeURIComponent(keyword),
per_page: perPage,
orientation: filters.orientation,
collections: collections.join(),
page
};
photos: searcher.bind(this, "/search/photos"),
Object.keys(query).forEach(key => {
if (!query[key] && key != "query") {
delete query[key];
}
});
users: searcher.bind(this, "/search/users"),
return this.request({
url: "/search/photos",
method: "GET",
query
});
},
collections: searcher.bind(this, "/search/collections")
};
}
users: (keyword = "", page = 1, perPage = 10) => {
const query = {
query: encodeURIComponent(keyword),
per_page: perPage,
page
};
function searcher(url, keyword = "", page = 1, per_page = 10) {
const query = {
query: keyword,
page,
per_page
return this.request({
url: "/search/users",
method: "GET",
query
});
},
collections: (keyword = "", page = 1, perPage = 10) => {
const query = {
query: encodeURIComponent(keyword),
per_page: perPage,
page
};
return this.request({
url: "/search/collections",
method: "GET",
query
});
}
};
return this.request({
url,
method: "GET",
query
});
}

@@ -12,3 +12,2 @@ /* @flow */

import photos from "./methods/photos";
import categories from "./methods/categories";
import collections from "./methods/collections";

@@ -21,7 +20,8 @@ import search from "./methods/search";

_apiVersion: string;
_applicationId: string;
_secret: string;
_accessKey: string;
_secret: ?string;
_callbackUrl: ?string;
_bearerToken: ?string;
_headers: ?Object;
_timeout: ?number;

@@ -32,3 +32,2 @@ auth: Object;

photos: Object;
categories: Object;
collections: Object;

@@ -43,7 +42,8 @@ search: Object;

apiVersion: string,
applicationId: string,
secret: string,
accessKey: string,
secret?: string,
callbackUrl?: string,
bearerToken?: string,
headers?: Object
headers?: Object,
timeout?: number
}

@@ -53,3 +53,3 @@ ) {

this._apiVersion = options.apiVersion || API_VERSION;
this._applicationId = options.applicationId;
this._accessKey = options.accessKey;
this._secret = options.secret;

@@ -59,2 +59,3 @@ this._callbackUrl = options.callbackUrl;

this._headers = options.headers || {};
this._timeout = options.timeout || 0; // 0 defaults to the OS timeout behaviour.

@@ -65,3 +66,2 @@ this.auth = auth.bind(this)();

this.photos = photos.bind(this)();
this.categories = categories.bind(this)();
this.collections = collections.bind(this)();

@@ -68,0 +68,0 @@ this.search = search.bind(this)();

@@ -32,4 +32,5 @@ /* @flow */

? `Bearer ${this._bearerToken}`
: `Client-ID ${this._applicationId}`
: `Client-ID ${this._accessKey}`
});
let timeout = this._timeout;

@@ -49,2 +50,3 @@ if (body) {

headers,
timeout,
body: (method !== "GET") && body

@@ -51,0 +53,0 @@ ? formUrlEncode(body)

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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