Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tayeh.js

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tayeh.js - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

dist/index.js

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

function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("axios")),n=t(require("querystringify")),i=require("dotenv");function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var c=function(){function t(t){if(this.API_KEY=t.api_key,this.API_SECRET=t.api_secret,this.basePath=t.api_url,this.authPath=t.auth_url,this.mediaPath=t.media_url,this.instance_id=t.instance_id,"string"!=typeof this.API_KEY||"string"!=typeof this.API_SECRET)throw new Error("You should define TAYEH_API_KEY & TAYEH_API_SECRET in your environment variables.")}var n=t.prototype;return n.get_token=function(){try{var t=this;return Promise.resolve(function(e,n){try{var i=Promise.resolve(t.get_auth("api/token",{auth:{username:t.API_KEY,password:t.API_SECRET}})).then(function(e){return t.API_ACCESS=e.data.access_token,!0})}catch(t){return n(t)}return i&&i.then?i.then(void 0,n):i}(0,function(t){throw new Error(t)}))}catch(t){return Promise.reject(t)}},n.set_token=function(t){this.API_ACCESS=t},n.delete=function(t,n){try{var i=this.basePath+t,s=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(e.delete(i,s))}catch(t){return Promise.reject(t)}},n.get=function(t,n){try{var i=this.basePath+t,s=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(e.get(i,s))}catch(t){return Promise.reject(t)}},n.get_auth=function(t,n){try{var i=this.authPath+t,s=r({headers:r({},{"Content-type":"application/json"})},n);return Promise.resolve(e.get(i,s))}catch(t){return Promise.reject(t)}},n.post=function(t,n,i){void 0===n&&(n={});try{var s=this.basePath+t,c=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},i);return Promise.resolve(e.post(s,n,c))}catch(t){return Promise.reject(t)}},n.post_media=function(t,n,i){void 0===n&&(n={});try{var s=this.mediaPath+t,c=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},i);return Promise.resolve(e.post(s,n,c))}catch(t){return Promise.reject(t)}},n.put=function(t,n,i){void 0===n&&(n={});try{var s=this.basePath+t,c=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},i);return Promise.resolve(e.put(s,n,c))}catch(t){return Promise.reject(t)}},n.post_auth=function(t,n,i){void 0===n&&(n={});try{var s=this.authPath+t,c=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},i);return Promise.resolve(e.post(s,n,c))}catch(t){return Promise.reject(t)}},t}(),o=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var n=e.prototype;return n.getMedia=function(t){return this.get("media/get/"+t)},n.uploadMedia=function(t){return this.post_media("image",t)},e}(c),a=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getInstance=function(){return this.get("instance/"+this.instance_id)},i.createInstance=function(t){return this.post("instance/instance",t)},i.updateInstance=function(t){return this.post("instance/instance/update",t)},i.getInstancePage=function(t,e){var i="instance/page/"+t;return e&&(i+=n.stringify(e,"?")),this.get(i)},i.getProducts=function(t){var e="instance/"+this.instance_id+"/products";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.createInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product",t)},i.deleteInstanceProduct=function(t){return this.delete("instance/"+this.instance_id+"/product/"+t)},i.updateInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product/update",t)},i.getInstanceTransactions=function(){return this.get("instance/"+this.instance_id+"/transactions")},i.findInstanceTransactions=function(t){var e="instance/"+this.instance_id+"/transactions/open";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getProductTransactions=function(t){return this.get("instance/"+this.instance_id+"/transactions/product/"+t)},i.deleteInstanceTransaction=function(t){return this.delete("instance/"+this.instance_id+"/transaction/"+t)},i.createInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction",t)},i.updateInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction/update",t)},i.getInstanceInvoices=function(t){var e="instance/"+this.instance_id+"/invoices";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceInvoice=function(t){return this.get("instance/"+this.instance_id+"/invoice/"+t)},i.deleteInstanceInvoice=function(t){return this.delete("instance/"+this.instance_id+"/invoice/"+t)},i.createInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice",t)},i.updateInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice/update",t)},i.getInstanceSeries=function(t){var e="instance/"+this.instance_id+"/series";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceTotal=function(t){var e="instance/"+this.instance_id+"/total/monthly";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceRevenue=function(t){var e="instance/"+this.instance_id+"/revenue";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceCustomers=function(t){var e="instance/"+this.instance_id+"/customers";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceCustomer=function(t){return this.get("instance/"+this.instance_id+"/customer/"+t)},i.deleteInstanceCustomer=function(t){return this.delete("instance/"+this.instance_id+"/customer/"+t)},i.createInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer",t)},i.updateInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer/update",t)},i.getInstanceUsers=function(t){var e="instance/"+this.instance_id+"/users";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceUser=function(t){return this.get("instance/"+this.instance_id+"/user/"+t)},i.deleteInstanceUser=function(t){return this.delete("instance/"+this.instance_id+"/user/"+t)},i.createInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user",t)},i.updateInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user/update",t)},i.getInstanceAddresses=function(t){var e="instance/"+this.instance_id+"/addresses";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.deleteInstanceAddress=function(t){return this.delete("instance/"+this.instance_id+"/address/"+t)},i.createInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address",t)},i.updateInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address/update",t)},i.getCategories=function(t){var e="instance/"+this.instance_id+"/categories";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getBanners=function(t){var e="instance/"+this.instance_id+"/banners";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getSearchFilters=function(t){var e="instance/"+this.instance_id+"/search-filters";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.sendInviteSms=function(t){return this.post("instance/"+this.instance_id+"/invite-sms",t)},i.getTopKeywords=function(t){var e="instance/"+this.instance_id+"/top-search-keywords";return t&&(e+=n.stringify(t,"?")),this.post(e,t)},e}(c),u=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getUserMe=function(){return this.get("user/me")},i.getInstancePrimary=function(){return this.get("user/instance/primary")},i.setInstancePrimary=function(t){var e="user/instance/primary";return e+=n.stringify(t,"?"),this.post(e)},i.getUserInstances=function(t){return t&&n.stringify(t,"?"),this.get("user/instances")},e}(c),h=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getPassword=function(t){return this.post_auth("customer/login",{username:t,instance:this.instance_id})},i.customerVerify=function(t,e){return this.post_auth("customer/verify",{username:t,password:e,instance:this.instance_id})},i.getCustomerMe=function(){return this.get("customer/me")},i.getCustomer=function(){return this.get("customer")},i.updateCustomer=function(t){return this.post("customer",t)},i.addProductToCart=function(t){return this.put("customer/cart",t)},i.toggleProductFavorite=function(t){return this.post("customer/favorite-product",t)},i.getCustomerCart=function(){return this.get("customer/cart")},i.updateCartItem=function(t){return this.post("customer/cart",t)},i.deleteCartItem=function(t){return this.delete("customer/cart/"+t)},i.getNotifications=function(t){var e="customer/notifications";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getFavorites=function(t){var e="customer/favorite-products";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getAddresses=function(){return this.get("customer/addresses")},i.createAddress=function(t){return this.put("customer/address",t)},i.updateAddress=function(t){return this.post("customer/address",t)},i.deleteAddress=function(t){return this.delete("customer/address/"+t)},e}(c),d=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var n=e.prototype;return n.sendSms=function(t){return this.post("crm/"+this.instance_id+"/send/normal",t)},n.sendTypedSms=function(t,e){return this.post("crm/"+this.instance_id+"/send/typed/"+t,e)},e}(c),p=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getProduct=function(t){return this.get("product/"+t)},i.getProductFeatures=function(t){return this.get("product/"+t+"/features")},i.getSimilarProducts=function(t){return this.get("product/"+t+"/similar-products")},i.getProductChoices=function(t){return this.get("product/"+t+"/choices")},i.getProductReviews=function(t,e){var i="product/"+t+"/reviews";return e&&(i+=n.stringify(e,"?")),this.get(i)},i.getRatingOptions=function(t){return this.get("product/"+t+"/rating-options")},i.sendNewReview=function(t,e){return this.put("product/"+t+"/review",e)},i.reportReview=function(t,e){return this.post("product/"+t+"/review/"+e+"/report")},e}(c),f=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getCountries=function(t){var e="countries";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getIranProvinces=function(t){var e="countries/IR/states";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getStateCities=function(t,e){var i="countries/IR/states/"+t+"/cities";return e&&(i+=n.stringify(e,"?")),this.get(i)},e}(c);i.config();var g,v=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(c);g=v,[a,u,o,h,d,p,f].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(g.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),module.exports=v;
function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("axios")),n=t(require("querystringify")),i=require("dotenv");function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var o=function(){function t(t){if(this.API_KEY=t.api_key,this.API_SECRET=t.api_secret,this.basePath=t.api_url,this.authPath=t.auth_url,this.mediaPath=t.media_url,this.instance_id=t.instance_id,"string"!=typeof this.API_KEY||"string"!=typeof this.API_SECRET)throw new Error("You should define TAYEH_API_KEY & TAYEH_API_SECRET in your environment variables.")}var n=t.prototype;return n.get_token=function(){try{var t=this;return Promise.resolve(function(e,n){try{var i=Promise.resolve(t.get_auth("api/token",{auth:{username:t.API_KEY,password:t.API_SECRET}})).then(function(e){return t.API_ACCESS=e.data.access_token,!0})}catch(t){return n(t)}return i&&i.then?i.then(void 0,n):i}(0,function(t){throw new Error(t)}))}catch(t){return Promise.reject(t)}},n.set_token=function(t){this.API_ACCESS=t},n.delete=function(t,n){try{var i=this.basePath+t,s=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(e.delete(i,s))}catch(t){return Promise.reject(t)}},n.get=function(t,n){try{var i=this.basePath+t,s=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(e.get(i,s))}catch(t){return Promise.reject(t)}},n.get_auth=function(t,n){try{var i=this.authPath+t,s=r({headers:r({},{"Content-type":"application/json"})},n);return Promise.resolve(e.get(i,s))}catch(t){return Promise.reject(t)}},n.post=function(t,n,i){void 0===n&&(n={});try{var s=this.basePath+t,o=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},i);return Promise.resolve(e.post(s,n,o))}catch(t){return Promise.reject(t)}},n.post_media=function(t,n,i){void 0===n&&(n={});try{var s=this.mediaPath+t,o=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},i);return Promise.resolve(e.post(s,n,o))}catch(t){return Promise.reject(t)}},n.put=function(t,n,i){void 0===n&&(n={});try{var s=this.basePath+t,o=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},i);return Promise.resolve(e.put(s,n,o))}catch(t){return Promise.reject(t)}},n.post_auth=function(t,n,i){void 0===n&&(n={});try{var s=this.authPath+t,o=r({headers:r({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},i);return Promise.resolve(e.post(s,n,o))}catch(t){return Promise.reject(t)}},t}(),c=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var n=e.prototype;return n.getMedia=function(t){return this.get("media/get/"+t)},n.uploadMedia=function(t){return this.post_media("image",t)},e}(o),a=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getInstance=function(){return this.get("instance/"+this.instance_id)},i.createInstance=function(t){return this.post("instance/instance",t)},i.updateInstance=function(t){return this.post("instance/instance/update",t)},i.getInstancePage=function(t,e){var i="instance/page/"+t;return e&&(i+=n.stringify(e,"?")),this.get(i)},i.getProducts=function(t){var e="instance/"+this.instance_id+"/products";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.createInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product",t)},i.deleteInstanceProduct=function(t){return this.delete("instance/"+this.instance_id+"/product/"+t)},i.updateInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product/update",t)},i.getInstanceTransactions=function(){return this.get("instance/"+this.instance_id+"/transactions")},i.findInstanceTransactions=function(t){var e="instance/"+this.instance_id+"/transactions/open";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getProductTransactions=function(t){return this.get("instance/"+this.instance_id+"/transactions/product/"+t)},i.deleteInstanceTransaction=function(t){return this.delete("instance/"+this.instance_id+"/transaction/"+t)},i.createInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction",t)},i.updateInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction/update",t)},i.getInstanceInvoices=function(t){var e="instance/"+this.instance_id+"/invoices";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceInvoice=function(t){return this.get("instance/"+this.instance_id+"/invoice/"+t)},i.deleteInstanceInvoice=function(t){return this.delete("instance/"+this.instance_id+"/invoice/"+t)},i.createInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice",t)},i.updateInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice/update",t)},i.getInstanceSeries=function(t){var e="instance/"+this.instance_id+"/series";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceTotal=function(t){var e="instance/"+this.instance_id+"/total/monthly";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceRevenue=function(t){var e="instance/"+this.instance_id+"/revenue";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceCustomers=function(t){var e="instance/"+this.instance_id+"/customers";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceCustomer=function(t){return this.get("instance/"+this.instance_id+"/customer/"+t)},i.deleteInstanceCustomer=function(t){return this.delete("instance/"+this.instance_id+"/customer/"+t)},i.createInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer",t)},i.updateInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer/update",t)},i.getInstanceUsers=function(t){var e="instance/"+this.instance_id+"/users";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceUser=function(t){return this.get("instance/"+this.instance_id+"/user/"+t)},i.deleteInstanceUser=function(t){return this.delete("instance/"+this.instance_id+"/user/"+t)},i.createInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user",t)},i.updateInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user/update",t)},i.getInstanceAddresses=function(t){var e="instance/"+this.instance_id+"/addresses";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.deleteInstanceAddress=function(t){return this.delete("instance/"+this.instance_id+"/address/"+t)},i.createInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address",t)},i.updateInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address/update",t)},i.getCategories=function(t){var e="instance/"+this.instance_id+"/categories";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getBanners=function(t){var e="instance/"+this.instance_id+"/banners";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getSearchFilters=function(t){var e="instance/"+this.instance_id+"/search-filters";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.sendInviteSms=function(t){return this.post("instance/"+this.instance_id+"/invite-sms",t)},i.getTopKeywords=function(t){var e="instance/"+this.instance_id+"/top-search-keywords";return t&&(e+=n.stringify(t,"?")),this.post(e,t)},e}(o),u=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getUserMe=function(){return this.get("user/me")},i.getInstancePrimary=function(){return this.get("user/instance/primary")},i.setInstancePrimary=function(t){var e="user/instance/primary";return e+=n.stringify(t,"?"),this.post(e)},i.getUserInstances=function(t){return t&&n.stringify(t,"?"),this.get("user/instances")},e}(o),h=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getPassword=function(t){return this.post_auth("customer/login",{username:t,instance:this.instance_id})},i.customerVerify=function(t,e){return this.post_auth("customer/verify",{username:t,password:e,instance:this.instance_id})},i.getCustomerMe=function(){return this.get("customer/me")},i.getCustomer=function(){return this.get("customer")},i.updateCustomer=function(t){return this.post("customer",t)},i.addProductToCart=function(t){return this.put("customer/cart",t)},i.toggleProductFavorite=function(t){return this.post("customer/favorite-product",t)},i.getCustomerCart=function(){return this.get("customer/cart")},i.updateCartItem=function(t){return this.post("customer/cart",t)},i.deleteCartItem=function(t){return this.delete("customer/cart/"+t)},i.getNotifications=function(t){var e="customer/notifications";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getFavorites=function(t){var e="customer/favorite-products";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getAddresses=function(){return this.get("customer/addresses")},i.createAddress=function(t){return this.put("customer/address",t)},i.updateAddress=function(t){return this.post("customer/address",t)},i.deleteAddress=function(t){return this.delete("customer/address/"+t)},i.setCartDelivery=function(t){return this.post("customer/cart/delivery",{address:t})},i.setAvatar=function(t){return this.post("customer/avatar",{avatar_id:t})},i.getInvoicesHistory=function(t){var e="customer/cart/history";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInvoice=function(t){return this.get("customer/invoice/"+t)},i.getCustomerCredit=function(){return this.get("customer/credit")},e}(o),d=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var n=e.prototype;return n.sendSms=function(t){return this.post("crm/"+this.instance_id+"/send/normal",t)},n.sendTypedSms=function(t,e){return this.post("crm/"+this.instance_id+"/send/typed/"+t,e)},e}(o),p=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getProduct=function(t){return this.get("product/"+t)},i.getProductFeatures=function(t){return this.get("product/"+t+"/features")},i.getSimilarProducts=function(t){return this.get("product/"+t+"/similar-products")},i.getProductChoices=function(t){return this.get("product/"+t+"/choices")},i.getProductReviews=function(t,e){var i="product/"+t+"/reviews";return e&&(i+=n.stringify(e,"?")),this.get(i)},i.getRatingOptions=function(t){return this.get("product/"+t+"/rating-options")},i.sendNewReview=function(t,e){return this.put("product/"+t+"/review",e)},i.reportReview=function(t,e){return this.post("product/"+t+"/review/"+e+"/report")},e}(o),f=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.getCountries=function(t){var e="countries";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getIranProvinces=function(t){var e="countries/IR/states";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getStateCities=function(t,e){var i="countries/IR/states/"+t+"/cities";return e&&(i+=n.stringify(e,"?")),this.get(i)},e}(o);i.config();var g,v=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(o);g=v,[a,u,c,h,d,p,f].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(g.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),module.exports=v;
//# sourceMappingURL=index.js.map

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

import t from"axios";import e from"querystringify";import{config as s}from"dotenv";class n{constructor(t){if(this.API_KEY=t.api_key,this.API_SECRET=t.api_secret,this.basePath=t.api_url,this.authPath=t.auth_url,this.mediaPath=t.media_url,this.instance_id=t.instance_id,"string"!=typeof this.API_KEY||"string"!=typeof this.API_SECRET)throw new Error("You should define TAYEH_API_KEY & TAYEH_API_SECRET in your environment variables.")}async get_token(){try{const{access_token:t}=(await this.get_auth("api/token",{auth:{username:this.API_KEY,password:this.API_SECRET}})).data;return this.API_ACCESS=t,!0}catch(t){throw new Error(t)}}set_token(t){this.API_ACCESS=t}async delete(e,s){const n=this.basePath+e,i={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...s};return await t.delete(n,i)}async get(e,s){const n=this.basePath+e,i={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...s};return await t.get(n,i)}async get_auth(e,s){const n=this.authPath+e,i={headers:{"Content-type":"application/json"},...s};return await t.get(n,i)}async post(e,s={},n){const i=this.basePath+e,r={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...n};return await t.post(i,s,r)}async post_media(e,s={},n){const i=this.mediaPath+e,r={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...n};return await t.post(i,s,r)}async put(e,s={},n){const i=this.basePath+e,r={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...n};return await t.put(i,s,r)}async post_auth(e,s={},n){const i=this.authPath+e,r={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...n};return await t.post(i,s,r)}}s();class i extends n{}var r;r=i,[class extends n{getInstance(){return this.get("instance/"+this.instance_id)}createInstance(t){return this.post("instance/instance",t)}updateInstance(t){return this.post("instance/instance/update",t)}getInstancePage(t,s){let n="instance/page/"+t;return s&&(n+=e.stringify(s,"?")),this.get(n)}getProducts(t){let s=`instance/${this.instance_id}/products`;return t&&(s+=e.stringify(t,"?")),this.get(s)}createInstanceProduct(t){return this.post(`instance/${this.instance_id}/product`,t)}deleteInstanceProduct(t){return this.delete(`instance/${this.instance_id}/product/${t}`)}updateInstanceProduct(t){return this.post(`instance/${this.instance_id}/product/update`,t)}getInstanceTransactions(){return this.get(`instance/${this.instance_id}/transactions`)}findInstanceTransactions(t){let s=`instance/${this.instance_id}/transactions/open`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getProductTransactions(t){return this.get(`instance/${this.instance_id}/transactions/product/${t}`)}deleteInstanceTransaction(t){return this.delete(`instance/${this.instance_id}/transaction/${t}`)}createInstanceTransaction(t){return this.post(`instance/${this.instance_id}/transaction`,t)}updateInstanceTransaction(t){return this.post(`instance/${this.instance_id}/transaction/update`,t)}getInstanceInvoices(t){let s=`instance/${this.instance_id}/invoices`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceInvoice(t){return this.get(`instance/${this.instance_id}/invoice/${t}`)}deleteInstanceInvoice(t){return this.delete(`instance/${this.instance_id}/invoice/${t}`)}createInstanceInvoice(t){return this.post(`instance/${this.instance_id}/invoice`,t)}updateInstanceInvoice(t){return this.post(`instance/${this.instance_id}/invoice/update`,t)}getInstanceSeries(t){let s=`instance/${this.instance_id}/series`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceTotal(t){let s=`instance/${this.instance_id}/total/monthly`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceRevenue(t){let s=`instance/${this.instance_id}/revenue`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceCustomers(t){let s=`instance/${this.instance_id}/customers`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceCustomer(t){return this.get(`instance/${this.instance_id}/customer/${t}`)}deleteInstanceCustomer(t){return this.delete(`instance/${this.instance_id}/customer/${t}`)}createInstanceCustomer(t){return this.post(`instance/${this.instance_id}/customer`,t)}updateInstanceCustomer(t){return this.post(`instance/${this.instance_id}/customer/update`,t)}getInstanceUsers(t){let s=`instance/${this.instance_id}/users`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceUser(t){return this.get(`instance/${this.instance_id}/user/${t}`)}deleteInstanceUser(t){return this.delete(`instance/${this.instance_id}/user/${t}`)}createInstanceUser(t){return this.post(`instance/${this.instance_id}/user`,t)}updateInstanceUser(t){return this.post(`instance/${this.instance_id}/user/update`,t)}getInstanceAddresses(t){let s=`instance/${this.instance_id}/addresses`;return t&&(s+=e.stringify(t,"?")),this.get(s)}deleteInstanceAddress(t){return this.delete(`instance/${this.instance_id}/address/${t}`)}createInstanceAddress(t){return this.post(`instance/${this.instance_id}/address`,t)}updateInstanceAddress(t){return this.post(`instance/${this.instance_id}/address/update`,t)}getCategories(t){let s=`instance/${this.instance_id}/categories`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getBanners(t){let s=`instance/${this.instance_id}/banners`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getSearchFilters(t){let s=`instance/${this.instance_id}/search-filters`;return t&&(s+=e.stringify(t,"?")),this.get(s)}sendInviteSms(t){return this.post(`instance/${this.instance_id}/invite-sms`,t)}getTopKeywords(t){let s=`instance/${this.instance_id}/top-search-keywords`;return t&&(s+=e.stringify(t,"?")),this.post(s,t)}},class extends n{getUserMe(){return this.get("user/me")}getInstancePrimary(){return this.get("user/instance/primary")}setInstancePrimary(t){let s="user/instance/primary";return s+=e.stringify(t,"?"),this.post(s)}getUserInstances(t){return t&&e.stringify(t,"?"),this.get("user/instances")}},class extends n{getMedia(t){return this.get("media/get/"+t)}uploadMedia(t){return this.post_media("image",t)}},class extends n{getPassword(t){return this.post_auth("customer/login",{username:t,instance:this.instance_id})}customerVerify(t,e){return this.post_auth("customer/verify",{username:t,password:e,instance:this.instance_id})}getCustomerMe(){return this.get("customer/me")}getCustomer(){return this.get("customer")}updateCustomer(t){return this.post("customer",t)}addProductToCart(t){return this.put("customer/cart",t)}toggleProductFavorite(t){return this.post("customer/favorite-product",t)}getCustomerCart(){return this.get("customer/cart")}updateCartItem(t){return this.post("customer/cart",t)}deleteCartItem(t){return this.delete("customer/cart/"+t)}getNotifications(t){let s="customer/notifications";return t&&(s+=e.stringify(t,"?")),this.get(s)}getFavorites(t){let s="customer/favorite-products";return t&&(s+=e.stringify(t,"?")),this.get(s)}getAddresses(){return this.get("customer/addresses")}createAddress(t){return this.put("customer/address",t)}updateAddress(t){return this.post("customer/address",t)}deleteAddress(t){return this.delete("customer/address/"+t)}},class extends n{sendSms(t){return this.post(`crm/${this.instance_id}/send/normal`,t)}sendTypedSms(t,e){return this.post(`crm/${this.instance_id}/send/typed/${t}`,e)}},class extends n{getProduct(t){return this.get("product/"+t)}getProductFeatures(t){return this.get(`product/${t}/features`)}getSimilarProducts(t){return this.get(`product/${t}/similar-products`)}getProductChoices(t){return this.get(`product/${t}/choices`)}getProductReviews(t,s){let n=`product/${t}/reviews`;return s&&(n+=e.stringify(s,"?")),this.get(n)}getRatingOptions(t){return this.get(`product/${t}/rating-options`)}sendNewReview(t,e){return this.put(`product/${t}/review`,e)}reportReview(t,e){return this.post(`product/${t}/review/${e}/report`)}},class extends n{getCountries(t){let s="countries";return t&&(s+=e.stringify(t,"?")),this.get(s)}getIranProvinces(t){let s="countries/IR/states";return t&&(s+=e.stringify(t,"?")),this.get(s)}getStateCities(t,s){let n=`countries/IR/states/${t}/cities`;return s&&(n+=e.stringify(s,"?")),this.get(n)}}].forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(e=>{Object.defineProperty(r.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})});export default i;
import t from"axios";import e from"querystringify";import{config as s}from"dotenv";class n{constructor(t){if(this.API_KEY=t.api_key,this.API_SECRET=t.api_secret,this.basePath=t.api_url,this.authPath=t.auth_url,this.mediaPath=t.media_url,this.instance_id=t.instance_id,"string"!=typeof this.API_KEY||"string"!=typeof this.API_SECRET)throw new Error("You should define TAYEH_API_KEY & TAYEH_API_SECRET in your environment variables.")}async get_token(){try{const{access_token:t}=(await this.get_auth("api/token",{auth:{username:this.API_KEY,password:this.API_SECRET}})).data;return this.API_ACCESS=t,!0}catch(t){throw new Error(t)}}set_token(t){this.API_ACCESS=t}async delete(e,s){const n=this.basePath+e,i={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...s};return await t.delete(n,i)}async get(e,s){const n=this.basePath+e,i={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...s};return await t.get(n,i)}async get_auth(e,s){const n=this.authPath+e,i={headers:{"Content-type":"application/json"},...s};return await t.get(n,i)}async post(e,s={},n){const i=this.basePath+e,r={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...n};return await t.post(i,s,r)}async post_media(e,s={},n){const i=this.mediaPath+e,r={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...n};return await t.post(i,s,r)}async put(e,s={},n){const i=this.basePath+e,r={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...n};return await t.put(i,s,r)}async post_auth(e,s={},n){const i=this.authPath+e,r={headers:{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"},...n};return await t.post(i,s,r)}}s();class i extends n{}var r;r=i,[class extends n{getInstance(){return this.get("instance/"+this.instance_id)}createInstance(t){return this.post("instance/instance",t)}updateInstance(t){return this.post("instance/instance/update",t)}getInstancePage(t,s){let n="instance/page/"+t;return s&&(n+=e.stringify(s,"?")),this.get(n)}getProducts(t){let s=`instance/${this.instance_id}/products`;return t&&(s+=e.stringify(t,"?")),this.get(s)}createInstanceProduct(t){return this.post(`instance/${this.instance_id}/product`,t)}deleteInstanceProduct(t){return this.delete(`instance/${this.instance_id}/product/${t}`)}updateInstanceProduct(t){return this.post(`instance/${this.instance_id}/product/update`,t)}getInstanceTransactions(){return this.get(`instance/${this.instance_id}/transactions`)}findInstanceTransactions(t){let s=`instance/${this.instance_id}/transactions/open`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getProductTransactions(t){return this.get(`instance/${this.instance_id}/transactions/product/${t}`)}deleteInstanceTransaction(t){return this.delete(`instance/${this.instance_id}/transaction/${t}`)}createInstanceTransaction(t){return this.post(`instance/${this.instance_id}/transaction`,t)}updateInstanceTransaction(t){return this.post(`instance/${this.instance_id}/transaction/update`,t)}getInstanceInvoices(t){let s=`instance/${this.instance_id}/invoices`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceInvoice(t){return this.get(`instance/${this.instance_id}/invoice/${t}`)}deleteInstanceInvoice(t){return this.delete(`instance/${this.instance_id}/invoice/${t}`)}createInstanceInvoice(t){return this.post(`instance/${this.instance_id}/invoice`,t)}updateInstanceInvoice(t){return this.post(`instance/${this.instance_id}/invoice/update`,t)}getInstanceSeries(t){let s=`instance/${this.instance_id}/series`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceTotal(t){let s=`instance/${this.instance_id}/total/monthly`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceRevenue(t){let s=`instance/${this.instance_id}/revenue`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceCustomers(t){let s=`instance/${this.instance_id}/customers`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceCustomer(t){return this.get(`instance/${this.instance_id}/customer/${t}`)}deleteInstanceCustomer(t){return this.delete(`instance/${this.instance_id}/customer/${t}`)}createInstanceCustomer(t){return this.post(`instance/${this.instance_id}/customer`,t)}updateInstanceCustomer(t){return this.post(`instance/${this.instance_id}/customer/update`,t)}getInstanceUsers(t){let s=`instance/${this.instance_id}/users`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getInstanceUser(t){return this.get(`instance/${this.instance_id}/user/${t}`)}deleteInstanceUser(t){return this.delete(`instance/${this.instance_id}/user/${t}`)}createInstanceUser(t){return this.post(`instance/${this.instance_id}/user`,t)}updateInstanceUser(t){return this.post(`instance/${this.instance_id}/user/update`,t)}getInstanceAddresses(t){let s=`instance/${this.instance_id}/addresses`;return t&&(s+=e.stringify(t,"?")),this.get(s)}deleteInstanceAddress(t){return this.delete(`instance/${this.instance_id}/address/${t}`)}createInstanceAddress(t){return this.post(`instance/${this.instance_id}/address`,t)}updateInstanceAddress(t){return this.post(`instance/${this.instance_id}/address/update`,t)}getCategories(t){let s=`instance/${this.instance_id}/categories`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getBanners(t){let s=`instance/${this.instance_id}/banners`;return t&&(s+=e.stringify(t,"?")),this.get(s)}getSearchFilters(t){let s=`instance/${this.instance_id}/search-filters`;return t&&(s+=e.stringify(t,"?")),this.get(s)}sendInviteSms(t){return this.post(`instance/${this.instance_id}/invite-sms`,t)}getTopKeywords(t){let s=`instance/${this.instance_id}/top-search-keywords`;return t&&(s+=e.stringify(t,"?")),this.post(s,t)}},class extends n{getUserMe(){return this.get("user/me")}getInstancePrimary(){return this.get("user/instance/primary")}setInstancePrimary(t){let s="user/instance/primary";return s+=e.stringify(t,"?"),this.post(s)}getUserInstances(t){return t&&e.stringify(t,"?"),this.get("user/instances")}},class extends n{getMedia(t){return this.get("media/get/"+t)}uploadMedia(t){return this.post_media("image",t)}},class extends n{getPassword(t){return this.post_auth("customer/login",{username:t,instance:this.instance_id})}customerVerify(t,e){return this.post_auth("customer/verify",{username:t,password:e,instance:this.instance_id})}getCustomerMe(){return this.get("customer/me")}getCustomer(){return this.get("customer")}updateCustomer(t){return this.post("customer",t)}addProductToCart(t){return this.put("customer/cart",t)}toggleProductFavorite(t){return this.post("customer/favorite-product",t)}getCustomerCart(){return this.get("customer/cart")}updateCartItem(t){return this.post("customer/cart",t)}deleteCartItem(t){return this.delete("customer/cart/"+t)}getNotifications(t){let s="customer/notifications";return t&&(s+=e.stringify(t,"?")),this.get(s)}getFavorites(t){let s="customer/favorite-products";return t&&(s+=e.stringify(t,"?")),this.get(s)}getAddresses(){return this.get("customer/addresses")}createAddress(t){return this.put("customer/address",t)}updateAddress(t){return this.post("customer/address",t)}deleteAddress(t){return this.delete("customer/address/"+t)}setCartDelivery(t){return this.post("customer/cart/delivery",{address:t})}setAvatar(t){return this.post("customer/avatar",{avatar_id:t})}getInvoicesHistory(t){let s="customer/cart/history";return t&&(s+=e.stringify(t,"?")),this.get(s)}getInvoice(t){return this.get("customer/invoice/"+t)}getCustomerCredit(){return this.get("customer/credit")}},class extends n{sendSms(t){return this.post(`crm/${this.instance_id}/send/normal`,t)}sendTypedSms(t,e){return this.post(`crm/${this.instance_id}/send/typed/${t}`,e)}},class extends n{getProduct(t){return this.get("product/"+t)}getProductFeatures(t){return this.get(`product/${t}/features`)}getSimilarProducts(t){return this.get(`product/${t}/similar-products`)}getProductChoices(t){return this.get(`product/${t}/choices`)}getProductReviews(t,s){let n=`product/${t}/reviews`;return s&&(n+=e.stringify(s,"?")),this.get(n)}getRatingOptions(t){return this.get(`product/${t}/rating-options`)}sendNewReview(t,e){return this.put(`product/${t}/review`,e)}reportReview(t,e){return this.post(`product/${t}/review/${e}/report`)}},class extends n{getCountries(t){let s="countries";return t&&(s+=e.stringify(t,"?")),this.get(s)}getIranProvinces(t){let s="countries/IR/states";return t&&(s+=e.stringify(t,"?")),this.get(s)}getStateCities(t,s){let n=`countries/IR/states/${t}/cities`;return s&&(n+=e.stringify(s,"?")),this.get(n)}}].forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(e=>{Object.defineProperty(r.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})});export default i;
//# sourceMappingURL=index.modern.js.map

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

import t from"axios";import n from"querystringify";import{config as e}from"dotenv";function i(){return(i=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t}).apply(this,arguments)}function r(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}var s=function(){function n(t){if(this.API_KEY=t.api_key,this.API_SECRET=t.api_secret,this.basePath=t.api_url,this.authPath=t.auth_url,this.mediaPath=t.media_url,this.instance_id=t.instance_id,"string"!=typeof this.API_KEY||"string"!=typeof this.API_SECRET)throw new Error("You should define TAYEH_API_KEY & TAYEH_API_SECRET in your environment variables.")}var e=n.prototype;return e.get_token=function(){try{var t=this;return Promise.resolve(function(n,e){try{var i=Promise.resolve(t.get_auth("api/token",{auth:{username:t.API_KEY,password:t.API_SECRET}})).then(function(n){return t.API_ACCESS=n.data.access_token,!0})}catch(t){return e(t)}return i&&i.then?i.then(void 0,e):i}(0,function(t){throw new Error(t)}))}catch(t){return Promise.reject(t)}},e.set_token=function(t){this.API_ACCESS=t},e.delete=function(n,e){try{var r=this.basePath+n,s=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},e);return Promise.resolve(t.delete(r,s))}catch(t){return Promise.reject(t)}},e.get=function(n,e){try{var r=this.basePath+n,s=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},e);return Promise.resolve(t.get(r,s))}catch(t){return Promise.reject(t)}},e.get_auth=function(n,e){try{var r=this.authPath+n,s=i({headers:i({},{"Content-type":"application/json"})},e);return Promise.resolve(t.get(r,s))}catch(t){return Promise.reject(t)}},e.post=function(n,e,r){void 0===e&&(e={});try{var s=this.basePath+n,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,e,o))}catch(t){return Promise.reject(t)}},e.post_media=function(n,e,r){void 0===e&&(e={});try{var s=this.mediaPath+n,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,e,o))}catch(t){return Promise.reject(t)}},e.put=function(n,e,r){void 0===e&&(e={});try{var s=this.basePath+n,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.put(s,e,o))}catch(t){return Promise.reject(t)}},e.post_auth=function(n,e,r){void 0===e&&(e={});try{var s=this.authPath+n,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,e,o))}catch(t){return Promise.reject(t)}},n}(),o=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var e=n.prototype;return e.getMedia=function(t){return this.get("media/get/"+t)},e.uploadMedia=function(t){return this.post_media("image",t)},n}(s),c=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var i=e.prototype;return i.getInstance=function(){return this.get("instance/"+this.instance_id)},i.createInstance=function(t){return this.post("instance/instance",t)},i.updateInstance=function(t){return this.post("instance/instance/update",t)},i.getInstancePage=function(t,e){var i="instance/page/"+t;return e&&(i+=n.stringify(e,"?")),this.get(i)},i.getProducts=function(t){var e="instance/"+this.instance_id+"/products";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.createInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product",t)},i.deleteInstanceProduct=function(t){return this.delete("instance/"+this.instance_id+"/product/"+t)},i.updateInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product/update",t)},i.getInstanceTransactions=function(){return this.get("instance/"+this.instance_id+"/transactions")},i.findInstanceTransactions=function(t){var e="instance/"+this.instance_id+"/transactions/open";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getProductTransactions=function(t){return this.get("instance/"+this.instance_id+"/transactions/product/"+t)},i.deleteInstanceTransaction=function(t){return this.delete("instance/"+this.instance_id+"/transaction/"+t)},i.createInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction",t)},i.updateInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction/update",t)},i.getInstanceInvoices=function(t){var e="instance/"+this.instance_id+"/invoices";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceInvoice=function(t){return this.get("instance/"+this.instance_id+"/invoice/"+t)},i.deleteInstanceInvoice=function(t){return this.delete("instance/"+this.instance_id+"/invoice/"+t)},i.createInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice",t)},i.updateInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice/update",t)},i.getInstanceSeries=function(t){var e="instance/"+this.instance_id+"/series";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceTotal=function(t){var e="instance/"+this.instance_id+"/total/monthly";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceRevenue=function(t){var e="instance/"+this.instance_id+"/revenue";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceCustomers=function(t){var e="instance/"+this.instance_id+"/customers";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceCustomer=function(t){return this.get("instance/"+this.instance_id+"/customer/"+t)},i.deleteInstanceCustomer=function(t){return this.delete("instance/"+this.instance_id+"/customer/"+t)},i.createInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer",t)},i.updateInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer/update",t)},i.getInstanceUsers=function(t){var e="instance/"+this.instance_id+"/users";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getInstanceUser=function(t){return this.get("instance/"+this.instance_id+"/user/"+t)},i.deleteInstanceUser=function(t){return this.delete("instance/"+this.instance_id+"/user/"+t)},i.createInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user",t)},i.updateInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user/update",t)},i.getInstanceAddresses=function(t){var e="instance/"+this.instance_id+"/addresses";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.deleteInstanceAddress=function(t){return this.delete("instance/"+this.instance_id+"/address/"+t)},i.createInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address",t)},i.updateInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address/update",t)},i.getCategories=function(t){var e="instance/"+this.instance_id+"/categories";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getBanners=function(t){var e="instance/"+this.instance_id+"/banners";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getSearchFilters=function(t){var e="instance/"+this.instance_id+"/search-filters";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.sendInviteSms=function(t){return this.post("instance/"+this.instance_id+"/invite-sms",t)},i.getTopKeywords=function(t){var e="instance/"+this.instance_id+"/top-search-keywords";return t&&(e+=n.stringify(t,"?")),this.post(e,t)},e}(s),a=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var i=e.prototype;return i.getUserMe=function(){return this.get("user/me")},i.getInstancePrimary=function(){return this.get("user/instance/primary")},i.setInstancePrimary=function(t){var e="user/instance/primary";return e+=n.stringify(t,"?"),this.post(e)},i.getUserInstances=function(t){return t&&n.stringify(t,"?"),this.get("user/instances")},e}(s),u=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var i=e.prototype;return i.getPassword=function(t){return this.post_auth("customer/login",{username:t,instance:this.instance_id})},i.customerVerify=function(t,n){return this.post_auth("customer/verify",{username:t,password:n,instance:this.instance_id})},i.getCustomerMe=function(){return this.get("customer/me")},i.getCustomer=function(){return this.get("customer")},i.updateCustomer=function(t){return this.post("customer",t)},i.addProductToCart=function(t){return this.put("customer/cart",t)},i.toggleProductFavorite=function(t){return this.post("customer/favorite-product",t)},i.getCustomerCart=function(){return this.get("customer/cart")},i.updateCartItem=function(t){return this.post("customer/cart",t)},i.deleteCartItem=function(t){return this.delete("customer/cart/"+t)},i.getNotifications=function(t){var e="customer/notifications";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getFavorites=function(t){var e="customer/favorite-products";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getAddresses=function(){return this.get("customer/addresses")},i.createAddress=function(t){return this.put("customer/address",t)},i.updateAddress=function(t){return this.post("customer/address",t)},i.deleteAddress=function(t){return this.delete("customer/address/"+t)},e}(s),h=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var e=n.prototype;return e.sendSms=function(t){return this.post("crm/"+this.instance_id+"/send/normal",t)},e.sendTypedSms=function(t,n){return this.post("crm/"+this.instance_id+"/send/typed/"+t,n)},n}(s),d=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var i=e.prototype;return i.getProduct=function(t){return this.get("product/"+t)},i.getProductFeatures=function(t){return this.get("product/"+t+"/features")},i.getSimilarProducts=function(t){return this.get("product/"+t+"/similar-products")},i.getProductChoices=function(t){return this.get("product/"+t+"/choices")},i.getProductReviews=function(t,e){var i="product/"+t+"/reviews";return e&&(i+=n.stringify(e,"?")),this.get(i)},i.getRatingOptions=function(t){return this.get("product/"+t+"/rating-options")},i.sendNewReview=function(t,n){return this.put("product/"+t+"/review",n)},i.reportReview=function(t,n){return this.post("product/"+t+"/review/"+n+"/report")},e}(s),p=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var i=e.prototype;return i.getCountries=function(t){var e="countries";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getIranProvinces=function(t){var e="countries/IR/states";return t&&(e+=n.stringify(t,"?")),this.get(e)},i.getStateCities=function(t,e){var i="countries/IR/states/"+t+"/cities";return e&&(i+=n.stringify(e,"?")),this.get(i)},e}(s);e();var f,g=function(t){function n(){return t.apply(this,arguments)||this}return r(n,t),n}(s);f=g,[c,a,o,u,h,d,p].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(n){Object.defineProperty(f.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))})});export default g;
import t from"axios";import e from"querystringify";import{config as n}from"dotenv";function i(){return(i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var s=function(){function e(t){if(this.API_KEY=t.api_key,this.API_SECRET=t.api_secret,this.basePath=t.api_url,this.authPath=t.auth_url,this.mediaPath=t.media_url,this.instance_id=t.instance_id,"string"!=typeof this.API_KEY||"string"!=typeof this.API_SECRET)throw new Error("You should define TAYEH_API_KEY & TAYEH_API_SECRET in your environment variables.")}var n=e.prototype;return n.get_token=function(){try{var t=this;return Promise.resolve(function(e,n){try{var i=Promise.resolve(t.get_auth("api/token",{auth:{username:t.API_KEY,password:t.API_SECRET}})).then(function(e){return t.API_ACCESS=e.data.access_token,!0})}catch(t){return n(t)}return i&&i.then?i.then(void 0,n):i}(0,function(t){throw new Error(t)}))}catch(t){return Promise.reject(t)}},n.set_token=function(t){this.API_ACCESS=t},n.delete=function(e,n){try{var r=this.basePath+e,s=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(t.delete(r,s))}catch(t){return Promise.reject(t)}},n.get=function(e,n){try{var r=this.basePath+e,s=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(t.get(r,s))}catch(t){return Promise.reject(t)}},n.get_auth=function(e,n){try{var r=this.authPath+e,s=i({headers:i({},{"Content-type":"application/json"})},n);return Promise.resolve(t.get(r,s))}catch(t){return Promise.reject(t)}},n.post=function(e,n,r){void 0===n&&(n={});try{var s=this.basePath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},n.post_media=function(e,n,r){void 0===n&&(n={});try{var s=this.mediaPath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},n.put=function(e,n,r){void 0===n&&(n={});try{var s=this.basePath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.put(s,n,o))}catch(t){return Promise.reject(t)}},n.post_auth=function(e,n,r){void 0===n&&(n={});try{var s=this.authPath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},e}(),o=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.getMedia=function(t){return this.get("media/get/"+t)},n.uploadMedia=function(t){return this.post_media("image",t)},e}(s),c=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getInstance=function(){return this.get("instance/"+this.instance_id)},i.createInstance=function(t){return this.post("instance/instance",t)},i.updateInstance=function(t){return this.post("instance/instance/update",t)},i.getInstancePage=function(t,n){var i="instance/page/"+t;return n&&(i+=e.stringify(n,"?")),this.get(i)},i.getProducts=function(t){var n="instance/"+this.instance_id+"/products";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.createInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product",t)},i.deleteInstanceProduct=function(t){return this.delete("instance/"+this.instance_id+"/product/"+t)},i.updateInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product/update",t)},i.getInstanceTransactions=function(){return this.get("instance/"+this.instance_id+"/transactions")},i.findInstanceTransactions=function(t){var n="instance/"+this.instance_id+"/transactions/open";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getProductTransactions=function(t){return this.get("instance/"+this.instance_id+"/transactions/product/"+t)},i.deleteInstanceTransaction=function(t){return this.delete("instance/"+this.instance_id+"/transaction/"+t)},i.createInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction",t)},i.updateInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction/update",t)},i.getInstanceInvoices=function(t){var n="instance/"+this.instance_id+"/invoices";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceInvoice=function(t){return this.get("instance/"+this.instance_id+"/invoice/"+t)},i.deleteInstanceInvoice=function(t){return this.delete("instance/"+this.instance_id+"/invoice/"+t)},i.createInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice",t)},i.updateInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice/update",t)},i.getInstanceSeries=function(t){var n="instance/"+this.instance_id+"/series";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceTotal=function(t){var n="instance/"+this.instance_id+"/total/monthly";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceRevenue=function(t){var n="instance/"+this.instance_id+"/revenue";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceCustomers=function(t){var n="instance/"+this.instance_id+"/customers";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceCustomer=function(t){return this.get("instance/"+this.instance_id+"/customer/"+t)},i.deleteInstanceCustomer=function(t){return this.delete("instance/"+this.instance_id+"/customer/"+t)},i.createInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer",t)},i.updateInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer/update",t)},i.getInstanceUsers=function(t){var n="instance/"+this.instance_id+"/users";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceUser=function(t){return this.get("instance/"+this.instance_id+"/user/"+t)},i.deleteInstanceUser=function(t){return this.delete("instance/"+this.instance_id+"/user/"+t)},i.createInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user",t)},i.updateInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user/update",t)},i.getInstanceAddresses=function(t){var n="instance/"+this.instance_id+"/addresses";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.deleteInstanceAddress=function(t){return this.delete("instance/"+this.instance_id+"/address/"+t)},i.createInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address",t)},i.updateInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address/update",t)},i.getCategories=function(t){var n="instance/"+this.instance_id+"/categories";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getBanners=function(t){var n="instance/"+this.instance_id+"/banners";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getSearchFilters=function(t){var n="instance/"+this.instance_id+"/search-filters";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.sendInviteSms=function(t){return this.post("instance/"+this.instance_id+"/invite-sms",t)},i.getTopKeywords=function(t){var n="instance/"+this.instance_id+"/top-search-keywords";return t&&(n+=e.stringify(t,"?")),this.post(n,t)},n}(s),a=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getUserMe=function(){return this.get("user/me")},i.getInstancePrimary=function(){return this.get("user/instance/primary")},i.setInstancePrimary=function(t){var n="user/instance/primary";return n+=e.stringify(t,"?"),this.post(n)},i.getUserInstances=function(t){return t&&e.stringify(t,"?"),this.get("user/instances")},n}(s),u=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getPassword=function(t){return this.post_auth("customer/login",{username:t,instance:this.instance_id})},i.customerVerify=function(t,e){return this.post_auth("customer/verify",{username:t,password:e,instance:this.instance_id})},i.getCustomerMe=function(){return this.get("customer/me")},i.getCustomer=function(){return this.get("customer")},i.updateCustomer=function(t){return this.post("customer",t)},i.addProductToCart=function(t){return this.put("customer/cart",t)},i.toggleProductFavorite=function(t){return this.post("customer/favorite-product",t)},i.getCustomerCart=function(){return this.get("customer/cart")},i.updateCartItem=function(t){return this.post("customer/cart",t)},i.deleteCartItem=function(t){return this.delete("customer/cart/"+t)},i.getNotifications=function(t){var n="customer/notifications";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getFavorites=function(t){var n="customer/favorite-products";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getAddresses=function(){return this.get("customer/addresses")},i.createAddress=function(t){return this.put("customer/address",t)},i.updateAddress=function(t){return this.post("customer/address",t)},i.deleteAddress=function(t){return this.delete("customer/address/"+t)},i.setCartDelivery=function(t){return this.post("customer/cart/delivery",{address:t})},i.setAvatar=function(t){return this.post("customer/avatar",{avatar_id:t})},i.getInvoicesHistory=function(t){var n="customer/cart/history";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInvoice=function(t){return this.get("customer/invoice/"+t)},i.getCustomerCredit=function(){return this.get("customer/credit")},n}(s),h=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.sendSms=function(t){return this.post("crm/"+this.instance_id+"/send/normal",t)},n.sendTypedSms=function(t,e){return this.post("crm/"+this.instance_id+"/send/typed/"+t,e)},e}(s),d=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getProduct=function(t){return this.get("product/"+t)},i.getProductFeatures=function(t){return this.get("product/"+t+"/features")},i.getSimilarProducts=function(t){return this.get("product/"+t+"/similar-products")},i.getProductChoices=function(t){return this.get("product/"+t+"/choices")},i.getProductReviews=function(t,n){var i="product/"+t+"/reviews";return n&&(i+=e.stringify(n,"?")),this.get(i)},i.getRatingOptions=function(t){return this.get("product/"+t+"/rating-options")},i.sendNewReview=function(t,e){return this.put("product/"+t+"/review",e)},i.reportReview=function(t,e){return this.post("product/"+t+"/review/"+e+"/report")},n}(s),p=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getCountries=function(t){var n="countries";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getIranProvinces=function(t){var n="countries/IR/states";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getStateCities=function(t,n){var i="countries/IR/states/"+t+"/cities";return n&&(i+=e.stringify(n,"?")),this.get(i)},n}(s);n();var f,g=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(s);f=g,[c,a,o,u,h,d,p].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(f.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})});export default g;
//# sourceMappingURL=index.module.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("axios"),require("querystringify"),require("dotenv")):"function"==typeof define&&define.amd?define(["axios","querystringify","dotenv"],e):(t=t||self).tayehJs=e(t.axios,t.querystringify,t.dotenv)}(this,function(t,e,n){function i(){return(i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var s=function(){function e(t){if(this.API_KEY=t.api_key,this.API_SECRET=t.api_secret,this.basePath=t.api_url,this.authPath=t.auth_url,this.mediaPath=t.media_url,this.instance_id=t.instance_id,"string"!=typeof this.API_KEY||"string"!=typeof this.API_SECRET)throw new Error("You should define TAYEH_API_KEY & TAYEH_API_SECRET in your environment variables.")}var n=e.prototype;return n.get_token=function(){try{var t=this;return Promise.resolve(function(e,n){try{var i=Promise.resolve(t.get_auth("api/token",{auth:{username:t.API_KEY,password:t.API_SECRET}})).then(function(e){return t.API_ACCESS=e.data.access_token,!0})}catch(t){return n(t)}return i&&i.then?i.then(void 0,n):i}(0,function(t){throw new Error(t)}))}catch(t){return Promise.reject(t)}},n.set_token=function(t){this.API_ACCESS=t},n.delete=function(e,n){try{var r=this.basePath+e,s=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(t.delete(r,s))}catch(t){return Promise.reject(t)}},n.get=function(e,n){try{var r=this.basePath+e,s=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(t.get(r,s))}catch(t){return Promise.reject(t)}},n.get_auth=function(e,n){try{var r=this.authPath+e,s=i({headers:i({},{"Content-type":"application/json"})},n);return Promise.resolve(t.get(r,s))}catch(t){return Promise.reject(t)}},n.post=function(e,n,r){void 0===n&&(n={});try{var s=this.basePath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},n.post_media=function(e,n,r){void 0===n&&(n={});try{var s=this.mediaPath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},n.put=function(e,n,r){void 0===n&&(n={});try{var s=this.basePath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.put(s,n,o))}catch(t){return Promise.reject(t)}},n.post_auth=function(e,n,r){void 0===n&&(n={});try{var s=this.authPath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},e}(),o=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.getMedia=function(t){return this.get("media/get/"+t)},n.uploadMedia=function(t){return this.post_media("image",t)},e}(s),c=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getInstance=function(){return this.get("instance/"+this.instance_id)},i.createInstance=function(t){return this.post("instance/instance",t)},i.updateInstance=function(t){return this.post("instance/instance/update",t)},i.getInstancePage=function(t,n){var i="instance/page/"+t;return n&&(i+=e.stringify(n,"?")),this.get(i)},i.getProducts=function(t){var n="instance/"+this.instance_id+"/products";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.createInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product",t)},i.deleteInstanceProduct=function(t){return this.delete("instance/"+this.instance_id+"/product/"+t)},i.updateInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product/update",t)},i.getInstanceTransactions=function(){return this.get("instance/"+this.instance_id+"/transactions")},i.findInstanceTransactions=function(t){var n="instance/"+this.instance_id+"/transactions/open";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getProductTransactions=function(t){return this.get("instance/"+this.instance_id+"/transactions/product/"+t)},i.deleteInstanceTransaction=function(t){return this.delete("instance/"+this.instance_id+"/transaction/"+t)},i.createInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction",t)},i.updateInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction/update",t)},i.getInstanceInvoices=function(t){var n="instance/"+this.instance_id+"/invoices";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceInvoice=function(t){return this.get("instance/"+this.instance_id+"/invoice/"+t)},i.deleteInstanceInvoice=function(t){return this.delete("instance/"+this.instance_id+"/invoice/"+t)},i.createInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice",t)},i.updateInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice/update",t)},i.getInstanceSeries=function(t){var n="instance/"+this.instance_id+"/series";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceTotal=function(t){var n="instance/"+this.instance_id+"/total/monthly";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceRevenue=function(t){var n="instance/"+this.instance_id+"/revenue";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceCustomers=function(t){var n="instance/"+this.instance_id+"/customers";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceCustomer=function(t){return this.get("instance/"+this.instance_id+"/customer/"+t)},i.deleteInstanceCustomer=function(t){return this.delete("instance/"+this.instance_id+"/customer/"+t)},i.createInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer",t)},i.updateInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer/update",t)},i.getInstanceUsers=function(t){var n="instance/"+this.instance_id+"/users";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceUser=function(t){return this.get("instance/"+this.instance_id+"/user/"+t)},i.deleteInstanceUser=function(t){return this.delete("instance/"+this.instance_id+"/user/"+t)},i.createInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user",t)},i.updateInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user/update",t)},i.getInstanceAddresses=function(t){var n="instance/"+this.instance_id+"/addresses";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.deleteInstanceAddress=function(t){return this.delete("instance/"+this.instance_id+"/address/"+t)},i.createInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address",t)},i.updateInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address/update",t)},i.getCategories=function(t){var n="instance/"+this.instance_id+"/categories";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getBanners=function(t){var n="instance/"+this.instance_id+"/banners";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getSearchFilters=function(t){var n="instance/"+this.instance_id+"/search-filters";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.sendInviteSms=function(t){return this.post("instance/"+this.instance_id+"/invite-sms",t)},i.getTopKeywords=function(t){var n="instance/"+this.instance_id+"/top-search-keywords";return t&&(n+=e.stringify(t,"?")),this.post(n,t)},n}(s),a=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getUserMe=function(){return this.get("user/me")},i.getInstancePrimary=function(){return this.get("user/instance/primary")},i.setInstancePrimary=function(t){var n="user/instance/primary";return n+=e.stringify(t,"?"),this.post(n)},i.getUserInstances=function(t){return t&&e.stringify(t,"?"),this.get("user/instances")},n}(s),u=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getPassword=function(t){return this.post_auth("customer/login",{username:t,instance:this.instance_id})},i.customerVerify=function(t,e){return this.post_auth("customer/verify",{username:t,password:e,instance:this.instance_id})},i.getCustomerMe=function(){return this.get("customer/me")},i.getCustomer=function(){return this.get("customer")},i.updateCustomer=function(t){return this.post("customer",t)},i.addProductToCart=function(t){return this.put("customer/cart",t)},i.toggleProductFavorite=function(t){return this.post("customer/favorite-product",t)},i.getCustomerCart=function(){return this.get("customer/cart")},i.updateCartItem=function(t){return this.post("customer/cart",t)},i.deleteCartItem=function(t){return this.delete("customer/cart/"+t)},i.getNotifications=function(t){var n="customer/notifications";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getFavorites=function(t){var n="customer/favorite-products";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getAddresses=function(){return this.get("customer/addresses")},i.createAddress=function(t){return this.put("customer/address",t)},i.updateAddress=function(t){return this.post("customer/address",t)},i.deleteAddress=function(t){return this.delete("customer/address/"+t)},n}(s),h=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.sendSms=function(t){return this.post("crm/"+this.instance_id+"/send/normal",t)},n.sendTypedSms=function(t,e){return this.post("crm/"+this.instance_id+"/send/typed/"+t,e)},e}(s),d=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getProduct=function(t){return this.get("product/"+t)},i.getProductFeatures=function(t){return this.get("product/"+t+"/features")},i.getSimilarProducts=function(t){return this.get("product/"+t+"/similar-products")},i.getProductChoices=function(t){return this.get("product/"+t+"/choices")},i.getProductReviews=function(t,n){var i="product/"+t+"/reviews";return n&&(i+=e.stringify(n,"?")),this.get(i)},i.getRatingOptions=function(t){return this.get("product/"+t+"/rating-options")},i.sendNewReview=function(t,e){return this.put("product/"+t+"/review",e)},i.reportReview=function(t,e){return this.post("product/"+t+"/review/"+e+"/report")},n}(s),p=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getCountries=function(t){var n="countries";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getIranProvinces=function(t){var n="countries/IR/states";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getStateCities=function(t,n){var i="countries/IR/states/"+t+"/cities";return n&&(i+=e.stringify(n,"?")),this.get(i)},n}(s);n.config();var f,g=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(s);return f=g,[c,a,o,u,h,d,p].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(f.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),g});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("axios"),require("querystringify"),require("dotenv")):"function"==typeof define&&define.amd?define(["axios","querystringify","dotenv"],e):(t=t||self).tayehJs=e(t.axios,t.querystringify,t.dotenv)}(this,function(t,e,n){function i(){return(i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var s=function(){function e(t){if(this.API_KEY=t.api_key,this.API_SECRET=t.api_secret,this.basePath=t.api_url,this.authPath=t.auth_url,this.mediaPath=t.media_url,this.instance_id=t.instance_id,"string"!=typeof this.API_KEY||"string"!=typeof this.API_SECRET)throw new Error("You should define TAYEH_API_KEY & TAYEH_API_SECRET in your environment variables.")}var n=e.prototype;return n.get_token=function(){try{var t=this;return Promise.resolve(function(e,n){try{var i=Promise.resolve(t.get_auth("api/token",{auth:{username:t.API_KEY,password:t.API_SECRET}})).then(function(e){return t.API_ACCESS=e.data.access_token,!0})}catch(t){return n(t)}return i&&i.then?i.then(void 0,n):i}(0,function(t){throw new Error(t)}))}catch(t){return Promise.reject(t)}},n.set_token=function(t){this.API_ACCESS=t},n.delete=function(e,n){try{var r=this.basePath+e,s=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(t.delete(r,s))}catch(t){return Promise.reject(t)}},n.get=function(e,n){try{var r=this.basePath+e,s=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},n);return Promise.resolve(t.get(r,s))}catch(t){return Promise.reject(t)}},n.get_auth=function(e,n){try{var r=this.authPath+e,s=i({headers:i({},{"Content-type":"application/json"})},n);return Promise.resolve(t.get(r,s))}catch(t){return Promise.reject(t)}},n.post=function(e,n,r){void 0===n&&(n={});try{var s=this.basePath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},n.post_media=function(e,n,r){void 0===n&&(n={});try{var s=this.mediaPath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},n.put=function(e,n,r){void 0===n&&(n={});try{var s=this.basePath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.put(s,n,o))}catch(t){return Promise.reject(t)}},n.post_auth=function(e,n,r){void 0===n&&(n={});try{var s=this.authPath+e,o=i({headers:i({},{Authorization:"Bearer "+this.API_ACCESS,"Content-type":"application/json"})},r);return Promise.resolve(t.post(s,n,o))}catch(t){return Promise.reject(t)}},e}(),o=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.getMedia=function(t){return this.get("media/get/"+t)},n.uploadMedia=function(t){return this.post_media("image",t)},e}(s),c=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getInstance=function(){return this.get("instance/"+this.instance_id)},i.createInstance=function(t){return this.post("instance/instance",t)},i.updateInstance=function(t){return this.post("instance/instance/update",t)},i.getInstancePage=function(t,n){var i="instance/page/"+t;return n&&(i+=e.stringify(n,"?")),this.get(i)},i.getProducts=function(t){var n="instance/"+this.instance_id+"/products";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.createInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product",t)},i.deleteInstanceProduct=function(t){return this.delete("instance/"+this.instance_id+"/product/"+t)},i.updateInstanceProduct=function(t){return this.post("instance/"+this.instance_id+"/product/update",t)},i.getInstanceTransactions=function(){return this.get("instance/"+this.instance_id+"/transactions")},i.findInstanceTransactions=function(t){var n="instance/"+this.instance_id+"/transactions/open";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getProductTransactions=function(t){return this.get("instance/"+this.instance_id+"/transactions/product/"+t)},i.deleteInstanceTransaction=function(t){return this.delete("instance/"+this.instance_id+"/transaction/"+t)},i.createInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction",t)},i.updateInstanceTransaction=function(t){return this.post("instance/"+this.instance_id+"/transaction/update",t)},i.getInstanceInvoices=function(t){var n="instance/"+this.instance_id+"/invoices";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceInvoice=function(t){return this.get("instance/"+this.instance_id+"/invoice/"+t)},i.deleteInstanceInvoice=function(t){return this.delete("instance/"+this.instance_id+"/invoice/"+t)},i.createInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice",t)},i.updateInstanceInvoice=function(t){return this.post("instance/"+this.instance_id+"/invoice/update",t)},i.getInstanceSeries=function(t){var n="instance/"+this.instance_id+"/series";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceTotal=function(t){var n="instance/"+this.instance_id+"/total/monthly";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceRevenue=function(t){var n="instance/"+this.instance_id+"/revenue";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceCustomers=function(t){var n="instance/"+this.instance_id+"/customers";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceCustomer=function(t){return this.get("instance/"+this.instance_id+"/customer/"+t)},i.deleteInstanceCustomer=function(t){return this.delete("instance/"+this.instance_id+"/customer/"+t)},i.createInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer",t)},i.updateInstanceCustomer=function(t){return this.post("instance/"+this.instance_id+"/customer/update",t)},i.getInstanceUsers=function(t){var n="instance/"+this.instance_id+"/users";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInstanceUser=function(t){return this.get("instance/"+this.instance_id+"/user/"+t)},i.deleteInstanceUser=function(t){return this.delete("instance/"+this.instance_id+"/user/"+t)},i.createInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user",t)},i.updateInstanceUser=function(t){return this.post("instance/"+this.instance_id+"/user/update",t)},i.getInstanceAddresses=function(t){var n="instance/"+this.instance_id+"/addresses";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.deleteInstanceAddress=function(t){return this.delete("instance/"+this.instance_id+"/address/"+t)},i.createInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address",t)},i.updateInstanceAddress=function(t){return this.post("instance/"+this.instance_id+"/address/update",t)},i.getCategories=function(t){var n="instance/"+this.instance_id+"/categories";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getBanners=function(t){var n="instance/"+this.instance_id+"/banners";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getSearchFilters=function(t){var n="instance/"+this.instance_id+"/search-filters";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.sendInviteSms=function(t){return this.post("instance/"+this.instance_id+"/invite-sms",t)},i.getTopKeywords=function(t){var n="instance/"+this.instance_id+"/top-search-keywords";return t&&(n+=e.stringify(t,"?")),this.post(n,t)},n}(s),a=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getUserMe=function(){return this.get("user/me")},i.getInstancePrimary=function(){return this.get("user/instance/primary")},i.setInstancePrimary=function(t){var n="user/instance/primary";return n+=e.stringify(t,"?"),this.post(n)},i.getUserInstances=function(t){return t&&e.stringify(t,"?"),this.get("user/instances")},n}(s),u=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getPassword=function(t){return this.post_auth("customer/login",{username:t,instance:this.instance_id})},i.customerVerify=function(t,e){return this.post_auth("customer/verify",{username:t,password:e,instance:this.instance_id})},i.getCustomerMe=function(){return this.get("customer/me")},i.getCustomer=function(){return this.get("customer")},i.updateCustomer=function(t){return this.post("customer",t)},i.addProductToCart=function(t){return this.put("customer/cart",t)},i.toggleProductFavorite=function(t){return this.post("customer/favorite-product",t)},i.getCustomerCart=function(){return this.get("customer/cart")},i.updateCartItem=function(t){return this.post("customer/cart",t)},i.deleteCartItem=function(t){return this.delete("customer/cart/"+t)},i.getNotifications=function(t){var n="customer/notifications";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getFavorites=function(t){var n="customer/favorite-products";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getAddresses=function(){return this.get("customer/addresses")},i.createAddress=function(t){return this.put("customer/address",t)},i.updateAddress=function(t){return this.post("customer/address",t)},i.deleteAddress=function(t){return this.delete("customer/address/"+t)},i.setCartDelivery=function(t){return this.post("customer/cart/delivery",{address:t})},i.setAvatar=function(t){return this.post("customer/avatar",{avatar_id:t})},i.getInvoicesHistory=function(t){var n="customer/cart/history";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getInvoice=function(t){return this.get("customer/invoice/"+t)},i.getCustomerCredit=function(){return this.get("customer/credit")},n}(s),h=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.sendSms=function(t){return this.post("crm/"+this.instance_id+"/send/normal",t)},n.sendTypedSms=function(t,e){return this.post("crm/"+this.instance_id+"/send/typed/"+t,e)},e}(s),d=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getProduct=function(t){return this.get("product/"+t)},i.getProductFeatures=function(t){return this.get("product/"+t+"/features")},i.getSimilarProducts=function(t){return this.get("product/"+t+"/similar-products")},i.getProductChoices=function(t){return this.get("product/"+t+"/choices")},i.getProductReviews=function(t,n){var i="product/"+t+"/reviews";return n&&(i+=e.stringify(n,"?")),this.get(i)},i.getRatingOptions=function(t){return this.get("product/"+t+"/rating-options")},i.sendNewReview=function(t,e){return this.put("product/"+t+"/review",e)},i.reportReview=function(t,e){return this.post("product/"+t+"/review/"+e+"/report")},n}(s),p=function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var i=n.prototype;return i.getCountries=function(t){var n="countries";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getIranProvinces=function(t){var n="countries/IR/states";return t&&(n+=e.stringify(t,"?")),this.get(n)},i.getStateCities=function(t,n){var i="countries/IR/states/"+t+"/cities";return n&&(i+=e.stringify(n,"?")),this.get(i)},n}(s);n.config();var f,g=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(s);return f=g,[c,a,o,u,h,d,p].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(f.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),g});
//# sourceMappingURL=index.umd.js.map
{
"name": "tayeh.js",
"version": "0.0.4",
"version": "0.0.5",
"description": "tayeh shop-api client",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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