Skip to content

Commit

Permalink
Updated readme and example
Browse files Browse the repository at this point in the history
  • Loading branch information
Grégoire Weber committed Mar 31, 2017
1 parent 10ed194 commit 67e9f5c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var barracks = new Barracks({
});
```

### Check for an update:
### Check for new packages and package updates:
```js
var packages = [
{
Expand Down
28 changes: 21 additions & 7 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,38 @@ process.argv.forEach(function (val, index) {
** documentation for more information. **/
var barracksBaseUrl = args.baseUrl;
var barracksApiKey = args.apiKey;
var isSelfSigned = args.selfSigned;

if (!barracksApiKey) {
console.log('Argument --apiKey <API_KEY> is mandatory.');
console.log('<API_KEY> is your user api key that you can find on the Account page of Barracks.');
console.log('You can also use the argument --baseUrl <BARRACKS_URL> if you want to request another domain than the default one.');
console.log('And the argument --selfSigned with value 1 or 0 if your baseUrl use a self signed certificate.');
process.exit();
}

var device = {
versionId: 'v0.0.0',
unitId: 'unit9'
};
var unitId = 'SDK-example-unit';

var packages = [
{
reference: 'greg.pckg.test',
version: '0.2.0'
},
{
reference: 'com.test.1234',
version: 'v-1490894199'
},
{
reference: 'ref-package-1490294068',
version: 'coucou'
}
];

var barracks = new Barracks({
baseURL: barracksBaseUrl,
apiKey: barracksApiKey,
unitId: device.unitId,
downloadFilePath: '/tmp/file.tmp'
unitId: unitId,
allowSelfSigned: (isSelfSigned ? (isSelfSigned === '1') : false)
});

function donwloadPackages(packages) {
Expand Down Expand Up @@ -77,7 +91,7 @@ function handleUnavailablePackages(packages) {

function waitAndDisplayUpdate() {
setTimeout(function () {
barracks.checkUpdate(device.versionId, { gender: 'Female' }).then(function (response) {
barracks.checkUpdate(packages, { test: 'coucou' }).then(function (response) {
handleAvailablePackages(response.available);
handleChangedPackages(response.changed);
handleUnchangedPackages(response.unchanged);
Expand Down

0 comments on commit 67e9f5c

Please sign in to comment.