forked from Ermlab/nxt-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsers.js
More file actions
102 lines (90 loc) · 2.59 KB
/
Users.js
File metadata and controls
102 lines (90 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Generated by CoffeeScript 1.7.1
(function() {
var BaseModel, Users,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
BaseModel = require('../BaseModel');
Users = (function(_super) {
__extends(Users, _super);
function Users() {
this.session = __bind(this.session, this);
this.create = __bind(this.create, this);
this.show = __bind(this.show, this);
this.current = __bind(this.current, this);
this.all = __bind(this.all, this);
return Users.__super__.constructor.apply(this, arguments);
}
Users.prototype.all = function(fn) {
if (fn == null) {
fn = null;
}
this.debug("Users::all()");
return this.get("users", (function(_this) {
return function(data) {
if (fn) {
return fn(data);
}
};
})(this));
};
Users.prototype.current = function(fn) {
if (fn == null) {
fn = null;
}
this.debug("Users::current()");
return this.get("user", function(data) {
if (fn) {
return fn(data);
}
});
};
Users.prototype.show = function(userId, fn) {
if (fn == null) {
fn = null;
}
this.debug("Users::show()");
return this.get("users/" + (parseInt(userId)), (function(_this) {
return function(data) {
if (fn) {
return fn(data);
}
};
})(this));
};
Users.prototype.create = function(params, fn) {
if (params == null) {
params = {};
}
if (fn == null) {
fn = null;
}
this.debug("Users::create()", params);
return this.post("users", params, function(data) {
if (fn) {
return fn(data);
}
});
};
Users.prototype.session = function(email, password, fn) {
var params;
if (fn == null) {
fn = null;
}
this.debug("Users::session()");
params = {
email: email,
password: password
};
return this.post("session", params, function(data) {
if (fn) {
return fn(data);
}
});
};
return Users;
})(BaseModel);
module.exports = function(client) {
return new Users(client);
};
}).call(this);