charltoons/hipchatter

Add emoticons

macklinu opened this issue · 5 comments

Hello! I would like to add emoticons to this project. I've forked it and started working on an emoticons function that I wanted to run by you.

hipchatter.emoticons(params, callback);

When retrieving a specific emoticon

hipchatter.emoticons(34, function(err, results){} );

or

hipchatter.emoticons('fonzie', function(err, results){} );

When retrieving all emoticons
You could pass in an optional object that will set the query string parameters. Below is an object with the default query string params.

hipchatter.emoticons({start_index: 0, max_results: 100, type: 'all'}, function(err, results){} );

Or you could just leave it blank to get all emoticons with the default params (meaning the first 100).

hipchatter.emoticons(function(err, results){} );

However...

Elsewhere in the API, you use different functions to retrieve an array of objects vs. that specific object, like hipchatter.webhooks() vs. hipchatter.get_webhook()`. So instead, this could be:

hipchatter.emoticons(params, callback); // params optional
hipchatter.get_emoticon(id, callback); // id required

Thoughts on which one makes more sense? Thanks!

Awesome, thanks! So my initial thinking was just to keep it as colloquial as possible. But, I thought get_webhook and get_webhooks looked too similar and could unintentionally lead to typos. For now, I think that we should keep the similar structure (get_emoticon(id, callback) and emoticons(params, callback)) but include emoticons(id, callback) as a shortcut by using:

get_emoticon: function(id, callback){
    // get_emoticon()
},
emoticons: function(params, callback){
    if (typeof params === 'number') return this.get_emoticon(params, callback);
    // rest of emoticons()
}

Does that make sense? Thoughts?

That makes sense to me. I can work with that.

I'd like to edit the hipchatter.request() or hipchatter.request() functions to allow sending a GET request with query string parameters. For example, to select a certain range of emoticons via the Hipchat API, a URL would look something like this:

api.hipchat.com/v2/emoticon?auth_token=XXX&type=group

This allows to get emoticons uploaded by the group/company you belong to. I'll rework some of the API functions and let you review them via a pull request sometime later this week/weekend if that's cool.

Sounds good to me! Thats what tests are for 😃

PR #4 should take care of this pending code approval.

#4 Merged.