Snippets

ESTI design interal_api favorites call

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'
      )
    })
  }

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.