@spree/storefront-api-v2-sdk
Version:
Node module to easily integrate your JavaScript or TypeScript application with Spree API V2. You can create an entirely custom Storefront in JS/TS with this package including one page checkout, Single Page Apps, PWAs and so on
2 lines • 26.2 kB
JavaScript
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(global,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=11)}([function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(e)}t.exports=n},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,n){var r=n(6);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}},function(t,e,n){var r=n(12),o=n(5);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?o(t):e}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,r)}t.exports=n},function(t,e){t.exports=require("axios")},function(t,e){t.exports=require("qs")},function(t,e,n){var r=n(0),o=n(6),u=n(13),c=n(14);function i(e){var n="function"==typeof Map?new Map:void 0;return t.exports=i=function(t){if(null===t||!u(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return c(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)},i(e)}t.exports=i},function(t,e){t.exports=require("lodash/get")},function(t,e,n){t.exports=n(16)},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e){t.exports=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}},function(t,e,n){var r=n(6),o=n(15);function u(e,n,c){return o()?t.exports=u=Reflect.construct:t.exports=u=function(t,e,n){var o=[null];o.push.apply(o,e);var u=new(Function.bind.apply(t,o));return n&&r(u,n.prototype),u},u.apply(null,arguments)}t.exports=u},function(t,e){t.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}},function(t,e,n){"use strict";n.r(e),n.d(e,"Client",(function(){return ht})),n.d(e,"Http",(function(){return q})),n.d(e,"Result",(function(){return L})),n.d(e,"errors",(function(){return r})),n.d(e,"makeClient",(function(){return lt})),n.d(e,"endpoints",(function(){return u})),n.d(e,"routes",(function(){return o}));var r={};n.r(r),n.d(r,"BasicSpreeError",(function(){return O})),n.d(r,"ExpandedSpreeError",(function(){return j})),n.d(r,"MisconfigurationError",(function(){return T})),n.d(r,"NoResponseError",(function(){return M})),n.d(r,"SpreeError",(function(){return b})),n.d(r,"SpreeSDKError",(function(){return w}));var o={};n.r(o),n.d(o,"storefrontPath",(function(){return B})),n.d(o,"Routes",(function(){return N}));var u={};n.r(u),n.d(u,"Account",(function(){return Q})),n.d(u,"Authentication",(function(){return X})),n.d(u,"Cart",(function(){return V})),n.d(u,"Checkout",(function(){return Z})),n.d(u,"Countries",(function(){return nt})),n.d(u,"Order",(function(){return ut})),n.d(u,"Products",(function(){return st})),n.d(u,"Taxons",(function(){return pt}));var c=n(1),i=n.n(c),s=n(4),a=n.n(s),f=n(2),p=n.n(f),h=n(3),l=n.n(h),d=n(0),y=n.n(d),v=n(7),m=n.n(v),R=n(8),P=n(5),k=n.n(P),x=n(9);function g(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}let w=function(t){p()(n,t);var e=g(n);function n(t){var r;return i()(this,n),r=e.call(this,t),Object.setPrototypeOf(k()(r),n.prototype),r}return n}(n.n(x)()(Error));function S(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}let b=function(t){p()(n,t);var e=S(n);function n(t){var r;i()(this,n),r=e.call(this,`Spree returned a HTTP ${t.status} error code`),Object.setPrototypeOf(k()(r),n.prototype),r.name="SpreeError";const o=Object.assign({},t);return Object.defineProperties(o,{config:{enumerable:!1},data:{enumerable:!1},headers:{enumerable:!1},request:{enumerable:!1}}),r.serverResponse=o,r}return n}(w);function C(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var O=function(t){p()(n,t);var e=C(n);function n(t,r){var o;return i()(this,n),o=e.call(this,t),Object.setPrototypeOf(k()(o),n.prototype),o.name="BasicSpreeError",o.summary=r,o}return n}(b),_=n(10),E=n.n(_);function D(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}let j=function(t){p()(n,t);var e=D(n);function n(t,r,o){var u;return i()(this,n),u=e.call(this,t,r),Object.setPrototypeOf(k()(u),n.prototype),u.name="ExpandedSpreeError",u.errors=Object.keys(o).reduce((t,e)=>{const n=e.split(".");let r=n.shift(),u=t;for(;r;)u[r]||(0===n.length?u[r]=o[e]:u[r]={}),u=u[r],r=n.shift();return t},{}),u}return a()(n,[{key:"getErrors",value:function(t){return E()(this.errors,t,null)}}]),n}(O);function A(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}let T=function(t){p()(n,t);var e=A(n);function n(t){var r;return i()(this,n),r=e.call(this,"Incorrect request setup: "+t),Object.setPrototypeOf(k()(r),n.prototype),r.name="MisconfigurationError",r}return n}(w);function I(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}let M=function(t){p()(n,t);var e=I(n);function n(){var t;return i()(this,n),t=e.call(this,"No response received from Spree"),Object.setPrototypeOf(k()(t),n.prototype),t.name="NoResponseError",t}return n}(w);var $,L={success:t=>(t=>({isSuccess:()=>!0,isFail:()=>!1,success:()=>t,fail:()=>{throw new Error("Cannot call fail() on success.")}}))(t),fail:t=>(t=>({isSuccess:()=>!1,isFail:()=>!0,success:()=>{throw new Error("Cannot call success() on fail.")},fail:()=>t}))(t)};!function(t){t[t.BASIC=0]="BASIC",t[t.FULL=1]="FULL",t[t.LIMITED=2]="LIMITED"}($||($={}));var F=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let q=function(){function t(e){i()(this,t),this.host=e||process.env.SPREE_HOST||"http://localhost:3000/",this.axios=m.a.create({baseURL:this.host,headers:{"Content-Type":"application/json"},paramsSerializer:t=>R.stringify(t,{arrayFormat:"brackets"})})}return a()(t,[{key:"spreeResponse",value:function(t,e,n={},r={}){return F(this,void 0,void 0,(function*(){try{const o=this.spreeOrderHeaders(n),u={url:e,params:r,method:t,headers:o},c=yield this.axios(u);return L.success(c.data)}catch(t){return L.fail(this.processError(t))}}))}},{key:"classifyError",value:function(t){const{error:e,errors:n}=t.response.data;return"string"==typeof e?"object"==typeof n?$.FULL:$.BASIC:$.LIMITED}},{key:"processError",value:function(t){return t.response?this.processSpreeError(t):t.request?new M:new T(t.message)}},{key:"processSpreeError",value:function(t){const{error:e,errors:n}=t.response.data,r=this.classifyError(t);return r===$.FULL?new j(t.response,e,n):r===$.BASIC?new O(t.response,e):new b(t.response)}},{key:"spreeOrderHeaders",value:function(t){const e={};return t.orderToken&&(e["X-Spree-Order-Token"]=t.orderToken),t.bearerToken&&(e.Authorization="Bearer "+t.bearerToken),e}}]),t}();const B="api/v2/storefront",N={productsPath:()=>B+"/products",productPath:t=>`${B}/products/${t}`,taxonsPath:()=>B+"/taxons",taxonPath:t=>`${B}/taxons/${t}`,countriesPath:()=>B+"/countries",countryPath:t=>`${B}/countries/${t}`,cartPath:()=>B+"/cart",cartAddItemPath:()=>B+"/cart/add_item",cartRemoveItemPath:t=>`${B}/cart/remove_line_item/${t}`,cartEmptyPath:()=>B+"/cart/empty",cartSetItemQuantity:()=>B+"/cart/set_quantity",cartApplyCodePath:()=>B+"/cart/apply_coupon_code",cartRemoveCodePath:t=>`${B}/cart/remove_coupon_code/${t}`,cartEstimateShippingMethodsPath:()=>B+"/cart/estimate_shipping_rates",checkoutPath:()=>B+"/checkout",checkoutNextPath:()=>B+"/checkout/next",checkoutAdvancePath:()=>B+"/checkout/advance",checkoutCompletePath:()=>B+"/checkout/complete",checkoutAddStoreCreditsPath:()=>B+"/checkout/add_store_credit",checkoutRemoveStoreCreditsPath:()=>B+"/checkout/remove_store_credit",checkoutPaymentMethodsPath:()=>B+"/checkout/payment_methods",checkoutShippingMethodsPath:()=>B+"/checkout/shipping_rates",oauthTokenPath:()=>"spree_oauth/token",accountPath:()=>B+"/account",accountAddressPath:t=>`${B}/account/addresses/${t}`,accountAddressesPath:()=>B+"/account/addresses",accountConfirmPath:t=>`${B}/account_confirmations/${t}`,accountCreditCardsPath:()=>B+"/account/credit_cards",accountDefaultCreditCardPath:()=>B+"/account/credit_cards/default",accountCompletedOrdersPath:()=>B+"/account/orders",accountCompletedOrderPath:t=>`${B}/account/orders/${t}`,orderStatusPath:t=>`${B}/order_status/${t}`};function U(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var H=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let Q=function(t){p()(n,t);var e=U(n);function n(){return i()(this,n),e.apply(this,arguments)}return a()(n,[{key:"accountInfo",value:function(t,e={}){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.accountPath(),t,e)}))}},{key:"creditCardsList",value:function(t,e={}){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.accountCreditCardsPath(),t,e)}))}},{key:"defaultCreditCard",value:function(t,e={}){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.accountDefaultCreditCardPath(),t,e)}))}},{key:"completedOrdersList",value:function(t,e={}){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.accountCompletedOrdersPath(),t,e)}))}},{key:"completedOrder",value:function(t,e,n={}){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.accountCompletedOrderPath(e),t,n)}))}},{key:"create",value:function(t){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("post",N.accountPath(),{},t)}))}},{key:"confirm",value:function(t){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.accountConfirmPath(t))}))}},{key:"update",value:function(t,e){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.accountPath(),t,e)}))}},{key:"addressesList",value:function(t){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.accountAddressesPath(),t)}))}},{key:"createAddress",value:function(t,e){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("post",N.accountAddressesPath(),t,e)}))}},{key:"updateAddress",value:function(t,e,n){return H(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.accountAddressPath(e),t,n)}))}}]),n}(q);function z(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var K=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let X=function(t){p()(n,t);var e=z(n);function n(){return i()(this,n),e.apply(this,arguments)}return a()(n,[{key:"getToken",value:function(t){return K(this,void 0,void 0,(function*(){return yield this.spreeResponse("post",N.oauthTokenPath(),{},(({username:t,password:e})=>({username:t,password:e,grant_type:"password"}))(t))}))}},{key:"refreshToken",value:function(t){return K(this,void 0,void 0,(function*(){return yield this.spreeResponse("post",N.oauthTokenPath(),{},(({refresh_token:t})=>({refresh_token:t,grant_type:"refresh_token"}))(t))}))}}]),n}(q);function G(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var J=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let V=function(t){p()(n,t);var e=G(n);function n(){return i()(this,n),e.apply(this,arguments)}return a()(n,[{key:"show",value:function(t,e={}){return J(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.cartPath(),t,e)}))}},{key:"create",value:function(t,e={}){return J(this,void 0,void 0,(function*(){return yield this.spreeResponse("post",N.cartPath(),t,e)}))}},{key:"addItem",value:function(t,e){return J(this,void 0,void 0,(function*(){return yield this.spreeResponse("post",N.cartAddItemPath(),t,e)}))}},{key:"removeItem",value:function(t,e,n={}){return J(this,void 0,void 0,(function*(){return yield this.spreeResponse("delete",N.cartRemoveItemPath(e),t,n)}))}},{key:"emptyCart",value:function(t,e={}){return J(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.cartEmptyPath(),t,e)}))}},{key:"setQuantity",value:function(t,e){return J(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.cartSetItemQuantity(),t,e)}))}},{key:"applyCouponCode",value:function(t,e){return J(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.cartApplyCodePath(),t,e)}))}},{key:"removeCouponCode",value:function(t,e=null,n={}){return J(this,void 0,void 0,(function*(){let r="";return r=null!==e?N.cartRemoveCodePath(e):N.cartRemoveCodePath(""),yield this.spreeResponse("delete",r,t,n)}))}},{key:"estimateShippingMethods",value:function(t,e){return J(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.cartEstimateShippingMethodsPath(),t,e)}))}}]),n}(q);function W(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var Y=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let Z=function(t){p()(n,t);var e=W(n);function n(){return i()(this,n),e.apply(this,arguments)}return a()(n,[{key:"orderNext",value:function(t,e={}){return Y(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.checkoutNextPath(),t,e)}))}},{key:"orderUpdate",value:function(t,e){return Y(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.checkoutPath(),t,e)}))}},{key:"advance",value:function(t,e={}){return Y(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.checkoutAdvancePath(),t,e)}))}},{key:"complete",value:function(t,e={}){return Y(this,void 0,void 0,(function*(){return yield this.spreeResponse("patch",N.checkoutCompletePath(),t,e)}))}},{key:"addStoreCredits",value:function(t,e){return Y(this,void 0,void 0,(function*(){return yield this.spreeResponse("post",N.checkoutAddStoreCreditsPath(),t,e)}))}},{key:"removeStoreCredits",value:function(t,e={}){return Y(this,void 0,void 0,(function*(){return yield this.spreeResponse("post",N.checkoutRemoveStoreCreditsPath(),t,e)}))}},{key:"paymentMethods",value:function(t){return Y(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.checkoutPaymentMethodsPath(),t)}))}},{key:"shippingMethods",value:function(t,e={}){return Y(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.checkoutShippingMethodsPath(),t,e)}))}}]),n}(q);function tt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var et=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let nt=function(t){p()(n,t);var e=tt(n);function n(){return i()(this,n),e.apply(this,arguments)}return a()(n,[{key:"list",value:function(){return et(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.countriesPath())}))}},{key:"show",value:function(t,e={}){return et(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.countryPath(t),{},e)}))}}]),n}(q);function rt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var ot=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let ut=function(t){p()(n,t);var e=rt(n);function n(){return i()(this,n),e.apply(this,arguments)}return a()(n,[{key:"status",value:function(t,e,n={}){return ot(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.orderStatusPath(e),t,n)}))}}]),n}(q);function ct(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var it=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let st=function(t){p()(n,t);var e=ct(n);function n(){return i()(this,n),e.apply(this,arguments)}return a()(n,[{key:"list",value:function(t={}){return it(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.productsPath(),{},t)}))}},{key:"show",value:function(t,e={}){return it(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.productPath(t),{},e)}))}}]),n}(q);function at(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=y()(t);if(e){var o=y()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l()(this,n)}}var ft=function(t,e,n,r){return new(n||(n=Promise))((function(o,u){function c(t){try{s(r.next(t))}catch(t){u(t)}}function i(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,i)}s((r=r.apply(t,e||[])).next())}))};let pt=function(t){p()(n,t);var e=at(n);function n(){return i()(this,n),e.apply(this,arguments)}return a()(n,[{key:"list",value:function(t={}){return ft(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.taxonsPath(),{},t)}))}},{key:"show",value:function(t,e={}){return ft(this,void 0,void 0,(function*(){return yield this.spreeResponse("get",N.taxonPath(t),{},e)}))}}]),n}(q);var ht=function(){function t(e={}){i()(this,t),this.host=e.host||null,this.addEndpoints()}return a()(t,[{key:"addEndpoints",value:function(){this.account=this.makeAccount(),this.authentication=this.makeAuthentication(),this.cart=this.makeCart(),this.checkout=this.makeCheckout(),this.countries=this.makeCountries(),this.order=this.makeOrder(),this.products=this.makeProducts(),this.taxons=this.makeTaxons()}},{key:"makeAccount",value:function(){return new Q(this.host)}},{key:"makeAuthentication",value:function(){return new X(this.host)}},{key:"makeCart",value:function(){return new V(this.host)}},{key:"makeCheckout",value:function(){return new Z(this.host)}},{key:"makeCountries",value:function(){return new nt(this.host)}},{key:"makeOrder",value:function(){return new ut(this.host)}},{key:"makeProducts",value:function(){return new st(this.host)}},{key:"makeTaxons",value:function(){return new pt(this.host)}}]),t}();const lt=(t={})=>new ht(t)}])}));
//# sourceMappingURL=index.js.map