Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
suda committed Feb 10, 2017
1 parent 2ea7ff4 commit 766c4d0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
24 changes: 12 additions & 12 deletions src/Agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ export default class Agent {
}

get(uri, auth, query) {
return this.request({uri, auth, method: 'get', query: query});
return this.request({ uri, auth, method: 'get', query: query });
}

head(uri, auth) {
return this.request({uri, auth, method: 'head'});
return this.request({ uri, auth, method: 'head' });
}

post(uri, data, auth) {
return this.request({uri, data, auth, method: 'post'});
return this.request({ uri, data, auth, method: 'post' });
}

put(uri, data, auth) {
return this.request({uri, data, auth, method: 'put'});
return this.request({ uri, data, auth, method: 'put' });
}

delete(uri, data, auth) {
return this.request({uri, data, auth, method: 'delete'});
return this.request({ uri, data, auth, method: 'delete' });
}


Expand All @@ -60,9 +60,9 @@ export default class Agent {
* @param {Object} files array of file names and file content
* @return {Promise} A promise. fulfilled with {body, statusCode}, rejected with { statusCode, errorDescription, error, body }
*/
request({uri, method, data = undefined, auth, query = undefined, form = undefined, files = undefined}) {
request({ uri, method, data = undefined, auth, query = undefined, form = undefined, files = undefined }) {
const requestFiles = this._sanitizeFiles(files);
return this._request({uri, method, data, auth, query, form, files: requestFiles});
return this._request({ uri, method, data, auth, query, form, files: requestFiles });
}

/**
Expand All @@ -76,8 +76,8 @@ export default class Agent {
* @param {Object} files array of file names and file content
* @return {Promise} A promise. fulfilled with {body, statusCode}, rejected with { statusCode, errorDescription, error, body }
*/
_request({uri, method, data, auth, query, form, files}) {
const req = this._buildRequest({uri, method, data, auth, query, form, files});
_request({ uri, method, data, auth, query, form, files }) {
const req = this._buildRequest({ uri, method, data, auth, query, form, files });
return this._promiseResponse(req);
}

Expand Down Expand Up @@ -112,7 +112,7 @@ export default class Agent {
shortErrorDescription = body.error_description;
}
const reason = new Error(errorDescription);
Object.assign(reason, {statusCode, errorDescription, shortErrorDescription, error, body});
Object.assign(reason, { statusCode, errorDescription, shortErrorDescription, error, body });
reject(reason);
} else {
fulfill({
Expand All @@ -123,7 +123,7 @@ export default class Agent {
});
}

_buildRequest({uri, method, data, auth, query, form, files, makerequest=request}) {
_buildRequest({ uri, method, data, auth, query, form, files, makerequest=request }) {
const req = makerequest(method, uri);
if (this.prefix) {
req.use(this.prefix);
Expand Down Expand Up @@ -165,7 +165,7 @@ export default class Agent {
if (auth.username !== undefined) {
req.auth(auth.username, auth.password);
} else {
req.set({Authorization: `Bearer ${auth}`});
req.set({ Authorization: `Bearer ${auth}` });
}
}
return req;
Expand Down
2 changes: 1 addition & 1 deletion src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class Client {
* @return {Promise} To publish the library
*/
publishLibrary(name) {
return this.api.publishLibrary({name, auth: this.auth })
return this.api.publishLibrary({ name, auth: this.auth })
.then(payload => {
const library = payload.body.data || {};
return new Library(this, library);
Expand Down
2 changes: 1 addition & 1 deletion src/Defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export default {
baseUrl: 'https://api.particle.io',
clientSecret: 'particle-api',
clientId: 'particle-api',
tokenDuration: 7776000, // 90 days
tokenDuration: 7776000 // 90 days
};
21 changes: 11 additions & 10 deletions src/EventStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ class EventStream extends EventEmitter {
res.on('end', () => {
try {
body = JSON.parse(body);
} catch (e) {}
this.emit('response', {
statusCode,
body
});
let errorDescription = `HTTP error ${statusCode} from ${this.uri}`;
if (body && body.error_description) {
errorDescription += ' - ' + body.error_description;
} finally {
this.emit('response', {
statusCode,
body
});
let errorDescription = `HTTP error ${statusCode} from ${this.uri}`;
if (body && body.error_description) {
errorDescription += ' - ' + body.error_description;
}
reject({ statusCode, errorDescription, body });
this.req = undefined;
}
reject({ statusCode, errorDescription, body });
this.req = undefined;
});
return;
}
Expand Down
24 changes: 12 additions & 12 deletions src/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Particle {
grant_type: 'password',
client_id: this.clientId,
client_secret: this.clientSecret,
expires_in: tokenDuration,
expires_in: tokenDuration
}, method: 'post' });
}

Expand All @@ -56,7 +56,7 @@ class Particle {
return this.post('/v1/users', {
username,
password,
account_info : accountInfo,
account_info : accountInfo
});
}

Expand Down Expand Up @@ -89,7 +89,7 @@ class Particle {
*/
removeAccessToken({ username, password, token }) {
return this.delete(`/v1/access_tokens/${token}`, {
access_token: token,
access_token: token
}, { username, password });
}

Expand Down Expand Up @@ -166,14 +166,14 @@ class Particle {
return this.post('/v1/device_claims', { iccid }, auth);
}

validatePromoCode({auth, promoCode}) {
validatePromoCode({ auth, promoCode }) {
return this.get(`/v1/promo_code/${promoCode}`, auth);
}

changeProduct({ deviceId, productId, shouldUpdate, auth }) {
return this.put(`/v1/devices/${deviceId}`, {
product_id: productId,
update_after_claim: shouldUpdate || false,
update_after_claim: shouldUpdate || false
}, auth);
}

Expand All @@ -197,7 +197,7 @@ class Particle {
*/
signalDevice({ deviceId, signal, auth }) {
return this.put(`/v1/devices/${deviceId}`, {
signal: ( !!signal ? '1' : '0' ),
signal: ( signal ? '1' : '0' )
}, auth);
}

Expand Down Expand Up @@ -228,7 +228,7 @@ class Particle {
*/
flashTinker({ deviceId, auth }) {
return this.put(`/v1/devices/${deviceId}`, {
app: 'tinker',
app: 'tinker'
}, auth);
}

Expand Down Expand Up @@ -296,7 +296,7 @@ class Particle {
*/
callFunction({ deviceId, name, argument, auth }) {
return this.post(`/v1/devices/${deviceId}/${name}`, {
args: argument,
args: argument
}, auth);
}

Expand Down Expand Up @@ -433,7 +433,7 @@ class Particle {
return this.put(`/v1/sims/${iccid}`, {
country: countryCode,
promo_code: promoCode,
action: 'activate',
action: 'activate'
}, auth);
}

Expand Down Expand Up @@ -530,8 +530,8 @@ class Particle {
files, auth, method: 'post' });
}

publishLibrary({auth, name}) {
return this.request({ uri: `/v1/libraries/${name}`, auth, method: 'patch', data: {visibility:'public'}});
publishLibrary({ auth, name }) {
return this.request({ uri: `/v1/libraries/${name}`, auth, method: 'patch', data: { visibility:'public' } });
}

/**
Expand Down Expand Up @@ -588,7 +588,7 @@ class Particle {
}

client(options = {}) {
return new Client(Object.assign({ api: this}, options));
return new Client(Object.assign({ api: this }, options));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/superagent-binary-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default function binaryParser(res, fn) {
let data = [];
res.on('data', chunk => data.push(chunk));
res.on('end', () => fn(null, Buffer.concat(data)));
};
}

0 comments on commit 766c4d0

Please sign in to comment.