From 7dfb8ec8f5e0640709d762cfb2efe7f0a37ecf92 Mon Sep 17 00:00:00 2001
From: Dan Jones <dan.jones@noc.ac.uk>
Date: Thu, 12 Jan 2023 11:00:00 +0000
Subject: [PATCH] fix: check presence of config

---
 dist/adapter.esm.js  | 21 +++++++++++----------
 dist/adapter.js      | 21 +++++++++++----------
 src/adapter/index.js | 21 +++++++++++----------
 3 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/dist/adapter.esm.js b/dist/adapter.esm.js
index da7f498..f0577e3 100644
--- a/dist/adapter.esm.js
+++ b/dist/adapter.esm.js
@@ -68,12 +68,13 @@ class Adapter {
    * @returns {object}
    */
   auth() {
-    let config = this.config;
+    let adapterConfig = this.config;
+    console.error('config', adapterConfig);
     return this.axios
-      .get(`${config.api}/token`, {
+      .get(`${adapterConfig.api}/token`, {
         params: {
-          client_id: config.client_id,
-          secret: config.secret,
+          client_id: adapterConfig.client_id,
+          secret: adapterConfig.secret,
         },
       })
       .then((response) => {
@@ -89,10 +90,10 @@ class Adapter {
    * @returns {object}
    */
   poll() {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
-        return this.axios.get(`${config.api}/receive`, {
+        return this.axios.get(`${adapterConfig.api}/receive`, {
           headers,
         });
       })
@@ -118,11 +119,11 @@ class Adapter {
    * @returns 
    */
   publish(topic, body) {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
         return this.axios.post(
-          `${config.api}/send`,
+          `${adapterConfig.api}/send`,
           {
             topic,
             body,
@@ -149,11 +150,11 @@ class Adapter {
    * @returns 
    */
   broadcast(body) {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
         return this.axios.post(
-          `${config.api}/notify`,
+          `${adapterConfig.api}/notify`,
           {
             body,
           },
diff --git a/dist/adapter.js b/dist/adapter.js
index 3f49e26..c0a62b5 100644
--- a/dist/adapter.js
+++ b/dist/adapter.js
@@ -70,12 +70,13 @@ class Adapter {
    * @returns {object}
    */
   auth() {
-    let config = this.config;
+    let adapterConfig = this.config;
+    console.error('config', adapterConfig);
     return this.axios
-      .get(`${config.api}/token`, {
+      .get(`${adapterConfig.api}/token`, {
         params: {
-          client_id: config.client_id,
-          secret: config.secret,
+          client_id: adapterConfig.client_id,
+          secret: adapterConfig.secret,
         },
       })
       .then((response) => {
@@ -91,10 +92,10 @@ class Adapter {
    * @returns {object}
    */
   poll() {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
-        return this.axios.get(`${config.api}/receive`, {
+        return this.axios.get(`${adapterConfig.api}/receive`, {
           headers,
         });
       })
@@ -120,11 +121,11 @@ class Adapter {
    * @returns 
    */
   publish(topic, body) {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
         return this.axios.post(
-          `${config.api}/send`,
+          `${adapterConfig.api}/send`,
           {
             topic,
             body,
@@ -151,11 +152,11 @@ class Adapter {
    * @returns 
    */
   broadcast(body) {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
         return this.axios.post(
-          `${config.api}/notify`,
+          `${adapterConfig.api}/notify`,
           {
             body,
           },
diff --git a/src/adapter/index.js b/src/adapter/index.js
index 91320eb..934cd13 100644
--- a/src/adapter/index.js
+++ b/src/adapter/index.js
@@ -68,12 +68,13 @@ export class Adapter {
    * @returns {object}
    */
   auth() {
-    let config = this.config;
+    let adapterConfig = this.config;
+    console.error('config', adapterConfig);
     return this.axios
-      .get(`${config.api}/token`, {
+      .get(`${adapterConfig.api}/token`, {
         params: {
-          client_id: config.client_id,
-          secret: config.secret,
+          client_id: adapterConfig.client_id,
+          secret: adapterConfig.secret,
         },
       })
       .then((response) => {
@@ -89,10 +90,10 @@ export class Adapter {
    * @returns {object}
    */
   poll() {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
-        return this.axios.get(`${config.api}/receive`, {
+        return this.axios.get(`${adapterConfig.api}/receive`, {
           headers,
         });
       })
@@ -118,11 +119,11 @@ export class Adapter {
    * @returns 
    */
   publish(topic, body) {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
         return this.axios.post(
-          `${config.api}/send`,
+          `${adapterConfig.api}/send`,
           {
             topic,
             body,
@@ -149,11 +150,11 @@ export class Adapter {
    * @returns 
    */
   broadcast(body) {
-    let config = this.config;
+    let adapterConfig = this.config;
     return this.getAuthorizationHeader()
       .then((headers) => {
         return this.axios.post(
-          `${config.api}/notify`,
+          `${adapterConfig.api}/notify`,
           {
             body,
           },
-- 
GitLab