"docs/git@git.noc.ac.uk:thopri/PyNEMO.git" did not exist on "eec647615c21e31b169cb144fcd0d8929a62efc8"
Unverified Commit 20f10b52 authored by Dan Jones's avatar Dan Jones
Browse files

fix: correct use of this in wrong context

parent 33f25858
...@@ -6,8 +6,8 @@ import axios from 'axios'; ...@@ -6,8 +6,8 @@ import axios from 'axios';
*/ */
class Adapter { class Adapter {
constructor(protocol, config) { constructor(protocol, config) {
this.config = config;
this.protocol = protocol; this.protocol = protocol;
this.config = config;
this.axios = axios; this.axios = axios;
this.validator = new Validator(protocol.schema); this.validator = new Validator(protocol.schema);
this.auth(); this.auth();
...@@ -68,11 +68,12 @@ class Adapter { ...@@ -68,11 +68,12 @@ class Adapter {
* @returns {object} * @returns {object}
*/ */
auth() { auth() {
let config = this.config;
return this.axios return this.axios
.get(`${this.config.api}/token`, { .get(`${config.api}/token`, {
params: { params: {
client_id: this.config.client_id, client_id: config.client_id,
secret: this.config.secret, secret: config.secret,
}, },
}) })
.then((response) => { .then((response) => {
...@@ -88,9 +89,10 @@ class Adapter { ...@@ -88,9 +89,10 @@ class Adapter {
* @returns {object} * @returns {object}
*/ */
poll() { poll() {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.get(`${this.config.api}/receive`, { return this.axios.get(`${config.api}/receive`, {
headers, headers,
}); });
}) })
...@@ -116,10 +118,11 @@ class Adapter { ...@@ -116,10 +118,11 @@ class Adapter {
* @returns * @returns
*/ */
publish(topic, body) { publish(topic, body) {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${this.config.api}/send`, `${config.api}/send`,
{ {
topic, topic,
body, body,
...@@ -146,10 +149,11 @@ class Adapter { ...@@ -146,10 +149,11 @@ class Adapter {
* @returns * @returns
*/ */
broadcast(body) { broadcast(body) {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${this.config.api}/notify`, `${config.api}/notify`,
{ {
body, body,
}, },
......
...@@ -8,8 +8,8 @@ var axios = require('axios'); ...@@ -8,8 +8,8 @@ var axios = require('axios');
*/ */
class Adapter { class Adapter {
constructor(protocol, config) { constructor(protocol, config) {
this.config = config;
this.protocol = protocol; this.protocol = protocol;
this.config = config;
this.axios = axios; this.axios = axios;
this.validator = new Validator(protocol.schema); this.validator = new Validator(protocol.schema);
this.auth(); this.auth();
...@@ -70,11 +70,12 @@ class Adapter { ...@@ -70,11 +70,12 @@ class Adapter {
* @returns {object} * @returns {object}
*/ */
auth() { auth() {
let config = this.config;
return this.axios return this.axios
.get(`${this.config.api}/token`, { .get(`${config.api}/token`, {
params: { params: {
client_id: this.config.client_id, client_id: config.client_id,
secret: this.config.secret, secret: config.secret,
}, },
}) })
.then((response) => { .then((response) => {
...@@ -90,9 +91,10 @@ class Adapter { ...@@ -90,9 +91,10 @@ class Adapter {
* @returns {object} * @returns {object}
*/ */
poll() { poll() {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.get(`${this.config.api}/receive`, { return this.axios.get(`${config.api}/receive`, {
headers, headers,
}); });
}) })
...@@ -118,10 +120,11 @@ class Adapter { ...@@ -118,10 +120,11 @@ class Adapter {
* @returns * @returns
*/ */
publish(topic, body) { publish(topic, body) {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${this.config.api}/send`, `${config.api}/send`,
{ {
topic, topic,
body, body,
...@@ -148,10 +151,11 @@ class Adapter { ...@@ -148,10 +151,11 @@ class Adapter {
* @returns * @returns
*/ */
broadcast(body) { broadcast(body) {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${this.config.api}/notify`, `${config.api}/notify`,
{ {
body, body,
}, },
......
...@@ -6,8 +6,8 @@ import axios from 'axios'; ...@@ -6,8 +6,8 @@ import axios from 'axios';
*/ */
export class Adapter { export class Adapter {
constructor(protocol, config) { constructor(protocol, config) {
this.config = config;
this.protocol = protocol; this.protocol = protocol;
this.config = config;
this.axios = axios; this.axios = axios;
this.validator = new Validator(protocol.schema); this.validator = new Validator(protocol.schema);
this.auth(); this.auth();
...@@ -68,11 +68,12 @@ export class Adapter { ...@@ -68,11 +68,12 @@ export class Adapter {
* @returns {object} * @returns {object}
*/ */
auth() { auth() {
let config = this.config;
return this.axios return this.axios
.get(`${this.config.api}/token`, { .get(`${config.api}/token`, {
params: { params: {
client_id: this.config.client_id, client_id: config.client_id,
secret: this.config.secret, secret: config.secret,
}, },
}) })
.then((response) => { .then((response) => {
...@@ -88,9 +89,10 @@ export class Adapter { ...@@ -88,9 +89,10 @@ export class Adapter {
* @returns {object} * @returns {object}
*/ */
poll() { poll() {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.get(`${this.config.api}/receive`, { return this.axios.get(`${config.api}/receive`, {
headers, headers,
}); });
}) })
...@@ -116,10 +118,11 @@ export class Adapter { ...@@ -116,10 +118,11 @@ export class Adapter {
* @returns * @returns
*/ */
publish(topic, body) { publish(topic, body) {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${this.config.api}/send`, `${config.api}/send`,
{ {
topic, topic,
body, body,
...@@ -146,10 +149,11 @@ export class Adapter { ...@@ -146,10 +149,11 @@ export class Adapter {
* @returns * @returns
*/ */
broadcast(body) { broadcast(body) {
let config = this.config;
return this.getAuthorizationHeader() return this.getAuthorizationHeader()
.then((headers) => { .then((headers) => {
return this.axios.post( return this.axios.post(
`${this.config.api}/notify`, `${config.api}/notify`,
{ {
body, body,
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment