-
Notifications
You must be signed in to change notification settings - Fork 1
/
taskk.js
124 lines (103 loc) · 3 KB
/
taskk.js
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Generated by CoffeeScript 1.5.0
(function() {
var TaskkAPI;
TaskkAPI = (function() {
var auth, domain, make_base_auth;
domain = "https://api.taskk.it/v1/";
auth = "";
function TaskkAPI(token) {
this.token = token;
if (this.token) {
this.set_token(this.token);
}
}
TaskkAPI.prototype.set_token = function(token) {
return auth = "?token=" + token;
};
TaskkAPI.prototype.ping = function() {
return $.get(domain + "auth/ping/" + auth);
};
make_base_auth = function(user, password) {};
TaskkAPI.prototype.login = function(login, password) {
return $.ajax({
type: "POST",
url: domain + "auth/login/",
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function(xhr) {
var basic_auth, hash, tok;
tok = login + ":" + password;
hash = btoa(tok);
basic_auth = "Basic " + hash;
xhr.setRequestHeader("Authorization", basic_auth);
}
});
};
TaskkAPI.prototype.get_lists = function() {
return $.get(domain + "lists/" + auth);
};
TaskkAPI.prototype.get_tasks = function() {
return $.get(domain + "tasks/" + auth);
};
TaskkAPI.prototype.get_task = function(id) {
return $.get(domain + "tasks/" + id + "/" + auth);
};
TaskkAPI.prototype.get_list = function(id) {
return $.get(domain + "lists/" + id + "/" + auth);
};
TaskkAPI.prototype.create_task = function(params) {
return $.ajax({
url: domain + "tasks/" + auth,
type: "POST",
data: JSON.stringify({
task: params
}),
contentType: "application/json; charset=utf-8",
dataType: "json"
});
};
TaskkAPI.prototype.create_list = function(params) {
return $.ajax({
url: domain + "lists/" + auth,
type: "POST",
data: JSON.stringify({
list: params
}),
contentType: "application/json; charset=utf-8",
dataType: "json"
});
};
TaskkAPI.prototype.edit_task = function(id, params) {
return $.ajax({
url: domain + "tasks/" + id + "/" + auth,
type: "PUT",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
task: params
})
});
};
TaskkAPI.prototype.complete_task = function(id) {
return $.ajax({
url: domain + "tasks/" + id + "/complete" + auth,
type: "PUT",
contentType: "application/json; charset=utf-8",
dataType: "json"
});
};
TaskkAPI.prototype.edit_list = function(id, params) {
return $.ajax({
url: domain + "lists/" + id + "/" + auth,
type: "PUT",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
list: params
})
});
};
return TaskkAPI;
})();
window.TaskkAPI = TaskkAPI;
}).call(this);