I want to write a Yeoman generator to setup new projects. During this process, I want it to create a new project in Basecamp. Is it possible to hit the BCX API — or any API for that matter — with Yeoman? And how would I do this?
I actually found this out by myself and it really isn’t that difficult. I just used the request node module to do this.
For the BCX API and my project in particular I did it this way (inside a Yeoman Generator):
var r = request.defaults({
'auth': {
'user': 'USERNAME',
'pass': 'PASSWORD',
'sendImmediately': true
},
'header': {
'User-Agent': 'PROJECT NAME (EMAIL_ADDRESS)'
}
});
r.post({
'url': 'https://basecamp.com/ACCOUNT_ID/api/v1/projects.json',
'json': true,
'body': {
'name': 'foobar'
}
}, function(error, response, body) {
// Callback Stuff
});
I hope this helps anyone.