diff --git a/dist/adapter.esm.js b/dist/adapter.esm.js index c8c1dac52e0fb3ef28f64cb2d4f8797f290b3bad..da7f4982f1ba7eb6110732c53203f66c8e8ebf6b 100644 --- a/dist/adapter.esm.js +++ b/dist/adapter.esm.js @@ -6,8 +6,8 @@ import axios from 'axios'; */ class Adapter { constructor(protocol, config) { - this.config = config; this.protocol = protocol; + this.config = config; this.axios = axios; this.validator = new Validator(protocol.schema); this.auth(); @@ -68,11 +68,12 @@ class Adapter { * @returns {object} */ auth() { + let config = this.config; return this.axios - .get(`${this.config.api}/token`, { + .get(`${config.api}/token`, { params: { - client_id: this.config.client_id, - secret: this.config.secret, + client_id: config.client_id, + secret: config.secret, }, }) .then((response) => { @@ -88,9 +89,10 @@ class Adapter { * @returns {object} */ poll() { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { - return this.axios.get(`${this.config.api}/receive`, { + return this.axios.get(`${config.api}/receive`, { headers, }); }) @@ -116,10 +118,11 @@ class Adapter { * @returns */ publish(topic, body) { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { return this.axios.post( - `${this.config.api}/send`, + `${config.api}/send`, { topic, body, @@ -146,10 +149,11 @@ class Adapter { * @returns */ broadcast(body) { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { return this.axios.post( - `${this.config.api}/notify`, + `${config.api}/notify`, { body, }, diff --git a/dist/adapter.js b/dist/adapter.js index 51b0ce26dd3c215f4c38d0e3e3a763abf4b41031..3f49e269011c7dd018349a138765d922c8666578 100644 --- a/dist/adapter.js +++ b/dist/adapter.js @@ -8,8 +8,8 @@ var axios = require('axios'); */ class Adapter { constructor(protocol, config) { - this.config = config; this.protocol = protocol; + this.config = config; this.axios = axios; this.validator = new Validator(protocol.schema); this.auth(); @@ -70,11 +70,12 @@ class Adapter { * @returns {object} */ auth() { + let config = this.config; return this.axios - .get(`${this.config.api}/token`, { + .get(`${config.api}/token`, { params: { - client_id: this.config.client_id, - secret: this.config.secret, + client_id: config.client_id, + secret: config.secret, }, }) .then((response) => { @@ -90,9 +91,10 @@ class Adapter { * @returns {object} */ poll() { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { - return this.axios.get(`${this.config.api}/receive`, { + return this.axios.get(`${config.api}/receive`, { headers, }); }) @@ -118,10 +120,11 @@ class Adapter { * @returns */ publish(topic, body) { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { return this.axios.post( - `${this.config.api}/send`, + `${config.api}/send`, { topic, body, @@ -148,10 +151,11 @@ class Adapter { * @returns */ broadcast(body) { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { return this.axios.post( - `${this.config.api}/notify`, + `${config.api}/notify`, { body, }, diff --git a/src/adapter/index.js b/src/adapter/index.js index 9c1a21a9df9bf8d9cd91abeab525df75b8aca8d2..91320eb47e00d30256b50a7c13e871e35e487aa6 100644 --- a/src/adapter/index.js +++ b/src/adapter/index.js @@ -6,8 +6,8 @@ import axios from 'axios'; */ export class Adapter { constructor(protocol, config) { - this.config = config; this.protocol = protocol; + this.config = config; this.axios = axios; this.validator = new Validator(protocol.schema); this.auth(); @@ -68,11 +68,12 @@ export class Adapter { * @returns {object} */ auth() { + let config = this.config; return this.axios - .get(`${this.config.api}/token`, { + .get(`${config.api}/token`, { params: { - client_id: this.config.client_id, - secret: this.config.secret, + client_id: config.client_id, + secret: config.secret, }, }) .then((response) => { @@ -88,9 +89,10 @@ export class Adapter { * @returns {object} */ poll() { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { - return this.axios.get(`${this.config.api}/receive`, { + return this.axios.get(`${config.api}/receive`, { headers, }); }) @@ -116,10 +118,11 @@ export class Adapter { * @returns */ publish(topic, body) { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { return this.axios.post( - `${this.config.api}/send`, + `${config.api}/send`, { topic, body, @@ -146,10 +149,11 @@ export class Adapter { * @returns */ broadcast(body) { + let config = this.config; return this.getAuthorizationHeader() .then((headers) => { return this.axios.post( - `${this.config.api}/notify`, + `${config.api}/notify`, { body, },