-
Notifications
You must be signed in to change notification settings - Fork 132
/
jsonrpc.php
166 lines (111 loc) · 3.48 KB
/
jsonrpc.php
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
require 'common.php';
require 'vendor/JsonRPC/Server.php';
use JsonRPC\Server;
$server = new Server;
$server->authentication(array(
Model\get_config_value('username') => Model\get_config_value('api_token')
));
// Get all feeds
$server->register('feed.list', function () {
return Model\get_feeds();
});
// Get one feed
$server->register('feed.info', function ($feed_id) {
return Model\get_feed($feed_id);
});
// Add a new feed
$server->register('feed.create', function($url) {
$result = Model\import_feed($url);
Model\write_debug();
return $result;
});
// Delete a feed
$server->register('feed.delete', function($feed_id) {
return Model\remove_feed($feed_id);
});
// Delete all feeds
$server->register('feed.delete_all', function() {
return Model\remove_feeds();
});
// Enable a feed
$server->register('feed.enable', function($feed_id) {
return Model\enable_feed($feed_id);
});
// Disable a feed
$server->register('feed.disable', function($feed_id) {
return Model\disable_feed($feed_id);
});
// Update a feed
$server->register('feed.update', function($feed_id) {
return Model\update_feed($feed_id);
});
// Get all items for a specific feed
$server->register('item.feed.list', function ($feed_id, $offset = null, $limit = null) {
return Model\get_feed_items($feed_id, $offset, $limit);
});
// Count all feed items
$server->register('item.feed.count', function ($feed_id) {
return Model\count_feed_items($feed_id);
});
// Get all bookmark items
$server->register('item.bookmark.list', function ($offset = null, $limit = null) {
return Model\get_bookmarks($offset, $limit);
});
// Count bookmarks
$server->register('item.bookmark.count', function () {
return Model\count_bookmarks();
});
// Add a bookmark
$server->register('item.bookmark.create', function ($item_id) {
return Model\set_bookmark_value($item_id, 1);
});
// Remove a bookmark
$server->register('item.bookmark.delete', function ($item_id) {
return Model\set_bookmark_value($item_id, 0);
});
// Get all unread items
$server->register('item.list_unread', function ($offset = null, $limit = null) {
return Model\get_items('unread', $offset, $limit);
});
// Count all unread items
$server->register('item.count_unread', function () {
return Model\count_items('unread');
});
// Get all read items
$server->register('item.list_read', function ($offset = null, $limit = null) {
return Model\get_items('read', $offset, $limit);
});
// Count all read items
$server->register('item.count_read', function () {
return Model\count_items('read');
});
// Get one item
$server->register('item.info', function ($item_id) {
return Model\get_item($item_id);
});
// Delete an item
$server->register('item.delete', function($item_id) {
return Model\set_item_removed($item_id);
});
// Mark item as read
$server->register('item.mark_as_read', function($item_id) {
return Model\set_item_read($item_id);
});
// Mark item as unread
$server->register('item.mark_as_unread', function($item_id) {
return Model\set_item_unread($item_id);
});
// Change the status of list of items
$server->register('item.set_list_status', function($status, array $items) {
return Model\set_items_status($status, $items);
});
// Flush all read items
$server->register('item.flush', function() {
return Model\mark_as_removed();
});
// Mark all unread items as read
$server->register('item.mark_all_as_read', function() {
return Model\mark_as_read();
});
echo $server->execute();