// Generated by CoffeeScript 1.8.0
(function() {
  var User,
    __slice = [].slice;

  User = (function() {
    function User(login, client) {
      this.login = login;
      this.client = client;
    }

    User.prototype.profile = function(data) {
      return Object.keys(data).forEach((function(_this) {
        return function(e) {
          return _this[e] = data[e];
        };
      })(this));
    };

    User.prototype.info = function(cb) {
      return this.client.get("/users/" + this.login, function(err, s, b, h) {
        if (err) {
          return cb(err);
        }
        if (s !== 200) {
          return cb(new Error('User info error'));
        } else {
          return cb(null, b, h);
        }
      });
    };

    User.prototype.followers = function() {
      var cb, params, _i, _ref;
      params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
      return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/followers"].concat(__slice.call(params), [function(err, s, b, h) {
        if (err) {
          return cb(err);
        }
        if (s !== 200) {
          return cb(new Error('User followers error'));
        } else {
          return cb(null, b, h);
        }
      }]));
    };

    User.prototype.following = function() {
      var cb, params, _i, _ref;
      params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
      return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/following"].concat(__slice.call(params), [function(err, s, b, h) {
        if (err) {
          return cb(err);
        }
        if (s !== 200) {
          return cb(new Error('User following error'));
        } else {
          return cb(null, b, h);
        }
      }]));
    };

    User.prototype.repos = function() {
      var cb, params, _i, _ref;
      params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
      return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/repos"].concat(__slice.call(params), [function(err, s, b, h) {
        if (err) {
          return cb(err);
        }
        if (s !== 200) {
          return cb(new Error('User repos error'));
        } else {
          return cb(null, b, h);
        }
      }]));
    };

    User.prototype.events = function() {
      var cb, events, params, _i, _ref;
      params = 3 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 2) : (_i = 0, []), events = arguments[_i++], cb = arguments[_i++];
      if (!cb && typeof events === 'function') {
        cb = events;
        events = null;
      } else if (events != null) {
        if (typeof events === 'number' && params.length > 0) {
          params[1] = events;
          events = null;
        } else if (!Array.isArray(events)) {
          events = [events];
        }
      }
      return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/events"].concat(__slice.call(params), [function(err, s, b, h) {
        if (err) {
          return cb(err);
        }
        if (s !== 200) {
          return cb(new Error('User events error'));
        }
        if (events != null) {
          b = b.filter(function(event) {
            return events.indexOf(event.type) !== -1;
          });
        }
        return cb(null, b, h);
      }]));
    };

    User.prototype.orgs = function() {
      var cb, params, _i, _ref;
      params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
      return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/orgs"].concat(__slice.call(params), [function(err, s, b, h) {
        if (err) {
          return cb(err);
        }
        if (s !== 200) {
          return cb(new Error('User organizations error'));
        } else {
          return cb(null, b, h);
        }
      }]));
    };

    return User;

  })();

  module.exports = User;

}).call(this);
