var data = require('./skus.json');

var getters = {
  "EYESHADOW": function(item) {
    var colors = item.colors;
    return [item.skuType, item.skuNo, colors[0].colorCode, colors[0].glossIntensity, colors[0].shimmerColorCode, colors[0].shimmerIntensity]
  },
  "LIPCOLOR": function(item) {
    var colors = item.colors;
    return [item.skuType, item.skuNo, colors[0].colorCode, colors[0].glossIntensity, colors[0].shimmerColorCode, colors[0].shimmerIntensity]
  },
  "EYELINER": function(item) {
    var colors = item.colors;
    return [item.skuType, item.skuNo, colors[0].colorCode, colors[0].glossIntensity, colors[0].shimmerColorCode, colors[0].shimmerIntensity]
  }
};

var cols = ['Type', 'SKU ID', 'Color', 'Gloss %', 'Shimmer Color', 'Shimmer %'];

var fs = require('fs');

fs.writeFile('skus.csv',
  cols.join(',')+'\n'+
  data.results.map(item=> getters[item.skuType](item).join(',')).join('\n'),function(){

  });