package com.sailthru.client.params.job;

import com.google.gson.reflect.TypeToken;
import com.sailthru.client.params.ApiFileParams;

import java.io.File;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class PurchaseImportJob extends Job implements ApiFileParams {

    protected transient File file = null;

    public PurchaseImportJob() {
        this.job = "purchase_import";
    }

    public PurchaseImportJob setFile(String filePath) {
        this.file = new File(filePath);
        return this;
    }

    public PurchaseImportJob setFile(File file) {
        this.file = file;
        return this;
    }

    @Override
    public Type getType() {
        return new TypeToken<PurchaseImportJob>() {}.getType();
    }

    public Map<String, File> getFileParams() {
        Map<String, File> files = new HashMap<String, File>();
        if (this.file != null) {
            files.put("file", this.file);
        }
        return files;
    }
}

@@ -129,28 +129,155 @@
 ms;%0A
-%0Aimport java.io.File
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException
 ;%0Aim
@@ -424,16 +424,102 @@
 arams %7B%0A
+    protected static Logger logger = LoggerFactory.getLogger(PurchaseImportJob.class);
 %0A    pro
@@ -535,24 +535,35 @@
 ansient File
+InputStream
  file = null
@@ -695,24 +695,42 @@
 filePath) %7B%0A
+        try %7B%0A    
         this
@@ -745,16 +745,27 @@
 new File
+InputStream
 (filePat
@@ -780,103 +780,334 @@
     
-return this;%0A    %7D%0A%0A    public PurchaseImportJob setFile(File file) %7B%0A        this.file = file;
+%7D catch (FileNotFoundException e) %7B%0A            logger.error(e.getMessage());%0A        %7D%0A        return this;%0A    %7D%0A%0A    public PurchaseImportJob setFile(File file) %7B%0A        try %7B%0A            this.file = new FileInputStream(file);%0A        %7D catch (FileNotFoundException e) %7B%0A            logger.error(e.getMessage());%0A        %7D
 %0A   
@@ -1271,16 +1271,27 @@
 ng, File
+InputStream
 %3E getFil
@@ -1326,16 +1326,27 @@
 ng, File
+InputStream
 %3E files 
@@ -1371,16 +1371,27 @@
 ng, File
+InputStream
 %3E();%0A   

Change implementation from File to FileInputStream