├── example.js ├── src ├── index.js ├── Feedback.js ├── Payments.js ├── Customers.js ├── Subscriptions.js ├── Queries.js ├── Groups.js ├── Coupons.js ├── Categories.js ├── Whitelists.js ├── Blacklists.js ├── Orders.js ├── Products.js └── Request.js ├── package.json ├── README.md ├── LICENSE ├── .gitignore └── tests └── index.js /example.js: -------------------------------------------------------------------------------- 1 | const sellix = require("@sellix/node-sdk")("", "") 2 | 3 | void (async () => { 4 | try { 5 | const blacklists = await sellix.blacklists.list() 6 | console.log(blacklists) 7 | } catch (e) { 8 | console.log(e) 9 | } 10 | })() -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | module.exports = (apiKey, merchant = null) => { 2 | const e = {} 3 | 4 | void [ 5 | "Blacklists", 6 | "Whitelists", 7 | "Categories", 8 | "Coupons", 9 | "Feedback", 10 | "Orders", 11 | "Products", 12 | "Groups", 13 | "Queries", 14 | "Payments", 15 | "Customers", 16 | "Subscriptions" 17 | ].forEach(component => { 18 | e[component.toLowerCase()] = require(`./${component}.js`)(apiKey, merchant) 19 | }) 20 | 21 | return e 22 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@sellix/node-sdk", 3 | "version": "1.0.14", 4 | "description": "Sellix NodeJS SDK", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "DEBUG=SellixApiClient node tests/index.js" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/Sellix/node-sdk.git" 12 | }, 13 | "author": "Daniele Servadei", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/Sellix/node-sdk/issues" 17 | }, 18 | "homepage": "https://github.com/Sellix/node-sdk#readme", 19 | "dependencies": { 20 | "debug": "^4.3.3", 21 | "node-fetch": "2" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Feedback.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "feedback" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "feedback" 14 | }) 15 | } 16 | 17 | e.reply = async (id, body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: `${_base}/reply/${id}`, 22 | method: "POST", 23 | body 24 | }) 25 | } 26 | 27 | e.list = async () => { 28 | return request({ 29 | apiKey, 30 | merchant, 31 | endpoint: _base, 32 | key: "feedback" 33 | }) 34 | } 35 | 36 | return e 37 | } -------------------------------------------------------------------------------- /src/Payments.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "payments" 7 | 8 | e.create = async (body) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: _base, 13 | method: "POST", 14 | key: { 15 | oneOf: ["url,uniqid", "invoice"] 16 | }, 17 | body 18 | }) 19 | } 20 | 21 | e.complete = async (id) => { 22 | return request({ 23 | apiKey, 24 | merchant, 25 | endpoint: `${_base}/${id}`, 26 | method: "PUT" 27 | }) 28 | } 29 | 30 | e.delete = async (id) => { 31 | return request({ 32 | apiKey, 33 | merchant, 34 | endpoint: `${_base}/${id}`, 35 | method: "DELETE" 36 | }) 37 | } 38 | 39 | return e 40 | } -------------------------------------------------------------------------------- /src/Customers.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "customers" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "customer" 14 | }) 15 | } 16 | 17 | e.create = async (body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | method: "POST", 23 | key: "customer_id", 24 | body 25 | }) 26 | } 27 | 28 | e.list = async () => { 29 | return request({ 30 | apiKey, 31 | merchant, 32 | endpoint: _base, 33 | key: "customers" 34 | }) 35 | } 36 | 37 | e.update = async (id, body) => { 38 | return request({ 39 | apiKey, 40 | merchant, 41 | endpoint: `${_base}/${id}`, 42 | method: "PUT", 43 | body 44 | }) 45 | } 46 | 47 | return e 48 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sellix NodeJS SDK 2 | 3 | ![node-sdk-tag](https://img.shields.io/github/v/tag/sellix/node-sdk?sort=date&color=blueviolet) 4 | ![npm](https://img.shields.io/npm/v/@sellix/node-sdk) 5 | ![downloads](https://img.shields.io/npm/dt/@sellix/node-sdk) 6 | 7 | ## Introduction 8 | 9 | Sellix public API for developers to access merchant resources 10 | 11 | ## Requirements 12 | 13 | - NodeJS 14 | 15 | ## Installation 16 | 17 | Install the package through NPM. 18 | 19 | ``` 20 | npm i @sellix/node-sdk 21 | ``` 22 | 23 | ## Usage 24 | 25 | ```js 26 | // pass only if you need to be authenticated as an additional store 27 | const sellix = require("@sellix/node-sdk")("", "") 28 | 29 | void (async () => { 30 | try { 31 | const products = await sellix.products.list() 32 | } catch (e) { 33 | console.log(e) 34 | } 35 | })() 36 | ``` 37 | 38 | ## Documentation 39 | 40 | [Sellix Developers API](https://developers.sellix.io) 41 | -------------------------------------------------------------------------------- /src/Subscriptions.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "subscriptions" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "subscription" 14 | }) 15 | } 16 | 17 | e.create = async (body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | method: "POST", 23 | key: { 24 | oneOf: ["url,uniqid", "subscription_id"] 25 | }, 26 | body 27 | }) 28 | } 29 | 30 | e.list = async () => { 31 | return request({ 32 | apiKey, 33 | merchant, 34 | endpoint: _base, 35 | key: "subscriptions" 36 | }) 37 | } 38 | 39 | e.delete = async (id) => { 40 | return request({ 41 | apiKey, 42 | merchant, 43 | endpoint: `${_base}/${id}`, 44 | method: "DELETE" 45 | }) 46 | } 47 | 48 | return e 49 | } -------------------------------------------------------------------------------- /src/Queries.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "queries" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "query" 14 | }) 15 | } 16 | 17 | e.list = async () => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | key: "queries" 23 | }) 24 | } 25 | 26 | e.reply = async (id, body) => { 27 | return request({ 28 | apiKey, 29 | merchant, 30 | endpoint: `${_base}/reply/${id}`, 31 | method: "POST", 32 | body 33 | }) 34 | } 35 | 36 | e.close = async (id) => { 37 | return request({ 38 | apiKey, 39 | merchant, 40 | endpoint: `${_base}/close/${id}`, 41 | method: "POST" 42 | }) 43 | } 44 | 45 | e.reopen = async (id) => { 46 | return request({ 47 | apiKey, 48 | merchant, 49 | endpoint: `${_base}/reopen/${id}`, 50 | method: "POST" 51 | }) 52 | } 53 | 54 | return e 55 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Sellix 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Groups.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "groups" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "group" 14 | }) 15 | } 16 | 17 | e.create = async (body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | method: "POST", 23 | key: "uniqid", 24 | body 25 | }) 26 | } 27 | 28 | e.list = async () => { 29 | return request({ 30 | apiKey, 31 | merchant, 32 | endpoint: _base, 33 | key: "groups" 34 | }) 35 | } 36 | 37 | e.update = async (id, body) => { 38 | return request({ 39 | apiKey, 40 | merchant, 41 | endpoint: `${_base}/${id}`, 42 | method: "PUT", 43 | body 44 | }) 45 | } 46 | 47 | e.delete = async (id) => { 48 | return request({ 49 | apiKey, 50 | merchant, 51 | endpoint: `${_base}/${id}`, 52 | method: "DELETE" 53 | }) 54 | } 55 | 56 | return e 57 | } -------------------------------------------------------------------------------- /src/Coupons.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "coupons" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "coupon" 14 | }) 15 | } 16 | 17 | e.create = async (body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | method: "POST", 23 | key: "uniqid", 24 | body 25 | }) 26 | } 27 | 28 | e.list = async () => { 29 | return request({ 30 | apiKey, 31 | merchant, 32 | endpoint: _base, 33 | key: "coupons" 34 | }) 35 | } 36 | 37 | e.update = async (id, body) => { 38 | return request({ 39 | apiKey, 40 | merchant, 41 | endpoint: `${_base}/${id}`, 42 | method: "PUT", 43 | body 44 | }) 45 | } 46 | 47 | e.delete = async (id) => { 48 | return request({ 49 | apiKey, 50 | merchant, 51 | endpoint: `${_base}/${id}`, 52 | method: "DELETE" 53 | }) 54 | } 55 | 56 | return e 57 | } -------------------------------------------------------------------------------- /src/Categories.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "categories" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "category" 14 | }) 15 | } 16 | 17 | e.create = async (body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | method: "POST", 23 | key: "uniqid", 24 | body 25 | }) 26 | } 27 | 28 | e.list = async () => { 29 | return request({ 30 | apiKey, 31 | merchant, 32 | endpoint: _base, 33 | key: "categories" 34 | }) 35 | } 36 | 37 | e.update = async (id, body) => { 38 | return request({ 39 | apiKey, 40 | merchant, 41 | endpoint: `${_base}/${id}`, 42 | method: "PUT", 43 | body 44 | }) 45 | } 46 | 47 | e.delete = async (id) => { 48 | return request({ 49 | apiKey, 50 | merchant, 51 | endpoint: `${_base}/${id}`, 52 | method: "DELETE" 53 | }) 54 | } 55 | 56 | return e 57 | } -------------------------------------------------------------------------------- /src/Whitelists.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "whitelists" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "whitelist" 14 | }) 15 | } 16 | 17 | e.create = async (body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | method: "POST", 23 | key: "uniqid", 24 | body 25 | }) 26 | } 27 | 28 | e.list = async () => { 29 | return request({ 30 | apiKey, 31 | merchant, 32 | endpoint: _base, 33 | key: "whitelists" 34 | }) 35 | } 36 | 37 | e.update = async (id, body) => { 38 | return request({ 39 | apiKey, 40 | merchant, 41 | endpoint: `${_base}/${id}`, 42 | method: "PUT", 43 | body 44 | }) 45 | } 46 | 47 | e.delete = async (id) => { 48 | return request({ 49 | apiKey, 50 | merchant, 51 | endpoint: `${_base}/${id}`, 52 | method: "DELETE" 53 | }) 54 | } 55 | 56 | return e 57 | } -------------------------------------------------------------------------------- /src/Blacklists.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "blacklists" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "blacklist" 14 | }) 15 | } 16 | 17 | e.create = async (body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | method: "POST", 23 | key: "uniqid", 24 | body 25 | }) 26 | } 27 | 28 | e.list = async () => { 29 | return request({ 30 | apiKey, 31 | merchant, 32 | endpoint: _base, 33 | key: "blacklists" 34 | }) 35 | } 36 | 37 | e.update = async (id, body) => { 38 | return request({ 39 | apiKey, 40 | merchant, 41 | endpoint: `${_base}/${id}`, 42 | method: "PUT", 43 | body 44 | }) 45 | } 46 | 47 | e.delete = async (id) => { 48 | return request({ 49 | apiKey, 50 | merchant, 51 | endpoint: `${_base}/${id}`, 52 | method: "DELETE" 53 | }) 54 | } 55 | 56 | return e 57 | } -------------------------------------------------------------------------------- /src/Orders.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "orders" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "order" 14 | }) 15 | } 16 | 17 | e.list = async (page = null) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | key: page ? `orders?page=${page}` : "orders", 23 | }) 24 | } 25 | 26 | e.update = async (id, body) => { 27 | return request({ 28 | apiKey, 29 | merchant, 30 | endpoint: `${_base}/update/${id}`, 31 | method: "PUT", 32 | key: "order", 33 | body 34 | }) 35 | } 36 | 37 | e.issue_replacement = async (id, body) => { 38 | return request({ 39 | apiKey, 40 | merchant, 41 | endpoint: `${_base}/replacement/${id}`, 42 | method: "POST", 43 | body 44 | }) 45 | } 46 | 47 | e.update_custom_fields = async (id, body) => { 48 | return request({ 49 | apiKey, 50 | merchant, 51 | endpoint: `${_base}/${id}/custom_fields`, 52 | method: "PUT", 53 | body 54 | }) 55 | } 56 | 57 | return e 58 | } -------------------------------------------------------------------------------- /src/Products.js: -------------------------------------------------------------------------------- 1 | const request = require("./Request.js") 2 | 3 | module.exports = (apiKey, merchant) => { 4 | const e = {} 5 | 6 | const _base = "products" 7 | 8 | e.get = async (id) => { 9 | return request({ 10 | apiKey, 11 | merchant, 12 | endpoint: `${_base}/${id}`, 13 | key: "product" 14 | }) 15 | } 16 | 17 | e.create = async (body) => { 18 | return request({ 19 | apiKey, 20 | merchant, 21 | endpoint: _base, 22 | method: "POST", 23 | key: "uniqid", 24 | body 25 | }) 26 | } 27 | 28 | e.list = async () => { 29 | return request({ 30 | apiKey, 31 | merchant, 32 | endpoint: _base, 33 | key: "products" 34 | }) 35 | } 36 | 37 | e.update = async (id, body) => { 38 | return request({ 39 | apiKey, 40 | merchant, 41 | endpoint: `${_base}/${id}`, 42 | method: "PUT", 43 | body 44 | }) 45 | } 46 | 47 | e.delete = async (id) => { 48 | return request({ 49 | apiKey, 50 | merchant, 51 | endpoint: `${_base}/${id}`, 52 | method: "DELETE" 53 | }) 54 | } 55 | 56 | e.licensing = { 57 | check: async (body) => { 58 | return request({ 59 | apiKey, 60 | merchant, 61 | endpoint: `${_base}/licensing/check`, 62 | method: "POST", 63 | key: "license", 64 | body 65 | }) 66 | }, 67 | 68 | update_hardware_id: async (body) => { 69 | return request({ 70 | apiKey, 71 | merchant, 72 | endpoint: `${_base}/licensing/hardware_id`, 73 | method: "PUT", 74 | key: "license", 75 | body 76 | }) 77 | } 78 | } 79 | 80 | return e 81 | } 82 | -------------------------------------------------------------------------------- /src/Request.js: -------------------------------------------------------------------------------- 1 | const fetch = require("node-fetch") 2 | 3 | const _request = async ({ 4 | apiKey, 5 | merchant, 6 | endpoint, 7 | key = null, 8 | method = "GET", 9 | body = null 10 | }) => { 11 | const options = { 12 | method, 13 | headers: { 14 | "Content-Type": "application/json", 15 | "Authorization": `Bearer ${apiKey}` 16 | } 17 | } 18 | 19 | if (body) { 20 | options.body = JSON.stringify(body) 21 | } 22 | 23 | if (merchant) { 24 | options.headers["X-Sellix-Merchant"] = merchant 25 | } 26 | 27 | const response = await fetch(`https://dev.sellix.io/v1/${endpoint}`, options) 28 | const data = await response.json() 29 | 30 | return _handleResponse({ 31 | response: data, 32 | key 33 | }) 34 | } 35 | 36 | const _handleResponse = ({ 37 | response, 38 | key 39 | }) => { 40 | if (response.status !== 200) { 41 | if (response.error) { 42 | throw new Error(response.error) 43 | } 44 | 45 | throw new Error(JSON.stringify(response)) 46 | } else { 47 | if (key === null) { 48 | return null 49 | } 50 | 51 | if (!!key && key.constructor === Object && key.oneOf) { 52 | updatedResponse = {} 53 | 54 | for (const option of key.oneOf) { 55 | if (option.includes(",")) { 56 | option.split(",").forEach(keyOption => { 57 | if (response.data && response.data[keyOption]) { 58 | updatedResponse[keyOption] = response.data[keyOption] 59 | } 60 | }) 61 | } else if (response.data && response.data[option]) { 62 | return response.data[option] 63 | } 64 | } 65 | 66 | return updatedResponse 67 | } 68 | 69 | return response.data[key] 70 | } 71 | } 72 | 73 | module.exports = (obj) => { 74 | return _request(obj) 75 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* -------------------------------------------------------------------------------- /tests/index.js: -------------------------------------------------------------------------------- 1 | const sellix = require("../src/index.js")("", "") 2 | const debug = require("debug")("SellixApiClient") 3 | 4 | void (async () => { 5 | const tests = [] 6 | 7 | try { 8 | if (!tests.length || tests.includes("blacklists")) { 9 | debug("Testing blacklists") 10 | const blacklistPayload = { 11 | type: "EMAIL", 12 | data: "sample@gmail.com", 13 | note: "demo" 14 | } 15 | const blacklistId = await sellix.blacklists.create(blacklistPayload) 16 | debug(" Create blacklist passed ✓") 17 | await sellix.blacklists.get(blacklistId) 18 | debug(" Get blacklist passed ✓") 19 | await sellix.blacklists.list() 20 | debug(" List blacklists passed ✓") 21 | await sellix.blacklists.update(blacklistId, blacklistPayload) 22 | debug(" Update blacklist passed ✓") 23 | await sellix.blacklists.delete(blacklistId) 24 | debug(" Delete blacklist passed ✓") 25 | } 26 | 27 | if (!tests.length || tests.includes("whitelists")) { 28 | debug("Testing whitelists") 29 | const whitelistPayload = { 30 | type: "EMAIL", 31 | data: "sample@gmail.com", 32 | note: "demo" 33 | } 34 | const whitelistId = await sellix.whitelists.create(whitelistPayload) 35 | debug(" Create whitelist passed ✓") 36 | await sellix.whitelists.get(whitelistId) 37 | debug(" Get whitelist passed ✓") 38 | await sellix.whitelists.list() 39 | debug(" List whitelists passed ✓") 40 | await sellix.whitelists.update(whitelistId, whitelistPayload) 41 | debug(" Update whitelist passed ✓") 42 | await sellix.whitelists.delete(whitelistId) 43 | debug(" Delete whitelist passed ✓") 44 | } 45 | 46 | if (!tests.length || tests.includes("categories")) { 47 | debug("Testing categories") 48 | const categoryPayload = { 49 | title: "Software", 50 | unlisted: false, 51 | products_bound: [], 52 | sort_priority: 0 53 | } 54 | const categoryId = await sellix.categories.create(categoryPayload) 55 | debug(" Create category passed ✓") 56 | await sellix.categories.get(categoryId) 57 | debug(" Get category passed ✓") 58 | await sellix.categories.list() 59 | debug(" List categories passed ✓") 60 | await sellix.categories.update(categoryId, categoryPayload) 61 | debug(" Update category passed ✓") 62 | await sellix.categories.delete(categoryId) 63 | debug(" Delete category passed ✓") 64 | } 65 | 66 | if (!tests.length || tests.includes("groups")) { 67 | debug("Testing groups") 68 | const groupPayload = { 69 | title: "Software Group", 70 | unlisted: false, 71 | products_bound: [], 72 | sort_priority: 0 73 | } 74 | const groupId = await sellix.groups.create(groupPayload) 75 | debug(" Create group passed ✓") 76 | await sellix.groups.get(groupId) 77 | debug(" Get group passed ✓") 78 | await sellix.groups.list() 79 | debug(" List groups passed ✓") 80 | await sellix.groups.update(groupId, groupPayload) 81 | debug(" Update group passed ✓") 82 | await sellix.groups.delete(groupId) 83 | debug(" Delete group passed ✓") 84 | } 85 | 86 | if (!tests.length || tests.includes("coupons")) { 87 | debug("Testing coupons") 88 | const couponPayload = { 89 | code: "TESTING_COUPON", 90 | discount_value: 35, 91 | max_uses: 50, 92 | products_bound: [], 93 | discount_type: "PERCENTAGE", 94 | disabled_with_volume_discounts: true 95 | } 96 | const couponId = await sellix.coupons.create(couponPayload) 97 | debug(" Create coupon passed ✓") 98 | await sellix.coupons.get(couponId) 99 | debug(" Get coupon passed ✓") 100 | await sellix.coupons.list() 101 | debug(" List coupons passed ✓") 102 | await sellix.coupons.update(couponId, couponPayload) 103 | debug(" Update coupon passed ✓") 104 | await sellix.coupons.delete(couponId) 105 | debug(" Delete coupon passed ✓") 106 | } 107 | 108 | if (!tests.length || tests.includes("feedback")) { 109 | debug("Testing feedback") 110 | const feedbackList = await sellix.feedback.list() 111 | debug(" List feedback passed ✓") 112 | if (feedbackList[0]) { 113 | const { uniqid: feedbackId } = feedbackList[0] 114 | await sellix.feedback.get(feedbackId) 115 | debug(" Get feedback passed ✓") 116 | await sellix.feedback.reply(feedbackId, { 117 | reply: "Testing reply" 118 | }) 119 | debug(" Reply feedback passed ✓") 120 | } 121 | } 122 | 123 | if (!tests.length || tests.includes("orders")) { 124 | debug("Testing orders") 125 | const ordersList = await sellix.orders.list() 126 | debug(" List orders passed ✓") 127 | if (ordersList[0]) { 128 | const { uniqid: orderId } = ordersList[0] 129 | await sellix.orders.get(orderId) 130 | debug(" Get order passed ✓") 131 | await sellix.orders.update(orderId, { 132 | gateway: "STRIPE", 133 | stripe_apm: "ideal" 134 | }) 135 | debug(" Update order passed ✓") 136 | await sellix.orders.issue_replacement(orderId, { 137 | quantity: 1, 138 | prouct_id: "demo" 139 | }) 140 | debug(" Issue order replacement passed ✓") 141 | await sellix.orders.update_custom_fields(orderId, { 142 | custom_fields: { 143 | user_id: "demo" 144 | } 145 | }) 146 | debug(" Update order custom fields passed ✓") 147 | } 148 | } 149 | 150 | if (!tests.length || tests.includes("products")) { 151 | debug("Testing products") 152 | const productPayload = { 153 | title: "Software Activation Keys", 154 | price: 12.5, 155 | description: "Product description example.", 156 | currency: "EUR", 157 | gateways: ["PAYPAL", "STRIPE", "BITCOIN"], 158 | type: "SERIALS", 159 | serials: [ 160 | "activation-key-#1" 161 | ] 162 | } 163 | const productId = await sellix.products.create(productPayload) 164 | debug(" Create product passed ✓") 165 | await sellix.products.get(productId) 166 | debug(" Get product passed ✓") 167 | await sellix.products.list() 168 | debug(" List products passed ✓") 169 | await sellix.products.update(productId, productPayload) 170 | debug(" Update product passed ✓") 171 | await sellix.products.delete(productId) 172 | debug(" Delete product passed ✓") 173 | await sellix.products.licensing.update_hardware_id({ 174 | key: "activation-key-#1", 175 | product_id: "demo", 176 | hardware_id: "example-id" 177 | }) 178 | debug(" License update hardware_id passed ✓") 179 | await sellix.products.licensing.check({ 180 | key: "activation-key-#1", 181 | product_id: "demo", 182 | hardware_id: "example-id" 183 | }) 184 | debug(" License check passed ✓") 185 | } 186 | 187 | if (!tests.length || tests.includes("queries")) { 188 | debug("Testing queries") 189 | const queries = await sellix.queries.list() 190 | debug(" List queries passed ✓") 191 | if (queries[0]) { 192 | const { uniqid: queryId } = queries[0] 193 | await sellix.queries.get(queryId) 194 | debug(" Get query passed ✓") 195 | await sellix.queries.reply(queryId, { 196 | reply: "Testing reply" 197 | }) 198 | debug(" Reply query passed ✓") 199 | await sellix.queries.close(queryId) 200 | debug(" Close query passed ✓") 201 | await sellix.queries.reopen(queryId) 202 | debug(" Reopen query passed ✓") 203 | } 204 | } 205 | 206 | if (!tests.length || tests.includes("payments")) { 207 | debug("Testing payments") 208 | const paymentPayload = { 209 | title: "Sellix Payment", 210 | value: 1.5, 211 | currency: "EUR", 212 | quantity: 5, 213 | email: "no-reply@sellix.io", 214 | white_label: false, 215 | return_url: "https://sample.sellix.io/return" 216 | } 217 | const paymentNoWhiteLabel = await sellix.payments.create(paymentPayload) 218 | debug(" Create payment no white label passed ✓") 219 | paymentPayload.white_label = true 220 | const paymentWhiteLabel = await sellix.payments.create(paymentPayload) 221 | debug(" Create payment white label passed ✓") 222 | await sellix.payments.delete(paymentNoWhiteLabel.uniqid) 223 | debug(" Delete payment no white label passed ✓") 224 | await sellix.payments.delete(paymentWhiteLabel.uniqid) 225 | debug(" Delete payment white label passed ✓") 226 | await sellix.payments.complete(paymentWhiteLabel.uniqid) 227 | debug(" Complete payment white label passed ✓") 228 | } 229 | 230 | if (!tests.length || tests.includes("customers")) { 231 | debug("Testing customers") 232 | const customerPayload = { 233 | "email": "sampleJames@gmail.com", 234 | "name": "James", 235 | "surname": "Smith", 236 | "phone": "3287261000", 237 | "phone_country_code": "IT", 238 | "country_code": "IT", 239 | "street_address": "St. Rome 404", 240 | "additional_address_info": null, 241 | "city": "Rome", 242 | "postal_code": "0", 243 | "state": "Italy" 244 | } 245 | const customerId = await sellix.customers.create(customerPayload) 246 | debug(" Create customer passed ✓") 247 | await sellix.customers.get(customerId) 248 | debug(" Get customer passed ✓") 249 | await sellix.customers.list() 250 | debug(" List customers passed ✓") 251 | await sellix.customers.update(customerId, customerPayload) 252 | debug(" Update customer passed ✓") 253 | } 254 | 255 | if (!tests.length || tests.includes("subscriptions")) { 256 | debug("Testing subscriptions") 257 | const subscriptionPayload = { 258 | "product_id": "61a8de6277597", 259 | "coupon_code": null, 260 | "custom_fields": { 261 | "user_id": "demo" 262 | }, 263 | "customer_id": "cst_9f006addc898a645", 264 | "gateway": null 265 | } 266 | await sellix.subscriptions.create(subscriptionPayload) 267 | debug(" Create subscription passed ✓") 268 | await sellix.subscriptions.list() 269 | debug(" List subscriptions passed ✓") 270 | } 271 | } catch (e) { 272 | debug(e) 273 | } 274 | })() --------------------------------------------------------------------------------