printify-sdk-js
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -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)}}var r;r=new WeakMap,module.exports=class{constructor(s){r.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,r,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,r,"f")}`},a=Object.assign(Object.assign({},i),{headers:Object.assign(Object.assign({},o),i.headers||{})});try{const s=await fetch(`https://api.printify.com${t}`,a);if(!s.ok)throw new Error(`Printify SDK Error: ${s.status} ${s.statusText}`);return await s.json()}catch(s){throw s}}}; | ||
"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}}}; | ||
//# 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)}}var r;class h{constructor(s){r.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,r,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,r,"f")}`},a=Object.assign(Object.assign({},i),{headers:Object.assign(Object.assign({},o),i.headers||{})});try{const s=await fetch(`https://api.printify.com${t}`,a);if(!s.ok)throw new Error(`Printify SDK Error: ${s.status} ${s.statusText}`);return await s.json()}catch(s){throw s}}}r=new WeakMap;export{h as default}; | ||
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}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -20,7 +20,9 @@ # Printify SDK Documentation (Node.js) | ||
shopId: '123456', // global query by shop_id | ||
accessToken: process.env.API_TOKEN, | ||
accessToken: process.env.PRINTIFY_API_TOKEN, | ||
}); | ||
(async () => { | ||
const data = {/* ... */}; | ||
const data = { | ||
/* ... */ | ||
}; | ||
const result = await printify.orders.submit(data); | ||
@@ -27,0 +29,0 @@ |
{ | ||
"name": "printify-sdk-js", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Printify SDK for JavaScript. Client for Node.js", | ||
@@ -5,0 +5,0 @@ "author": "Spencer Lepine <spencer.sayhello@gmail.com>", |
# Printify SDK for TypeScript (Node.js) | ||
  | ||
 | ||
[](https://www.npmjs.com/package/printify-sdk-js) | ||
  | ||
 | ||
@@ -13,3 +14,3 @@ Printify SDK for Node.js. A basic TypeScript wrapper for the Printify REST API (v1). Guidelines and source endpoints can be found here: | ||
1. Printify API Token ([documentation](https://developers.printify.com)) | ||
- Printify Personal Access Token (create one [here](https://printify.com/app/account/api)) | ||
@@ -19,3 +20,10 @@ ### Installation | ||
```sh | ||
# Npm | ||
npm install printify-sdk-js | ||
# Yarn | ||
yarn add printify-sdk-js | ||
# Pnpm | ||
pnpm add printify-sdk-js | ||
``` | ||
@@ -27,2 +35,7 @@ | ||
```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 | ||
``` | ||
```js | ||
@@ -34,10 +47,15 @@ import Printify from 'printify-sdk-js'; | ||
shopId: '123456', // global query by shop_id | ||
accessToken: process.env.API_TOKEN, | ||
accessToken: process.env.PRINTIFY_API_TOKEN, | ||
}); | ||
(async () => { | ||
const data = {/* ... */}; | ||
const result = await printify.orders.submit(data); | ||
console.log(result); // { "id": "5a96f649b2439217d070f507" } | ||
const data = { | ||
/* ... */ | ||
}; | ||
try { | ||
const result = await printify.orders.submit(data); | ||
console.log(result); // { "id": "5a96f649b2439217d070f507" } | ||
} catch (error) { | ||
console.error('Error submitting order:', error); | ||
} | ||
})(); | ||
@@ -44,0 +62,0 @@ ``` |
97486
83