Skip to content

Commit

Permalink
Merge pull request #10 from kiteco/adds-kite-local
Browse files Browse the repository at this point in the history
Adds kite local
  • Loading branch information
dbratz1177 authored Nov 20, 2018
2 parents 1ed9b9a + 6cfcb75 commit 756429f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ KiteAPI.requestJSON({path}).then(data => {
})
```

#### .isKiteLocal()

Makes a `GET` request to Kite at the endpoint `/clientapi/iskitelocal`. Responds with a boolean resolving Promise to `true` in the case of a `200` status code, `false` otherwise

```js
KiteAPI.isKiteLocal().then(isLocal => {
// do stuff related to kite-locality
})
```

#### .setKiteSetting(key, value)

Makes a `POST` request to Kite at the endpoint `/clientapi/settings/${key}`, where the body is set to `value`. It automatically parses the JSON response when the status code is `200`
Expand Down
9 changes: 9 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ const KiteAPI = {
.then(data => JSON.parse(data));
},

isKiteLocal() {
return this.request({
path: '/clientapi/iskitelocal',
method: 'GET',
})
.then(() => true)
.catch(() => false);
},

setKiteSetting(key, value) {
return this.requestJSON({
path: `/clientapi/settings/${key}`,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kite-api",
"version": "2.1.2",
"version": "2.2.0",
"description": "API methods to access Kite",
"main": "lib/index.js",
"repository": {
Expand Down
8 changes: 8 additions & 0 deletions test/kite-api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ describe('KiteAPI', () => {
});
});

describe('.isKiteLocal()', () => {
it('returns a boolean resolving promise', () => {
return KiteAPI.isKiteLocal().then((isLocal) => {
expect(isLocal).to.be.a('boolean')
})
})
})

describe('.canAuthenticateUser()', () => {
withKite({reachable: false}, () => {
it('returns a rejecting promise', () => {
Expand Down

0 comments on commit 756429f

Please sign in to comment.