package com.avg.zaap.crashlibrary.publish.cap.http;

import com.avg.zaap.crashlibrary.publish.cap.http.boundary.IBoundaryGenerator;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * This interface denotes the common behavior for the CAP request dependency factories.
 * <p/>
 * Created by marek.osvald on 7.6.2016.
 */
public interface ICapRequestFactory {

    /**
     * Returns an instance of boundary generator.
     *
     * @return an instance of boundary generator
     */
    IBoundaryGenerator getBoundaryGenerator();

    /**
     * Returns a URL for given string.
     *
     * @param url URL string to retrieve the URL for
     * @return a URL for given string
     * @throws MalformedURLException provided that given string is invalid
     */
    URL openURL(String url) throws MalformedURLException;

    /**
     * Returns an instance of {@link java.io.PrintWriter}.
     *
     * @param outputStream OutputStream to retrieve the writer for
     * @return an instance of PrintWriter
     */
    Writer getPrintWriter(OutputStream outputStream);

    /**
     * Opens a file for given file path.
     *
     * @param filePath file path to open the file for
     * @return a File instance
     */
    File openFile(String filePath);

    /**
     * Returns an instance of input stream reader for given input stream.
     *
     * @param inputStream input stream to get the reader for
     * @return an instance of input stream reader for given input stream
     */
    InputStreamReader getInputStreamReader(InputStream inputStream);

    /**
     * Returns an instance of file input stream
     *
     * @param file file to open the file input stream for
     * @return an instance of file input stream
     * @throws FileNotFoundException provided that file does not exist
     */
    FileInputStream getFileInputStream(File file) throws FileNotFoundException;

    /**
     * Returns an instance of {@link java.io.StringWriter}.
     *
     * @return an instance of StringWriter
     */
    Writer getStringWriter();

}
