Created by
Robert Poz
last modified
|
favorites: function favorites(cb) {
// { favorites: [{ channel_id: <id>, ... }]
this.req('tv_favorites', {}, function(resp) {
var converted = {
favorites: _.map(resp, function(i) { return { channel_id: i }; })
}
cb(converted)
})
},
favorites_set: function(place, channel_id, cb, method) {
var method = method || 'post'
var cb_wrap = function(resp) { cb(resp || {}) }
this.req('tv_favorites', { ch_id: channel_id }, cb_wrap, cb_wrap, method)
},
favorites_remove: function(place, channel_id, cb) {
var self = this;
var cb_wrap = function(resp) { cb(resp || {}) }
this.req('tv_favorites', {}, function(favorites_arr) {
self.favorites_set(
0,
_.without(favorites_arr, channel_id).join(),
cb_wrap,
'put'
)
})
}
|