printify-api
Version:
Printify's REST API allows your application to manage a Printify shop on behalf of a Printify Merchant. Create products, submit orders, and more...
1 lines • 3.23 kB
JavaScript
module.exports=function(t){var o={};function s(i){if(o[i])return o[i].exports;var n=o[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,s),n.l=!0,n.exports}return s.m=t,s.c=o,s.d=function(t,o,i){s.o(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,o){if(1&o&&(t=s(t)),8&o)return t;if(4&o&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&o&&"string"!=typeof t)for(var n in t)s.d(i,n,function(o){return t[o]}.bind(null,n));return i},s.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(o,"a",o),o},s.o=function(t,o){return Object.prototype.hasOwnProperty.call(t,o)},s.p="",s(s.s=0)}([function(t,o,s){"use strict";var i=s(1),n=s(2),e=s(3).EventEmitter,r=s(4),u=s(5),p=s(6);function a(t){e.call(this),this.opts=Object.assign({version:"v1",access_token:"",shop_id:""},t||{}),this.baseURL=["https://api.printify.com",this.opts.version].join("/"),this.axios=n.create({baseURL:this.baseURL,headers:{Authorization:"Bearer "+this.opts.access_token}}),this.axios.interceptors.response.use((function(t){return t&&t.data?t.data:null}),(function(t){return console.log(i.inspect(t)),Promise.reject(t&&t.response?t.response.data:t)})),this.Product=new r(this.axios,this.opts.shop_id),this.Order=new p(this.axios,this.opts.shop_id),this.Webhook=new u(this.axios,this.opts.shop_id)}a.prototype={shops:function(){return this.axios.get("shops.json")},catalogues:function(){return this.axios.get("catalog/blueprints.json")},catalog:function(t){return this.axios.get(`catalog/blueprints/${t}.json`)},providers:function(t){return t?this.axios.get(`catalog/blueprints/${t}/print_providers.json`):this.axios.get("catalog/print_providers.json")},provider:function(t){return this.axios.get(`catalog/print_providers/${t}.json`)},variants:function(t,o){return this.axios.get(`catalog/blueprints/${t}/print_providers/${o}/variants.json`)},shipping:function(t,o){return this.axios.get(`catalog/blueprints/${t}/print_providers/${o}/shipping.json`)},upload:function(t){return this.axios.post("uploads/images.json",t)}},i.inherits(a,e),t.exports=a},function(t,o){t.exports=require("util")},function(t,o){t.exports=require("axios")},function(t,o){t.exports=require("events")},function(t,o){},function(t,o){},function(t,o){var s=function(t,o){this.axios=t,this.shop_id=o};s.prototype={id:function(t){return t||this.shop_id},fetch:function(t){return t=this.id(t),this.axios.get(`shops/${t}/orders.json`)},lists:function(t){return this.fetch(t)},info:function(t,o){return o=this.id(o),this.axios.get(`shops/${o}/orders/${t}.json`)},create:function(t,o){return o=this.id(o),this.axios.post(`shops/${o}/orders.json`,t)},send_to_production:function(t,o){return o=this.id(o),this.axios.post(`shops/${o}/orders/${t}/send_to_production.json`)},publish:function(t,o){return this.send_to_production(t,o)},shipping_cost:function(t,o){return o=this.id(o),this.axios.post(`shops/${o}/orders/shipping.json`,t)}},t.exports=s}]);