yoho-api.js 1.64 KB
'use strict';

/**
 * 连接提交
 * http://ziyuan.baidu.com/linksubmit/index?site=https://www.yohobuy.com/
 */
class YohoApi extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    searchList(params, cache) {
        params = Object.assign({
            limit: 100,
            method: 'app.search.li',
            status: 1,
            stocknumber: 1,
            attribute_not: 2,
            udid: 'seo_format_data'
        }, params);

        return this.get({
            data: params,
            param: {
                cache: cache || false
            }
        }).catch(e => {
            console.log(e.message);
            return {code: 400, data: {}, message: e.message};
        });
    }

    bdPromotion(params, cache) {
        params = Object.assign({
            method: 'web.product.bdPromotion',
            udid: 'seo_format_data'
        }, params);

        return this.get({
            data: params,
            param: {
                cache: cache || false
            }
        }).catch(e => {
            console.log(e.message);
            return {code: e.statusCode || 400, data: {}, message: e.message};
        });
    }

    getLastArticleList(params) {
        params = Object.assign({
            limit: 100,
            udid: 'seo_format_data'
        }, params);

        return this.get({
            url: '/guang/api/v2/article/getLastArticleList',
            data: params,
            api: global.yoho.ServiceAPI
        }).catch(e => {
            console.log(e.message);
            return {code: e.statusCode || 400, data: {}, message: e.message};
        });
    }
}

module.exports = YohoApi;