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AAU,EAAE,IACjB,OAAQ,EAAE,OACV,KAAM,EAAE,MAAQ,OAEpB,OAAO,CACX,CAAE,MAAO,GAEL,MADA,YAAY,GACN,CACV,CACJ","file":"/npm/@volusion/volt-api@0.1.1/volt.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@volusion/volt-api@0.1.1/volt.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const axios = require('axios');\nconst querystring = require('querystring');\nconst baseUrl = \"https://volt-api.volusion.com\"\n\nmodule.exports = class voltApi {\n\n    constructor(config) {\n        this.config = config;\n    }\n\n    // Orders\n\n    async addOrder(data) {\n        return await this.makeVoltApiRequest({method: \"POST\", url: `/orders`, data: data})\n    }\n    async getOrders(options) {\n        return await this.makeVoltApiRequest({method: \"GET\", url: `/orders` + otq(options)})\n        // todo: make sure we support updatedAfter. Also need to handle paging or just return a boat load 🚢.\n    }\n    async updateOrder(id, data) {\n        return await this.makeVoltApiRequest({method: \"PUT\", url: `/orders/${id}`, data: data})\n    }\n    async addOrderPaymentLifecycleEvent(id, data) {\n        return await this.makeVoltApiRequest({method: \"POST\", url: `/orders/${id}/paymentlifecycleevent`, data: data})\n    }\n    async addOrderFulfillmentEvent(id, data) {\n        return await this.makeVoltApiRequest({method: \"POST\", url: `/orders/${id}/fulfillmentlifecycleevent`, data: data})\n    }\n    async deleteOrder(id) {\n        return await this.makeVoltApiRequest({method: \"DELETE\", url: `/orders/${id}`})\n    }\n\n    // Products\n\n    async addProduct(data) {\n        return await this.makeVoltApiRequest({method: \"POST\", url: `/products`, data: data})\n    }\n    async getProducts(options) {\n        return await this.makeVoltApiRequest({method: \"GET\", url: `/products` + otq(options)})\n    }\n    async updateProduct(id, data) {\n        return await this.makeVoltApiRequest({method: \"PUT\", url: `/products/${id}`, data: data})\n    }\n    async deleteProduct(id) {\n        return await this.makeVoltApiRequest({method: \"DELETE\", url: `/products/${id}`})\n    }\n\n    // Categories\n\n    async getCategories(options) {\n        return await this.makeVoltApiRequest({method: \"GET\", url: `/categorytree` + otq(options)})\n    }\n\n    // Shoppers\n    // NOTE: This url doesn't currently match the admin /admin/shoppers url, but we plan to change all the urls to this short prefix anyways soon\n\n    async addShopper(data) {\n        return await this.makeVoltApiRequest({method: \"POST\", url: `/shoppers`, data: data})\n    }\n    async getShoppers(options) {\n        return await this.makeVoltApiRequest({method: \"GET\", url: `/shoppers` + otq(options)})\n    }\n    async updateShopper(id, data) {\n        return await this.makeVoltApiRequest({method: \"PUT\", url: `/shoppers/${id}`, data: data})\n    }\n    async deleteShopper(id) {\n        return await this.makeVoltApiRequest({method: \"DELETE\", url: `/shoppers/${id}`})\n    }\n\n    // Store Information\n\n    async getStoreInformation(options) {\n        return await this.makeVoltApiRequest({method: \"GET\", url: `/storeinformation` + otq(options)})\n    }\n    \n    // Webhooks\n\n    async addWebhook(data) {\n        return await this.makeVoltApiRequest({method: \"POST\", url: `/webhooks`, data: data})\n    }\n    async getWebhooks(options) {\n        return await this.makeVoltApiRequest({method: \"GET\", url: `/webhooks` + otq(options)})\n    }\n    async updateWebhook(id, data) {\n        return await this.makeVoltApiRequest({method: \"PUT\", url: `/webhooks/${id}`, data: data})\n    }\n    async deleteWebhook(id) {\n        return await this.makeVoltApiRequest({method: \"DELETE\", url: `/webhooks/${id}`})\n    }\n\n    //*********************************************************\n    async makeVoltApiRequest(r) {\n        try {\n            const { data } = await axios({\n                headers: {\n                    \"Authorization\": this.config.apiKey,\n                    \"Content-Type\": \"application/json\"\n                },\n                url: baseUrl + r.url,\n                method: r.method,\n                data: r.data || null\n            });\n            return data;\n        } catch (error) {\n            handleError(error);\n            throw error;\n        }\n    }\n\n}\n\n// ----------------------------------------------------\n// Helper Functions\n// ----------------------------------------------------\n\nfunction otq(options) {\n    \n    // turns something like this:\n    // {\n    //     pageSize: 10,\n    //     foo: bar    \n    // }\n    // into this:\n    // \"?pageSize=10&foo=bar\"\n\n    let qs = querystring.stringify(options);\n    if (qs) {\n        qs = \"?\" + qs\n    }\n    return qs;\n\n}\n\nfunction handleError(error) {\n    if (error.response) {\n        // The request was made and the server responded with a status code that falls out of the range of 2xx\n        console.log(\"error.response.data\", error.response.data);\n        console.log(\"error.response.status\", error.response.status);\n    } else if (error.request) {\n        // The request was made but no response was received\n        console.log(\"error.request\", error.request);\n    } else {\n        // Something happened in setting up the request that triggered an Error\n        console.log(\"error.message\", error.message);\n    }\n}\n"]}