package com.qa.utilities;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import io.restassured.response.Response;

public class Util {
	static Properties prop = new Properties();
	public String getValue(String key) {
		try {
            prop.load(new FileInputStream("src/test/resources/config/application.properties"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
		return prop.getProperty(key);
	}
	public File convertJsonFiletoFile(String loc) {
		return new File(loc);
	}
	public Response post_employee(File file) {
		RestUtil.setreqPayload(file);
		RestUtil.setContentType(getValue("content_JSON_type"));
		Response response = RestUtil.setPostwebserviceUrl(getValue("employee_base_uri"), getValue("employee_service_resurce_POST"));
		return response;
	}
	public Response get_driver(String driverId) {
		
		RestUtil.setContentType(getValue("content_JSON_type"));
		//RestUtil.setpathParams(driverId);
		return RestUtil.setGETEndPoint(getValue("driver_base_uri"),getValue("driver_resources_uri"),driverId);
		 
		
	}
	
	public Response post_XMLData_employee(File file) {
		RestUtil.setreqPayload(file);
		RestUtil.setContentType(getValue("content_XML_type"));
		Response response = RestUtil.setPostwebserviceUrl(getValue("employee_base_uri_xml"), getValue("employee_service_resurce_xml_POST"));
		return response;
	}
	
	
	
}