const Request = require("./Request")
    , productSample = require('./data/ProductSample');

class Product extends Request {

    constructor() {
        super()
    }

    getProductPage(params) {
        return this.request({ method: 'GET', path: '/v2/providers/seller_api/apis/api/v1/marketplace/seller-products?' + this.getQuery(params) })
    }

    getProduct(params) {
        return this.request({ method: 'GET', path: '/v2/providers/seller_api/apis/api/v1/marketplace/seller-products/' + params.sellerProductId })
    }

    postProduct(products) {
        let promises = products.map((v, k) => {
            for (var n in v) {
                productSample[n] = v[n]
            }
            console.log(JSON.stringify(productSample,  null, 2))
            return this.request({ method: 'POST', path: '/v2/providers/seller_api/apis/api/v1/marketplace/seller-products', body: JSON.stringify(productSample,  null, 2) })
        })
        return Promise.all(promises);
    }

    deleteProduct(products) {
        let promises = products.map((v, k) => {
            return this.request({ method: 'DELETE', path: '/v2/providers/seller_api/apis/api/v1/marketplace/seller-products/' + v })
        })
        return Promise.all(promises);
    }


}



module.exports = Product