Skip to content

Commit

Permalink
Modified clients to get a component from its reference
Browse files Browse the repository at this point in the history
  • Loading branch information
VladRomero committed Apr 7, 2017
1 parent 24b4d33 commit 2a2f566
Show file tree
Hide file tree
Showing 4 changed files with 473 additions and 378 deletions.
3 changes: 1 addition & 2 deletions bin/barracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ if (config.v2Enabled) {
.command('create-segment', 'Create a new segment')
.command('edit-segment', 'Edit an existing segment')
.command('set-active-segments', 'Set active segments in priority order')
.command('check-update', 'Check for an update the same way a device would')
.command('package', 'Get a package from its reference');
.command('check-update', 'Check for an update the same way a device would');

if (config.experimental) {
barracks.command('create-filter', 'Create a filter')
Expand Down
21 changes: 21 additions & 0 deletions clients/Barracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,27 @@ class Barracks {
});
});
}

getPackage(token, componentRef) {
return new Promise((resolve, reject) => {
logger.debug('Getting package from its reference', componentRef);
this.client.sendEndpointRequest('getPackage', {
headers: {
'x-auth-token': token
},
pathVariables: {
componentRef
}
}).then(response => {
const myPackage = response.body;
logger.debug('Package retrieved:', myPackage);
resolve(myPackage);
}).catch(errResponse => {
logger.debug('Failed to retrieve package');
reject(errResponse.message);
});
});
}
}

module.exports = Barracks;

0 comments on commit 2a2f566

Please sign in to comment.