package com.andela.webservice;


import android.util.Base64;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by Spykins on 08/06/16.
 */
public class HttpManager {

    public static String getData(RequestPackage p) {

        BufferedReader reader = null;
        String uri = p.getUri();
        //We need to append parameter only when we are making a get request
        //if it's any other request, we will use the parameter in a different way

        if(p.getMethod().equals("GET")) {
            uri += "?" + p.getEncodedParams();
        }

        try {
            URL url = new URL(uri);
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestMethod(p.getMethod()); //This is value, GET, or POST

            StringBuilder sb = new StringBuilder();
            reader = new BufferedReader(new InputStreamReader(con.getInputStream()));

            String line;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }

            return sb.toString();

        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
        }

    }

}
@@ -30,37 +30,8 @@
 ;%0A%0A%0A
-import android.util.Base64;%0A%0A
 impo
@@ -158,47 +158,8 @@
 on;%0A
-import java.net.MalformedURLException;%0A
 impo
@@ -755,24 +755,25 @@
 nnection();%0A
+%0A
             
@@ -839,17 +839,16 @@
 or POST%0A
-%0A
         

Use the RequestPackage in the HttpManager class