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.0.2 to 1.1.0

2

dist/index.cjs.js

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

"use strict";function s(s,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?s!==t||!o:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(s):o?o.value:t.get(s)}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(s,t){this.listBlueprints=(s=>async()=>await s("/v1/catalog/blueprints.json",{method:"GET"}))(s),this.getBlueprint=(s=>async t=>await s(`/v1/catalog/blueprints/${t}.json`,{method:"GET"}))(s),this.getBlueprintProviders=(s=>async t=>await s(`/v1/catalog/blueprints/${t}/print_providers.json`,{method:"GET"}))(s),this.getBlueprintVariants=(s=>async(t,i)=>await s(`/v1/catalog/blueprints/${t}/print_providers/${i}/variants.json`,{method:"GET"}))(s),this.getVariantShipping=(s=>async(t,i)=>await s(`/v1/catalog/blueprints/${t}/print_providers/${i}/shipping.json`,{method:"GET"}))(s),this.listProviders=(s=>async()=>await s("/v1/catalog/print_providers.json",{method:"GET"}))(s),this.getProvider=(s=>async t=>await s(`/v1/catalog/print_providers/${t}.json`,{method:"GET"}))(s)}}class i{constructor(s,t){this.list=((s,t)=>async(i={})=>{const{page:o,limit:a,status:e,sku:n}=i,r=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==a&&{limit:a.toString()}),void 0!==e&&{status:e}),void 0!==n&&{sku:n})).toString();return await s(`/v1/shops/${t}/orders.json${r?`?${r}`:""}`,{method:"GET"})})(s,t),this.getOne=((s,t)=>async i=>await s(`/v1/shops/${t}/orders/${i}.json`,{method:"GET"}))(s,t),this.submit=((s,t)=>async i=>await s(`/v1/shops/${t}/orders.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.submitExpress=((s,t)=>async i=>await s(`/v1/shops/${t}/express.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.sendToProduction=((s,t)=>async i=>await s(`/v1/shops/${t}/orders/${i}/send_to_production.json`,{method:"POST"}))(s,t),this.calculateShipping=((s,t)=>async i=>await s(`/v1/shops/${t}/orders/shipping.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.cancelUnpaid=((s,t)=>async i=>await s(`/v1/shops/${t}/orders/${i}/cancel.json`,{method:"POST"}))(s,t)}}class o{constructor(s,t){this.create=((s,t)=>async i=>await s(`/v1/shops/${t}/products.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.deleteOne=((s,t)=>async i=>{await s(`/v1/shops/${t}/products/${i}.json`,{method:"DELETE"})})(s,t),this.getOne=((s,t)=>async i=>await s(`/v1/shops/${t}/products/${i}.json`,{method:"GET"}))(s,t),this.list=((s,t)=>async(i={})=>{const{page:o,limit:a}=i,e=new URLSearchParams(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==a&&{limit:a.toString()})).toString(),n=e.toString()?`?${e.toString()}`:"";return await s(`/v1/shops/${t}/products.json${n}`,{method:"GET"})})(s,t),this.notifyUnpublished=((s,t)=>async i=>{await s(`/v1/shops/${t}/products/${i}/unpublish.json`,{method:"POST"})})(s,t),this.publishOne=((s,t)=>async(i,o)=>s(`/v1/shops/${t}/products/${i}/publish.json`,{method:"POST",body:JSON.stringify(o)}))(s,t),this.setPublishFailed=((s,t)=>async(i,o)=>{await s(`/v1/shops/${t}/products/${i}/publishing_failed.json`,{method:"POST",body:JSON.stringify(o)})})(s,t),this.setPublishSucceeded=((s,t)=>async(i,o)=>{await s(`/v1/shops/${t}/products/${i}/publishing_succeeded.json`,{method:"POST",body:JSON.stringify(o)})})(s,t),this.updateOne=((s,t)=>async(i,o)=>s(`/v1/shops/${t}/products/${i}.json`,{method:"PUT",body:JSON.stringify(o)}))(s,t)}}class a{constructor(s,t){this.deleteOne=((s,t)=>async i=>{await s(`/v1/shops/${i||t}/connection.json`,{method:"DELETE"})})(s,t),this.list=(s=>async()=>await s("/v1/shops.json",{method:"GET"}))(s)}}class e{constructor(s,t){this.archive=(s=>async t=>{await s(`/v1/uploads/${t}/archive.json`,{method:"POST"})})(s),this.getById=(s=>async t=>await s(`/v1/uploads/${t}.json`,{method:"GET"}))(s),this.list=(s=>async(t,i)=>{const o=new URLSearchParams;void 0!==t&&o.append("page",t.toString()),void 0!==i&&o.append("limit",i.toString());const a="/v1/uploads.json"+(o.toString()?`?${o.toString()}`:"");return s(a,{method:"GET"})})(s),this.uploadImage=(s=>async t=>await s("/v1/uploads/images.json",{method:"POST",body:JSON.stringify(t)}))(s)}}class n{constructor(s,t){this.list=((s,t)=>async()=>await s(`/v1/shops/${t}/webhooks.json`,{method:"GET"}))(s,t),this.create=((s,t)=>async i=>await s(`/v1/shops/${t}/webhooks.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.updateOne=((s,t)=>async(i,o)=>await s(`/v1/shops/${t}/webhooks/${i}.json`,{method:"PUT",body:JSON.stringify(o)}))(s,t),this.deleteOne=((s,t)=>async i=>await s(`/v1/shops/${t}/webhooks/${i}.json`,{method:"DELETE"}))(s,t)}}const r="https://api.printify.com";var h;h=new WeakMap,module.exports=class{constructor(s){h.set(this,void 0),this.shopId=s.shopId,function(s,t,i,o,a){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?s!==t||!a:!t.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?a.call(s,i):a?a.value=i:t.set(s,i)}(this,h,s.accessToken,"f"),this.catalog=new t(this.fetchData.bind(this),this.shopId),this.orders=new i(this.fetchData.bind(this),this.shopId),this.products=new o(this.fetchData.bind(this),this.shopId),this.shops=new a(this.fetchData.bind(this),this.shopId),this.uploads=new e(this.fetchData.bind(this),this.shopId),this.webhooks=new n(this.fetchData.bind(this),this.shopId)}async fetchData(t,i={}){const o={"Content-Type":"application/json",Authorization:`Bearer ${s(this,h,"f")}`},a=Object.assign(Object.assign({},i),{headers:Object.assign(Object.assign({},o),i.headers||{})});try{const s=await fetch(`${r}${t}`,a);if(!s.ok)throw console.error(`Printify SDK Error: ${s.status} ${s.statusText} - Requested URL: ${r}${t}`),new Error(`Printify SDK Error: ${s.status} ${s.statusText}`);return await s.json()}catch(s){throw s}}};
"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=>async()=>await 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=>async()=>await 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)=>async(s={})=>{const{page:o,limit:n,status:a,sku:i}=s,r=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==n&&{limit:n.toString()}),void 0!==a&&{status:a}),void 0!==i&&{sku:i})).toString();return await t(`/v1/shops/${e}/orders.json${r?`?${r}`:""}`,{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 a{constructor(t,e){this.create=((t,e)=>async s=>await 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)=>async(s={})=>{const{page:o,limit:n}=s,a=new URLSearchParams(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==n&&{limit:n.toString()})).toString(),i=a.toString()?`?${a.toString()}`:"";return await 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)=>{await t(`/v1/shops/${e}/products/${s}/publishing_failed.json`,{method:"POST",data:JSON.stringify(o)})})(t,e),this.setPublishSucceeded=((t,e)=>async(s,o)=>{await 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 r{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=>async e=>await t("/v1/uploads/images.json",{method:"POST",data:JSON.stringify(e)}))(t)}}class c{constructor(t,e){this.list=((t,e)=>async()=>await t(`/v1/shops/${e}/webhooks.json`,{method:"GET"}))(t,e),this.create=((t,e)=>async s=>await t(`/v1/shops/${e}/webhooks.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.updateOne=((t,e)=>async(s,o)=>await t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e),this.deleteOne=((t,e)=>async s=>await t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"DELETE"}))(t,e)}}const d="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 y(t){return!!t.config?.method&&(_(t)&&-1!==g.indexOf(t.config.method))}function f(t){return E(t)||y(t)}function m(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 w={retries:3,retryCondition:f,retryDelay:function(t=0,e=void 0){return Math.max(0,m(e))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function v(t,e,s=!1){const o=function(t,e){return{...w,...e,...t[l]}}(t,e||{});return o.retryCount=o.retryCount||0,o.lastRequestTime&&!s||(o.lastRequestTime=Date.now()),t[l]=o,o}const R=(t,e)=>{const s=t.interceptors.request.use((t=>(v(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=v(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:a,onRetry:i}=e,r=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),!a&&o.timeout&&e.lastRequestTime){const t=Date.now()-e.lastRequestTime,n=o.timeout-t-r;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)}),r);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;R.isNetworkError=E,R.isSafeRequestError=function(t){return!!t.config?.method&&(_(t)&&-1!==T.indexOf(t.config.method))},R.isIdempotentRequestError=y,R.isNetworkOrIdempotentRequestError=f,R.exponentialDelay=function(t=0,e=void 0,s=100){const o=2**t*s,n=Math.max(o,m(e));return n+.2*n*Math.random()},R.linearDelay=function(t=100){return(e=0,s=void 0)=>{const o=e*t;return Math.max(o,m(s))}},R.isRetryableError=_,R(e.default,{retries:3,retryDelay:R.exponentialDelay});O=new WeakMap,module.exports=class{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 o(this.fetchData.bind(this),this.shopId),this.orders=new n(this.fetchData.bind(this),this.shopId),this.products=new a(this.fetchData.bind(this),this.shopId),this.shops=new i(this.fetchData.bind(this),this.shopId),this.uploads=new r(this.fetchData.bind(this),this.shopId),this.webhooks=new c(this.fetchData.bind(this),this.shopId)}logError(t){this.enableLogging&&console.error(t)}logRequest(t,e){this.enableLogging&&console.log(`Requesting ${t.toUpperCase()} ${d}${e}`)}async fetchData(t,o={}){var n,a,i;const r={"Content-Type":"application/json",Authorization:`Bearer ${s(this,O,"f")}`},c=Object.assign(Object.assign({},o.method?o:Object.assign(Object.assign({},o),{method:"GET"})),{baseURL:d,headers:Object.assign(Object.assign({},r),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,c);break;case"put":s=await e.default.put(t,o.data,c);break;case"delete":s=await e.default.delete(t,c);break;case"patch":s=await e.default.patch(t,o.data,c);break;default:s=await e.default.get(t,c)}return s.data}catch(s){if(e.default.isAxiosError(s)){const e=`Printify SDK Error: ${null===(a=s.response)||void 0===a?void 0:a.status} ${null===(i=s.response)||void 0===i?void 0:i.statusText} - Requested URL: ${d}${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 @@

function s(s,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?s!==t||!o:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(s):o?o.value:t.get(s)}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(s,t){this.listBlueprints=(s=>async()=>await s("/v1/catalog/blueprints.json",{method:"GET"}))(s),this.getBlueprint=(s=>async t=>await s(`/v1/catalog/blueprints/${t}.json`,{method:"GET"}))(s),this.getBlueprintProviders=(s=>async t=>await s(`/v1/catalog/blueprints/${t}/print_providers.json`,{method:"GET"}))(s),this.getBlueprintVariants=(s=>async(t,i)=>await s(`/v1/catalog/blueprints/${t}/print_providers/${i}/variants.json`,{method:"GET"}))(s),this.getVariantShipping=(s=>async(t,i)=>await s(`/v1/catalog/blueprints/${t}/print_providers/${i}/shipping.json`,{method:"GET"}))(s),this.listProviders=(s=>async()=>await s("/v1/catalog/print_providers.json",{method:"GET"}))(s),this.getProvider=(s=>async t=>await s(`/v1/catalog/print_providers/${t}.json`,{method:"GET"}))(s)}}class i{constructor(s,t){this.list=((s,t)=>async(i={})=>{const{page:o,limit:a,status:e,sku:n}=i,r=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==a&&{limit:a.toString()}),void 0!==e&&{status:e}),void 0!==n&&{sku:n})).toString();return await s(`/v1/shops/${t}/orders.json${r?`?${r}`:""}`,{method:"GET"})})(s,t),this.getOne=((s,t)=>async i=>await s(`/v1/shops/${t}/orders/${i}.json`,{method:"GET"}))(s,t),this.submit=((s,t)=>async i=>await s(`/v1/shops/${t}/orders.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.submitExpress=((s,t)=>async i=>await s(`/v1/shops/${t}/express.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.sendToProduction=((s,t)=>async i=>await s(`/v1/shops/${t}/orders/${i}/send_to_production.json`,{method:"POST"}))(s,t),this.calculateShipping=((s,t)=>async i=>await s(`/v1/shops/${t}/orders/shipping.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.cancelUnpaid=((s,t)=>async i=>await s(`/v1/shops/${t}/orders/${i}/cancel.json`,{method:"POST"}))(s,t)}}class o{constructor(s,t){this.create=((s,t)=>async i=>await s(`/v1/shops/${t}/products.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.deleteOne=((s,t)=>async i=>{await s(`/v1/shops/${t}/products/${i}.json`,{method:"DELETE"})})(s,t),this.getOne=((s,t)=>async i=>await s(`/v1/shops/${t}/products/${i}.json`,{method:"GET"}))(s,t),this.list=((s,t)=>async(i={})=>{const{page:o,limit:a}=i,e=new URLSearchParams(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==a&&{limit:a.toString()})).toString(),n=e.toString()?`?${e.toString()}`:"";return await s(`/v1/shops/${t}/products.json${n}`,{method:"GET"})})(s,t),this.notifyUnpublished=((s,t)=>async i=>{await s(`/v1/shops/${t}/products/${i}/unpublish.json`,{method:"POST"})})(s,t),this.publishOne=((s,t)=>async(i,o)=>s(`/v1/shops/${t}/products/${i}/publish.json`,{method:"POST",body:JSON.stringify(o)}))(s,t),this.setPublishFailed=((s,t)=>async(i,o)=>{await s(`/v1/shops/${t}/products/${i}/publishing_failed.json`,{method:"POST",body:JSON.stringify(o)})})(s,t),this.setPublishSucceeded=((s,t)=>async(i,o)=>{await s(`/v1/shops/${t}/products/${i}/publishing_succeeded.json`,{method:"POST",body:JSON.stringify(o)})})(s,t),this.updateOne=((s,t)=>async(i,o)=>s(`/v1/shops/${t}/products/${i}.json`,{method:"PUT",body:JSON.stringify(o)}))(s,t)}}class a{constructor(s,t){this.deleteOne=((s,t)=>async i=>{await s(`/v1/shops/${i||t}/connection.json`,{method:"DELETE"})})(s,t),this.list=(s=>async()=>await s("/v1/shops.json",{method:"GET"}))(s)}}class e{constructor(s,t){this.archive=(s=>async t=>{await s(`/v1/uploads/${t}/archive.json`,{method:"POST"})})(s),this.getById=(s=>async t=>await s(`/v1/uploads/${t}.json`,{method:"GET"}))(s),this.list=(s=>async(t,i)=>{const o=new URLSearchParams;void 0!==t&&o.append("page",t.toString()),void 0!==i&&o.append("limit",i.toString());const a="/v1/uploads.json"+(o.toString()?`?${o.toString()}`:"");return s(a,{method:"GET"})})(s),this.uploadImage=(s=>async t=>await s("/v1/uploads/images.json",{method:"POST",body:JSON.stringify(t)}))(s)}}class n{constructor(s,t){this.list=((s,t)=>async()=>await s(`/v1/shops/${t}/webhooks.json`,{method:"GET"}))(s,t),this.create=((s,t)=>async i=>await s(`/v1/shops/${t}/webhooks.json`,{method:"POST",body:JSON.stringify(i)}))(s,t),this.updateOne=((s,t)=>async(i,o)=>await s(`/v1/shops/${t}/webhooks/${i}.json`,{method:"PUT",body:JSON.stringify(o)}))(s,t),this.deleteOne=((s,t)=>async i=>await s(`/v1/shops/${t}/webhooks/${i}.json`,{method:"DELETE"}))(s,t)}}const r="https://api.printify.com";var h;class c{constructor(s){h.set(this,void 0),this.shopId=s.shopId,function(s,t,i,o,a){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?s!==t||!a:!t.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?a.call(s,i):a?a.value=i:t.set(s,i)}(this,h,s.accessToken,"f"),this.catalog=new t(this.fetchData.bind(this),this.shopId),this.orders=new i(this.fetchData.bind(this),this.shopId),this.products=new o(this.fetchData.bind(this),this.shopId),this.shops=new a(this.fetchData.bind(this),this.shopId),this.uploads=new e(this.fetchData.bind(this),this.shopId),this.webhooks=new n(this.fetchData.bind(this),this.shopId)}async fetchData(t,i={}){const o={"Content-Type":"application/json",Authorization:`Bearer ${s(this,h,"f")}`},a=Object.assign(Object.assign({},i),{headers:Object.assign(Object.assign({},o),i.headers||{})});try{const s=await fetch(`${r}${t}`,a);if(!s.ok)throw console.error(`Printify SDK Error: ${s.status} ${s.statusText} - Requested URL: ${r}${t}`),new Error(`Printify SDK Error: ${s.status} ${s.statusText}`);return await s.json()}catch(s){throw s}}}h=new WeakMap;export{c 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=>async()=>await 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=>async()=>await 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)=>async(s={})=>{const{page:o,limit:n,status:a,sku:i}=s,r=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==n&&{limit:n.toString()}),void 0!==a&&{status:a}),void 0!==i&&{sku:i})).toString();return await t(`/v1/shops/${e}/orders.json${r?`?${r}`:""}`,{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)=>async s=>await 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)=>async(s={})=>{const{page:o,limit:n}=s,a=new URLSearchParams(Object.assign(Object.assign({},void 0!==o&&{page:o.toString()}),void 0!==n&&{limit:n.toString()})).toString(),i=a.toString()?`?${a.toString()}`:"";return await 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)=>{await t(`/v1/shops/${e}/products/${s}/publishing_failed.json`,{method:"POST",data:JSON.stringify(o)})})(t,e),this.setPublishSucceeded=((t,e)=>async(s,o)=>{await 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 a{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=>async e=>await t("/v1/uploads/images.json",{method:"POST",data:JSON.stringify(e)}))(t)}}class r{constructor(t,e){this.list=((t,e)=>async()=>await t(`/v1/shops/${e}/webhooks.json`,{method:"GET"}))(t,e),this.create=((t,e)=>async s=>await t(`/v1/shops/${e}/webhooks.json`,{method:"POST",data:JSON.stringify(s)}))(t,e),this.updateOne=((t,e)=>async(s,o)=>await t(`/v1/shops/${e}/webhooks/${s}.json`,{method:"PUT",data:JSON.stringify(o)}))(t,e),this.deleteOne=((t,e)=>async s=>await 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 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=h((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 y(t){return E(t)||_(t)}function m(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 w={retries:3,retryCondition:y,retryDelay:function(t=0,e=void 0){return Math.max(0,m(e))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function v(t,e,s=!1){const o=function(t,e){return{...w,...e,...t[p]}}(t,e||{});return o.retryCount=o.retryCount||0,o.lastRequestTime&&!s||(o.lastRequestTime=Date.now()),t[p]=o,o}const R=(t,e)=>{const s=t.interceptors.request.use((t=>(v(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=v(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:a,onRetry:i}=e,r=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),!a&&o.timeout&&e.lastRequestTime){const t=Date.now()-e.lastRequestTime,n=o.timeout-t-r;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)}),r);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 f;R.isNetworkError=E,R.isSafeRequestError=function(t){return!!t.config?.method&&(g(t)&&-1!==l.indexOf(t.config.method))},R.isIdempotentRequestError=_,R.isNetworkOrIdempotentRequestError=y,R.exponentialDelay=function(t=0,e=void 0,s=100){const o=2**t*s,n=Math.max(o,m(e));return n+.2*n*Math.random()},R.linearDelay=function(t=100){return(e=0,s=void 0)=>{const o=e*t;return Math.max(o,m(s))}},R.isRetryableError=g,R(t,{retries:3,retryDelay:R.exponentialDelay});class O{constructor(t){var e;f.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,f,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 a(this.fetchData.bind(this),this.shopId),this.uploads=new i(this.fetchData.bind(this),this.shopId),this.webhooks=new r(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(s,o={}){var n,a,i;const r={"Content-Type":"application/json",Authorization:`Bearer ${e(this,f,"f")}`},h=Object.assign(Object.assign({},o.method?o:Object.assign(Object.assign({},o),{method:"GET"})),{baseURL:c,headers:Object.assign(Object.assign({},r),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,h);break;case"put":e=await t.put(s,o.data,h);break;case"delete":e=await t.delete(s,h);break;case"patch":e=await t.patch(s,o.data,h);break;default:e=await t.get(s,h)}return e.data}catch(e){if(t.isAxiosError(e)){const t=`Printify SDK Error: ${null===(a=e.response)||void 0===a?void 0:a.status} ${null===(i=e.response)||void 0===i?void 0:i.statusText} - Requested URL: ${c}${s}`;throw this.logError(t),new Error(t)}{const t="Printify SDK Unknown Error";throw this.logError(t),new Error(t)}}}}f=new WeakMap;export{O as default};
//# sourceMappingURL=index.esm.js.map

@@ -11,3 +11,11 @@ # Printify SDK Documentation (Node.js)

```sh
$ curl -X GET <https://api.printify.com/v1/shops.json> --header "Authorization: Bearer $PRINTIFY_API_TOKEN"`
# generate a token: https://printify.com/app/account/api
export PRINTIFY_API_TOKEN="asdfASDFasdfASDFasdfASDF"
# fetch your shopId
curl -X GET https://api.printify.com/v1/shops.json --header "Authorization: Bearer $PRINTIFY_API_TOKEN"
# Expected response: [{"id":1234567,"title":"My Store Name","sales_channel":"custom_integration"}]
# store for process.env.PRINTIFY_API_TOKEN
echo "PRINTIFY_API_TOKEN=\"$PRINTIFY_API_TOKEN\"" >> .env
```

@@ -22,12 +30,43 @@

accessToken: process.env.PRINTIFY_API_TOKEN,
enableLogging: true, // on by default
});
(async () => {
const data = {
/* ... */
};
const result = await printify.orders.submit(data);
const orderData = {
label: 'order_123456',
line_items: [
{
print_provider_id: '12345',
blueprint_id: '67890',
variant_id: '112233',
print_areas: {
front: 'https://example.com/path/to/sticker.png', // **must be public
},
quantity: 1,
},
// ...
],
shipping_method: 1,
is_printify_express: false,
is_economy_shipping: false,
send_shipping_notification: true, // send email
address_to: {
first_name: 'John',
last_name: 'Doe',
email: 'johndoe@gmail.com',
phone: '0574 69 21 90',
country: 'US',
region: 'NY',
address1: '123 Main Street',
address2: '',
city: 'New York',
zip: '10001',
},
};
try {
const result = await printify.orders.submit(orderData);
console.log(result); // { "id": "5a96f649b2439217d070f507" }
})();
} catch (error) {
console.error('Error submitting order:', error);
}
```

@@ -34,0 +73,0 @@

{
"name": "printify-sdk-js",
"version": "1.0.2",
"version": "1.1.0",
"description": "Printify SDK for JavaScript. Client for Node.js",

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

"build": "rollup -c",
"test": "jest --passWithNoTests",
"release": "npm run test && npm run build",
"test": "jest",
"format": "prettier --write .",

@@ -54,3 +55,3 @@ "lint": "eslint . --ext .js,.jsx,.ts,.tsx",

"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "lint-staged && npm run release"
}

@@ -63,7 +64,15 @@ },

},
"dependencies": {
"@types/jest": "^29.5.14",
"axios": "^1.7.7",
"axios-retry": "^4.5.0"
},
"peerDependencies": {
"axios": "^1.7.7"
},
"devDependencies": {
"@jest/types": "^29.6.3",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.10",

@@ -70,0 +79,0 @@ "@typescript-eslint/eslint-plugin": "^5.8.0",

@@ -34,4 +34,11 @@ # Printify SDK for TypeScript (Node.js)

```sh
$ curl -X GET <https://api.printify.com/v1/shops.json> --header "Authorization: Bearer $PRINTIFY_API_TOKEN"`
# ref: https://developers.printify.com/#create-a-personal-access-token
# generate a token: https://printify.com/app/account/api
export PRINTIFY_API_TOKEN="asdfASDFasdfASDFasdfASDF"
# fetch your shopId
curl -X GET https://api.printify.com/v1/shops.json --header "Authorization: Bearer $PRINTIFY_API_TOKEN"
# Expected response: [{"id":1234567,"title":"My Store Name","sales_channel":"custom_integration"}]
# store for process.env.PRINTIFY_API_TOKEN
echo "PRINTIFY_API_TOKEN=\"$PRINTIFY_API_TOKEN\"" >> .env
```

@@ -46,15 +53,43 @@

accessToken: process.env.PRINTIFY_API_TOKEN,
enableLogging: true, // on by default
});
(async () => {
const data = {
/* ... */
};
try {
const result = await printify.orders.submit(data);
console.log(result); // { "id": "5a96f649b2439217d070f507" }
} catch (error) {
console.error('Error submitting order:', error);
}
})();
const orderData = {
label: order_123456,
line_items: [
{
print_provider_id: '12345',
blueprint_id: '67890',
variant_id: '112233',
print_areas: {
front: 'https://example.com/path/to/sticker.png', // **must be public
},
quantity: 1,
},
// ...
],
shipping_method: 1,
is_printify_express: false,
is_economy_shipping: false,
send_shipping_notification: true, // send email
address_to: {
first_name: 'John',
last_name: 'Doe',
email: 'johndoe@gmail.com',
phone: '0574 69 21 90',
country: 'US',
region: 'NY',
address1: '123 Main Street',
address2: '',
city: 'New York',
zip: '10001',
},
};
try {
const result = await printify.orders.submit(orderData);
console.log(result); // { "id": "5a96f649b2439217d070f507" }
} catch (error) {
console.error('Error submitting order:', error);
}
```

@@ -61,0 +96,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