From 1dfffc8a5f3b53db4373432afd9e17bc8cbd923a Mon Sep 17 00:00:00 2001 From: Jonathan Steele Date: Mon, 22 May 2017 15:39:59 +0100 Subject: [PATCH] feat: Add order items method (#85) * feat: Adding Items method for Orders class * test: Tests passing * build: Rollup --- dist/moltin.cjs.js | 2 +- dist/moltin.cjs.js.map | 2 +- src/endpoints/orders.js | 4 ++++ test/factories.js | 12 ++++++++++++ test/unit/orders.js | 19 +++++++++++++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/dist/moltin.cjs.js b/dist/moltin.cjs.js index 76dd0d5c7..c1eed98b1 100644 --- a/dist/moltin.cjs.js +++ b/dist/moltin.cjs.js @@ -1,2 +1,2 @@ -"use strict";function buildRelationshipData(t,e){var n=[];return null===e||0===e.length?"[]":"string"==typeof e?[{type:t,id:e}]:(Array.isArray(e)&&(n=e.map(function(e){return{type:t,id:e}})),n)}function cartIdentifier(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1);var n=new StorageFactory;return t||e||null===n.get("mcart")?(e||(e="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(16*Math.random()|0).toString(16)})),n.set("mcart",e),e):n.get("mcart")}function parseJSON(t){return new Promise(function(e){return t.json().then(function(n){return e({status:t.status,ok:t.ok,json:n})})})}function setHeaderContentType(t,e){var n="application/json";return"files"===t&&"POST"===e&&(n="multipart/form-data"),n}function formatFilterString(t,e){return Object.keys(e).map(function(n){var r=e[n];return t+"("+n+","+r+")"}).join(":")}function formatQueryString(t,e){if("limit"===t||"offset"===t)return"page"+e;if("filter"===t){return t+"="+Object.keys(e).map(function(t){return formatFilterString(t,e[t])}).join(":")}return t+"="+e}function buildQueryParams(t){var e=t.includes,n=t.sort,r=t.limit,i=t.offset,o=t.filter,s={};return e&&(s.include=e),n&&(s.sort="("+n+")"),r&&(s.limit="[limit]="+r),i&&(s.offset="[offset]="+i),o&&(s.filter=o),Object.keys(s).map(function(t){return formatQueryString(t,s[t])}).join("&")}function buildURL(t,e){if(e.includes||e.sort||e.limit||e.offset||e.filter){return t+"?"+buildQueryParams(e)}return t}function buildRequestBody(t){return t?'{"data":'+JSON.stringify(t)+"}":null}function buildCartItemData(t,e,n){return void 0===n&&(n="cart_item"),{id:t,type:n,quantity:parseInt(e,10)}}function isFunc(t){return"[object Function]"===toString.call(t)}function icPart(t){return t.split("").map(function(t){return"(?:"+t.toUpperCase()+"|"+t.toLowerCase()+")"}).join("")}function remove(t,e){for(var n=t.length-1;n>=0;n--)t[n]===e&&Array.prototype.splice.call(t,n,1)}function hasProp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function en(t){t.plural(/$/,"s"),t.plural(/s$/i,"s"),t.plural(/^(ax|test)is$/i,"$1es"),t.plural(/(octop|vir)us$/i,"$1i"),t.plural(/(octop|vir)i$/i,"$1i"),t.plural(/(alias|status)$/i,"$1es"),t.plural(/(bu)s$/i,"$1ses"),t.plural(/(buffal|tomat)o$/i,"$1oes"),t.plural(/([ti])um$/i,"$1a"),t.plural(/([ti])a$/i,"$1a"),t.plural(/sis$/i,"ses"),t.plural(/(?:([^f])fe|([lr])f)$/i,"$1$2ves"),t.plural(/(hive)$/i,"$1s"),t.plural(/([^aeiouy]|qu)y$/i,"$1ies"),t.plural(/(x|ch|ss|sh)$/i,"$1es"),t.plural(/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"),t.plural(/^(m|l)ouse$/i,"$1ice"),t.plural(/^(m|l)ice$/i,"$1ice"),t.plural(/^(ox)$/i,"$1en"),t.plural(/^(oxen)$/i,"$1"),t.plural(/(quiz)$/i,"$1zes"),t.singular(/s$/i,""),t.singular(/(ss)$/i,"$1"),t.singular(/(n)ews$/i,"$1ews"),t.singular(/([ti])a$/i,"$1um"),t.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"),t.singular(/(^analy)(sis|ses)$/i,"$1sis"),t.singular(/([^f])ves$/i,"$1fe"),t.singular(/(hive)s$/i,"$1"),t.singular(/(tive)s$/i,"$1"),t.singular(/([lr])ves$/i,"$1f"),t.singular(/([^aeiouy]|qu)ies$/i,"$1y"),t.singular(/(s)eries$/i,"$1eries"),t.singular(/(m)ovies$/i,"$1ovie"),t.singular(/(x|ch|ss|sh)es$/i,"$1"),t.singular(/^(m|l)ice$/i,"$1ouse"),t.singular(/(bus)(es)?$/i,"$1"),t.singular(/(o)es$/i,"$1"),t.singular(/(shoe)s$/i,"$1"),t.singular(/(cris|test)(is|es)$/i,"$1is"),t.singular(/^(a)x[ie]s$/i,"$1xis"),t.singular(/(octop|vir)(us|i)$/i,"$1us"),t.singular(/(alias|status)(es)?$/i,"$1"),t.singular(/^(ox)en/i,"$1"),t.singular(/(vert|ind)ices$/i,"$1ex"),t.singular(/(matr)ices$/i,"$1ix"),t.singular(/(quiz)zes$/i,"$1"),t.singular(/(database)s$/i,"$1"),t.irregular("person","people"),t.irregular("man","men"),t.irregular("child","children"),t.irregular("sex","sexes"),t.irregular("move","moves"),t.irregular("zombie","zombies"),t.uncountable("equipment","information","rice","money","species","series","fish","sheep","jeans","police")}function inflections(t,e){if(isFunc(t)&&(e=t,t=null),t=t||"en",!e)return Inflector.getInstance(t);e(Inflector.getInstance(t))}function applyInflections(t,e){var n,r,i,o=""+t;if(0===o.length)return o;var s=o.toLowerCase().match(/\b\w+$/);if(s&&inflections().uncountables.indexOf(s[0])>-1)return o;for(var a=0,u=e.length;a1&&void 0!==arguments[1]?arguments[1]:"en").plurals)}function capitalize(t){var e=null===t||void 0===t?"":String(t);return e.charAt(0).toUpperCase()+e.slice(1)}function transliterations(t,e){if(isFunc(t)&&(e=t,t=null),t=t||"en",!e)return Transliterator.getInstance(t);e(Transliterator.getInstance(t))}function transliterate(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.locale||"en",r=e.replacement||"?";return transliterations(n).transliterate(t,r)}Object.defineProperty(exports,"__esModule",{value:!0});var fetchEverywhere=require("fetch-everywhere"),es6Promise=require("es6-promise"),pkg=require("../package.json"),Config=function(t){this.client_id=t.client_id,this.client_secret=t.client_secret,this.host="api.moltin.com",this.port="443",this.protocol="https",this.version="v2",this.debug=!1,this.currency=t.currency,this.language=!1,this.timeout=6e4,this.auth={expires:3600,uri:"oauth/access_token"},this.methods=["GET","POST","PUT","DELETE"],this.sdk={version:pkg.version,language:"JS"}},StorageFactory=function(){if("undefined"==typeof localStorage||null===localStorage){var t=require("node-localstorage").LocalStorage;this.localStorage=new t("./localStorage")}else this.localStorage=window.localStorage};StorageFactory.prototype.set=function(t,e){return this.localStorage.setItem(t,e)},StorageFactory.prototype.get=function(t){return this.localStorage.getItem(t)},StorageFactory.prototype.delete=function(t){return this.localStorage.removeItem(t)};var RequestFactory=function(t){this.config=t,this.storage=new StorageFactory};RequestFactory.prototype.authenticate=function(){var t=this.config,e=this.storage;if(!t.client_id)throw new Error("You must have a client_id set");var n={grant_type:t.client_secret?"client_credentials":"implicit",client_id:t.client_id};t.client_secret&&(n.client_secret=t.client_secret);var r=new Promise(function(e,r){fetch(t.protocol+"://"+t.host+"/"+t.auth.uri,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:Object.keys(n).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(n[t])}).join("&")}).then(parseJSON).then(function(t){t.ok&&e(t.json),r(t.json)}).catch(function(){return r("Fetch error - check your network")})});return r.then(function(t){e.set("mtoken",t.access_token),e.set("mexpires",t.expires)}),r},RequestFactory.prototype.send=function(t,e,n){var r=this;void 0===n&&(n=null);var i=this.config,o=this.storage;return new Promise(function(s,a){var u=function(){var r={Authorization:"Bearer: "+o.get("mtoken"),"Content-Type":setHeaderContentType(t,e),"X-MOLTIN-SDK-LANGUAGE":i.sdk.language,"X-MOLTIN-SDK-VERSION":i.sdk.version};i.currency&&(r["X-MOLTIN-CURRENCY"]=i.currency),fetch(i.protocol+"://"+i.host+"/"+i.version+"/"+t,{method:e.toUpperCase(),headers:r,body:buildRequestBody(n)}).then(parseJSON).then(function(t){t.ok&&s(t.json),a(t.json)}).catch(function(){return a("Fetch error - check your network")})};return!o.get("mtoken")||Date.now().toString()>=o.get("mexpires")?r.authenticate().then(u).catch(function(t){return a(t)}):u()})};var toString=Object.prototype.toString,classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},createClass=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"all";"all"===t?(this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[]):this[t]=[]}}]),t}(),defaults$1={en:en};for(var locale in defaults$1)inflections(locale,defaults$1[locale]);var DEFAULT_APPROXIMATIONS={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","×":"x","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"Th","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","ĝ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"'n","Ŋ":"NG","ŋ":"ng","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z"},DEFAULT_REPLACEMENT_CHAR="?",instances$1={},Transliterator=function(){function t(){var e=this;classCallCheck(this,t),this.approximations={};for(var n in DEFAULT_APPROXIMATIONS)e.approximate(n,DEFAULT_APPROXIMATIONS[n])}return createClass(t,null,[{key:"getInstance",value:function(e){return instances$1[e]=instances$1[e]||new t,instances$1[e]}}]),createClass(t,[{key:"approximate",value:function(t,e){this.approximations[t]=e}},{key:"transliterate",value:function(t,e){var n=this;return t.replace(/[^\u0000-\u007f]/g,function(t){return n.approximations[t]||e||DEFAULT_REPLACEMENT_CHAR})}}]),t}(),BaseExtend=function(t){this.request=new RequestFactory(t),this.config=t};BaseExtend.prototype.All=function(){return this.call=this.request.send(buildURL(this.endpoint,{includes:this.includes,sort:this.sort,limit:this.limit,offset:this.offset,filter:this.filter}),"GET"),this.call},BaseExtend.prototype.Get=function(t){return this.call=this.request.send(buildURL(this.endpoint+"/"+t,{includes:this.includes}),"GET"),this.call},BaseExtend.prototype.Limit=function(t){return this.limit=t,this},BaseExtend.prototype.Offset=function(t){return this.offset=t,this},BaseExtend.prototype.Sort=function(t){return this.sort=t,this};var CatalogueExtend=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Create=function(t){return this.request.send(""+this.endpoint,"POST",t)},e.prototype.Delete=function(t){return this.request.send(this.endpoint+"/"+t,"DELETE")},e.prototype.Update=function(t,e){return this.request.send(this.endpoint+"/"+t,"PUT",e)},e.prototype.With=function(t){return this.includes=t.toString().toLowerCase(),this},e}(BaseExtend),ProductsEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="products"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Filter=function(t){return this.filter=t,this},e.prototype.CreateRelationships=function(t,e,n){var r=buildRelationshipData(e,n);return this.request.send(this.endpoint+"/"+t+"/relationships/"+pluralize(e),"POST",r)},e.prototype.DeleteRelationships=function(t,e,n){var r=buildRelationshipData(e,n);return this.request.send(this.endpoint+"/"+t+"/relationships/"+pluralize(e),"DELETE",r)},e.prototype.UpdateRelationships=function(t,e,n){void 0===n&&(n=null);var r=buildRelationshipData(e,n);return this.request.send(this.endpoint+"/"+t+"/relationships/"+pluralize(e),"PUT",r)},e}(CatalogueExtend),CurrenciesEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="currencies",this.storage=new StorageFactory}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Create=function(t){return this.request.send(""+this.endpoint,"POST",t)},e.prototype.Delete=function(t){return this.request.send(this.endpoint+"/"+t,"DELETE")},e.prototype.Update=function(t,e){return this.request.send(this.endpoint+"/"+t,"PUT",e)},e.prototype.Set=function(t){var e=this.storage,n=this.config;return e.set("mcurrency",t),n.currency=t,new Promise(function(t,n){var r=e.get("mcurrency");try{t(r)}catch(t){n(new Error(t))}})},e.prototype.Active=function(){var t=this.storage;return new Promise(function(e,n){var r=t.get("mcurrency");try{e(r)}catch(t){n(new Error(t))}})},e}(BaseExtend),BrandsEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="brands"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(CatalogueExtend),CartEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="carts",this.cartId=cartIdentifier()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Get=function(t){return void 0===t&&(t=this.cartId),this.request.send(this.endpoint+"/"+t,"GET")},e.prototype.Items=function(t){return void 0===t&&(t=this.cartId),this.request.send(this.endpoint+"/"+t+"/items","GET")},e.prototype.AddProduct=function(t,e,n){void 0===e&&(e=1),void 0===n&&(n=this.cartId);var r=buildCartItemData(t,e);return this.request.send(this.endpoint+"/"+n+"/items","POST",r)},e.prototype.AddCustomItem=function(t,e){void 0===e&&(e=this.cartId);var n=Object.assign(t,{type:"custom_item"});return this.request.send(this.endpoint+"/"+e+"/items","POST",n)},e.prototype.RemoveItem=function(t,e){return void 0===e&&(e=this.cartId),this.request.send(this.endpoint+"/"+e+"/items/"+t,"DELETE")},e.prototype.UpdateItemQuantity=function(t,e,n){void 0===n&&(n=this.cartId);var r=buildCartItemData(t,e);return this.request.send(this.endpoint+"/"+n+"/items/"+t,"PUT",r)},e.prototype.Checkout=function(t,e){return void 0===e&&(e=this.cartId),this.request.send(this.endpoint+"/"+e+"/checkout","POST",t)},e.prototype.Delete=function(t){return void 0===t&&(t=this.cartId),this.request.send(this.endpoint+"/"+t,"DELETE")},e}(BaseExtend),CategoriesEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="categories"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Tree=function(){return this.request.send(this.endpoint+"/tree","GET")},e}(CatalogueExtend),CollectionsEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="collections"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(CatalogueExtend),OrdersEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="orders"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Payment=function(t,e){return this.request.send(this.endpoint+"/"+t+"/payments","POST",e)},e}(BaseExtend),GatewaysEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="gateways"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Update=function(t,e){return this.request.send(this.endpoint+"/"+t,"PUT",e)},e.prototype.Enabled=function(t,e){return this.request.send(this.endpoint+"/"+t,"PUT",{type:"gateway",enabled:e})},e}(BaseExtend),FilesEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="files"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Create=function(t){return this.request.send(""+this.endpoint,"POST",t)},e.prototype.Delete=function(t){return this.request.send(this.endpoint+"/"+t,"DELETE")},e}(BaseExtend),Moltin=function(t){this.config=t,this.request=new RequestFactory(t),this.storage=new StorageFactory,this.Products=new ProductsEndpoint(t),this.Currencies=new CurrenciesEndpoint(t),this.Brands=new BrandsEndpoint(t),this.Cart=new CartEndpoint(t),this.Categories=new CategoriesEndpoint(t),this.Collections=new CollectionsEndpoint(t),this.Orders=new OrdersEndpoint(t),this.Gateways=new GatewaysEndpoint(t),this.Files=new FilesEndpoint(t)};Moltin.prototype.Authenticate=function(){return this.request.authenticate()};var gateway=function(t){return new Moltin(new Config(t))};exports.default=Moltin,exports.gateway=gateway; +"use strict";function buildRelationshipData(t,e){var n=[];return null===e||0===e.length?"[]":"string"==typeof e?[{type:t,id:e}]:(Array.isArray(e)&&(n=e.map(function(e){return{type:t,id:e}})),n)}function cartIdentifier(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1);var n=new StorageFactory;return t||e||null===n.get("mcart")?(e||(e="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(16*Math.random()|0).toString(16)})),n.set("mcart",e),e):n.get("mcart")}function parseJSON(t){return new Promise(function(e){return t.json().then(function(n){return e({status:t.status,ok:t.ok,json:n})})})}function setHeaderContentType(t,e){var n="application/json";return"files"===t&&"POST"===e&&(n="multipart/form-data"),n}function formatFilterString(t,e){return Object.keys(e).map(function(n){var r=e[n];return t+"("+n+","+r+")"}).join(":")}function formatQueryString(t,e){if("limit"===t||"offset"===t)return"page"+e;if("filter"===t){return t+"="+Object.keys(e).map(function(t){return formatFilterString(t,e[t])}).join(":")}return t+"="+e}function buildQueryParams(t){var e=t.includes,n=t.sort,r=t.limit,i=t.offset,o=t.filter,s={};return e&&(s.include=e),n&&(s.sort="("+n+")"),r&&(s.limit="[limit]="+r),i&&(s.offset="[offset]="+i),o&&(s.filter=o),Object.keys(s).map(function(t){return formatQueryString(t,s[t])}).join("&")}function buildURL(t,e){if(e.includes||e.sort||e.limit||e.offset||e.filter){return t+"?"+buildQueryParams(e)}return t}function buildRequestBody(t){return t?'{"data":'+JSON.stringify(t)+"}":null}function buildCartItemData(t,e,n){return void 0===n&&(n="cart_item"),{id:t,type:n,quantity:parseInt(e,10)}}function isFunc(t){return"[object Function]"===toString.call(t)}function icPart(t){return t.split("").map(function(t){return"(?:"+t.toUpperCase()+"|"+t.toLowerCase()+")"}).join("")}function remove(t,e){for(var n=t.length-1;n>=0;n--)t[n]===e&&Array.prototype.splice.call(t,n,1)}function hasProp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function en(t){t.plural(/$/,"s"),t.plural(/s$/i,"s"),t.plural(/^(ax|test)is$/i,"$1es"),t.plural(/(octop|vir)us$/i,"$1i"),t.plural(/(octop|vir)i$/i,"$1i"),t.plural(/(alias|status)$/i,"$1es"),t.plural(/(bu)s$/i,"$1ses"),t.plural(/(buffal|tomat)o$/i,"$1oes"),t.plural(/([ti])um$/i,"$1a"),t.plural(/([ti])a$/i,"$1a"),t.plural(/sis$/i,"ses"),t.plural(/(?:([^f])fe|([lr])f)$/i,"$1$2ves"),t.plural(/(hive)$/i,"$1s"),t.plural(/([^aeiouy]|qu)y$/i,"$1ies"),t.plural(/(x|ch|ss|sh)$/i,"$1es"),t.plural(/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"),t.plural(/^(m|l)ouse$/i,"$1ice"),t.plural(/^(m|l)ice$/i,"$1ice"),t.plural(/^(ox)$/i,"$1en"),t.plural(/^(oxen)$/i,"$1"),t.plural(/(quiz)$/i,"$1zes"),t.singular(/s$/i,""),t.singular(/(ss)$/i,"$1"),t.singular(/(n)ews$/i,"$1ews"),t.singular(/([ti])a$/i,"$1um"),t.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"),t.singular(/(^analy)(sis|ses)$/i,"$1sis"),t.singular(/([^f])ves$/i,"$1fe"),t.singular(/(hive)s$/i,"$1"),t.singular(/(tive)s$/i,"$1"),t.singular(/([lr])ves$/i,"$1f"),t.singular(/([^aeiouy]|qu)ies$/i,"$1y"),t.singular(/(s)eries$/i,"$1eries"),t.singular(/(m)ovies$/i,"$1ovie"),t.singular(/(x|ch|ss|sh)es$/i,"$1"),t.singular(/^(m|l)ice$/i,"$1ouse"),t.singular(/(bus)(es)?$/i,"$1"),t.singular(/(o)es$/i,"$1"),t.singular(/(shoe)s$/i,"$1"),t.singular(/(cris|test)(is|es)$/i,"$1is"),t.singular(/^(a)x[ie]s$/i,"$1xis"),t.singular(/(octop|vir)(us|i)$/i,"$1us"),t.singular(/(alias|status)(es)?$/i,"$1"),t.singular(/^(ox)en/i,"$1"),t.singular(/(vert|ind)ices$/i,"$1ex"),t.singular(/(matr)ices$/i,"$1ix"),t.singular(/(quiz)zes$/i,"$1"),t.singular(/(database)s$/i,"$1"),t.irregular("person","people"),t.irregular("man","men"),t.irregular("child","children"),t.irregular("sex","sexes"),t.irregular("move","moves"),t.irregular("zombie","zombies"),t.uncountable("equipment","information","rice","money","species","series","fish","sheep","jeans","police")}function inflections(t,e){if(isFunc(t)&&(e=t,t=null),t=t||"en",!e)return Inflector.getInstance(t);e(Inflector.getInstance(t))}function applyInflections(t,e){var n,r,i,o=""+t;if(0===o.length)return o;var s=o.toLowerCase().match(/\b\w+$/);if(s&&inflections().uncountables.indexOf(s[0])>-1)return o;for(var a=0,u=e.length;a1&&void 0!==arguments[1]?arguments[1]:"en").plurals)}function capitalize(t){var e=null===t||void 0===t?"":String(t);return e.charAt(0).toUpperCase()+e.slice(1)}function transliterations(t,e){if(isFunc(t)&&(e=t,t=null),t=t||"en",!e)return Transliterator.getInstance(t);e(Transliterator.getInstance(t))}function transliterate(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.locale||"en",r=e.replacement||"?";return transliterations(n).transliterate(t,r)}Object.defineProperty(exports,"__esModule",{value:!0});var fetchEverywhere=require("fetch-everywhere"),es6Promise=require("es6-promise"),pkg=require("../package.json"),Config=function(t){this.client_id=t.client_id,this.client_secret=t.client_secret,this.host="api.moltin.com",this.port="443",this.protocol="https",this.version="v2",this.debug=!1,this.currency=t.currency,this.language=!1,this.timeout=6e4,this.auth={expires:3600,uri:"oauth/access_token"},this.methods=["GET","POST","PUT","DELETE"],this.sdk={version:pkg.version,language:"JS"}},StorageFactory=function(){if("undefined"==typeof localStorage||null===localStorage){var t=require("node-localstorage").LocalStorage;this.localStorage=new t("./localStorage")}else this.localStorage=window.localStorage};StorageFactory.prototype.set=function(t,e){return this.localStorage.setItem(t,e)},StorageFactory.prototype.get=function(t){return this.localStorage.getItem(t)},StorageFactory.prototype.delete=function(t){return this.localStorage.removeItem(t)};var RequestFactory=function(t){this.config=t,this.storage=new StorageFactory};RequestFactory.prototype.authenticate=function(){var t=this.config,e=this.storage;if(!t.client_id)throw new Error("You must have a client_id set");var n={grant_type:t.client_secret?"client_credentials":"implicit",client_id:t.client_id};t.client_secret&&(n.client_secret=t.client_secret);var r=new Promise(function(e,r){fetch(t.protocol+"://"+t.host+"/"+t.auth.uri,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:Object.keys(n).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(n[t])}).join("&")}).then(parseJSON).then(function(t){t.ok&&e(t.json),r(t.json)}).catch(function(){return r("Fetch error - check your network")})});return r.then(function(t){e.set("mtoken",t.access_token),e.set("mexpires",t.expires)}),r},RequestFactory.prototype.send=function(t,e,n){var r=this;void 0===n&&(n=null);var i=this.config,o=this.storage;return new Promise(function(s,a){var u=function(){var r={Authorization:"Bearer: "+o.get("mtoken"),"Content-Type":setHeaderContentType(t,e),"X-MOLTIN-SDK-LANGUAGE":i.sdk.language,"X-MOLTIN-SDK-VERSION":i.sdk.version};i.currency&&(r["X-MOLTIN-CURRENCY"]=i.currency),fetch(i.protocol+"://"+i.host+"/"+i.version+"/"+t,{method:e.toUpperCase(),headers:r,body:buildRequestBody(n)}).then(parseJSON).then(function(t){t.ok&&s(t.json),a(t.json)}).catch(function(){return a("Fetch error - check your network")})};return!o.get("mtoken")||Date.now().toString()>=o.get("mexpires")?r.authenticate().then(u).catch(function(t){return a(t)}):u()})};var toString=Object.prototype.toString,classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},createClass=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"all";"all"===t?(this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[]):this[t]=[]}}]),t}(),defaults$1={en:en};for(var locale in defaults$1)inflections(locale,defaults$1[locale]);var DEFAULT_APPROXIMATIONS={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","×":"x","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"Th","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","ĝ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"'n","Ŋ":"NG","ŋ":"ng","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z"},DEFAULT_REPLACEMENT_CHAR="?",instances$1={},Transliterator=function(){function t(){var e=this;classCallCheck(this,t),this.approximations={};for(var n in DEFAULT_APPROXIMATIONS)e.approximate(n,DEFAULT_APPROXIMATIONS[n])}return createClass(t,null,[{key:"getInstance",value:function(e){return instances$1[e]=instances$1[e]||new t,instances$1[e]}}]),createClass(t,[{key:"approximate",value:function(t,e){this.approximations[t]=e}},{key:"transliterate",value:function(t,e){var n=this;return t.replace(/[^\u0000-\u007f]/g,function(t){return n.approximations[t]||e||DEFAULT_REPLACEMENT_CHAR})}}]),t}(),BaseExtend=function(t){this.request=new RequestFactory(t),this.config=t};BaseExtend.prototype.All=function(){return this.call=this.request.send(buildURL(this.endpoint,{includes:this.includes,sort:this.sort,limit:this.limit,offset:this.offset,filter:this.filter}),"GET"),this.call},BaseExtend.prototype.Get=function(t){return this.call=this.request.send(buildURL(this.endpoint+"/"+t,{includes:this.includes}),"GET"),this.call},BaseExtend.prototype.Limit=function(t){return this.limit=t,this},BaseExtend.prototype.Offset=function(t){return this.offset=t,this},BaseExtend.prototype.Sort=function(t){return this.sort=t,this};var CatalogueExtend=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Create=function(t){return this.request.send(""+this.endpoint,"POST",t)},e.prototype.Delete=function(t){return this.request.send(this.endpoint+"/"+t,"DELETE")},e.prototype.Update=function(t,e){return this.request.send(this.endpoint+"/"+t,"PUT",e)},e.prototype.With=function(t){return this.includes=t.toString().toLowerCase(),this},e}(BaseExtend),ProductsEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="products"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Filter=function(t){return this.filter=t,this},e.prototype.CreateRelationships=function(t,e,n){var r=buildRelationshipData(e,n);return this.request.send(this.endpoint+"/"+t+"/relationships/"+pluralize(e),"POST",r)},e.prototype.DeleteRelationships=function(t,e,n){var r=buildRelationshipData(e,n);return this.request.send(this.endpoint+"/"+t+"/relationships/"+pluralize(e),"DELETE",r)},e.prototype.UpdateRelationships=function(t,e,n){void 0===n&&(n=null);var r=buildRelationshipData(e,n);return this.request.send(this.endpoint+"/"+t+"/relationships/"+pluralize(e),"PUT",r)},e}(CatalogueExtend),CurrenciesEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="currencies",this.storage=new StorageFactory}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Create=function(t){return this.request.send(""+this.endpoint,"POST",t)},e.prototype.Delete=function(t){return this.request.send(this.endpoint+"/"+t,"DELETE")},e.prototype.Update=function(t,e){return this.request.send(this.endpoint+"/"+t,"PUT",e)},e.prototype.Set=function(t){var e=this.storage,n=this.config;return e.set("mcurrency",t),n.currency=t,new Promise(function(t,n){var r=e.get("mcurrency");try{t(r)}catch(t){n(new Error(t))}})},e.prototype.Active=function(){var t=this.storage;return new Promise(function(e,n){var r=t.get("mcurrency");try{e(r)}catch(t){n(new Error(t))}})},e}(BaseExtend),BrandsEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="brands"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(CatalogueExtend),CartEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="carts",this.cartId=cartIdentifier()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Get=function(t){return void 0===t&&(t=this.cartId),this.request.send(this.endpoint+"/"+t,"GET")},e.prototype.Items=function(t){return void 0===t&&(t=this.cartId),this.request.send(this.endpoint+"/"+t+"/items","GET")},e.prototype.AddProduct=function(t,e,n){void 0===e&&(e=1),void 0===n&&(n=this.cartId);var r=buildCartItemData(t,e);return this.request.send(this.endpoint+"/"+n+"/items","POST",r)},e.prototype.AddCustomItem=function(t,e){void 0===e&&(e=this.cartId);var n=Object.assign(t,{type:"custom_item"});return this.request.send(this.endpoint+"/"+e+"/items","POST",n)},e.prototype.RemoveItem=function(t,e){return void 0===e&&(e=this.cartId),this.request.send(this.endpoint+"/"+e+"/items/"+t,"DELETE")},e.prototype.UpdateItemQuantity=function(t,e,n){void 0===n&&(n=this.cartId);var r=buildCartItemData(t,e);return this.request.send(this.endpoint+"/"+n+"/items/"+t,"PUT",r)},e.prototype.Checkout=function(t,e){return void 0===e&&(e=this.cartId),this.request.send(this.endpoint+"/"+e+"/checkout","POST",t)},e.prototype.Delete=function(t){return void 0===t&&(t=this.cartId),this.request.send(this.endpoint+"/"+t,"DELETE")},e}(BaseExtend),CategoriesEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="categories"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Tree=function(){return this.request.send(this.endpoint+"/tree","GET")},e}(CatalogueExtend),CollectionsEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="collections"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(CatalogueExtend),OrdersEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="orders"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Items=function(t){return this.request.send(this.endpoint+"/"+t+"/items","GET")},e.prototype.Payment=function(t,e){return this.request.send(this.endpoint+"/"+t+"/payments","POST",e)},e}(BaseExtend),GatewaysEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="gateways"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Update=function(t,e){return this.request.send(this.endpoint+"/"+t,"PUT",e)},e.prototype.Enabled=function(t,e){return this.request.send(this.endpoint+"/"+t,"PUT",{type:"gateway",enabled:e})},e}(BaseExtend),FilesEndpoint=function(t){function e(e){t.call(this,e),this.endpoint="files"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.Create=function(t){return this.request.send(""+this.endpoint,"POST",t)},e.prototype.Delete=function(t){return this.request.send(this.endpoint+"/"+t,"DELETE")},e}(BaseExtend),Moltin=function(t){this.config=t,this.request=new RequestFactory(t),this.storage=new StorageFactory,this.Products=new ProductsEndpoint(t),this.Currencies=new CurrenciesEndpoint(t),this.Brands=new BrandsEndpoint(t),this.Cart=new CartEndpoint(t),this.Categories=new CategoriesEndpoint(t),this.Collections=new CollectionsEndpoint(t),this.Orders=new OrdersEndpoint(t),this.Gateways=new GatewaysEndpoint(t),this.Files=new FilesEndpoint(t)};Moltin.prototype.Authenticate=function(){return this.request.authenticate()};var gateway=function(t){return new Moltin(new Config(t))};exports.default=Moltin,exports.gateway=gateway; //# sourceMappingURL=moltin.cjs.js.map diff --git a/dist/moltin.cjs.js.map b/dist/moltin.cjs.js.map index e399f7025..57c55996f 100644 --- a/dist/moltin.cjs.js.map +++ b/dist/moltin.cjs.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../src/utils/helpers.js","../node_modules/inflected/dist/esm/inflected.js","../src/config.js","../src/factories/storage.js","../src/factories/request.js","../src/extends/base.js","../src/extends/catalogue.js","../src/endpoints/products.js","../src/endpoints/currencies.js","../src/endpoints/brands.js","../src/endpoints/cart.js","../src/endpoints/categories.js","../src/endpoints/collections.js","../src/endpoints/orders.js","../src/endpoints/gateways.js","../src/endpoints/files.js","../src/moltin.js"],"sourcesContent":["import StorageFactory from '../factories/storage';\n\nexport function buildRelationshipData(type, ids) {\n let data = [];\n\n if (ids === null || ids.length === 0) {\n return '[]';\n }\n\n if (typeof ids === 'string') {\n return [{\n type,\n id: ids,\n }];\n }\n\n if (Array.isArray(ids)) {\n data = ids.map(id => ({\n type,\n id,\n }));\n }\n\n return data;\n}\n\nexport function cartIdentifier(reset = false, id = false) {\n const storage = new StorageFactory();\n\n if (!reset && !id && storage.get('mcart') !== null) {\n return storage.get('mcart');\n }\n\n if (!id) {\n id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[x]/g, () => (Math.random() * 16 | 0).toString(16));\n }\n\n storage.set('mcart', id);\n\n return id;\n}\n\nexport function parseJSON(response) {\n return new Promise(resolve => response.json()\n .then(json => resolve({\n status: response.status,\n ok: response.ok,\n json,\n })));\n}\n\nexport function setHeaderContentType(uri, method) {\n let contentType = 'application/json';\n\n if (uri === 'files' && method === 'POST') {\n contentType = 'multipart/form-data';\n }\n\n return contentType;\n}\n\nfunction formatFilterString(type, filter) {\n const filterStringArray = Object.keys(filter).map((key) => {\n const value = filter[key];\n\n return `${type}(${key},${value})`;\n });\n\n return filterStringArray.join(':');\n}\n\nfunction formatQueryString(key, value) {\n if (key === 'limit' || key === 'offset') {\n return `page${(value)}`;\n }\n\n if (key === 'filter') {\n const filterValues = Object.keys(value).map(\n filter => formatFilterString(filter, value[filter]));\n\n return `${key}=${filterValues.join(':')}`;\n }\n\n return `${key}=${value}`;\n}\n\nfunction buildQueryParams({ includes, sort, limit, offset, filter }) {\n const query = {};\n\n if (includes) {\n query.include = includes;\n }\n\n if (sort) {\n query.sort = `(${sort})`;\n }\n\n if (limit) {\n query.limit = `[limit]=${limit}`;\n }\n\n if (offset) {\n query.offset = `[offset]=${offset}`;\n }\n\n if (filter) {\n query.filter = filter;\n }\n\n return Object.keys(query).map(k => formatQueryString(k, query[k])).join('&');\n}\n\nexport function buildURL(endpoint, params) {\n if (params.includes || params.sort || params.limit || params.offset || params.filter) {\n const paramsString = buildQueryParams(params);\n\n return `${endpoint}?${paramsString}`;\n }\n\n return endpoint;\n}\n\n\nexport function buildRequestBody(body) {\n if (body) {\n return `{\"data\":${JSON.stringify(body)}}`;\n }\n\n return null;\n}\n\nexport function buildCartItemData(product, quantity, type = 'cart_item') {\n return {\n id: product,\n type,\n quantity: parseInt(quantity, 10),\n };\n}\n","var toString = Object.prototype.toString;\n\nfunction isFunc(obj) {\n return toString.call(obj) === \"[object Function]\";\n}\n\nvar classCallCheck = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};\n\nvar createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\n\nfunction icPart(str) {\n return str.split(\"\").map(function (c) {\n return \"(?:\" + c.toUpperCase() + \"|\" + c.toLowerCase() + \")\";\n }).join(\"\");\n}\n\nfunction remove(arr, elem) {\n for (var i = arr.length - 1; i >= 0; i--) {\n if (arr[i] === elem) {\n Array.prototype.splice.call(arr, i, 1);\n }\n }\n}\n\nfunction hasProp(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nvar instances = {};\n\nvar Inflector = function () {\n createClass(Inflector, null, [{\n key: \"getInstance\",\n value: function getInstance(locale) {\n instances[locale] = instances[locale] || new Inflector();\n return instances[locale];\n }\n }]);\n\n function Inflector() {\n classCallCheck(this, Inflector);\n\n this.plurals = [];\n this.singulars = [];\n this.uncountables = [];\n this.humans = [];\n this.acronyms = {};\n this.acronymRegex = /(?=a)b/;\n }\n\n createClass(Inflector, [{\n key: \"acronym\",\n value: function acronym(word) {\n this.acronyms[word.toLowerCase()] = word;\n\n var values = [];\n\n for (var key in this.acronyms) {\n if (hasProp(this.acronyms, key)) {\n values.push(this.acronyms[key]);\n }\n }\n\n this.acronymRegex = new RegExp(values.join(\"|\"));\n }\n }, {\n key: \"plural\",\n value: function plural(rule, replacement) {\n if (typeof rule === \"string\") {\n remove(this.uncountables, rule);\n }\n\n remove(this.uncountables, replacement);\n this.plurals.unshift([rule, replacement]);\n }\n }, {\n key: \"singular\",\n value: function singular(rule, replacement) {\n if (typeof rule === \"string\") {\n remove(this.uncountables, rule);\n }\n\n remove(this.uncountables, replacement);\n this.singulars.unshift([rule, replacement]);\n }\n }, {\n key: \"irregular\",\n value: function irregular(singular, plural) {\n remove(this.uncountables, singular);\n remove(this.uncountables, plural);\n\n var s0 = singular[0];\n var sRest = singular.substr(1);\n\n var p0 = plural[0];\n var pRest = plural.substr(1);\n\n if (s0.toUpperCase() === p0.toUpperCase()) {\n this.plural(new RegExp(\"(\" + s0 + \")\" + sRest + \"$\", \"i\"), \"$1\" + pRest);\n this.plural(new RegExp(\"(\" + p0 + \")\" + pRest + \"$\", \"i\"), \"$1\" + pRest);\n\n this.singular(new RegExp(\"(\" + s0 + \")\" + sRest + \"$\", \"i\"), \"$1\" + sRest);\n this.singular(new RegExp(\"(\" + p0 + \")\" + pRest + \"$\", \"i\"), \"$1\" + sRest);\n } else {\n var sRestIC = icPart(sRest);\n var pRestIC = icPart(pRest);\n\n this.plural(new RegExp(s0.toUpperCase() + sRestIC + \"$\"), p0.toUpperCase() + pRest);\n this.plural(new RegExp(s0.toLowerCase() + sRestIC + \"$\"), p0.toLowerCase() + pRest);\n this.plural(new RegExp(p0.toUpperCase() + pRestIC + \"$\"), p0.toUpperCase() + pRest);\n this.plural(new RegExp(p0.toLowerCase() + pRestIC + \"$\"), p0.toLowerCase() + pRest);\n\n this.singular(new RegExp(s0.toUpperCase() + sRestIC + \"$\"), s0.toUpperCase() + sRest);\n this.singular(new RegExp(s0.toLowerCase() + sRestIC + \"$\"), s0.toLowerCase() + sRest);\n this.singular(new RegExp(p0.toUpperCase() + pRestIC + \"$\"), s0.toUpperCase() + sRest);\n this.singular(new RegExp(p0.toLowerCase() + pRestIC + \"$\"), s0.toLowerCase() + sRest);\n }\n }\n }, {\n key: \"uncountable\",\n value: function uncountable() {\n for (var _len = arguments.length, words = Array(_len), _key = 0; _key < _len; _key++) {\n words[_key] = arguments[_key];\n }\n\n this.uncountables = this.uncountables.concat(words);\n }\n }, {\n key: \"human\",\n value: function human(rule, replacement) {\n this.humans.unshift([rule, replacement]);\n }\n }, {\n key: \"clear\",\n value: function clear() {\n var scope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"all\";\n\n if (scope === \"all\") {\n this.plurals = [];\n this.singulars = [];\n this.uncountables = [];\n this.humans = [];\n } else {\n this[scope] = [];\n }\n }\n }]);\n return Inflector;\n}();\n\nfunction en(inflector) {\n inflector.plural(/$/, \"s\");\n inflector.plural(/s$/i, \"s\");\n inflector.plural(/^(ax|test)is$/i, \"$1es\");\n inflector.plural(/(octop|vir)us$/i, \"$1i\");\n inflector.plural(/(octop|vir)i$/i, \"$1i\");\n inflector.plural(/(alias|status)$/i, \"$1es\");\n inflector.plural(/(bu)s$/i, \"$1ses\");\n inflector.plural(/(buffal|tomat)o$/i, \"$1oes\");\n inflector.plural(/([ti])um$/i, \"$1a\");\n inflector.plural(/([ti])a$/i, \"$1a\");\n inflector.plural(/sis$/i, \"ses\");\n inflector.plural(/(?:([^f])fe|([lr])f)$/i, \"$1$2ves\");\n inflector.plural(/(hive)$/i, \"$1s\");\n inflector.plural(/([^aeiouy]|qu)y$/i, \"$1ies\");\n inflector.plural(/(x|ch|ss|sh)$/i, \"$1es\");\n inflector.plural(/(matr|vert|ind)(?:ix|ex)$/i, \"$1ices\");\n inflector.plural(/^(m|l)ouse$/i, \"$1ice\");\n inflector.plural(/^(m|l)ice$/i, \"$1ice\");\n inflector.plural(/^(ox)$/i, \"$1en\");\n inflector.plural(/^(oxen)$/i, \"$1\");\n inflector.plural(/(quiz)$/i, \"$1zes\");\n\n inflector.singular(/s$/i, \"\");\n inflector.singular(/(ss)$/i, \"$1\");\n inflector.singular(/(n)ews$/i, \"$1ews\");\n inflector.singular(/([ti])a$/i, \"$1um\");\n inflector.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, \"$1sis\");\n inflector.singular(/(^analy)(sis|ses)$/i, \"$1sis\");\n inflector.singular(/([^f])ves$/i, \"$1fe\");\n inflector.singular(/(hive)s$/i, \"$1\");\n inflector.singular(/(tive)s$/i, \"$1\");\n inflector.singular(/([lr])ves$/i, \"$1f\");\n inflector.singular(/([^aeiouy]|qu)ies$/i, \"$1y\");\n inflector.singular(/(s)eries$/i, \"$1eries\");\n inflector.singular(/(m)ovies$/i, \"$1ovie\");\n inflector.singular(/(x|ch|ss|sh)es$/i, \"$1\");\n inflector.singular(/^(m|l)ice$/i, \"$1ouse\");\n inflector.singular(/(bus)(es)?$/i, \"$1\");\n inflector.singular(/(o)es$/i, \"$1\");\n inflector.singular(/(shoe)s$/i, \"$1\");\n inflector.singular(/(cris|test)(is|es)$/i, \"$1is\");\n inflector.singular(/^(a)x[ie]s$/i, \"$1xis\");\n inflector.singular(/(octop|vir)(us|i)$/i, \"$1us\");\n inflector.singular(/(alias|status)(es)?$/i, \"$1\");\n inflector.singular(/^(ox)en/i, \"$1\");\n inflector.singular(/(vert|ind)ices$/i, \"$1ex\");\n inflector.singular(/(matr)ices$/i, \"$1ix\");\n inflector.singular(/(quiz)zes$/i, \"$1\");\n inflector.singular(/(database)s$/i, \"$1\");\n\n inflector.irregular(\"person\", \"people\");\n inflector.irregular(\"man\", \"men\");\n inflector.irregular(\"child\", \"children\");\n inflector.irregular(\"sex\", \"sexes\");\n inflector.irregular(\"move\", \"moves\");\n inflector.irregular(\"zombie\", \"zombies\");\n\n inflector.uncountable(\"equipment\", \"information\", \"rice\", \"money\", \"species\", \"series\", \"fish\", \"sheep\", \"jeans\", \"police\");\n}\n\nvar defaults$1 = {\n en: en\n};\n\nfunction inflections(locale, fn) {\n if (isFunc(locale)) {\n fn = locale;\n locale = null;\n }\n\n locale = locale || \"en\";\n\n if (fn) {\n fn(Inflector.getInstance(locale));\n } else {\n return Inflector.getInstance(locale);\n }\n}\n\nfor (var locale in defaults$1) {\n inflections(locale, defaults$1[locale]);\n}\n\nfunction applyInflections(word, rules) {\n var result = \"\" + word,\n rule,\n regex,\n replacement;\n\n if (result.length === 0) {\n return result;\n } else {\n var match = result.toLowerCase().match(/\\b\\w+$/);\n\n if (match && inflections().uncountables.indexOf(match[0]) > -1) {\n return result;\n } else {\n for (var i = 0, ii = rules.length; i < ii; i++) {\n rule = rules[i];\n\n regex = rule[0];\n replacement = rule[1];\n\n if (result.match(regex)) {\n result = result.replace(regex, replacement);\n break;\n }\n }\n\n return result;\n }\n }\n}\n\nfunction pluralize(word) {\n var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"en\";\n\n return applyInflections(word, inflections(locale).plurals);\n}\n\nfunction singularize(word) {\n var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"en\";\n\n return applyInflections(word, inflections(locale).singulars);\n}\n\nfunction capitalize(str) {\n var result = str === null || str === undefined ? \"\" : String(str);\n return result.charAt(0).toUpperCase() + result.slice(1);\n}\n\nfunction camelize(term, uppercaseFirstLetter) {\n if (uppercaseFirstLetter === null || uppercaseFirstLetter === undefined) {\n uppercaseFirstLetter = true;\n }\n\n var result = \"\" + term;\n\n if (uppercaseFirstLetter) {\n result = result.replace(/^[a-z\\d]*/, function (a) {\n return inflections().acronyms[a] || capitalize(a);\n });\n } else {\n result = result.replace(new RegExp(\"^(?:\" + inflections().acronymRegex.source + \"(?=\\\\b|[A-Z_])|\\\\w)\"), function (a) {\n return a.toLowerCase();\n });\n }\n\n result = result.replace(/(?:_|(\\/))([a-z\\d]*)/gi, function (match, a, b, idx, string) {\n a || (a = \"\");\n return \"\" + a + (inflections().acronyms[b] || capitalize(b));\n });\n\n return result;\n}\n\nfunction underscore(camelCasedWord) {\n var result = \"\" + camelCasedWord;\n\n result = result.replace(new RegExp(\"(?:([A-Za-z\\\\d])|^)(\" + inflections().acronymRegex.source + \")(?=\\\\b|[^a-z])\", \"g\"), function (match, $1, $2) {\n return \"\" + ($1 || \"\") + ($1 ? \"_\" : \"\") + $2.toLowerCase();\n });\n\n result = result.replace(/([A-Z\\d]+)([A-Z][a-z])/g, \"$1_$2\");\n result = result.replace(/([a-z\\d])([A-Z])/g, \"$1_$2\");\n result = result.replace(/-/g, \"_\");\n\n return result.toLowerCase();\n}\n\nfunction humanize(lowerCaseAndUnderscoredWord, options) {\n var result = \"\" + lowerCaseAndUnderscoredWord;\n var humans = inflections().humans;\n var human = void 0,\n rule = void 0,\n replacement = void 0;\n\n options = options || {};\n\n if (options.capitalize === null || options.capitalize === undefined) {\n options.capitalize = true;\n }\n\n for (var i = 0, ii = humans.length; i < ii; i++) {\n human = humans[i];\n rule = human[0];\n replacement = human[1];\n\n if (rule.test && rule.test(result) || result.indexOf(rule) > -1) {\n result = result.replace(rule, replacement);\n break;\n }\n }\n\n result = result.replace(/_id$/, \"\");\n result = result.replace(/_/g, \" \");\n\n result = result.replace(/([a-z\\d]*)/gi, function (match) {\n return inflections().acronyms[match] || match.toLowerCase();\n });\n\n if (options.capitalize) {\n result = result.replace(/^\\w/, function (match) {\n return match.toUpperCase();\n });\n }\n\n return result;\n}\n\nfunction titleize(word) {\n return humanize(this.underscore(word)).replace(/(^|[\\s¿/]+)([a-z])/g, function (match, boundary, letter, idx, string) {\n return match.replace(letter, letter.toUpperCase());\n });\n}\n\nfunction tableize(className) {\n return pluralize(underscore(className));\n}\n\nfunction classify(tableName) {\n return camelize(singularize(tableName.replace(/.*\\./g, \"\")));\n}\n\nfunction dasherize(underscoredWord) {\n return underscoredWord.replace(/_/g, \"-\");\n}\n\nfunction foreignKey(className) {\n var separateWithUnderscore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n\n return \"\" + underscore(className) + (separateWithUnderscore ? \"_id\" : \"id\");\n}\n\nfunction ordinal(number) {\n var absNumber = Math.abs(Number(number));\n var mod100 = absNumber % 100;\n\n if (mod100 === 11 || mod100 === 12 || mod100 === 13) {\n return \"th\";\n } else {\n switch (absNumber % 10) {\n case 1:\n return \"st\";\n case 2:\n return \"nd\";\n case 3:\n return \"rd\";\n default:\n return \"th\";\n }\n }\n}\n\nfunction ordinalize(number) {\n return \"\" + number + ordinal(number);\n}\n\n// prettier-ignore\nvar DEFAULT_APPROXIMATIONS = {\n 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE',\n 'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I',\n 'Î': 'I', 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O',\n 'Õ': 'O', 'Ö': 'O', '×': 'x', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U',\n 'Ü': 'U', 'Ý': 'Y', 'Þ': 'Th', 'ß': 'ss', 'à': 'a', 'á': 'a', 'â': 'a',\n 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': 'ae', 'ç': 'c', 'è': 'e', 'é': 'e',\n 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'd',\n 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ø': 'o',\n 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y',\n 'Ā': 'A', 'ā': 'a', 'Ă': 'A', 'ă': 'a', 'Ą': 'A', 'ą': 'a', 'Ć': 'C',\n 'ć': 'c', 'Ĉ': 'C', 'ĉ': 'c', 'Ċ': 'C', 'ċ': 'c', 'Č': 'C', 'č': 'c',\n 'Ď': 'D', 'ď': 'd', 'Đ': 'D', 'đ': 'd', 'Ē': 'E', 'ē': 'e', 'Ĕ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W', 'ŵ': 'w',\n 'Ŷ': 'Y', 'ŷ': 'y', 'Ÿ': 'Y', 'Ź': 'Z', 'ź': 'z', 'Ż': 'Z', 'ż': 'z',\n 'Ž': 'Z', 'ž': 'z'\n};\n\nvar DEFAULT_REPLACEMENT_CHAR = \"?\";\n\nvar instances$1 = {};\n\nvar Transliterator = function () {\n createClass(Transliterator, null, [{\n key: 'getInstance',\n value: function getInstance(locale) {\n instances$1[locale] = instances$1[locale] || new Transliterator();\n return instances$1[locale];\n }\n }]);\n\n function Transliterator() {\n classCallCheck(this, Transliterator);\n\n this.approximations = {};\n\n for (var char in DEFAULT_APPROXIMATIONS) {\n this.approximate(char, DEFAULT_APPROXIMATIONS[char]);\n }\n }\n\n createClass(Transliterator, [{\n key: 'approximate',\n value: function approximate(char, replacement) {\n this.approximations[char] = replacement;\n }\n }, {\n key: 'transliterate',\n value: function transliterate(string, replacement) {\n var _this = this;\n\n return string.replace(/[^\\u0000-\\u007f]/g, function (c) {\n return _this.approximations[c] || replacement || DEFAULT_REPLACEMENT_CHAR;\n });\n }\n }]);\n return Transliterator;\n}();\n\nfunction transliterations(locale, fn) {\n if (isFunc(locale)) {\n fn = locale;\n locale = null;\n }\n\n locale = locale || \"en\";\n\n if (fn) {\n fn(Transliterator.getInstance(locale));\n } else {\n return Transliterator.getInstance(locale);\n }\n}\n\nfunction transliterate(string) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n var locale = options.locale || \"en\";\n var replacement = options.replacement || \"?\";\n\n return transliterations(locale).transliterate(string, replacement);\n}\n\nfunction parameterize(string) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (options.separator === undefined) {\n options.separator = \"-\";\n }\n\n if (options.separator === null) {\n options.separator = \"\";\n }\n\n // replace accented chars with their ascii equivalents\n var result = transliterate(string, options);\n\n result = result.replace(/[^a-z0-9\\-_]+/ig, options.separator);\n\n if (options.separator.length) {\n var separatorRegex = new RegExp(options.separator);\n\n // no more than one of the separator in a row\n result = result.replace(new RegExp(separatorRegex.source + \"{2,}\"), options.separator);\n\n // remove leading/trailing separator\n result = result.replace(new RegExp(\"^\" + separatorRegex.source + \"|\" + separatorRegex.source + \"$\", \"i\"), \"\");\n }\n\n return result.toLowerCase();\n}\n\nexport { pluralize, singularize, camelize, underscore, humanize, titleize, tableize, classify, dasherize, foreignKey, ordinal, ordinalize, transliterate, parameterize, capitalize, inflections, transliterations };\n","const pkg = require('../package.json');\n\nclass Config {\n constructor(options) {\n this.client_id = options.client_id;\n this.client_secret = options.client_secret;\n this.host = 'api.moltin.com';\n this.port = '443';\n this.protocol = 'https';\n this.version = 'v2';\n this.debug = false;\n this.currency = options.currency;\n this.language = false;\n this.timeout = 60000;\n this.auth = {\n expires: 3600,\n uri: 'oauth/access_token',\n };\n this.methods = ['GET', 'POST', 'PUT', 'DELETE'];\n this.sdk = {\n version: pkg.version,\n language: 'JS',\n };\n }\n}\n\nexport default Config;\n","/* jshint node: true */\n\nclass StorageFactory {\n constructor() {\n if (typeof localStorage === 'undefined' || localStorage === null) {\n const LocalStorage = require('node-localstorage').LocalStorage;\n\n this.localStorage = new LocalStorage('./localStorage');\n } else {\n this.localStorage = window.localStorage;\n }\n }\n\n set(key, value) {\n return this.localStorage.setItem(key, value);\n }\n\n get(key) {\n return this.localStorage.getItem(key);\n }\n\n delete(key) {\n return this.localStorage.removeItem(key);\n }\n}\n\nexport default StorageFactory;\n","import StorageFactory from './storage';\n\nimport { setHeaderContentType, buildRequestBody, parseJSON } from '../utils/helpers';\n\nclass RequestFactory {\n constructor(config) {\n this.config = config;\n\n this.storage = new StorageFactory();\n }\n\n authenticate() {\n const config = this.config;\n const storage = this.storage;\n\n if (!config.client_id) {\n throw new Error('You must have a client_id set');\n }\n\n const body = {\n grant_type: config.client_secret ? 'client_credentials' : 'implicit',\n client_id: config.client_id,\n };\n\n if (config.client_secret) {\n body.client_secret = config.client_secret;\n }\n\n const promise = new Promise((resolve, reject) => {\n fetch(`${config.protocol}://${config.host}/${config.auth.uri}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: Object.keys(body).map(k => `${encodeURIComponent(k)}=${encodeURIComponent(body[k])}`).join('&'),\n })\n .then(parseJSON)\n .then((response) => {\n if (response.ok) {\n resolve(response.json);\n }\n\n reject(response.json);\n })\n .catch(() => reject('Fetch error - check your network'));\n });\n\n promise.then((response) => {\n storage.set('mtoken', response.access_token);\n storage.set('mexpires', response.expires);\n });\n\n return promise;\n }\n\n send(uri, method, body = null) {\n const config = this.config;\n const storage = this.storage;\n\n const promise = new Promise((resolve, reject) => {\n const req = () => {\n const headers = {\n Authorization: `Bearer: ${storage.get('mtoken')}`,\n 'Content-Type': setHeaderContentType(uri, method),\n 'X-MOLTIN-SDK-LANGUAGE': config.sdk.language,\n 'X-MOLTIN-SDK-VERSION': config.sdk.version,\n };\n\n if (config.currency) {\n headers['X-MOLTIN-CURRENCY'] = config.currency;\n }\n\n fetch(`${config.protocol}://${config.host}/${config.version}/${uri}`, {\n method: method.toUpperCase(),\n headers,\n body: buildRequestBody(body),\n })\n .then(parseJSON)\n .then((response) => {\n if (response.ok) {\n resolve(response.json);\n }\n\n reject(response.json);\n })\n .catch(() => reject('Fetch error - check your network'));\n };\n\n if (!storage.get('mtoken') || Date.now().toString() >= storage.get('mexpires')) {\n return this.authenticate()\n .then(req)\n .catch(error => reject(error));\n }\n\n return req();\n });\n\n return promise;\n }\n}\n\nexport default RequestFactory;\n","import RequestFactory from '../factories/request';\nimport { buildURL } from '../utils/helpers';\n\nclass BaseExtend {\n constructor(config) {\n this.request = new RequestFactory(config);\n\n this.config = config;\n }\n\n All() {\n this.call = this.request.send(buildURL(this.endpoint, {\n includes: this.includes,\n sort: this.sort,\n limit: this.limit,\n offset: this.offset,\n filter: this.filter,\n }), 'GET');\n\n return this.call;\n }\n\n Get(id) {\n this.call = this.request.send(buildURL(`${this.endpoint}/${id}`, {\n includes: this.includes,\n }), 'GET');\n\n return this.call;\n }\n\n Limit(value) {\n this.limit = value;\n\n return this;\n }\n\n Offset(value) {\n this.offset = value;\n\n return this;\n }\n\n Sort(value) {\n this.sort = value;\n\n return this;\n }\n}\n\nexport default BaseExtend;\n","import BaseExtend from './base';\n\nclass CatalogueExtend extends BaseExtend {\n Create(body) {\n return this.request.send(`${this.endpoint}`, 'POST', body);\n }\n\n Delete(id) {\n return this.request.send(`${this.endpoint}/${id}`, 'DELETE');\n }\n\n Update(id, body) {\n return this.request.send(`${this.endpoint}/${id}`, 'PUT', body);\n }\n\n With(includes) {\n this.includes = includes.toString().toLowerCase();\n\n return this;\n }\n}\n\nexport default CatalogueExtend;\n","import { pluralize } from 'inflected';\nimport CatalogueExtend from '../extends/catalogue';\nimport { buildRelationshipData } from '../utils/helpers';\n\nclass ProductsEndpoint extends CatalogueExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'products';\n }\n\n Filter(filter) {\n this.filter = filter;\n\n return this;\n }\n\n CreateRelationships(id, type, resources) {\n const body = buildRelationshipData(type, resources);\n\n return this.request.send(`${this.endpoint}/${id}/relationships/${pluralize(type)}`, 'POST', body);\n }\n\n DeleteRelationships(id, type, resources) {\n const body = buildRelationshipData(type, resources);\n\n return this.request.send(`${this.endpoint}/${id}/relationships/${pluralize(type)}`, 'DELETE', body);\n }\n\n UpdateRelationships(id, type, resources = null) {\n const body = buildRelationshipData(type, resources);\n\n return this.request.send(`${this.endpoint}/${id}/relationships/${pluralize(type)}`, 'PUT', body);\n }\n}\n\nexport default ProductsEndpoint;\n","import BaseExtend from '../extends/base';\nimport StorageFactory from '../factories/storage';\n\nclass CurrenciesEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'currencies';\n this.storage = new StorageFactory();\n }\n\n Create(body) {\n return this.request.send(`${this.endpoint}`, 'POST', body);\n }\n\n Delete(id) {\n return this.request.send(`${this.endpoint}/${id}`, 'DELETE');\n }\n\n Update(id, body) {\n return this.request.send(`${this.endpoint}/${id}`, 'PUT', body);\n }\n\n Set(currency) {\n const storage = this.storage;\n const config = this.config;\n\n storage.set('mcurrency', currency);\n config.currency = currency;\n\n const promise = new Promise((resolve, reject) => {\n const request = storage.get('mcurrency');\n\n try {\n resolve(request);\n } catch (err) {\n reject(new Error(err));\n }\n });\n\n return promise;\n }\n\n Active() {\n const storage = this.storage;\n\n const promise = new Promise((resolve, reject) => {\n const request = storage.get('mcurrency');\n\n try {\n resolve(request);\n } catch (err) {\n reject(new Error(err));\n }\n });\n\n return promise;\n }\n}\n\nexport default CurrenciesEndpoint;\n","import CatalogueExtend from '../extends/catalogue';\n\nclass BrandsEndpoint extends CatalogueExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'brands';\n }\n}\n\nexport default BrandsEndpoint;\n","import BaseExtend from '../extends/base';\n\nimport { cartIdentifier, buildCartItemData } from '../utils/helpers';\n\nclass CartEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'carts';\n this.cartId = cartIdentifier();\n }\n\n Get(cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}`, 'GET');\n }\n\n Items(cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}/items`, 'GET');\n }\n\n AddProduct(productId, quantity = 1, cartId = this.cartId) {\n const body = buildCartItemData(productId, quantity);\n\n return this.request.send(`${this.endpoint}/${cartId}/items`, 'POST', body);\n }\n\n AddCustomItem(body, cartId = this.cartId) {\n const itemObject = Object.assign(body, {\n type: 'custom_item',\n });\n\n return this.request.send(`${this.endpoint}/${cartId}/items`, 'POST', itemObject);\n }\n\n RemoveItem(itemId, cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}/items/${itemId}`, 'DELETE');\n }\n\n UpdateItemQuantity(itemId, quantity, cartId = this.cartId) {\n const body = buildCartItemData(itemId, quantity);\n\n return this.request.send(`${this.endpoint}/${cartId}/items/${itemId}`, 'PUT', body);\n }\n\n Checkout(body, cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}/checkout`, 'POST', body);\n }\n\n Delete(cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}`, 'DELETE');\n }\n}\n\nexport default CartEndpoint;\n","import CatalogueExtend from '../extends/catalogue';\n\nclass CategoriesEndpoint extends CatalogueExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'categories';\n }\n\n Tree() {\n return this.request.send(`${this.endpoint}/tree`, 'GET');\n }\n}\n\nexport default CategoriesEndpoint;\n","import CatalogueExtend from '../extends/catalogue';\n\nclass CollectionsEndpoint extends CatalogueExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'collections';\n }\n}\n\nexport default CollectionsEndpoint;\n","import BaseExtend from '../extends/base';\n\nclass OrdersEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'orders';\n }\n\n Payment(id, body) {\n return this.request.send(`${this.endpoint}/${id}/payments`, 'POST', body);\n }\n}\n\nexport default OrdersEndpoint;\n","import BaseExtend from '../extends/base';\n\nclass GatewaysEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'gateways';\n }\n\n Update(slug, body) {\n return this.request.send(`${this.endpoint}/${slug}`, 'PUT', body);\n }\n\n Enabled(slug, enabled) {\n return this.request.send(`${this.endpoint}/${slug}`, 'PUT', {\n type: 'gateway',\n enabled,\n });\n }\n}\n\nexport default GatewaysEndpoint;\n","import BaseExtend from '../extends/base';\n\nclass FilesEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'files';\n }\n\n Create(body) {\n return this.request.send(`${this.endpoint}`, 'POST', body);\n }\n\n Delete(id) {\n return this.request.send(`${this.endpoint}/${id}`, 'DELETE');\n }\n}\n\nexport default FilesEndpoint;\n","import 'fetch-everywhere';\nimport 'es6-promise';\n\nimport Config from './config';\nimport RequestFactory from './factories/request';\nimport StorageFactory from './factories/storage';\nimport ProductsEndpoint from './endpoints/products';\nimport CurrenciesEndpoint from './endpoints/currencies';\nimport BrandsEndpoint from './endpoints/brands';\nimport CartEndpoint from './endpoints/cart';\nimport CategoriesEndpoint from './endpoints/categories';\nimport CollectionsEndpoint from './endpoints/collections';\nimport OrdersEndpoint from './endpoints/orders';\nimport GatewaysEndpoint from './endpoints/gateways';\nimport FilesEndpoint from './endpoints/files';\n\nexport default class Moltin {\n constructor(config) {\n this.config = config;\n this.request = new RequestFactory(config);\n this.storage = new StorageFactory();\n\n this.Products = new ProductsEndpoint(config);\n this.Currencies = new CurrenciesEndpoint(config);\n this.Brands = new BrandsEndpoint(config);\n this.Cart = new CartEndpoint(config);\n this.Categories = new CategoriesEndpoint(config);\n this.Collections = new CollectionsEndpoint(config);\n this.Orders = new OrdersEndpoint(config);\n this.Gateways = new GatewaysEndpoint(config);\n this.Files = new FilesEndpoint(config);\n }\n\n // Expose `authenticate` function on the Moltin class\n Authenticate() {\n return this.request.authenticate();\n }\n}\n\n// Export a function to instantiate the Moltin class\nconst gateway = config => new Moltin(new Config(config));\n\nexport { gateway };\n"],"names":["buildRelationshipData","type","ids","let","data","length","id","Array","isArray","map","cartIdentifier","reset","const","storage","StorageFactory","get","replace","Math","random","toString","set","parseJSON","response","Promise","resolve","json","then","status","ok","setHeaderContentType","uri","method","contentType","formatFilterString","filter","Object","keys","key","value","join","formatQueryString","buildQueryParams","ref","includes","sort","limit","offset","query","include","k","buildURL","endpoint","params","buildRequestBody","body","JSON","stringify","buildCartItemData","product","quantity","parseInt","isFunc","obj","call","icPart","str","split","c","toUpperCase","toLowerCase","remove","arr","elem","i","prototype","splice","hasProp","hasOwnProperty","en","inflector","plural","singular","irregular","uncountable","inflections","locale","fn","Inflector","getInstance","applyInflections","word","rules","rule","regex","replacement","result","match","uncountables","indexOf","ii","pluralize","arguments","undefined","plurals","capitalize","String","charAt","slice","transliterations","Transliterator","transliterate","string","options","pkg","require","Config","this","client_id","client_secret","host","port","protocol","version","debug","currency","language","timeout","auth","expires","methods","sdk","localStorage","LocalStorage","window","setItem","getItem","delete","removeItem","RequestFactory","config","authenticate","Error","grant_type","promise","reject","fetch","headers","Content-Type","encodeURIComponent","catch","access_token","send","req","Authorization","X-MOLTIN-SDK-LANGUAGE","X-MOLTIN-SDK-VERSION","Date","now","error","classCallCheck","instance","Constructor","TypeError","createClass","defineProperties","target","props","descriptor","enumerable","configurable","writable","defineProperty","protoProps","staticProps","instances","singulars","humans","acronyms","acronymRegex","values","push","RegExp","unshift","s0","sRest","substr","p0","pRest","sRestIC","pRestIC","_len","words","_key","concat","scope","defaults$1","DEFAULT_APPROXIMATIONS","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","Ā","ā","Ă","ă","Ą","ą","Ć","ć","Ĉ","ĉ","Ċ","ċ","Č","č","Ď","ď","Đ","đ","Ē","ē","Ĕ","ĕ","Ė","ė","Ę","ę","Ě","ě","Ĝ","ĝ","Ğ","ğ","Ġ","ġ","Ģ","ģ","Ĥ","ĥ","Ħ","ħ","Ĩ","ĩ","Ī","ī","Ĭ","ĭ","Į","į","İ","ı","IJ","ij","Ĵ","ĵ","Ķ","ķ","ĸ","Ĺ","ĺ","Ļ","ļ","Ľ","ľ","Ŀ","ŀ","Ł","ł","Ń","ń","Ņ","ņ","Ň","ň","ʼn","Ŋ","ŋ","Ō","ō","Ŏ","ŏ","Ő","ő","Œ","œ","Ŕ","ŕ","Ŗ","ŗ","Ř","ř","Ś","ś","Ŝ","ŝ","Ş","ş","Š","š","Ţ","ţ","Ť","ť","Ŧ","ŧ","Ũ","ũ","Ū","ū","Ŭ","ŭ","Ů","ů","Ű","ű","Ų","ų","Ŵ","ŵ","Ŷ","ŷ","Ÿ","Ź","ź","Ż","ż","Ž","ž","DEFAULT_REPLACEMENT_CHAR","instances$1","approximations","char","approximate","_this","BaseExtend","request","All","Get","Limit","Offset","Sort","CatalogueExtend","Create","Delete","Update","With","ProductsEndpoint","super","Filter","CreateRelationships","resources","DeleteRelationships","UpdateRelationships","CurrenciesEndpoint","Set","err","Active","BrandsEndpoint","CartEndpoint","cartId","Items","AddProduct","productId","AddCustomItem","itemObject","assign","RemoveItem","itemId","UpdateItemQuantity","Checkout","CategoriesEndpoint","Tree","CollectionsEndpoint","OrdersEndpoint","Payment","GatewaysEndpoint","slug","Enabled","enabled","FilesEndpoint","Moltin","Products","Currencies","Brands","Cart","Categories","Collections","Orders","Gateways","Files","Authenticate","gateway"],"mappings":"YAEO,SAASA,uBAAsBC,EAAMC,GAC1CC,GAAIC,KAEJ,OAAY,QAARF,GAA+B,IAAfA,EAAIG,OACf,KAGU,gBAARH,KAEPD,KAAAA,EACAK,GAAIJ,KAIJK,MAAMC,QAAQN,KAChBE,EAAOF,EAAIO,IAAI,SAAAH,UACbL,KAAAA,EACAK,GAAAA,MAIGF,GAGT,QAAgBM,gBAAeC,EAAeL,mBAAP,mBAAY,EACjDM,IAAMC,GAAU,GAAIC,eAEpB,OAAKH,IAAUL,GAA+B,OAAzBO,EAAQE,IAAI,UAI5BT,IACHA,EAAK,mCAAmCU,QAAQ,OAAQ,kBAAuB,GAAhBC,KAAKC,SAAgB,GAAGC,SAAS,OAGlGN,EAAQO,IAAI,QAASd,GAEdA,GATEO,EAAQE,IAAI,SAYvB,QAAgBM,WAAUC,GACxB,MAAO,IAAIC,SAAQ,SAAAC,SAAWF,GAASG,OACpCC,KAAK,SAAAD,SAAQD,IACZG,OAAQL,EAASK,OACjBC,GAAIN,EAASM,GACbH,KAAAA,QAIN,QAAgBI,sBAAqBC,EAAKC,GACxC5B,GAAI6B,GAAc,kBAMlB,OAJY,UAARF,GAA8B,SAAXC,IACrBC,EAAc,uBAGTA,EAG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,qBAAoBpS,GAC7CvB,KAAO0U,OAAS,GAAId,gBAAerS,GACnCvB,KAAO2U,SAAW,GAAIb,kBAAiBvS,GACvCvB,KAAO4U,MAAQ,GAAIV,eAAc3S,GAInC4S,kBAAEU,wBACA,MAAS7U,MAAKsR,QAAQ9P,eAKxBhI,IAAMsb,SAAU,SAAAvT,SAAU,IAAI4S,QAAO,GAAIpU,QAAOwB"} \ No newline at end of file +{"version":3,"file":null,"sources":["../src/utils/helpers.js","../node_modules/inflected/dist/esm/inflected.js","../src/config.js","../src/factories/storage.js","../src/factories/request.js","../src/extends/base.js","../src/extends/catalogue.js","../src/endpoints/products.js","../src/endpoints/currencies.js","../src/endpoints/brands.js","../src/endpoints/cart.js","../src/endpoints/categories.js","../src/endpoints/collections.js","../src/endpoints/orders.js","../src/endpoints/gateways.js","../src/endpoints/files.js","../src/moltin.js"],"sourcesContent":["import StorageFactory from '../factories/storage';\n\nexport function buildRelationshipData(type, ids) {\n let data = [];\n\n if (ids === null || ids.length === 0) {\n return '[]';\n }\n\n if (typeof ids === 'string') {\n return [{\n type,\n id: ids,\n }];\n }\n\n if (Array.isArray(ids)) {\n data = ids.map(id => ({\n type,\n id,\n }));\n }\n\n return data;\n}\n\nexport function cartIdentifier(reset = false, id = false) {\n const storage = new StorageFactory();\n\n if (!reset && !id && storage.get('mcart') !== null) {\n return storage.get('mcart');\n }\n\n if (!id) {\n id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[x]/g, () => (Math.random() * 16 | 0).toString(16));\n }\n\n storage.set('mcart', id);\n\n return id;\n}\n\nexport function parseJSON(response) {\n return new Promise(resolve => response.json()\n .then(json => resolve({\n status: response.status,\n ok: response.ok,\n json,\n })));\n}\n\nexport function setHeaderContentType(uri, method) {\n let contentType = 'application/json';\n\n if (uri === 'files' && method === 'POST') {\n contentType = 'multipart/form-data';\n }\n\n return contentType;\n}\n\nfunction formatFilterString(type, filter) {\n const filterStringArray = Object.keys(filter).map((key) => {\n const value = filter[key];\n\n return `${type}(${key},${value})`;\n });\n\n return filterStringArray.join(':');\n}\n\nfunction formatQueryString(key, value) {\n if (key === 'limit' || key === 'offset') {\n return `page${(value)}`;\n }\n\n if (key === 'filter') {\n const filterValues = Object.keys(value).map(\n filter => formatFilterString(filter, value[filter]));\n\n return `${key}=${filterValues.join(':')}`;\n }\n\n return `${key}=${value}`;\n}\n\nfunction buildQueryParams({ includes, sort, limit, offset, filter }) {\n const query = {};\n\n if (includes) {\n query.include = includes;\n }\n\n if (sort) {\n query.sort = `(${sort})`;\n }\n\n if (limit) {\n query.limit = `[limit]=${limit}`;\n }\n\n if (offset) {\n query.offset = `[offset]=${offset}`;\n }\n\n if (filter) {\n query.filter = filter;\n }\n\n return Object.keys(query).map(k => formatQueryString(k, query[k])).join('&');\n}\n\nexport function buildURL(endpoint, params) {\n if (params.includes || params.sort || params.limit || params.offset || params.filter) {\n const paramsString = buildQueryParams(params);\n\n return `${endpoint}?${paramsString}`;\n }\n\n return endpoint;\n}\n\n\nexport function buildRequestBody(body) {\n if (body) {\n return `{\"data\":${JSON.stringify(body)}}`;\n }\n\n return null;\n}\n\nexport function buildCartItemData(product, quantity, type = 'cart_item') {\n return {\n id: product,\n type,\n quantity: parseInt(quantity, 10),\n };\n}\n","var toString = Object.prototype.toString;\n\nfunction isFunc(obj) {\n return toString.call(obj) === \"[object Function]\";\n}\n\nvar classCallCheck = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};\n\nvar createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\n\nfunction icPart(str) {\n return str.split(\"\").map(function (c) {\n return \"(?:\" + c.toUpperCase() + \"|\" + c.toLowerCase() + \")\";\n }).join(\"\");\n}\n\nfunction remove(arr, elem) {\n for (var i = arr.length - 1; i >= 0; i--) {\n if (arr[i] === elem) {\n Array.prototype.splice.call(arr, i, 1);\n }\n }\n}\n\nfunction hasProp(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nvar instances = {};\n\nvar Inflector = function () {\n createClass(Inflector, null, [{\n key: \"getInstance\",\n value: function getInstance(locale) {\n instances[locale] = instances[locale] || new Inflector();\n return instances[locale];\n }\n }]);\n\n function Inflector() {\n classCallCheck(this, Inflector);\n\n this.plurals = [];\n this.singulars = [];\n this.uncountables = [];\n this.humans = [];\n this.acronyms = {};\n this.acronymRegex = /(?=a)b/;\n }\n\n createClass(Inflector, [{\n key: \"acronym\",\n value: function acronym(word) {\n this.acronyms[word.toLowerCase()] = word;\n\n var values = [];\n\n for (var key in this.acronyms) {\n if (hasProp(this.acronyms, key)) {\n values.push(this.acronyms[key]);\n }\n }\n\n this.acronymRegex = new RegExp(values.join(\"|\"));\n }\n }, {\n key: \"plural\",\n value: function plural(rule, replacement) {\n if (typeof rule === \"string\") {\n remove(this.uncountables, rule);\n }\n\n remove(this.uncountables, replacement);\n this.plurals.unshift([rule, replacement]);\n }\n }, {\n key: \"singular\",\n value: function singular(rule, replacement) {\n if (typeof rule === \"string\") {\n remove(this.uncountables, rule);\n }\n\n remove(this.uncountables, replacement);\n this.singulars.unshift([rule, replacement]);\n }\n }, {\n key: \"irregular\",\n value: function irregular(singular, plural) {\n remove(this.uncountables, singular);\n remove(this.uncountables, plural);\n\n var s0 = singular[0];\n var sRest = singular.substr(1);\n\n var p0 = plural[0];\n var pRest = plural.substr(1);\n\n if (s0.toUpperCase() === p0.toUpperCase()) {\n this.plural(new RegExp(\"(\" + s0 + \")\" + sRest + \"$\", \"i\"), \"$1\" + pRest);\n this.plural(new RegExp(\"(\" + p0 + \")\" + pRest + \"$\", \"i\"), \"$1\" + pRest);\n\n this.singular(new RegExp(\"(\" + s0 + \")\" + sRest + \"$\", \"i\"), \"$1\" + sRest);\n this.singular(new RegExp(\"(\" + p0 + \")\" + pRest + \"$\", \"i\"), \"$1\" + sRest);\n } else {\n var sRestIC = icPart(sRest);\n var pRestIC = icPart(pRest);\n\n this.plural(new RegExp(s0.toUpperCase() + sRestIC + \"$\"), p0.toUpperCase() + pRest);\n this.plural(new RegExp(s0.toLowerCase() + sRestIC + \"$\"), p0.toLowerCase() + pRest);\n this.plural(new RegExp(p0.toUpperCase() + pRestIC + \"$\"), p0.toUpperCase() + pRest);\n this.plural(new RegExp(p0.toLowerCase() + pRestIC + \"$\"), p0.toLowerCase() + pRest);\n\n this.singular(new RegExp(s0.toUpperCase() + sRestIC + \"$\"), s0.toUpperCase() + sRest);\n this.singular(new RegExp(s0.toLowerCase() + sRestIC + \"$\"), s0.toLowerCase() + sRest);\n this.singular(new RegExp(p0.toUpperCase() + pRestIC + \"$\"), s0.toUpperCase() + sRest);\n this.singular(new RegExp(p0.toLowerCase() + pRestIC + \"$\"), s0.toLowerCase() + sRest);\n }\n }\n }, {\n key: \"uncountable\",\n value: function uncountable() {\n for (var _len = arguments.length, words = Array(_len), _key = 0; _key < _len; _key++) {\n words[_key] = arguments[_key];\n }\n\n this.uncountables = this.uncountables.concat(words);\n }\n }, {\n key: \"human\",\n value: function human(rule, replacement) {\n this.humans.unshift([rule, replacement]);\n }\n }, {\n key: \"clear\",\n value: function clear() {\n var scope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"all\";\n\n if (scope === \"all\") {\n this.plurals = [];\n this.singulars = [];\n this.uncountables = [];\n this.humans = [];\n } else {\n this[scope] = [];\n }\n }\n }]);\n return Inflector;\n}();\n\nfunction en(inflector) {\n inflector.plural(/$/, \"s\");\n inflector.plural(/s$/i, \"s\");\n inflector.plural(/^(ax|test)is$/i, \"$1es\");\n inflector.plural(/(octop|vir)us$/i, \"$1i\");\n inflector.plural(/(octop|vir)i$/i, \"$1i\");\n inflector.plural(/(alias|status)$/i, \"$1es\");\n inflector.plural(/(bu)s$/i, \"$1ses\");\n inflector.plural(/(buffal|tomat)o$/i, \"$1oes\");\n inflector.plural(/([ti])um$/i, \"$1a\");\n inflector.plural(/([ti])a$/i, \"$1a\");\n inflector.plural(/sis$/i, \"ses\");\n inflector.plural(/(?:([^f])fe|([lr])f)$/i, \"$1$2ves\");\n inflector.plural(/(hive)$/i, \"$1s\");\n inflector.plural(/([^aeiouy]|qu)y$/i, \"$1ies\");\n inflector.plural(/(x|ch|ss|sh)$/i, \"$1es\");\n inflector.plural(/(matr|vert|ind)(?:ix|ex)$/i, \"$1ices\");\n inflector.plural(/^(m|l)ouse$/i, \"$1ice\");\n inflector.plural(/^(m|l)ice$/i, \"$1ice\");\n inflector.plural(/^(ox)$/i, \"$1en\");\n inflector.plural(/^(oxen)$/i, \"$1\");\n inflector.plural(/(quiz)$/i, \"$1zes\");\n\n inflector.singular(/s$/i, \"\");\n inflector.singular(/(ss)$/i, \"$1\");\n inflector.singular(/(n)ews$/i, \"$1ews\");\n inflector.singular(/([ti])a$/i, \"$1um\");\n inflector.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, \"$1sis\");\n inflector.singular(/(^analy)(sis|ses)$/i, \"$1sis\");\n inflector.singular(/([^f])ves$/i, \"$1fe\");\n inflector.singular(/(hive)s$/i, \"$1\");\n inflector.singular(/(tive)s$/i, \"$1\");\n inflector.singular(/([lr])ves$/i, \"$1f\");\n inflector.singular(/([^aeiouy]|qu)ies$/i, \"$1y\");\n inflector.singular(/(s)eries$/i, \"$1eries\");\n inflector.singular(/(m)ovies$/i, \"$1ovie\");\n inflector.singular(/(x|ch|ss|sh)es$/i, \"$1\");\n inflector.singular(/^(m|l)ice$/i, \"$1ouse\");\n inflector.singular(/(bus)(es)?$/i, \"$1\");\n inflector.singular(/(o)es$/i, \"$1\");\n inflector.singular(/(shoe)s$/i, \"$1\");\n inflector.singular(/(cris|test)(is|es)$/i, \"$1is\");\n inflector.singular(/^(a)x[ie]s$/i, \"$1xis\");\n inflector.singular(/(octop|vir)(us|i)$/i, \"$1us\");\n inflector.singular(/(alias|status)(es)?$/i, \"$1\");\n inflector.singular(/^(ox)en/i, \"$1\");\n inflector.singular(/(vert|ind)ices$/i, \"$1ex\");\n inflector.singular(/(matr)ices$/i, \"$1ix\");\n inflector.singular(/(quiz)zes$/i, \"$1\");\n inflector.singular(/(database)s$/i, \"$1\");\n\n inflector.irregular(\"person\", \"people\");\n inflector.irregular(\"man\", \"men\");\n inflector.irregular(\"child\", \"children\");\n inflector.irregular(\"sex\", \"sexes\");\n inflector.irregular(\"move\", \"moves\");\n inflector.irregular(\"zombie\", \"zombies\");\n\n inflector.uncountable(\"equipment\", \"information\", \"rice\", \"money\", \"species\", \"series\", \"fish\", \"sheep\", \"jeans\", \"police\");\n}\n\nvar defaults$1 = {\n en: en\n};\n\nfunction inflections(locale, fn) {\n if (isFunc(locale)) {\n fn = locale;\n locale = null;\n }\n\n locale = locale || \"en\";\n\n if (fn) {\n fn(Inflector.getInstance(locale));\n } else {\n return Inflector.getInstance(locale);\n }\n}\n\nfor (var locale in defaults$1) {\n inflections(locale, defaults$1[locale]);\n}\n\nfunction applyInflections(word, rules) {\n var result = \"\" + word,\n rule,\n regex,\n replacement;\n\n if (result.length === 0) {\n return result;\n } else {\n var match = result.toLowerCase().match(/\\b\\w+$/);\n\n if (match && inflections().uncountables.indexOf(match[0]) > -1) {\n return result;\n } else {\n for (var i = 0, ii = rules.length; i < ii; i++) {\n rule = rules[i];\n\n regex = rule[0];\n replacement = rule[1];\n\n if (result.match(regex)) {\n result = result.replace(regex, replacement);\n break;\n }\n }\n\n return result;\n }\n }\n}\n\nfunction pluralize(word) {\n var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"en\";\n\n return applyInflections(word, inflections(locale).plurals);\n}\n\nfunction singularize(word) {\n var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"en\";\n\n return applyInflections(word, inflections(locale).singulars);\n}\n\nfunction capitalize(str) {\n var result = str === null || str === undefined ? \"\" : String(str);\n return result.charAt(0).toUpperCase() + result.slice(1);\n}\n\nfunction camelize(term, uppercaseFirstLetter) {\n if (uppercaseFirstLetter === null || uppercaseFirstLetter === undefined) {\n uppercaseFirstLetter = true;\n }\n\n var result = \"\" + term;\n\n if (uppercaseFirstLetter) {\n result = result.replace(/^[a-z\\d]*/, function (a) {\n return inflections().acronyms[a] || capitalize(a);\n });\n } else {\n result = result.replace(new RegExp(\"^(?:\" + inflections().acronymRegex.source + \"(?=\\\\b|[A-Z_])|\\\\w)\"), function (a) {\n return a.toLowerCase();\n });\n }\n\n result = result.replace(/(?:_|(\\/))([a-z\\d]*)/gi, function (match, a, b, idx, string) {\n a || (a = \"\");\n return \"\" + a + (inflections().acronyms[b] || capitalize(b));\n });\n\n return result;\n}\n\nfunction underscore(camelCasedWord) {\n var result = \"\" + camelCasedWord;\n\n result = result.replace(new RegExp(\"(?:([A-Za-z\\\\d])|^)(\" + inflections().acronymRegex.source + \")(?=\\\\b|[^a-z])\", \"g\"), function (match, $1, $2) {\n return \"\" + ($1 || \"\") + ($1 ? \"_\" : \"\") + $2.toLowerCase();\n });\n\n result = result.replace(/([A-Z\\d]+)([A-Z][a-z])/g, \"$1_$2\");\n result = result.replace(/([a-z\\d])([A-Z])/g, \"$1_$2\");\n result = result.replace(/-/g, \"_\");\n\n return result.toLowerCase();\n}\n\nfunction humanize(lowerCaseAndUnderscoredWord, options) {\n var result = \"\" + lowerCaseAndUnderscoredWord;\n var humans = inflections().humans;\n var human = void 0,\n rule = void 0,\n replacement = void 0;\n\n options = options || {};\n\n if (options.capitalize === null || options.capitalize === undefined) {\n options.capitalize = true;\n }\n\n for (var i = 0, ii = humans.length; i < ii; i++) {\n human = humans[i];\n rule = human[0];\n replacement = human[1];\n\n if (rule.test && rule.test(result) || result.indexOf(rule) > -1) {\n result = result.replace(rule, replacement);\n break;\n }\n }\n\n result = result.replace(/_id$/, \"\");\n result = result.replace(/_/g, \" \");\n\n result = result.replace(/([a-z\\d]*)/gi, function (match) {\n return inflections().acronyms[match] || match.toLowerCase();\n });\n\n if (options.capitalize) {\n result = result.replace(/^\\w/, function (match) {\n return match.toUpperCase();\n });\n }\n\n return result;\n}\n\nfunction titleize(word) {\n return humanize(this.underscore(word)).replace(/(^|[\\s¿/]+)([a-z])/g, function (match, boundary, letter, idx, string) {\n return match.replace(letter, letter.toUpperCase());\n });\n}\n\nfunction tableize(className) {\n return pluralize(underscore(className));\n}\n\nfunction classify(tableName) {\n return camelize(singularize(tableName.replace(/.*\\./g, \"\")));\n}\n\nfunction dasherize(underscoredWord) {\n return underscoredWord.replace(/_/g, \"-\");\n}\n\nfunction foreignKey(className) {\n var separateWithUnderscore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n\n return \"\" + underscore(className) + (separateWithUnderscore ? \"_id\" : \"id\");\n}\n\nfunction ordinal(number) {\n var absNumber = Math.abs(Number(number));\n var mod100 = absNumber % 100;\n\n if (mod100 === 11 || mod100 === 12 || mod100 === 13) {\n return \"th\";\n } else {\n switch (absNumber % 10) {\n case 1:\n return \"st\";\n case 2:\n return \"nd\";\n case 3:\n return \"rd\";\n default:\n return \"th\";\n }\n }\n}\n\nfunction ordinalize(number) {\n return \"\" + number + ordinal(number);\n}\n\n// prettier-ignore\nvar DEFAULT_APPROXIMATIONS = {\n 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE',\n 'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I',\n 'Î': 'I', 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O',\n 'Õ': 'O', 'Ö': 'O', '×': 'x', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U',\n 'Ü': 'U', 'Ý': 'Y', 'Þ': 'Th', 'ß': 'ss', 'à': 'a', 'á': 'a', 'â': 'a',\n 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': 'ae', 'ç': 'c', 'è': 'e', 'é': 'e',\n 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'd',\n 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ø': 'o',\n 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y',\n 'Ā': 'A', 'ā': 'a', 'Ă': 'A', 'ă': 'a', 'Ą': 'A', 'ą': 'a', 'Ć': 'C',\n 'ć': 'c', 'Ĉ': 'C', 'ĉ': 'c', 'Ċ': 'C', 'ċ': 'c', 'Č': 'C', 'č': 'c',\n 'Ď': 'D', 'ď': 'd', 'Đ': 'D', 'đ': 'd', 'Ē': 'E', 'ē': 'e', 'Ĕ': 'E',\n 'ĕ': 'e', 'Ė': 'E', 'ė': 'e', 'Ę': 'E', 'ę': 'e', 'Ě': 'E', 'ě': 'e',\n 'Ĝ': 'G', 'ĝ': 'g', 'Ğ': 'G', 'ğ': 'g', 'Ġ': 'G', 'ġ': 'g', 'Ģ': 'G',\n 'ģ': 'g', 'Ĥ': 'H', 'ĥ': 'h', 'Ħ': 'H', 'ħ': 'h', 'Ĩ': 'I', 'ĩ': 'i',\n 'Ī': 'I', 'ī': 'i', 'Ĭ': 'I', 'ĭ': 'i', 'Į': 'I', 'į': 'i', 'İ': 'I',\n 'ı': 'i', 'IJ': 'IJ', 'ij': 'ij', 'Ĵ': 'J', 'ĵ': 'j', 'Ķ': 'K', 'ķ': 'k',\n 'ĸ': 'k', 'Ĺ': 'L', 'ĺ': 'l', 'Ļ': 'L', 'ļ': 'l', 'Ľ': 'L', 'ľ': 'l',\n 'Ŀ': 'L', 'ŀ': 'l', 'Ł': 'L', 'ł': 'l', 'Ń': 'N', 'ń': 'n', 'Ņ': 'N',\n 'ņ': 'n', 'Ň': 'N', 'ň': 'n', 'ʼn': '\\'n', 'Ŋ': 'NG', 'ŋ': 'ng',\n 'Ō': 'O', 'ō': 'o', 'Ŏ': 'O', 'ŏ': 'o', 'Ő': 'O', 'ő': 'o', 'Œ': 'OE',\n 'œ': 'oe', 'Ŕ': 'R', 'ŕ': 'r', 'Ŗ': 'R', 'ŗ': 'r', 'Ř': 'R', 'ř': 'r',\n 'Ś': 'S', 'ś': 's', 'Ŝ': 'S', 'ŝ': 's', 'Ş': 'S', 'ş': 's', 'Š': 'S',\n 'š': 's', 'Ţ': 'T', 'ţ': 't', 'Ť': 'T', 'ť': 't', 'Ŧ': 'T', 'ŧ': 't',\n 'Ũ': 'U', 'ũ': 'u', 'Ū': 'U', 'ū': 'u', 'Ŭ': 'U', 'ŭ': 'u', 'Ů': 'U',\n 'ů': 'u', 'Ű': 'U', 'ű': 'u', 'Ų': 'U', 'ų': 'u', 'Ŵ': 'W', 'ŵ': 'w',\n 'Ŷ': 'Y', 'ŷ': 'y', 'Ÿ': 'Y', 'Ź': 'Z', 'ź': 'z', 'Ż': 'Z', 'ż': 'z',\n 'Ž': 'Z', 'ž': 'z'\n};\n\nvar DEFAULT_REPLACEMENT_CHAR = \"?\";\n\nvar instances$1 = {};\n\nvar Transliterator = function () {\n createClass(Transliterator, null, [{\n key: 'getInstance',\n value: function getInstance(locale) {\n instances$1[locale] = instances$1[locale] || new Transliterator();\n return instances$1[locale];\n }\n }]);\n\n function Transliterator() {\n classCallCheck(this, Transliterator);\n\n this.approximations = {};\n\n for (var char in DEFAULT_APPROXIMATIONS) {\n this.approximate(char, DEFAULT_APPROXIMATIONS[char]);\n }\n }\n\n createClass(Transliterator, [{\n key: 'approximate',\n value: function approximate(char, replacement) {\n this.approximations[char] = replacement;\n }\n }, {\n key: 'transliterate',\n value: function transliterate(string, replacement) {\n var _this = this;\n\n return string.replace(/[^\\u0000-\\u007f]/g, function (c) {\n return _this.approximations[c] || replacement || DEFAULT_REPLACEMENT_CHAR;\n });\n }\n }]);\n return Transliterator;\n}();\n\nfunction transliterations(locale, fn) {\n if (isFunc(locale)) {\n fn = locale;\n locale = null;\n }\n\n locale = locale || \"en\";\n\n if (fn) {\n fn(Transliterator.getInstance(locale));\n } else {\n return Transliterator.getInstance(locale);\n }\n}\n\nfunction transliterate(string) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n var locale = options.locale || \"en\";\n var replacement = options.replacement || \"?\";\n\n return transliterations(locale).transliterate(string, replacement);\n}\n\nfunction parameterize(string) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (options.separator === undefined) {\n options.separator = \"-\";\n }\n\n if (options.separator === null) {\n options.separator = \"\";\n }\n\n // replace accented chars with their ascii equivalents\n var result = transliterate(string, options);\n\n result = result.replace(/[^a-z0-9\\-_]+/ig, options.separator);\n\n if (options.separator.length) {\n var separatorRegex = new RegExp(options.separator);\n\n // no more than one of the separator in a row\n result = result.replace(new RegExp(separatorRegex.source + \"{2,}\"), options.separator);\n\n // remove leading/trailing separator\n result = result.replace(new RegExp(\"^\" + separatorRegex.source + \"|\" + separatorRegex.source + \"$\", \"i\"), \"\");\n }\n\n return result.toLowerCase();\n}\n\nexport { pluralize, singularize, camelize, underscore, humanize, titleize, tableize, classify, dasherize, foreignKey, ordinal, ordinalize, transliterate, parameterize, capitalize, inflections, transliterations };\n","const pkg = require('../package.json');\n\nclass Config {\n constructor(options) {\n this.client_id = options.client_id;\n this.client_secret = options.client_secret;\n this.host = 'api.moltin.com';\n this.port = '443';\n this.protocol = 'https';\n this.version = 'v2';\n this.debug = false;\n this.currency = options.currency;\n this.language = false;\n this.timeout = 60000;\n this.auth = {\n expires: 3600,\n uri: 'oauth/access_token',\n };\n this.methods = ['GET', 'POST', 'PUT', 'DELETE'];\n this.sdk = {\n version: pkg.version,\n language: 'JS',\n };\n }\n}\n\nexport default Config;\n","/* jshint node: true */\n\nclass StorageFactory {\n constructor() {\n if (typeof localStorage === 'undefined' || localStorage === null) {\n const LocalStorage = require('node-localstorage').LocalStorage;\n\n this.localStorage = new LocalStorage('./localStorage');\n } else {\n this.localStorage = window.localStorage;\n }\n }\n\n set(key, value) {\n return this.localStorage.setItem(key, value);\n }\n\n get(key) {\n return this.localStorage.getItem(key);\n }\n\n delete(key) {\n return this.localStorage.removeItem(key);\n }\n}\n\nexport default StorageFactory;\n","import StorageFactory from './storage';\n\nimport { setHeaderContentType, buildRequestBody, parseJSON } from '../utils/helpers';\n\nclass RequestFactory {\n constructor(config) {\n this.config = config;\n\n this.storage = new StorageFactory();\n }\n\n authenticate() {\n const config = this.config;\n const storage = this.storage;\n\n if (!config.client_id) {\n throw new Error('You must have a client_id set');\n }\n\n const body = {\n grant_type: config.client_secret ? 'client_credentials' : 'implicit',\n client_id: config.client_id,\n };\n\n if (config.client_secret) {\n body.client_secret = config.client_secret;\n }\n\n const promise = new Promise((resolve, reject) => {\n fetch(`${config.protocol}://${config.host}/${config.auth.uri}`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: Object.keys(body).map(k => `${encodeURIComponent(k)}=${encodeURIComponent(body[k])}`).join('&'),\n })\n .then(parseJSON)\n .then((response) => {\n if (response.ok) {\n resolve(response.json);\n }\n\n reject(response.json);\n })\n .catch(() => reject('Fetch error - check your network'));\n });\n\n promise.then((response) => {\n storage.set('mtoken', response.access_token);\n storage.set('mexpires', response.expires);\n });\n\n return promise;\n }\n\n send(uri, method, body = null) {\n const config = this.config;\n const storage = this.storage;\n\n const promise = new Promise((resolve, reject) => {\n const req = () => {\n const headers = {\n Authorization: `Bearer: ${storage.get('mtoken')}`,\n 'Content-Type': setHeaderContentType(uri, method),\n 'X-MOLTIN-SDK-LANGUAGE': config.sdk.language,\n 'X-MOLTIN-SDK-VERSION': config.sdk.version,\n };\n\n if (config.currency) {\n headers['X-MOLTIN-CURRENCY'] = config.currency;\n }\n\n fetch(`${config.protocol}://${config.host}/${config.version}/${uri}`, {\n method: method.toUpperCase(),\n headers,\n body: buildRequestBody(body),\n })\n .then(parseJSON)\n .then((response) => {\n if (response.ok) {\n resolve(response.json);\n }\n\n reject(response.json);\n })\n .catch(() => reject('Fetch error - check your network'));\n };\n\n if (!storage.get('mtoken') || Date.now().toString() >= storage.get('mexpires')) {\n return this.authenticate()\n .then(req)\n .catch(error => reject(error));\n }\n\n return req();\n });\n\n return promise;\n }\n}\n\nexport default RequestFactory;\n","import RequestFactory from '../factories/request';\nimport { buildURL } from '../utils/helpers';\n\nclass BaseExtend {\n constructor(config) {\n this.request = new RequestFactory(config);\n\n this.config = config;\n }\n\n All() {\n this.call = this.request.send(buildURL(this.endpoint, {\n includes: this.includes,\n sort: this.sort,\n limit: this.limit,\n offset: this.offset,\n filter: this.filter,\n }), 'GET');\n\n return this.call;\n }\n\n Get(id) {\n this.call = this.request.send(buildURL(`${this.endpoint}/${id}`, {\n includes: this.includes,\n }), 'GET');\n\n return this.call;\n }\n\n Limit(value) {\n this.limit = value;\n\n return this;\n }\n\n Offset(value) {\n this.offset = value;\n\n return this;\n }\n\n Sort(value) {\n this.sort = value;\n\n return this;\n }\n}\n\nexport default BaseExtend;\n","import BaseExtend from './base';\n\nclass CatalogueExtend extends BaseExtend {\n Create(body) {\n return this.request.send(`${this.endpoint}`, 'POST', body);\n }\n\n Delete(id) {\n return this.request.send(`${this.endpoint}/${id}`, 'DELETE');\n }\n\n Update(id, body) {\n return this.request.send(`${this.endpoint}/${id}`, 'PUT', body);\n }\n\n With(includes) {\n this.includes = includes.toString().toLowerCase();\n\n return this;\n }\n}\n\nexport default CatalogueExtend;\n","import { pluralize } from 'inflected';\nimport CatalogueExtend from '../extends/catalogue';\nimport { buildRelationshipData } from '../utils/helpers';\n\nclass ProductsEndpoint extends CatalogueExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'products';\n }\n\n Filter(filter) {\n this.filter = filter;\n\n return this;\n }\n\n CreateRelationships(id, type, resources) {\n const body = buildRelationshipData(type, resources);\n\n return this.request.send(`${this.endpoint}/${id}/relationships/${pluralize(type)}`, 'POST', body);\n }\n\n DeleteRelationships(id, type, resources) {\n const body = buildRelationshipData(type, resources);\n\n return this.request.send(`${this.endpoint}/${id}/relationships/${pluralize(type)}`, 'DELETE', body);\n }\n\n UpdateRelationships(id, type, resources = null) {\n const body = buildRelationshipData(type, resources);\n\n return this.request.send(`${this.endpoint}/${id}/relationships/${pluralize(type)}`, 'PUT', body);\n }\n}\n\nexport default ProductsEndpoint;\n","import BaseExtend from '../extends/base';\nimport StorageFactory from '../factories/storage';\n\nclass CurrenciesEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'currencies';\n this.storage = new StorageFactory();\n }\n\n Create(body) {\n return this.request.send(`${this.endpoint}`, 'POST', body);\n }\n\n Delete(id) {\n return this.request.send(`${this.endpoint}/${id}`, 'DELETE');\n }\n\n Update(id, body) {\n return this.request.send(`${this.endpoint}/${id}`, 'PUT', body);\n }\n\n Set(currency) {\n const storage = this.storage;\n const config = this.config;\n\n storage.set('mcurrency', currency);\n config.currency = currency;\n\n const promise = new Promise((resolve, reject) => {\n const request = storage.get('mcurrency');\n\n try {\n resolve(request);\n } catch (err) {\n reject(new Error(err));\n }\n });\n\n return promise;\n }\n\n Active() {\n const storage = this.storage;\n\n const promise = new Promise((resolve, reject) => {\n const request = storage.get('mcurrency');\n\n try {\n resolve(request);\n } catch (err) {\n reject(new Error(err));\n }\n });\n\n return promise;\n }\n}\n\nexport default CurrenciesEndpoint;\n","import CatalogueExtend from '../extends/catalogue';\n\nclass BrandsEndpoint extends CatalogueExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'brands';\n }\n}\n\nexport default BrandsEndpoint;\n","import BaseExtend from '../extends/base';\n\nimport { cartIdentifier, buildCartItemData } from '../utils/helpers';\n\nclass CartEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'carts';\n this.cartId = cartIdentifier();\n }\n\n Get(cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}`, 'GET');\n }\n\n Items(cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}/items`, 'GET');\n }\n\n AddProduct(productId, quantity = 1, cartId = this.cartId) {\n const body = buildCartItemData(productId, quantity);\n\n return this.request.send(`${this.endpoint}/${cartId}/items`, 'POST', body);\n }\n\n AddCustomItem(body, cartId = this.cartId) {\n const itemObject = Object.assign(body, {\n type: 'custom_item',\n });\n\n return this.request.send(`${this.endpoint}/${cartId}/items`, 'POST', itemObject);\n }\n\n RemoveItem(itemId, cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}/items/${itemId}`, 'DELETE');\n }\n\n UpdateItemQuantity(itemId, quantity, cartId = this.cartId) {\n const body = buildCartItemData(itemId, quantity);\n\n return this.request.send(`${this.endpoint}/${cartId}/items/${itemId}`, 'PUT', body);\n }\n\n Checkout(body, cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}/checkout`, 'POST', body);\n }\n\n Delete(cartId = this.cartId) {\n return this.request.send(`${this.endpoint}/${cartId}`, 'DELETE');\n }\n}\n\nexport default CartEndpoint;\n","import CatalogueExtend from '../extends/catalogue';\n\nclass CategoriesEndpoint extends CatalogueExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'categories';\n }\n\n Tree() {\n return this.request.send(`${this.endpoint}/tree`, 'GET');\n }\n}\n\nexport default CategoriesEndpoint;\n","import CatalogueExtend from '../extends/catalogue';\n\nclass CollectionsEndpoint extends CatalogueExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'collections';\n }\n}\n\nexport default CollectionsEndpoint;\n","import BaseExtend from '../extends/base';\n\nclass OrdersEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'orders';\n }\n\n Items(id) {\n return this.request.send(`${this.endpoint}/${id}/items`, 'GET');\n }\n\n Payment(id, body) {\n return this.request.send(`${this.endpoint}/${id}/payments`, 'POST', body);\n }\n}\n\nexport default OrdersEndpoint;\n","import BaseExtend from '../extends/base';\n\nclass GatewaysEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'gateways';\n }\n\n Update(slug, body) {\n return this.request.send(`${this.endpoint}/${slug}`, 'PUT', body);\n }\n\n Enabled(slug, enabled) {\n return this.request.send(`${this.endpoint}/${slug}`, 'PUT', {\n type: 'gateway',\n enabled,\n });\n }\n}\n\nexport default GatewaysEndpoint;\n","import BaseExtend from '../extends/base';\n\nclass FilesEndpoint extends BaseExtend {\n constructor(endpoint) {\n super(endpoint);\n\n this.endpoint = 'files';\n }\n\n Create(body) {\n return this.request.send(`${this.endpoint}`, 'POST', body);\n }\n\n Delete(id) {\n return this.request.send(`${this.endpoint}/${id}`, 'DELETE');\n }\n}\n\nexport default FilesEndpoint;\n","import 'fetch-everywhere';\nimport 'es6-promise';\n\nimport Config from './config';\nimport RequestFactory from './factories/request';\nimport StorageFactory from './factories/storage';\nimport ProductsEndpoint from './endpoints/products';\nimport CurrenciesEndpoint from './endpoints/currencies';\nimport BrandsEndpoint from './endpoints/brands';\nimport CartEndpoint from './endpoints/cart';\nimport CategoriesEndpoint from './endpoints/categories';\nimport CollectionsEndpoint from './endpoints/collections';\nimport OrdersEndpoint from './endpoints/orders';\nimport GatewaysEndpoint from './endpoints/gateways';\nimport FilesEndpoint from './endpoints/files';\n\nexport default class Moltin {\n constructor(config) {\n this.config = config;\n this.request = new RequestFactory(config);\n this.storage = new StorageFactory();\n\n this.Products = new ProductsEndpoint(config);\n this.Currencies = new CurrenciesEndpoint(config);\n this.Brands = new BrandsEndpoint(config);\n this.Cart = new CartEndpoint(config);\n this.Categories = new CategoriesEndpoint(config);\n this.Collections = new CollectionsEndpoint(config);\n this.Orders = new OrdersEndpoint(config);\n this.Gateways = new GatewaysEndpoint(config);\n this.Files = new FilesEndpoint(config);\n }\n\n // Expose `authenticate` function on the Moltin class\n Authenticate() {\n return this.request.authenticate();\n }\n}\n\n// Export a function to instantiate the Moltin class\nconst gateway = config => new Moltin(new Config(config));\n\nexport { gateway };\n"],"names":["buildRelationshipData","type","ids","let","data","length","id","Array","isArray","map","cartIdentifier","reset","const","storage","StorageFactory","get","replace","Math","random","toString","set","parseJSON","response","Promise","resolve","json","then","status","ok","setHeaderContentType","uri","method","contentType","formatFilterString","filter","Object","keys","key","value","join","formatQueryString","buildQueryParams","ref","includes","sort","limit","offset","query","include","k","buildURL","endpoint","params","buildRequestBody","body","JSON","stringify","buildCartItemData","product","quantity","parseInt","isFunc","obj","call","icPart","str","split","c","toUpperCase","toLowerCase","remove","arr","elem","i","prototype","splice","hasProp","hasOwnProperty","en","inflector","plural","singular","irregular","uncountable","inflections","locale","fn","Inflector","getInstance","applyInflections","word","rules","rule","regex","replacement","result","match","uncountables","indexOf","ii","pluralize","arguments","undefined","plurals","capitalize","String","charAt","slice","transliterations","Transliterator","transliterate","string","options","pkg","require","Config","this","client_id","client_secret","host","port","protocol","version","debug","currency","language","timeout","auth","expires","methods","sdk","localStorage","LocalStorage","window","setItem","getItem","delete","removeItem","RequestFactory","config","authenticate","Error","grant_type","promise","reject","fetch","headers","Content-Type","encodeURIComponent","catch","access_token","send","req","Authorization","X-MOLTIN-SDK-LANGUAGE","X-MOLTIN-SDK-VERSION","Date","now","error","classCallCheck","instance","Constructor","TypeError","createClass","defineProperties","target","props","descriptor","enumerable","configurable","writable","defineProperty","protoProps","staticProps","instances","singulars","humans","acronyms","acronymRegex","values","push","RegExp","unshift","s0","sRest","substr","p0","pRest","sRestIC","pRestIC","_len","words","_key","concat","scope","defaults$1","DEFAULT_APPROXIMATIONS","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","Ā","ā","Ă","ă","Ą","ą","Ć","ć","Ĉ","ĉ","Ċ","ċ","Č","č","Ď","ď","Đ","đ","Ē","ē","Ĕ","ĕ","Ė","ė","Ę","ę","Ě","ě","Ĝ","ĝ","Ğ","ğ","Ġ","ġ","Ģ","ģ","Ĥ","ĥ","Ħ","ħ","Ĩ","ĩ","Ī","ī","Ĭ","ĭ","Į","į","İ","ı","IJ","ij","Ĵ","ĵ","Ķ","ķ","ĸ","Ĺ","ĺ","Ļ","ļ","Ľ","ľ","Ŀ","ŀ","Ł","ł","Ń","ń","Ņ","ņ","Ň","ň","ʼn","Ŋ","ŋ","Ō","ō","Ŏ","ŏ","Ő","ő","Œ","œ","Ŕ","ŕ","Ŗ","ŗ","Ř","ř","Ś","ś","Ŝ","ŝ","Ş","ş","Š","š","Ţ","ţ","Ť","ť","Ŧ","ŧ","Ũ","ũ","Ū","ū","Ŭ","ŭ","Ů","ů","Ű","ű","Ų","ų","Ŵ","ŵ","Ŷ","ŷ","Ÿ","Ź","ź","Ż","ż","Ž","ž","DEFAULT_REPLACEMENT_CHAR","instances$1","approximations","char","approximate","_this","BaseExtend","request","All","Get","Limit","Offset","Sort","CatalogueExtend","Create","Delete","Update","With","ProductsEndpoint","super","Filter","CreateRelationships","resources","DeleteRelationships","UpdateRelationships","CurrenciesEndpoint","Set","err","Active","BrandsEndpoint","CartEndpoint","cartId","Items","AddProduct","productId","AddCustomItem","itemObject","assign","RemoveItem","itemId","UpdateItemQuantity","Checkout","CategoriesEndpoint","Tree","CollectionsEndpoint","OrdersEndpoint","Payment","GatewaysEndpoint","slug","Enabled","enabled","FilesEndpoint","Moltin","Products","Currencies","Brands","Cart","Categories","Collections","Orders","Gateways","Files","Authenticate","gateway"],"mappings":"YAEO,SAASA,uBAAsBC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EAAM7X,GACX,MAAO8D,MAAKsR,QAAQnP,KAAQnC,KAAa,aAAI+T,EAAQ,MAAO7X,IAG9D4X,YAAAE,iBAAQD,EAAME,GACZ,MAAOjU,MAAKsR,QAAQnP,KAAQnC,KAAa,aAAI+T,EAAQ,OACnDlb,KAAM,UACNob,QAAAA,QAdyB5C,YCAzB6C,0BAAiC,WACzBnY,GACVmW,OAAMlS,KAAAjE,GAENiE,KAAKjE,SAAW,sGAGlBmY,YAAArC,gBAAO3V,GACL,MAAO8D,MAAKsR,QAAQnP,KAAK,GAAGnC,KAAa,SAAI,OAAQ9D,IAGvDgY,YAAApC,gBAAO5Y,GACL,MAAO8G,MAAKsR,QAAQnP,KAAQnC,KAAa,aAAI9G,EAAM,cAZ3BmY,YCcP8C,OAAO,SACd5S,GACZvB,KAAOuB,OAASA,EAChBvB,KAAOsR,QAAU,GAAIhQ,gBAAeC,GACpCvB,KAAOvG,QAAU,GAAIC,gBAErBsG,KAAOoU,SAAW,GAAInC,kBAAiB1Q,GACvCvB,KAAOqU,WAAa,GAAI7B,oBAAmBjR,GAC3CvB,KAAOsU,OAAS,GAAI1B,gBAAerR,GACnCvB,KAAOuU,KAAO,GAAI1B,cAAatR,GAC/BvB,KAAOwU,WAAa,GAAIf,oBAAmBlS,GAC3CvB,KAAOyU,YAAc,GAAId,qBAAoBpS,GAC7CvB,KAAO0U,OAAS,GAAId,gBAAerS,GACnCvB,KAAO2U,SAAW,GAAIb,kBAAiBvS,GACvCvB,KAAO4U,MAAQ,GAAIV,eAAc3S,GAInC4S,kBAAEU,wBACA,MAAS7U,MAAKsR,QAAQ9P,eAKxBhI,IAAMsb,SAAU,SAAAvT,SAAU,IAAI4S,QAAO,GAAIpU,QAAOwB"} \ No newline at end of file diff --git a/src/endpoints/orders.js b/src/endpoints/orders.js index f471e9043..53148b902 100644 --- a/src/endpoints/orders.js +++ b/src/endpoints/orders.js @@ -7,6 +7,10 @@ class OrdersEndpoint extends BaseExtend { this.endpoint = 'orders'; } + Items(id) { + return this.request.send(`${this.endpoint}/${id}/items`, 'GET'); + } + Payment(id, body) { return this.request.send(`${this.endpoint}/${id}/payments`, 'POST', body); } diff --git a/test/factories.js b/test/factories.js index 806586a78..754be3ffa 100644 --- a/test/factories.js +++ b/test/factories.js @@ -149,3 +149,15 @@ exports.ordersArray = [{ type: 'order', status: 'cancelled', }]; + +exports.orderItemsArray = [{ + id: 'item-1', + type: 'order_item', + quantity: 2, + product_id: 'product-1', +}, { + id: 'item-2', + type: 'order_item', + quantity: 1, + product_id: 'product-2', +}]; diff --git a/test/unit/orders.js b/test/unit/orders.js index fcf4a6985..bcd016edd 100644 --- a/test/unit/orders.js +++ b/test/unit/orders.js @@ -6,6 +6,7 @@ const assert = require('chai').assert; const nock = require('nock'); const moltin = require('../../dist/moltin.cjs.js'); const orders = require('../factories').ordersArray; +const orderItems = require('../factories').orderItemsArray; const apiUrl = 'https://api.moltin.com/v2'; @@ -53,6 +54,24 @@ describe('Moltin orders', () => { }); }); + it('should return an array of items from an order', () => { + // Intercept the API request + nock(apiUrl, { + reqHeaders: { + Authorization: 'a550d8cbd4a4627013452359ab69694cd446615a', + 'Content-Type': 'application/json', + }, + }) + .get('/orders/order-1/items') + .reply(200, orderItems[0]); + + return Moltin.Orders.Items(orders[0].id) + .then((response) => { + assert.propertyVal(response, 'id', 'item-1'); + assert.propertyVal(response, 'product_id', 'product-1'); + }); + }); + it('should complete a payment for an order', () => { // Intercept the API request nock(apiUrl, {