count.js 546 Bytes
'use strict';

const api = global.yoho.API;

const cartCount = (uid, shoppingKey) => {
    let params = {
        method: 'app.Shopping.count'
    };

    if (!uid && !shoppingKey) {
        return Promise.resolve({});
    }

    if (uid) {
        Object.assign(params, {
            uid: uid
        });
    }

    if (shoppingKey) {
        Object.assign(params, {
            shopping_key: shoppingKey
        });
    }

    return api.get('', params).then((result) => {
        return result;
    });
};

module.exports = {
    cartCount
};