Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
Typescript + other nice things
  • Loading branch information
walexnelson authored Aug 1, 2017
2 parents 0465c1b + 9d25992 commit cc0013c
Show file tree
Hide file tree
Showing 58 changed files with 4,336 additions and 1,609 deletions.
20 changes: 0 additions & 20 deletions .eslintrc

This file was deleted.

4 changes: 0 additions & 4 deletions .mocharc

This file was deleted.

9 changes: 0 additions & 9 deletions .npmignore

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
## 1.0.1

* NPM setup documentation

## 2.0.0

* Rewrite in TypeScript
* Require a Scope array as part of the DomoClient instantiation
* Replace pre-request validation with a post-request 401 check. If 401 then access token is refreshed and the original request is repeated
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
* View the [changelog](CHANGELOG.md)

### Usage
* See `/examples` for full usage
* For basic usage see [/examples](/examples)
* For full TypeScript usage refer to [/test](/test).
* Create an API Client on the [Domo Developer Portal](https://developer.domo.com/)
* Use your API Client id/secret to instantiate an SDK instance
* Multiple API Clients can be used by instantiating multiple SDK clients
Expand Down
16 changes: 8 additions & 8 deletions examples/create-dataset.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const Domo = require('../src');
const { DomoClient } = require('../dist');
const { API_SCOPE } = require('../dist/common/Constants');

let datasetId;
const clientId = process.env.DOMO_CLIENT_ID;
const clientSecret = process.env.DOMO_CLIENT_SECRET;
const host = 'api.domo.com';
let datasetId;
const scopes = [API_SCOPE.DATA];

const domo = new Domo(clientId, clientSecret, host);
const domo = new DomoClient(clientId, clientSecret, scopes, host);

const dataset = {
name: 'Boba Fett Contracts',
Expand All @@ -23,13 +25,11 @@ const dataset = {
}
};


domo.datasets.create(dataset)
.then(res => {
console.log('\nDataset Created', res.id);
datasetId = res.id;

console.log('\nDataset Created', datasetId);

const data = [
['Jabba the Hutt', '2017-01-01', '2017-06-01', '', 'Han Solo', 'Endor'],
['Darth Vader', '2017-01-01', '2017-06-01', '', 'Luke Skywalker', 'Tatooine']
Expand All @@ -46,5 +46,5 @@ domo.datasets.create(dataset)

return domo.datasets.exportData(datasetId, true);
})
.then(res => { console.log('\nDataset Exported:\n', res); })
.catch(err => { console.error(err); });
.then(console.log)
.catch(console.warn);
46 changes: 24 additions & 22 deletions examples/create-stream.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
const Domo = require('../src');
const { DomoClient } = require('../dist');
const { API_SCOPE, UPDATE_METHODS } = require('../dist/common/Constants');

const clientId = process.env.DOMO_CLIENT_ID;
const clientSecret = process.env.DOMO_CLIENT_SECRET;
const host = 'api.domo.com';

const domo = new Domo(clientId, clientSecret, host);

const dataset = {
name: 'Leonhard Euler Party',
description: 'Mathematician Guest List',
schema: {
columns: [{
type: 'STRING',
name: 'Friend'
}, {
type: 'STRING',
name: 'Attending'
}]
}
const scopes = [API_SCOPE.DATA];

const domo = new DomoClient(clientId, clientSecret, scopes, host);

const stream = {
dataSet: {
name: 'Leonhard Euler Party',
description: 'Mathematician Guest List',
schema: {
columns: [{
type: 'STRING',
name: 'Friend'
}, {
type: 'STRING',
name: 'Attending'
}]
}
},
updateMethod: UPDATE_METHODS[UPDATE_METHODS.APPEND]
};

domo.streams.create(dataset, 'APPEND')
domo.streams.create(stream)
.then(res => {
console.log('\nNew Stream: ', res.id, res.dataSet.id);

Expand All @@ -29,8 +34,6 @@ domo.streams.create(dataset, 'APPEND')
});
})
.then(res => {
console.log('\nExecution Ready:', res);

const data = [
['Pythagoras', 'FALSE'],
['Alan Turing', 'TRUE'],
Expand All @@ -44,6 +47,5 @@ domo.streams.create(dataset, 'APPEND')
return domo.streams.uploadPart(res.streamId, res.execId, 1, csv)
.then(() => domo.streams.commit(res.streamId, res.execId));
})
.then(res => {
console.log('\nDataset Ready: ', res);
});
.then(console.log)
.catch(console.warn);
21 changes: 14 additions & 7 deletions examples/get-dataset.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
const Domo = require('../src');
const { DomoClient } = require('../dist');
const { API_SCOPE } = require('../dist/common/Constants');

const clientId = process.env.DOMO_CLIENT_ID;
const clientSecret = process.env.DOMO_CLIENT_SECRET;

const datasetId = 'e10348d6-b0ab-4471-9195-4f862ac3c56c';
const scopes = [API_SCOPE.DATA];
const host = 'api.domo.com';

const domo = new Domo(clientId, clientSecret, host);
const domo = new DomoClient(clientId, clientSecret, scopes, host);

const limit = 5;
const offset = 0;
const sort = 'name';

domo.datasets.list('name', 5, 0)
.then(res => { console.log('\nDatasetList', res.length); })
.catch(err => { console.error(err); });
domo.datasets.list(limit, offset, sort)
.then(res => { console.log(`\nDatasetList: ${res.length}`); })
.catch(console.error);

domo.datasets.get(datasetId)
.then(res => { console.log('\nDataset', res); })
.catch(err => { console.error(err); });
.then(res => { console.log(`\nDataset: ${res.id} - ${res.name}`); })
.catch(console.error);
9 changes: 5 additions & 4 deletions examples/get-group.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const Domo = require('../src');

const { DomoClient } = require('../dist');
const { API_SCOPE } = require('../dist/common/Constants');
const clientId = process.env.DOMO_CLIENT_ID;
const clientSecret = process.env.DOMO_CLIENT_SECRET;
const host = 'api.domo.com';
const scopes = [API_SCOPE.USER];

const domo = new Domo(clientId, clientSecret, host);
const domo = new DomoClient(clientId, clientSecret, scopes, host);

domo.groups.list(3, 0)
.then(res => { console.log('\nGroup List', res); })
.catch(err => { console.error(err); });
.catch(console.error);
15 changes: 15 additions & 0 deletions examples/get-policies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { DomoClient } = require('../dist');
const { API_SCOPE } = require('../dist/common/Constants');

const clientId = process.env.DOMO_CLIENT_ID;
const clientSecret = process.env.DOMO_CLIENT_SECRET;

const datasetId = 'e10348d6-b0ab-4471-9195-4f862ac3c56c';
const scopes = [API_SCOPE.DATA];
const host = 'api.domo.com';

const domo = new DomoClient(clientId, clientSecret, scopes, host);

domo.policies.list(datasetId)
.then(res => { console.log(`\nPolicies: ${res.length}`); })
.catch(console.error);
14 changes: 8 additions & 6 deletions examples/get-user.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
const Domo = require('../src');
const { DomoClient } = require('../dist');
const { API_SCOPE } = require('../dist/common/Constants');

const clientId = process.env.DOMO_CLIENT_ID;
const clientSecret = process.env.DOMO_CLIENT_SECRET;
const userId = '715147833';
const host = 'api.domo.com';
const scopes = [API_SCOPE.USER];

const domo = new Domo(clientId, clientSecret, host);
const domo = new DomoClient(clientId, clientSecret, scopes, host);

domo.users.get(userId)
.then(res => { console.log('\nUser', res); })
.catch(err => { console.error(err); });
.then(res => { console.log('\nUser', res.email); })
.catch(console.error);

domo.users.list(3, 0)
.then(res => { console.log('\nUser List', res); })
.catch(err => { console.error(err); });
.then(res => { console.log('\nUser List', res.length); })
.catch(console.error);
7 changes: 7 additions & 0 deletions mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test/**/*.spec.ts
--require ts-node/register
--compilers ts:ts-node/register
--reporter list
--watch-extensions ts
--recursive
--colors
Loading

0 comments on commit cc0013c

Please sign in to comment.