/*
 * Avocore : twitter.js
 * copyright (c) 2015 Susisu
 */

"use strict";

function end_module() {
    module.exports = Object.freeze({
        "KeySet" : KeySet,
        "URIBase": URIBase,
        "rest"   : rest
    });
}

var request = require("request");

var actions = require("./actions.js");

function KeySet(consumerKey, consumerSecret, token, tokenSecret) {
    this.consumerKey    = consumerKey;
    this.consumerSecret = consumerSecret;
    this.token          = token;
    this.tokenSecret    = tokenSecret;
}

var URIBase = Object.freeze({
    "rest"      : "https://api.twitter.com/1.1/",
    "stream"    : "https://stream.twitter.com/1.1/",
    "userStream": "https://userstream.twitter.com/1.1/",
    "siteStream": "https://sitestream.twitter.com/1.1/",
    "media"     : "https://upload.twitter.com/1.1/"
});

function rest(keys, method, apiName, params) {
    method = method.toUpperCase();
    var options = {
        "oauth": {
            "consumer_key"   : keys.consumerKey,
            "consumer_secret": keys.consumerSecret,
            "token"          : keys.token,
            "token_secret"   : keys.tokenSecret
        },
        "method": method,
        "url"   : URIBase.rest + apiName + ".json"
    };
    switch (method) {
        case "GET":
            options["qs"] = params;
            break;
        case "POST":
            options["form"] = params;
            break;
        default:
            throw new Error("unknown request method: " + method);
    }
    return new actions.Action(function (emit) {
        request(options, function (error, response, data) {
            if (!error) {
                emit(data);
            }
            else {
                console.log(error);
            }
        });
    });
}

end_module();

@@ -208,16 +208,237 @@
   : rest
+,%0A%0A        %22getHomeTimeline%22 : getHomeTimeline,%0A        %22getMentions%22     : getMentions,%0A        %22getFollowersList%22: getFollowersList,%0A        %22updateStatus%22    : updateStatus,%0A        %22createFriendship%22: createFriendship
 %0A    %7D);
@@ -513,16 +513,53 @@
 ons.js%22)
+,%0A    utils   = require(%22./utils.js%22)
 ;%0A%0Afunct
@@ -2020,16 +2020,692 @@
  %7D);%0A%7D%0A%0A
+function getHomeTimeline(keys, params) %7B%0A    return rest(keys, %22get%22, %22statuses/home_timeline%22, params)%0A        .bind(utils.parseJSON);%0A%7D%0A%0Afunction getMentions(keys, params) %7B%0A    return rest(keys, %22get%22, %22statuses/mentions_timeline%22, params)%0A        .bind(utils.parseJSON);%0A%7D%0A%0Afunction getFollowersList(keys, params) %7B%0A    return rest(keys, %22get%22, %22followers/list%22, params)%0A        .bind(utils.parseJSON);%0A%7D%0A%0Afunction updateStatus(keys, params) %7B%0A    return rest(keys, %22post%22, %22statuses/update%22, params)%0A        .bind(utils.parseJSON);%0A%7D%0A%0Afunction createFriendship(keys, params) %7B%0A    return rest(keys, %22pos%22, %22friendships/create%22, params)%0A        .bind(utils.parseJSON);%0A%7D%0A%0A
 end_modu

Add some APIs