 class CsvMapping
 
   mapOrders: (template, orders) ->
-    deferred = Q.defer()
-
     @analyseTemplate(template)
     .then ([header, mappings]) =>
       rows = []

        @mapOrder(order, mappings)

      data = _.flatten rows, true

      Csv().from([header].concat data)
      .to.string (asString) ->
        deferred.resolve asString

      .on 'error', (error) ->
        deferred.reject error

    deferred.promise

  mapOrder: (order, mappings) ->
    rows = []
    rows.push _.map mappings, (mapping) =>


    deferred.promise

  toCSV: (header, data) ->
    deferred = Q.defer()
    
    Csv().from([header].concat data)
    .to.string (asString) ->
      deferred.resolve asString
    .on 'error', (error) ->
      deferred.reject error
    
    deferred.promise


module.exports = CsvMapping