             endDate.getTime()
         ]
 
-        execFile file, args, (err, stdout, stderr) ->
-            return cb new Error "stdout: #{stdout}, stderr: #{stderr} err: #{err.toString()}" if err?
-            cb null, JSON.parse(stdout)
+        @_exec 'get-sales-leads-by-sub-id-per-day', args, cb

{execFile} = require 'child_process'

module.exports = class

    constructor: (@options) ->

    getPrograms: (displayOptions, query, cb) ->

        file = "#{__dirname}/php/get-programs.php"

        args = [
            @options.publisherId
            @options.publisherWebservicePassword

            JSON.stringify query
        ]

        @_exec 'get-programs', args, lift cb, (results) ->
            results?.ProgramCollection?.Program || []

    getShops: (cb) ->
        args = [@options.publisherId, @options.productWebservicePassword]

        @_exec 'get-shop-list-v3', args, lift cb, (results) -> results?.Shops?.Shop

    getSalesForDayRange: (startDate, endDate, cb) ->
        args = [
            @options.publisherId
            @options.publisherWebservicePassword
