From bb2521bced19a67240844c03a84f0bd0a7cedfce Mon Sep 17 00:00:00 2001 From: Ryan Glover Date: Thu, 5 Mar 2020 12:26:49 -0600 Subject: [PATCH 1/5] release v0.42.0 --- README.md | 2 +- dist/index.min.js | 2 +- package.json | 4 ++-- src/index.test.js | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 967e7dc..ad6e023 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Official JavaScript library for the Command API. -[Read the Documentation](https://portal.oncommand.io/docs/command-js/0.41.0/introduction) \ No newline at end of file +[Read the Documentation](https://portal.oncommand.io/docs/command-js/0.42.0/introduction) \ No newline at end of file diff --git a/dist/index.min.js b/dist/index.min.js index ea8fbdb..51e7638 100644 --- a/dist/index.min.js +++ b/dist/index.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).command=e()}(this,(function(){"use strict";const t=require("axios");return class{constructor(t,e={}){t||this._throwFormattedError("A valid API key is required."),this.apiKey=t,this.version="0.41.0",this.customerId=e.customerId||null,this.debug=e.debug||!1,this.customers={login:this._loginCustomer.bind(this),logout:this._logoutCustomer.bind(this),create:this._createCustomer.bind(this),update:this._updateCustomer.bind(this),delete:this._deleteCustomer.bind(this)}}_logDebugMessage(t){console.log("[[[ Command.js DEBUG ]]]"),console.log(t)}_throwFormattedError(t){throw new Error(`[Command] ${t} See https://portal.oncommand.io/docs/command-js/${this.version}/introduction.`)}_request(e,s,r={},o=null){return this.debug&&this._logDebugMessage({method:e,url:`https://api.oncommand.io/v1${s}`,headers:{"x-api-key":this.apiKey},data:r}),t({method:e,url:`https://api.oncommand.io/v1${s}`,headers:{"x-api-key":this.apiKey},data:r}).then(t=>(callbak&&o(t),t)).catch(t=>{if(t&&t.response){const{status:e}=t.response,s=t.response&&t.response.data&&t.response.data&&t.response.data.data&&t.response.data.data.error;console.warn(`[${e}] ${s}`),t.response.data&&console.warn(t.response.data),this.debug&&t.response.data&&t.response.data.data&&(this._logDebugMessage(t.response.data.data.error),this._logDebugMessage(t.response.data.data.validationErrors))}})}track(t,e){if(!t)throw new Error("Must pass a key to track.");const s={key:t};return this.customerId&&(s.customerId=this.customerId),e&&(s.properties=e),this._request("post","/behavior",s)}_loginCustomer(t){if(!t)throw new Error("Must pass a customerId.");return this.customerId=t,this._request("put","/customers/login",{customerId:t})}_logoutCustomer(t){if(!t&&!this.customerId)throw new Error("Must have a customerId to logout.");return this._request("put","/customers/logout",{customerId:t||this.customerId},()=>{this.customerId=null})}_createCustomer(t){if(!t)throw new Error("Must pass a customer.");return this._request("post","/customers",{...t})}_updateCustomer(t,e){if(!t)throw new Error("Must pass a customerId.");if(!e)throw new Error("Must pass an update for the customer.");return this._request("put",`/customers/${t}`,{...e})}_deleteCustomer(t){if(!t)throw new Error("Must pass a customerId.");return this._request("delete",`/customers/${t}`)}}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).command=e()}(this,(function(){"use strict";const t=require("axios");return class{constructor(t,e={}){t||this._throwFormattedError("A valid API key is required."),this.apiKey=t,this.version="0.42.0",this.customerId=e.customerId||null,this.debug=e.debug||!1,this.customers={login:this._loginCustomer.bind(this),logout:this._logoutCustomer.bind(this),create:this._createCustomer.bind(this),update:this._updateCustomer.bind(this),delete:this._deleteCustomer.bind(this)}}_logDebugMessage(t){console.log("[[[ Command.js DEBUG ]]]"),console.log(t)}_throwFormattedError(t){throw new Error(`[Command] ${t} See https://portal.oncommand.io/docs/command-js/${this.version}/introduction.`)}_request(e,s,r={},o=null){return this.debug&&this._logDebugMessage({method:e,url:`https://api.oncommand.io/v1${s}`,headers:{"x-api-key":this.apiKey},data:r}),t({method:e,url:`https://api.oncommand.io/v1${s}`,headers:{"x-api-key":this.apiKey},data:r}).then(t=>(callbak&&o(t),t)).catch(t=>{if(t&&t.response){const{status:e}=t.response,s=t.response&&t.response.data&&t.response.data&&t.response.data.data&&t.response.data.data.error;console.warn(`[${e}] ${s}`),t.response.data&&console.warn(t.response.data),this.debug&&t.response.data&&t.response.data.data&&(this._logDebugMessage(t.response.data.data.error),this._logDebugMessage(t.response.data.data.validationErrors))}})}track(t,e){if(!t)throw new Error("Must pass a key to track.");const s={key:t};return this.customerId&&(s.customerId=this.customerId),e&&(s.properties=e),this._request("post","/behavior",s)}_loginCustomer(t){if(!t)throw new Error("Must pass a customerId.");return this.customerId=t,this._request("put","/customers/login",{customerId:t})}_logoutCustomer(t){if(!t&&!this.customerId)throw new Error("Must have a customerId to logout.");return this._request("put","/customers/logout",{customerId:t||this.customerId},()=>{this.customerId=null})}_createCustomer(t){if(!t)throw new Error("Must pass a customer.");return this._request("post","/customers",{...t})}_updateCustomer(t,e){if(!t)throw new Error("Must pass a customerId.");if(!e)throw new Error("Must pass an update for the customer.");return this._request("put",`/customers/${t}`,{...e})}_deleteCustomer(t){if(!t)throw new Error("Must pass a customerId.");return this._request("delete",`/customers/${t}`)}}})); diff --git a/package.json b/package.json index 6a6c766..dbd8b1a 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ ], "author": "oncommandio", "license": "MIT", - "homepage": "https://portal.oncommand.io/docs/command-js/0.41.0/introduction", + "homepage": "https://portal.oncommand.io/docs/command-js/0.42.0/introduction", "dependencies": { "axios": "^0.19.0" }, @@ -33,4 +33,4 @@ "rollup": "^1.32.0", "rollup-plugin-terser": "^5.2.0" } -} +} \ No newline at end of file diff --git a/src/index.test.js b/src/index.test.js index 2e2b865..45f695e 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -30,7 +30,7 @@ describe("index.js", () => { command.track("an event"); expect(axios).toHaveBeenCalledWith({ method: "post", - url: `http://localhost:4000/api/v1/behavior`, + url: `https://api.oncommand.io/v1/behavior`, headers: { "x-api-key": "apiKey123" }, @@ -52,7 +52,7 @@ describe("index.js", () => { command.customers.login("1234"); expect(axios).toHaveBeenCalledWith({ method: "put", - url: `http://localhost:4000/api/v1/customers/login`, + url: `https://api.oncommand.io/v1/customers/login`, headers: { "x-api-key": "apiKey123" }, @@ -75,7 +75,7 @@ describe("index.js", () => { command.customers.logout(); expect(axios).toHaveBeenCalledWith({ method: "put", - url: `http://localhost:4000/api/v1/customers/logout`, + url: `https://api.oncommand.io/v1/customers/logout`, headers: { "x-api-key": "apiKey123" }, @@ -97,7 +97,7 @@ describe("index.js", () => { command.customers.create({ emailAddress: "test@test.com" }); expect(axios).toHaveBeenCalledWith({ method: "post", - url: `http://localhost:4000/api/v1/customers`, + url: `https://api.oncommand.io/v1/customers`, headers: { "x-api-key": "apiKey123" }, @@ -121,7 +121,7 @@ describe("index.js", () => { }); expect(axios).toHaveBeenCalledWith({ method: "put", - url: `http://localhost:4000/api/v1/customers/customerId123`, + url: `https://api.oncommand.io/v1/customers/customerId123`, headers: { "x-api-key": "apiKey123" }, @@ -150,7 +150,7 @@ describe("index.js", () => { command.customers.delete("customerId123"); expect(axios).toHaveBeenCalledWith({ method: "delete", - url: `http://localhost:4000/api/v1/customers/customerId123`, + url: `https://api.oncommand.io/v1/customers/customerId123`, headers: { "x-api-key": "apiKey123" }, From 21ee9cb37eab137ab0618e9bc1c062ebd032a111 Mon Sep 17 00:00:00 2001 From: Ryan Glover Date: Thu, 5 Mar 2020 12:26:55 -0600 Subject: [PATCH 2/5] 0.42.0 --- package-lock.json | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1c42b6a..9531eab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@oncommandio/js", - "version": "0.41.0", + "version": "0.42.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index dbd8b1a..187ca0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oncommandio/js", - "version": "0.41.0", + "version": "0.42.0", "description": "Official JavaScript library for the Command API.", "main": "dist/index.min.js", "scripts": { @@ -33,4 +33,4 @@ "rollup": "^1.32.0", "rollup-plugin-terser": "^5.2.0" } -} \ No newline at end of file +} From d58865fcd7b9aaa546deef18c64a0d816ac8def3 Mon Sep 17 00:00:00 2001 From: Ryan Glover Date: Thu, 5 Mar 2020 15:53:44 -0600 Subject: [PATCH 3/5] release v0.43.0 --- README.md | 2 +- dist/index.min.js | 2 +- package.json | 4 ++-- src/index.js | 5 ++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ad6e023..31ac772 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Official JavaScript library for the Command API. -[Read the Documentation](https://portal.oncommand.io/docs/command-js/0.42.0/introduction) \ No newline at end of file +[Read the Documentation](https://portal.oncommand.io/docs/command-js/0.43.0/introduction) \ No newline at end of file diff --git a/dist/index.min.js b/dist/index.min.js index 51e7638..1d08af6 100644 --- a/dist/index.min.js +++ b/dist/index.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).command=e()}(this,(function(){"use strict";const t=require("axios");return class{constructor(t,e={}){t||this._throwFormattedError("A valid API key is required."),this.apiKey=t,this.version="0.42.0",this.customerId=e.customerId||null,this.debug=e.debug||!1,this.customers={login:this._loginCustomer.bind(this),logout:this._logoutCustomer.bind(this),create:this._createCustomer.bind(this),update:this._updateCustomer.bind(this),delete:this._deleteCustomer.bind(this)}}_logDebugMessage(t){console.log("[[[ Command.js DEBUG ]]]"),console.log(t)}_throwFormattedError(t){throw new Error(`[Command] ${t} See https://portal.oncommand.io/docs/command-js/${this.version}/introduction.`)}_request(e,s,r={},o=null){return this.debug&&this._logDebugMessage({method:e,url:`https://api.oncommand.io/v1${s}`,headers:{"x-api-key":this.apiKey},data:r}),t({method:e,url:`https://api.oncommand.io/v1${s}`,headers:{"x-api-key":this.apiKey},data:r}).then(t=>(callbak&&o(t),t)).catch(t=>{if(t&&t.response){const{status:e}=t.response,s=t.response&&t.response.data&&t.response.data&&t.response.data.data&&t.response.data.data.error;console.warn(`[${e}] ${s}`),t.response.data&&console.warn(t.response.data),this.debug&&t.response.data&&t.response.data.data&&(this._logDebugMessage(t.response.data.data.error),this._logDebugMessage(t.response.data.data.validationErrors))}})}track(t,e){if(!t)throw new Error("Must pass a key to track.");const s={key:t};return this.customerId&&(s.customerId=this.customerId),e&&(s.properties=e),this._request("post","/behavior",s)}_loginCustomer(t){if(!t)throw new Error("Must pass a customerId.");return this.customerId=t,this._request("put","/customers/login",{customerId:t})}_logoutCustomer(t){if(!t&&!this.customerId)throw new Error("Must have a customerId to logout.");return this._request("put","/customers/logout",{customerId:t||this.customerId},()=>{this.customerId=null})}_createCustomer(t){if(!t)throw new Error("Must pass a customer.");return this._request("post","/customers",{...t})}_updateCustomer(t,e){if(!t)throw new Error("Must pass a customerId.");if(!e)throw new Error("Must pass an update for the customer.");return this._request("put",`/customers/${t}`,{...e})}_deleteCustomer(t){if(!t)throw new Error("Must pass a customerId.");return this._request("delete",`/customers/${t}`)}}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).command=e()}(this,(function(){"use strict";const t=require("axios");return class{constructor(t,e={}){t||this._throwFormattedError("A valid API key is required."),this.apiKey=t,this.version="0.43.0",this.customerId=e.customerId||null,this.debug=e.debug||!1,this.customers={login:this._loginCustomer.bind(this),logout:this._logoutCustomer.bind(this),create:this._createCustomer.bind(this),update:this._updateCustomer.bind(this),delete:this._deleteCustomer.bind(this)}}_logDebugMessage(t){console.log("[[[ Command.js DEBUG ]]]"),console.log(t)}_throwFormattedError(t){throw new Error(`[Command] ${t} See https://portal.oncommand.io/docs/command-js/${this.version}/introduction.`)}_request(e,s,r={}){return this.debug&&this._logDebugMessage({method:e,url:`https://api.oncommand.io/v1${s}`,headers:{"x-api-key":this.apiKey},data:r}),t({method:e,url:`https://api.oncommand.io/v1${s}`,headers:{"x-api-key":this.apiKey},data:r}).then(t=>t&&t.data&&t.data.data).catch(t=>{if(t&&t.response){const{status:e}=t.response,s=t.response&&t.response.data&&t.response.data&&t.response.data.data&&t.response.data.data.error;console.warn(`[${e}] ${s}`),t.response.data&&console.warn(t.response.data),this.debug&&t.response.data&&t.response.data.data&&(this._logDebugMessage(t.response.data.data.error),this._logDebugMessage(t.response.data.data.validationErrors))}})}track(t,e){if(!t)throw new Error("Must pass a key to track.");const s={key:t};return this.customerId&&(s.customerId=this.customerId),e&&(s.properties=e),this._request("post","/behavior",s)}_loginCustomer(t){if(!t)throw new Error("Must pass a customerId.");return this.customerId=t,this._request("put","/customers/login",{customerId:t})}_logoutCustomer(t){if(!t&&!this.customerId)throw new Error("Must have a customerId to logout.");return this._request("put","/customers/logout",{customerId:t||this.customerId},()=>{this.customerId=null})}_createCustomer(t){if(!t)throw new Error("Must pass a customer.");return this._request("post","/customers",{...t})}_updateCustomer(t,e){if(!t)throw new Error("Must pass a customerId.");if(!e)throw new Error("Must pass an update for the customer.");return this._request("put",`/customers/${t}`,{...e})}_deleteCustomer(t){if(!t)throw new Error("Must pass a customerId.");return this._request("delete",`/customers/${t}`)}}})); diff --git a/package.json b/package.json index 187ca0b..7f10cf7 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ ], "author": "oncommandio", "license": "MIT", - "homepage": "https://portal.oncommand.io/docs/command-js/0.42.0/introduction", + "homepage": "https://portal.oncommand.io/docs/command-js/0.43.0/introduction", "dependencies": { "axios": "^0.19.0" }, @@ -33,4 +33,4 @@ "rollup": "^1.32.0", "rollup-plugin-terser": "^5.2.0" } -} +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 98af0ae..50c6659 100644 --- a/src/index.js +++ b/src/index.js @@ -28,7 +28,7 @@ class CommandAPI { ); } - _request(method, path, data = {}, callback = null) { + _request(method, path, data = {}) { if (this.debug) { this._logDebugMessage({ method, @@ -50,8 +50,7 @@ class CommandAPI { data }) .then(response => { - if (callbak) callback(response); - return response; + return response && response.data && response.data.data; }) .catch(error => { if (error && error.response) { From b31a38d00d390e7e66b4dcc45547e35bd7539c25 Mon Sep 17 00:00:00 2001 From: Ryan Glover Date: Thu, 5 Mar 2020 15:53:50 -0600 Subject: [PATCH 4/5] 0.43.0 --- package-lock.json | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9531eab..f133876 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@oncommandio/js", - "version": "0.42.0", + "version": "0.43.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7f10cf7..818550e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oncommandio/js", - "version": "0.42.0", + "version": "0.43.0", "description": "Official JavaScript library for the Command API.", "main": "dist/index.min.js", "scripts": { @@ -33,4 +33,4 @@ "rollup": "^1.32.0", "rollup-plugin-terser": "^5.2.0" } -} \ No newline at end of file +} From 351b44ca2f0dbe50730255f3c7182f2cb6eafcca Mon Sep 17 00:00:00 2001 From: Clever Beagle Date: Wed, 29 Apr 2020 23:00:53 -0500 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31ac772..4bea281 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Official JavaScript library for the Command API. -[Read the Documentation](https://portal.oncommand.io/docs/command-js/0.43.0/introduction) \ No newline at end of file +[Read the Documentation](http://portal.oncommand.io/docs/command-js/0.43.0/introduction)