New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

printify-sdk-js

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

printify-sdk-js - npm Package Compare versions

Comparing version 1.2.0-beta to 1.2.0

2

dist/index.cjs.js

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

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=t(require("axios"));function s(t,e,s,o){if("a"===s&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?o:"a"===s?o.call(t):o?o.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;class o{constructor(t,e){this.listBlueprints=(t=>()=>t("/v1/catalog/blueprints.json",{method:"GET"}))(t),this.getBlueprint=(t=>async e=>await t(`/v1/catalog/blueprints/${e}.json`,{method:"GET"}))(t),this.getBlueprintProviders=(t=>async e=>await t(`/v1/catalog/blueprints/${e}/print_providers.json`,{method:"GET"}))(t),this.getBlueprintVariants=(t=>async(e,s)=>await t(`/v1/catalog/blueprints/${e}/print_providers/${s}/variants.json`,{method:"GET"}))(t),this.getVariantShipping=(t=>async(e,s)=>await t(`/v1/catalog/blueprints/${e}/print_providers/${s}/shipping.json`,{method:"GET"}))(t),this.listProviders=(t=>()=>t("/v1/catalog/print_providers.json",{method:"GET"}))(t),this.getProvider=(t=>async e=>await t(`/v1/catalog/print_providers/${e}.json`,{method:"GET"}))(t)}}class n{constructor(t,e){this.list=((t,e)=>(s={})=>{const{page:o,limit:n,status:r,sku:i}=s,a=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==n&&{limit:n.toString()}),void 0!==r&&{status:r}),void 0!==i&&{sku:i})).toString();return t(`/v1/shops/${e}/orders.json${a?`?${a}`:""}`,{method:"GET"})})(t,e),this.getOne=((t,e)=>async s=>await t(`/v1/shops/${e}/orders/${s}.json`,{method:"GET"}))(t,e),this.submit=((t,e)=>async s=>await t(`/v1/shops/${e}/orders.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.submitExpress=((t,e)=>async s=>await t(`/v1/shops/${e}/express.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.sendToProduction=((t,e)=>async s=>await t(`/v1/shops/${e}/orders/${s}/send_to_production.json`,{method:"POST"}))(t,e),this.calculateShipping=((t,e)=>async s=>await t(`/v1/shops/${e}/orders/shipping.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.cancelUnpaid=((t,e)=>async s=>await t(`/v1/shops/${e}/orders/${s}/cancel.json`,{method:"POST"}))(t,e)}}class r{constructor(t,e){this.create=((t,e)=>s=>t(`/v1/shops/${e}/products.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.deleteOne=((t,e)=>async s=>{await t(`/v1/shops/${e}/products/${s}.json`,{method:"DELETE"})})(t,e),this.getOne=((t,e)=>async s=>await t(`/v1/shops/${e}/products/${s}.json`,{method:"GET"}))(t,e),this.list=((t,e)=>(s={})=>{const{page:o,limit:n}=s,r=new URLSearchParams(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==n&&{limit:n.toString()})).toString(),i=r.toString()?`?${r.toString()}`:"";return t(`/v1/shops/${e}/products.json${i}`,{method:"GET"})})(t,e),this.notifyUnpublished=((t,e)=>async s=>{await t(`/v1/shops/${e}/products/${s}/unpublish.json`,{method:"POST"})})(t,e),this.publishOne=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publish.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.setPublishFailed=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publishing_failed.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.setPublishSucceeded=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publishing_succeeded.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.updateOne=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e)}}class i{constructor(t,e){this.deleteOne=((t,e)=>async s=>{await t(`/v1/shops/${s||e}/connection.json`,{method:"DELETE"})})(t,e),this.list=(t=>async()=>await t("/v1/shops.json",{method:"GET"}))(t)}}class a{constructor(t,e){this.archive=(t=>async e=>{await t(`/v1/uploads/${e}/archive.json`,{method:"POST"})})(t),this.getById=(t=>async e=>await t(`/v1/uploads/${e}.json`,{method:"GET"}))(t),this.list=(t=>async(e,s)=>{const o=new URLSearchParams;void 0!==e&&o.append("page",e.toString()),void 0!==s&&o.append("limit",s.toString());const n="/v1/uploads.json"+(o.toString()?`?${o.toString()}`:"");return t(n,{method:"GET"})})(t),this.uploadImage=(t=>e=>t("/v1/uploads/images.json",{method:"POST",data:JSON.stringify(e)}))(t)}}class d{constructor(t,e){this.list=((t,e)=>()=>t(`/v1/shops/${e}/webhooks.json`,{method:"GET"}))(t,e),this.create=((t,e)=>s=>t(`/v1/shops/${e}/webhooks.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.updateOne=((t,e)=>(s,o)=>t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e),this.deleteOne=((t,e)=>s=>t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"DELETE"}))(t,e)}}const c="https://api.printify.com";function h(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const u=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);var p=h((t=>!u.has(t&&t.code)));const l="axios-retry";function E(t){return!t.response&&(!!t.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(t.code)&&p(t)))}const T=["get","head","options"],g=T.concat(["put","delete"]);function _(t){return"ECONNABORTED"!==t.code&&(!t.response||429===t.response.status||t.response.status>=500&&t.response.status<=599)}function f(t){return!!t.config?.method&&(_(t)&&-1!==g.indexOf(t.config.method))}function m(t){return E(t)||f(t)}function v(t=void 0){const e=t?.response?.headers["retry-after"];if(!e)return 0;let s=1e3*(Number(e)||0);return 0===s&&(s=(new Date(e).valueOf()||0)-Date.now()),Math.max(0,s)}const R={retries:3,retryCondition:m,retryDelay:function(t=0,e=void 0){return Math.max(0,v(e))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function y(t,e,s=!1){const o=function(t,e){return{...R,...e,...t[l]}}(t,e||{});return o.retryCount=o.retryCount||0,o.lastRequestTime&&!s||(o.lastRequestTime=Date.now()),t[l]=o,o}const O=(t,e)=>{const s=t.interceptors.request.use((t=>(y(t,e,!0),t[l]?.validateResponse&&(t.validateStatus=()=>!1),t))),o=t.interceptors.response.use(null,(async s=>{const{config:o}=s;if(!o)return Promise.reject(s);const n=y(o,e);return s.response&&n.validateResponse?.(s.response)?s.response:await async function(t,e){const{retries:s,retryCondition:o}=t,n=(t.retryCount||0)<s&&o(e);if("object"==typeof n)try{return!1!==await n}catch(t){return!1}return n}(n,s)?async function(t,e,s,o){e.retryCount+=1;const{retryDelay:n,shouldResetTimeout:r,onRetry:i}=e,a=n(e.retryCount,s);if(function(t,e){t.defaults.agent===e.agent&&delete e.agent,t.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,t.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}(t,o),!r&&o.timeout&&e.lastRequestTime){const t=Date.now()-e.lastRequestTime,n=o.timeout-t-a;if(n<=0)return Promise.reject(s);o.timeout=n}return o.transformRequest=[t=>t],await i(e.retryCount,s,o),o.signal?.aborted?Promise.resolve(t(o)):new Promise((e=>{const s=()=>{clearTimeout(n),e(t(o))},n=setTimeout((()=>{e(t(o)),o.signal?.removeEventListener&&o.signal.removeEventListener("abort",s)}),a);o.signal?.addEventListener&&o.signal.addEventListener("abort",s,{once:!0})}))}(t,n,s,o):(await async function(t,e){t.retryCount>=t.retries&&await t.onMaxRetryTimesExceeded(e,t.retryCount)}(n,s),Promise.reject(s))}));return{requestInterceptorId:s,responseInterceptorId:o}};var w;O.isNetworkError=E,O.isSafeRequestError=function(t){return!!t.config?.method&&(_(t)&&-1!==T.indexOf(t.config.method))},O.isIdempotentRequestError=f,O.isNetworkOrIdempotentRequestError=m,O.exponentialDelay=function(t=0,e=void 0,s=100){const o=2**t*s,n=Math.max(o,v(e));return n+.2*n*Math.random()},O.linearDelay=function(t=100){return(e=0,s=void 0)=>{const o=e*t;return Math.max(o,v(s))}},O.isRetryableError=_,O(e.default,{retries:3,retryDelay:O.exponentialDelay});w=new WeakMap,module.exports=class{constructor(t){var e;w.set(this,void 0),this.shopId=t.shopId,function(t,e,s,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(t,s):n?n.value=s:e.set(t,s)}(this,w,t.accessToken,"f"),this.enableLogging=null===(e=t.enableLogging)||void 0===e||e,this.catalog=new o(this.fetchData.bind(this),this.shopId),this.orders=new n(this.fetchData.bind(this),this.shopId),this.products=new r(this.fetchData.bind(this),this.shopId),this.shops=new i(this.fetchData.bind(this),this.shopId),this.uploads=new a(this.fetchData.bind(this),this.shopId),this.webhooks=new d(this.fetchData.bind(this),this.shopId)}logError(t){this.enableLogging&&console.error(t)}logRequest(t,e){this.enableLogging&&console.log(`Requesting ${t.toUpperCase()} ${c}${e}`)}async fetchData(t,o={}){var n,r,i;const a={"Content-Type":"application/json",Authorization:`Bearer ${s(this,w,"f")}`},d=Object.assign(Object.assign({},o.method?o:Object.assign(Object.assign({},o),{method:"GET"})),{baseURL:c,headers:Object.assign(Object.assign({},a),o.headers||{})}),h=(null===(n=o.method)||void 0===n?void 0:n.toLowerCase())||"get";this.logRequest(h,t);try{let s;switch(h){case"post":s=await e.default.post(t,o.data,d);break;case"put":s=await e.default.put(t,o.data,d);break;case"delete":s=await e.default.delete(t,d);break;default:s=await e.default.get(t,d)}return s.data}catch(s){if(e.default.isAxiosError(s)){const e=`Printify SDK Error: ${null===(r=s.response)||void 0===r?void 0:r.status} ${null===(i=s.response)||void 0===i?void 0:i.statusText} - Requested URL: ${c}${t}`;throw this.logError(e),new Error(e)}{const t="Printify SDK Unknown Error";throw this.logError(t),new Error(t)}}}};
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=t(require("axios"));function s(t,e,s,o){if("a"===s&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?o:"a"===s?o.call(t):o?o.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;class o{constructor(t,e){this.listBlueprints=(t=>()=>t("/v1/catalog/blueprints.json",{method:"GET"}))(t),this.getBlueprint=(t=>e=>t(`/v1/catalog/blueprints/${e}.json`,{method:"GET"}))(t),this.getBlueprintProviders=(t=>e=>t(`/v1/catalog/blueprints/${e}/print_providers.json`,{method:"GET"}))(t),this.getBlueprintVariants=(t=>(e,s)=>t(`/v1/catalog/blueprints/${e}/print_providers/${s}/variants.json`,{method:"GET"}))(t),this.getVariantShipping=(t=>(e,s)=>t(`/v1/catalog/blueprints/${e}/print_providers/${s}/shipping.json`,{method:"GET"}))(t),this.listProviders=(t=>()=>t("/v1/catalog/print_providers.json",{method:"GET"}))(t),this.getProvider=(t=>e=>t(`/v1/catalog/print_providers/${e}.json`,{method:"GET"}))(t)}}class r{constructor(t,e){this.list=((t,e)=>(s={})=>{const{page:o,limit:r,status:n,sku:i}=s,a=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==r&&{limit:r.toString()}),void 0!==n&&{status:n}),void 0!==i&&{sku:i})).toString();return t(`/v1/shops/${e}/orders.json${a?`?${a}`:""}`,{method:"GET"})})(t,e),this.getOne=((t,e)=>s=>t(`/v1/shops/${e}/orders/${s}.json`,{method:"GET"}))(t,e),this.submit=((t,e)=>s=>t(`/v1/shops/${e}/orders.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.submitExpress=((t,e)=>s=>t(`/v1/shops/${e}/express.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.sendToProduction=((t,e)=>s=>t(`/v1/shops/${e}/orders/${s}/send_to_production.json`,{method:"POST"}))(t,e),this.calculateShipping=((t,e)=>s=>t(`/v1/shops/${e}/orders/shipping.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.cancelUnpaid=((t,e)=>s=>t(`/v1/shops/${e}/orders/${s}/cancel.json`,{method:"POST"}))(t,e)}}class n{constructor(t,e){this.create=((t,e)=>s=>t(`/v1/shops/${e}/products.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.deleteOne=((t,e)=>s=>t(`/v1/shops/${e}/products/${s}.json`,{method:"DELETE"}))(t,e),this.getOne=((t,e)=>s=>t(`/v1/shops/${e}/products/${s}.json`,{method:"GET"}))(t,e),this.list=((t,e)=>(s={})=>{const{page:o,limit:r}=s,n=new URLSearchParams(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==r&&{limit:r.toString()})).toString(),i=n.toString()?`?${n.toString()}`:"";return t(`/v1/shops/${e}/products.json${i}`,{method:"GET"})})(t,e),this.notifyUnpublished=((t,e)=>s=>t(`/v1/shops/${e}/products/${s}/unpublish.json`,{method:"POST"}))(t,e),this.publishOne=((t,e)=>(s,o)=>t(`/v1/shops/${e}/products/${s}/publish.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.setPublishFailed=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publishing_failed.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.setPublishSucceeded=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publishing_succeeded.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.updateOne=((t,e)=>(s,o)=>t(`/v1/shops/${e}/products/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e)}}class i{constructor(t,e){this.deleteOne=((t,e)=>s=>t(`/v1/shops/${s||e}/connection.json`,{method:"DELETE"}))(t,e),this.list=(t=>()=>t("/v1/shops.json",{method:"GET"}))(t)}}class a{constructor(t,e){this.archive=(t=>e=>t(`/v1/uploads/${e}/archive.json`,{method:"POST"}))(t),this.getById=(t=>e=>t(`/v1/uploads/${e}.json`,{method:"GET"}))(t),this.list=(t=>(e,s)=>{const o=new URLSearchParams;void 0!==e&&o.append("page",e.toString()),void 0!==s&&o.append("limit",s.toString());const r="/v1/uploads.json"+(o.toString()?`?${o.toString()}`:"");return t(r,{method:"GET"})})(t),this.uploadImage=(t=>e=>t("/v1/uploads/images.json",{method:"POST",data:JSON.stringify(e)}))(t)}}class h{constructor(t,e){this.list=((t,e)=>()=>t(`/v1/shops/${e}/webhooks.json`,{method:"GET"}))(t,e),this.create=((t,e)=>s=>t(`/v1/shops/${e}/webhooks.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.updateOne=((t,e)=>(s,o)=>t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e),this.deleteOne=((t,e)=>s=>t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"DELETE"}))(t,e)}}function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const c=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);var u=d((t=>!c.has(t&&t.code)));const p="axios-retry";function l(t){return!t.response&&(!!t.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(t.code)&&u(t)))}const E=["get","head","options"],T=E.concat(["put","delete"]);function g(t){return"ECONNABORTED"!==t.code&&(!t.response||429===t.response.status||t.response.status>=500&&t.response.status<=599)}function _(t){return!!t.config?.method&&(g(t)&&-1!==T.indexOf(t.config.method))}function m(t){return l(t)||_(t)}function f(t=void 0){const e=t?.response?.headers["retry-after"];if(!e)return 0;let s=1e3*(Number(e)||0);return 0===s&&(s=(new Date(e).valueOf()||0)-Date.now()),Math.max(0,s)}const v={retries:3,retryCondition:m,retryDelay:function(t=0,e=void 0){return Math.max(0,f(e))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function R(t,e,s=!1){const o=function(t,e){return{...v,...e,...t[p]}}(t,e||{});return o.retryCount=o.retryCount||0,o.lastRequestTime&&!s||(o.lastRequestTime=Date.now()),t[p]=o,o}const O=(t,e)=>{const s=t.interceptors.request.use((t=>(R(t,e,!0),t[p]?.validateResponse&&(t.validateStatus=()=>!1),t))),o=t.interceptors.response.use(null,(async s=>{const{config:o}=s;if(!o)return Promise.reject(s);const r=R(o,e);return s.response&&r.validateResponse?.(s.response)?s.response:await async function(t,e){const{retries:s,retryCondition:o}=t,r=(t.retryCount||0)<s&&o(e);if("object"==typeof r)try{return!1!==await r}catch(t){return!1}return r}(r,s)?async function(t,e,s,o){e.retryCount+=1;const{retryDelay:r,shouldResetTimeout:n,onRetry:i}=e,a=r(e.retryCount,s);if(function(t,e){t.defaults.agent===e.agent&&delete e.agent,t.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,t.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}(t,o),!n&&o.timeout&&e.lastRequestTime){const t=Date.now()-e.lastRequestTime,r=o.timeout-t-a;if(r<=0)return Promise.reject(s);o.timeout=r}return o.transformRequest=[t=>t],await i(e.retryCount,s,o),o.signal?.aborted?Promise.resolve(t(o)):new Promise((e=>{const s=()=>{clearTimeout(r),e(t(o))},r=setTimeout((()=>{e(t(o)),o.signal?.removeEventListener&&o.signal.removeEventListener("abort",s)}),a);o.signal?.addEventListener&&o.signal.addEventListener("abort",s,{once:!0})}))}(t,r,s,o):(await async function(t,e){t.retryCount>=t.retries&&await t.onMaxRetryTimesExceeded(e,t.retryCount)}(r,s),Promise.reject(s))}));return{requestInterceptorId:s,responseInterceptorId:o}};var S;O.isNetworkError=l,O.isSafeRequestError=function(t){return!!t.config?.method&&(g(t)&&-1!==E.indexOf(t.config.method))},O.isIdempotentRequestError=_,O.isNetworkOrIdempotentRequestError=m,O.exponentialDelay=function(t=0,e=void 0,s=100){const o=2**t*s,r=Math.max(o,f(e));return r+.2*r*Math.random()},O.linearDelay=function(t=100){return(e=0,s=void 0)=>{const o=e*t;return Math.max(o,f(s))}},O.isRetryableError=g,O(e.default,{retries:3,retryDelay:O.exponentialDelay});S=new WeakMap,module.exports=class{constructor(t){var e;S.set(this,void 0),this.shopId=t.shopId,function(t,e,s,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?r.call(t,s):r?r.value=s:e.set(t,s)}(this,S,t.accessToken,"f"),this.apiVersion=t.apiVersion||"v1",this.enableLogging=null===(e=t.enableLogging)||void 0===e||e,this.host=t.host||"api.printify.com",this.timeout=t.timeout||5e3,this.baseUrl=`https://${this.host}`,this.catalog=new o(this.fetchData.bind(this),this.shopId),this.orders=new r(this.fetchData.bind(this),this.shopId),this.products=new n(this.fetchData.bind(this),this.shopId),this.shops=new i(this.fetchData.bind(this),this.shopId),this.uploads=new a(this.fetchData.bind(this),this.shopId),this.webhooks=new h(this.fetchData.bind(this),this.shopId)}logError(t){this.enableLogging&&console.error(t)}logRequest(t,e){this.enableLogging&&console.log(`Requesting ${t.toUpperCase()} ${this.baseUrl}${e}`)}async fetchData(t,o={}){var r,n,i;const a={"Content-Type":"application/json",Authorization:`Bearer ${s(this,S,"f")}`},h=Object.assign(Object.assign({},o.method?o:Object.assign(Object.assign({},o),{method:"GET"})),{baseURL:this.baseUrl,timeout:this.timeout,headers:Object.assign(Object.assign({},a),o.headers||{})}),d=(null===(r=o.method)||void 0===r?void 0:r.toLowerCase())||"get";this.logRequest(d,t);try{let s;switch(d){case"post":s=await e.default.post(t,o.data,h);break;case"put":s=await e.default.put(t,o.data,h);break;case"delete":s=await e.default.delete(t,h);break;default:s=await e.default.get(t,h)}return s.data}catch(s){if(e.default.isAxiosError(s)){const e=`Printify SDK Error: ${null===(n=s.response)||void 0===n?void 0:n.status} ${null===(i=s.response)||void 0===i?void 0:i.statusText} - Requested URL: ${this.baseUrl}${t}`;throw this.logError(e),new Error(e)}{const t="Printify SDK Unknown Error";throw this.logError(t),new Error(t)}}}};
//# sourceMappingURL=index.cjs.js.map

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

import t from"axios";function e(t,e,s,o){if("a"===s&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?o:"a"===s?o.call(t):o?o.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;class s{constructor(t,e){this.listBlueprints=(t=>()=>t("/v1/catalog/blueprints.json",{method:"GET"}))(t),this.getBlueprint=(t=>async e=>await t(`/v1/catalog/blueprints/${e}.json`,{method:"GET"}))(t),this.getBlueprintProviders=(t=>async e=>await t(`/v1/catalog/blueprints/${e}/print_providers.json`,{method:"GET"}))(t),this.getBlueprintVariants=(t=>async(e,s)=>await t(`/v1/catalog/blueprints/${e}/print_providers/${s}/variants.json`,{method:"GET"}))(t),this.getVariantShipping=(t=>async(e,s)=>await t(`/v1/catalog/blueprints/${e}/print_providers/${s}/shipping.json`,{method:"GET"}))(t),this.listProviders=(t=>()=>t("/v1/catalog/print_providers.json",{method:"GET"}))(t),this.getProvider=(t=>async e=>await t(`/v1/catalog/print_providers/${e}.json`,{method:"GET"}))(t)}}class o{constructor(t,e){this.list=((t,e)=>(s={})=>{const{page:o,limit:n,status:r,sku:i}=s,a=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==n&&{limit:n.toString()}),void 0!==r&&{status:r}),void 0!==i&&{sku:i})).toString();return t(`/v1/shops/${e}/orders.json${a?`?${a}`:""}`,{method:"GET"})})(t,e),this.getOne=((t,e)=>async s=>await t(`/v1/shops/${e}/orders/${s}.json`,{method:"GET"}))(t,e),this.submit=((t,e)=>async s=>await t(`/v1/shops/${e}/orders.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.submitExpress=((t,e)=>async s=>await t(`/v1/shops/${e}/express.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.sendToProduction=((t,e)=>async s=>await t(`/v1/shops/${e}/orders/${s}/send_to_production.json`,{method:"POST"}))(t,e),this.calculateShipping=((t,e)=>async s=>await t(`/v1/shops/${e}/orders/shipping.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.cancelUnpaid=((t,e)=>async s=>await t(`/v1/shops/${e}/orders/${s}/cancel.json`,{method:"POST"}))(t,e)}}class n{constructor(t,e){this.create=((t,e)=>s=>t(`/v1/shops/${e}/products.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.deleteOne=((t,e)=>async s=>{await t(`/v1/shops/${e}/products/${s}.json`,{method:"DELETE"})})(t,e),this.getOne=((t,e)=>async s=>await t(`/v1/shops/${e}/products/${s}.json`,{method:"GET"}))(t,e),this.list=((t,e)=>(s={})=>{const{page:o,limit:n}=s,r=new URLSearchParams(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==n&&{limit:n.toString()})).toString(),i=r.toString()?`?${r.toString()}`:"";return t(`/v1/shops/${e}/products.json${i}`,{method:"GET"})})(t,e),this.notifyUnpublished=((t,e)=>async s=>{await t(`/v1/shops/${e}/products/${s}/unpublish.json`,{method:"POST"})})(t,e),this.publishOne=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publish.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.setPublishFailed=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publishing_failed.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.setPublishSucceeded=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publishing_succeeded.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.updateOne=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e)}}class r{constructor(t,e){this.deleteOne=((t,e)=>async s=>{await t(`/v1/shops/${s||e}/connection.json`,{method:"DELETE"})})(t,e),this.list=(t=>async()=>await t("/v1/shops.json",{method:"GET"}))(t)}}class i{constructor(t,e){this.archive=(t=>async e=>{await t(`/v1/uploads/${e}/archive.json`,{method:"POST"})})(t),this.getById=(t=>async e=>await t(`/v1/uploads/${e}.json`,{method:"GET"}))(t),this.list=(t=>async(e,s)=>{const o=new URLSearchParams;void 0!==e&&o.append("page",e.toString()),void 0!==s&&o.append("limit",s.toString());const n="/v1/uploads.json"+(o.toString()?`?${o.toString()}`:"");return t(n,{method:"GET"})})(t),this.uploadImage=(t=>e=>t("/v1/uploads/images.json",{method:"POST",data:JSON.stringify(e)}))(t)}}class a{constructor(t,e){this.list=((t,e)=>()=>t(`/v1/shops/${e}/webhooks.json`,{method:"GET"}))(t,e),this.create=((t,e)=>s=>t(`/v1/shops/${e}/webhooks.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.updateOne=((t,e)=>(s,o)=>t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e),this.deleteOne=((t,e)=>s=>t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"DELETE"}))(t,e)}}const h="https://api.printify.com";function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const d=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);var u=c((t=>!d.has(t&&t.code)));const p="axios-retry";function E(t){return!t.response&&(!!t.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(t.code)&&u(t)))}const l=["get","head","options"],T=l.concat(["put","delete"]);function g(t){return"ECONNABORTED"!==t.code&&(!t.response||429===t.response.status||t.response.status>=500&&t.response.status<=599)}function _(t){return!!t.config?.method&&(g(t)&&-1!==T.indexOf(t.config.method))}function m(t){return E(t)||_(t)}function v(t=void 0){const e=t?.response?.headers["retry-after"];if(!e)return 0;let s=1e3*(Number(e)||0);return 0===s&&(s=(new Date(e).valueOf()||0)-Date.now()),Math.max(0,s)}const R={retries:3,retryCondition:m,retryDelay:function(t=0,e=void 0){return Math.max(0,v(e))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function y(t,e,s=!1){const o=function(t,e){return{...R,...e,...t[p]}}(t,e||{});return o.retryCount=o.retryCount||0,o.lastRequestTime&&!s||(o.lastRequestTime=Date.now()),t[p]=o,o}const f=(t,e)=>{const s=t.interceptors.request.use((t=>(y(t,e,!0),t[p]?.validateResponse&&(t.validateStatus=()=>!1),t))),o=t.interceptors.response.use(null,(async s=>{const{config:o}=s;if(!o)return Promise.reject(s);const n=y(o,e);return s.response&&n.validateResponse?.(s.response)?s.response:await async function(t,e){const{retries:s,retryCondition:o}=t,n=(t.retryCount||0)<s&&o(e);if("object"==typeof n)try{return!1!==await n}catch(t){return!1}return n}(n,s)?async function(t,e,s,o){e.retryCount+=1;const{retryDelay:n,shouldResetTimeout:r,onRetry:i}=e,a=n(e.retryCount,s);if(function(t,e){t.defaults.agent===e.agent&&delete e.agent,t.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,t.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}(t,o),!r&&o.timeout&&e.lastRequestTime){const t=Date.now()-e.lastRequestTime,n=o.timeout-t-a;if(n<=0)return Promise.reject(s);o.timeout=n}return o.transformRequest=[t=>t],await i(e.retryCount,s,o),o.signal?.aborted?Promise.resolve(t(o)):new Promise((e=>{const s=()=>{clearTimeout(n),e(t(o))},n=setTimeout((()=>{e(t(o)),o.signal?.removeEventListener&&o.signal.removeEventListener("abort",s)}),a);o.signal?.addEventListener&&o.signal.addEventListener("abort",s,{once:!0})}))}(t,n,s,o):(await async function(t,e){t.retryCount>=t.retries&&await t.onMaxRetryTimesExceeded(e,t.retryCount)}(n,s),Promise.reject(s))}));return{requestInterceptorId:s,responseInterceptorId:o}};var O;f.isNetworkError=E,f.isSafeRequestError=function(t){return!!t.config?.method&&(g(t)&&-1!==l.indexOf(t.config.method))},f.isIdempotentRequestError=_,f.isNetworkOrIdempotentRequestError=m,f.exponentialDelay=function(t=0,e=void 0,s=100){const o=2**t*s,n=Math.max(o,v(e));return n+.2*n*Math.random()},f.linearDelay=function(t=100){return(e=0,s=void 0)=>{const o=e*t;return Math.max(o,v(s))}},f.isRetryableError=g,f(t,{retries:3,retryDelay:f.exponentialDelay});class w{constructor(t){var e;O.set(this,void 0),this.shopId=t.shopId,function(t,e,s,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(t,s):n?n.value=s:e.set(t,s)}(this,O,t.accessToken,"f"),this.enableLogging=null===(e=t.enableLogging)||void 0===e||e,this.catalog=new s(this.fetchData.bind(this),this.shopId),this.orders=new o(this.fetchData.bind(this),this.shopId),this.products=new n(this.fetchData.bind(this),this.shopId),this.shops=new r(this.fetchData.bind(this),this.shopId),this.uploads=new i(this.fetchData.bind(this),this.shopId),this.webhooks=new a(this.fetchData.bind(this),this.shopId)}logError(t){this.enableLogging&&console.error(t)}logRequest(t,e){this.enableLogging&&console.log(`Requesting ${t.toUpperCase()} ${h}${e}`)}async fetchData(s,o={}){var n,r,i;const a={"Content-Type":"application/json",Authorization:`Bearer ${e(this,O,"f")}`},c=Object.assign(Object.assign({},o.method?o:Object.assign(Object.assign({},o),{method:"GET"})),{baseURL:h,headers:Object.assign(Object.assign({},a),o.headers||{})}),d=(null===(n=o.method)||void 0===n?void 0:n.toLowerCase())||"get";this.logRequest(d,s);try{let e;switch(d){case"post":e=await t.post(s,o.data,c);break;case"put":e=await t.put(s,o.data,c);break;case"delete":e=await t.delete(s,c);break;default:e=await t.get(s,c)}return e.data}catch(e){if(t.isAxiosError(e)){const t=`Printify SDK Error: ${null===(r=e.response)||void 0===r?void 0:r.status} ${null===(i=e.response)||void 0===i?void 0:i.statusText} - Requested URL: ${h}${s}`;throw this.logError(t),new Error(t)}{const t="Printify SDK Unknown Error";throw this.logError(t),new Error(t)}}}}O=new WeakMap;export{w as default};
import t from"axios";function e(t,e,s,o){if("a"===s&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?o:"a"===s?o.call(t):o?o.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;class s{constructor(t,e){this.listBlueprints=(t=>()=>t("/v1/catalog/blueprints.json",{method:"GET"}))(t),this.getBlueprint=(t=>e=>t(`/v1/catalog/blueprints/${e}.json`,{method:"GET"}))(t),this.getBlueprintProviders=(t=>e=>t(`/v1/catalog/blueprints/${e}/print_providers.json`,{method:"GET"}))(t),this.getBlueprintVariants=(t=>(e,s)=>t(`/v1/catalog/blueprints/${e}/print_providers/${s}/variants.json`,{method:"GET"}))(t),this.getVariantShipping=(t=>(e,s)=>t(`/v1/catalog/blueprints/${e}/print_providers/${s}/shipping.json`,{method:"GET"}))(t),this.listProviders=(t=>()=>t("/v1/catalog/print_providers.json",{method:"GET"}))(t),this.getProvider=(t=>e=>t(`/v1/catalog/print_providers/${e}.json`,{method:"GET"}))(t)}}class o{constructor(t,e){this.list=((t,e)=>(s={})=>{const{page:o,limit:r,status:n,sku:i}=s,a=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==r&&{limit:r.toString()}),void 0!==n&&{status:n}),void 0!==i&&{sku:i})).toString();return t(`/v1/shops/${e}/orders.json${a?`?${a}`:""}`,{method:"GET"})})(t,e),this.getOne=((t,e)=>s=>t(`/v1/shops/${e}/orders/${s}.json`,{method:"GET"}))(t,e),this.submit=((t,e)=>s=>t(`/v1/shops/${e}/orders.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.submitExpress=((t,e)=>s=>t(`/v1/shops/${e}/express.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.sendToProduction=((t,e)=>s=>t(`/v1/shops/${e}/orders/${s}/send_to_production.json`,{method:"POST"}))(t,e),this.calculateShipping=((t,e)=>s=>t(`/v1/shops/${e}/orders/shipping.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.cancelUnpaid=((t,e)=>s=>t(`/v1/shops/${e}/orders/${s}/cancel.json`,{method:"POST"}))(t,e)}}class r{constructor(t,e){this.create=((t,e)=>s=>t(`/v1/shops/${e}/products.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.deleteOne=((t,e)=>s=>t(`/v1/shops/${e}/products/${s}.json`,{method:"DELETE"}))(t,e),this.getOne=((t,e)=>s=>t(`/v1/shops/${e}/products/${s}.json`,{method:"GET"}))(t,e),this.list=((t,e)=>(s={})=>{const{page:o,limit:r}=s,n=new URLSearchParams(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==r&&{limit:r.toString()})).toString(),i=n.toString()?`?${n.toString()}`:"";return t(`/v1/shops/${e}/products.json${i}`,{method:"GET"})})(t,e),this.notifyUnpublished=((t,e)=>s=>t(`/v1/shops/${e}/products/${s}/unpublish.json`,{method:"POST"}))(t,e),this.publishOne=((t,e)=>(s,o)=>t(`/v1/shops/${e}/products/${s}/publish.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.setPublishFailed=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publishing_failed.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.setPublishSucceeded=((t,e)=>async(s,o)=>t(`/v1/shops/${e}/products/${s}/publishing_succeeded.json`,{method:"POST",data:JSON.stringify(o)}))(t,e),this.updateOne=((t,e)=>(s,o)=>t(`/v1/shops/${e}/products/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e)}}class n{constructor(t,e){this.deleteOne=((t,e)=>s=>t(`/v1/shops/${s||e}/connection.json`,{method:"DELETE"}))(t,e),this.list=(t=>()=>t("/v1/shops.json",{method:"GET"}))(t)}}class i{constructor(t,e){this.archive=(t=>e=>t(`/v1/uploads/${e}/archive.json`,{method:"POST"}))(t),this.getById=(t=>e=>t(`/v1/uploads/${e}.json`,{method:"GET"}))(t),this.list=(t=>(e,s)=>{const o=new URLSearchParams;void 0!==e&&o.append("page",e.toString()),void 0!==s&&o.append("limit",s.toString());const r="/v1/uploads.json"+(o.toString()?`?${o.toString()}`:"");return t(r,{method:"GET"})})(t),this.uploadImage=(t=>e=>t("/v1/uploads/images.json",{method:"POST",data:JSON.stringify(e)}))(t)}}class a{constructor(t,e){this.list=((t,e)=>()=>t(`/v1/shops/${e}/webhooks.json`,{method:"GET"}))(t,e),this.create=((t,e)=>s=>t(`/v1/shops/${e}/webhooks.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.updateOne=((t,e)=>(s,o)=>t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e),this.deleteOne=((t,e)=>s=>t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"DELETE"}))(t,e)}}function h(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const d=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);var c=h((t=>!d.has(t&&t.code)));const u="axios-retry";function p(t){return!t.response&&(!!t.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(t.code)&&c(t)))}const l=["get","head","options"],E=l.concat(["put","delete"]);function T(t){return"ECONNABORTED"!==t.code&&(!t.response||429===t.response.status||t.response.status>=500&&t.response.status<=599)}function g(t){return!!t.config?.method&&(T(t)&&-1!==E.indexOf(t.config.method))}function m(t){return p(t)||g(t)}function _(t=void 0){const e=t?.response?.headers["retry-after"];if(!e)return 0;let s=1e3*(Number(e)||0);return 0===s&&(s=(new Date(e).valueOf()||0)-Date.now()),Math.max(0,s)}const v={retries:3,retryCondition:m,retryDelay:function(t=0,e=void 0){return Math.max(0,_(e))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function R(t,e,s=!1){const o=function(t,e){return{...v,...e,...t[u]}}(t,e||{});return o.retryCount=o.retryCount||0,o.lastRequestTime&&!s||(o.lastRequestTime=Date.now()),t[u]=o,o}const f=(t,e)=>{const s=t.interceptors.request.use((t=>(R(t,e,!0),t[u]?.validateResponse&&(t.validateStatus=()=>!1),t))),o=t.interceptors.response.use(null,(async s=>{const{config:o}=s;if(!o)return Promise.reject(s);const r=R(o,e);return s.response&&r.validateResponse?.(s.response)?s.response:await async function(t,e){const{retries:s,retryCondition:o}=t,r=(t.retryCount||0)<s&&o(e);if("object"==typeof r)try{return!1!==await r}catch(t){return!1}return r}(r,s)?async function(t,e,s,o){e.retryCount+=1;const{retryDelay:r,shouldResetTimeout:n,onRetry:i}=e,a=r(e.retryCount,s);if(function(t,e){t.defaults.agent===e.agent&&delete e.agent,t.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,t.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}(t,o),!n&&o.timeout&&e.lastRequestTime){const t=Date.now()-e.lastRequestTime,r=o.timeout-t-a;if(r<=0)return Promise.reject(s);o.timeout=r}return o.transformRequest=[t=>t],await i(e.retryCount,s,o),o.signal?.aborted?Promise.resolve(t(o)):new Promise((e=>{const s=()=>{clearTimeout(r),e(t(o))},r=setTimeout((()=>{e(t(o)),o.signal?.removeEventListener&&o.signal.removeEventListener("abort",s)}),a);o.signal?.addEventListener&&o.signal.addEventListener("abort",s,{once:!0})}))}(t,r,s,o):(await async function(t,e){t.retryCount>=t.retries&&await t.onMaxRetryTimesExceeded(e,t.retryCount)}(r,s),Promise.reject(s))}));return{requestInterceptorId:s,responseInterceptorId:o}};var O;f.isNetworkError=p,f.isSafeRequestError=function(t){return!!t.config?.method&&(T(t)&&-1!==l.indexOf(t.config.method))},f.isIdempotentRequestError=g,f.isNetworkOrIdempotentRequestError=m,f.exponentialDelay=function(t=0,e=void 0,s=100){const o=2**t*s,r=Math.max(o,_(e));return r+.2*r*Math.random()},f.linearDelay=function(t=100){return(e=0,s=void 0)=>{const o=e*t;return Math.max(o,_(s))}},f.isRetryableError=T,f(t,{retries:3,retryDelay:f.exponentialDelay});class S{constructor(t){var e;O.set(this,void 0),this.shopId=t.shopId,function(t,e,s,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?r.call(t,s):r?r.value=s:e.set(t,s)}(this,O,t.accessToken,"f"),this.apiVersion=t.apiVersion||"v1",this.enableLogging=null===(e=t.enableLogging)||void 0===e||e,this.host=t.host||"api.printify.com",this.timeout=t.timeout||5e3,this.baseUrl=`https://${this.host}`,this.catalog=new s(this.fetchData.bind(this),this.shopId),this.orders=new o(this.fetchData.bind(this),this.shopId),this.products=new r(this.fetchData.bind(this),this.shopId),this.shops=new n(this.fetchData.bind(this),this.shopId),this.uploads=new i(this.fetchData.bind(this),this.shopId),this.webhooks=new a(this.fetchData.bind(this),this.shopId)}logError(t){this.enableLogging&&console.error(t)}logRequest(t,e){this.enableLogging&&console.log(`Requesting ${t.toUpperCase()} ${this.baseUrl}${e}`)}async fetchData(s,o={}){var r,n,i;const a={"Content-Type":"application/json",Authorization:`Bearer ${e(this,O,"f")}`},h=Object.assign(Object.assign({},o.method?o:Object.assign(Object.assign({},o),{method:"GET"})),{baseURL:this.baseUrl,timeout:this.timeout,headers:Object.assign(Object.assign({},a),o.headers||{})}),d=(null===(r=o.method)||void 0===r?void 0:r.toLowerCase())||"get";this.logRequest(d,s);try{let e;switch(d){case"post":e=await t.post(s,o.data,h);break;case"put":e=await t.put(s,o.data,h);break;case"delete":e=await t.delete(s,h);break;default:e=await t.get(s,h)}return e.data}catch(e){if(t.isAxiosError(e)){const t=`Printify SDK Error: ${null===(n=e.response)||void 0===n?void 0:n.status} ${null===(i=e.response)||void 0===i?void 0:i.statusText} - Requested URL: ${this.baseUrl}${s}`;throw this.logError(t),new Error(t)}{const t="Printify SDK Unknown Error";throw this.logError(t),new Error(t)}}}}O=new WeakMap;export{S as default};
//# sourceMappingURL=index.esm.js.map
{
"name": "printify-sdk-js",
"version": "1.2.0-beta",
"version": "1.2.0",
"description": "Node.js SDK for the Printify API.",

@@ -70,3 +70,2 @@ "author": "Spencer Lepine <spencer.sayhello@gmail.com>",

"devDependencies": {
"@types/jest": "^29.5.14",
"@jest/types": "^29.6.3",

@@ -76,2 +75,3 @@ "@rollup/plugin-commonjs": "^26.0.1",

"@rollup/plugin-node-resolve": "^15.2.3",
"@types/jest": "^29.5.14",
"@types/node": "^20.14.10",

@@ -81,2 +81,3 @@ "@typescript-eslint/eslint-plugin": "^5.8.0",

"eslint": "^8.0.0",
"eslint-plugin-prettier": "^5.2.1",
"husky": "4.3.8",

@@ -99,2 +100,2 @@ "jest": "^29.7.0",

}
}
}

@@ -42,5 +42,5 @@ # Printify SDK for TypeScript (Node.js)

const printify = new Printify({
shopId: '123456', // (optional) find using printify.shops.list()
accessToken: process.env.PRINTIFY_API_TOKEN, // generate a token: https://printify.com/app/account/api
enableLogging: true, // (optional) enabled by default
shopId: '123456', // (optional) find using `printify.shops.list()`
enableLogging: true,
});

@@ -58,3 +58,6 @@

const printify = new Printify({ shopId: '123456', accessToken: process.env.PRINTIFY_API_TOKEN });
const printify = new Printify({
accessToken: process.env.PRINTIFY_API_TOKEN,
shopId: '123456',
});

@@ -72,5 +75,4 @@ const result: ListWebhooksResponse = await printify.webhooks.list();

const printify = new Printify({
accessToken: process.env.PRINTIFY_API_TOKEN,
shopId: '123456',
accessToken: process.env.PRINTIFY_API_TOKEN,
enableLogging: true,
});

@@ -84,2 +86,26 @@

## Configuration
```js
import Printify from 'printify-sdk-js';
const printify = new Printify({
accessToken: process.env.PRINTIFY_API_TOKEN,
shopId: '123456',
enableLogging: true,
apiVersion: 'v1',
host: 'api.printify.com',
timeout: 5000, // in ms
});
```
| Option | Default | Description |
| --------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------- | --- |
| `accessToken` | `null` | The API access token for authenticating requests. Generate one at [Printify API](https://printify.com/app/account/api). |
| `shopId` | `null` | (optional) The ID of the shop to use for API requests. Can be found using `printify.shops.list()`. |
| `enableLogging` | `true` | (optional) Enables logging of API requests and responses. Enabled by default. |
| `apiVersion` | `'v1'` | (optional) The API version |
| `host` | `'api.printify.com'` | The host for API requests. | |
| `timeout` | `5000` | (optional) Reqeust timeout in ms |
## Development

@@ -86,0 +112,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc