Skip to content

Commit

Permalink
Resolves #4
Browse files Browse the repository at this point in the history
  • Loading branch information
gpedro committed May 8, 2015
1 parent ecf6723 commit 95d6ce3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ $ npm run browser
#### getNoticias()
> Você pode integrar as chamadas das notícias do Vagalume em seu site. Assim, você poderá oferecer um conteúdo bastante atualizados sobre o que acontece no mundo da música. No código abaixo, mostramos as últimas 20 notícias publicadas com informações para link e imagem. ([ver mais](http://api.vagalume.com.br/docs/news/))
#### getImagens()
> O Vagalume possui também um banco de imagens organizadas por galerias. Disponibilizadas pelo próprio artista no caso como (Divulgação) ou as que os prórpios usuários enviam (Enviadas pelos usuários). ([ver mais](http://api.vagalume.com.br/docs/image/))
## License

MIT © [Gabriel Pedro](https://gpedro.net)
Expand Down
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ function Vagalume() {
return PRIVATE.wwwRequest('/news/index.js');
};

PUBLIC.getImagens = function (bandId, limit) {
PRIVATE.requiredParam('bandID', bandId, 'string');
PRIVATE.optionalParam('limit', limit, 'int');

var opts = { bandID: bandId };

if (limit > 0) {
opts.limit = limit;
}

return PRIVATE.apiRequest('/image.php?', opts);
};

return this;
}

Expand Down
35 changes: 35 additions & 0 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,39 @@ describe('node-vagalume node module', function () {

});


it('VagalumeAPI :: getImagens()', function () {

var fn = function () {
api.getImagens().catch(function (err) {
throw err;
});
};

assert.throws(function () { fn(); }, /O campo bandID é obrigatório/);

});

it('VagalumeAPI :: getImagens(q=3ade68b3gdb86eda3, limit=10)', function (done) {

api.getImagens('3ade68b3gdb86eda3', 10).then(function (response) {
assert(10, response.images.length);
done();
}).catch(function (err) {
throw err;
});

});

it('VagalumeAPI :: getImagens(q=3ade68b3gdb86eda3, limit=invalid)', function () {

var fn = function () {
return api.getImagens('3ade68b3gdb86eda3', 'hue').catch(function (err) {
throw err;
});
};

assert.throws(function () { fn(); }, /O campo limit deve ser do tipo int/);
});

});

0 comments on commit 95d6ce3

Please sign in to comment.