favorite-product-api.js 889 Bytes
/**
 * Created by TaoHuang on 2016/6/13.
 */

const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const log = require(`${library}/logger`);

const api = new API();

module.exports.isFavoriteAsync = function(uid, pid) {
    return api.get('', sign.apiSign({
        method: 'app.favorite.isFavorite',
        id: pid,
        uid: uid,
        type: 'product'
    })).catch(log.error);
};

module.exports.createAsync = function(uid, pid) {
    return api.get('', sign.apiSign({
        method: 'app.favorite.add',
        id: pid,
        uid: uid,
        type: 'product'
    })).catch(log.error);
};

module.exports.deleteAsync = function(uid, pid) {
    return api.get('', sign.apiSign({
        method: 'app.favorite.cancel',
        fav_id: pid,
        uid: uid,
        type: 'product'
    })).catch(log.error);
};