// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/exception/CoordinatePayloadException.java
// @SuppressWarnings("serial")
// public class CoordinatePayloadException extends RuntimeException {
// 
//     public CoordinatePayloadException(String msg) {
// 	super(msg);
//     }
// }
// 
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
// 
//     public String getJsonPayload(String url, String payload);
// 
// }


import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.exception.CoordinatePayloadException;
import com.digirati.themathmos.service.GetPayloadService;
package com.digirati.themathmos.service.impl;




@Service(GetPayloadServiceImpl.SERVICE_NAME)
public class GetPayloadServiceImpl implements GetPayloadService{


    private static final Logger LOG = Logger.getLogger(GetPayloadServiceImpl.class);

    public static final String SERVICE_NAME = "getPayloadServiceImpl";

    HttpClient httpClient;

    GetPayloadServiceImpl(){

	httpClient = HttpClientBuilder.create().build(); //Use this instead
    }

    @Override
    public String getJsonPayload(String url, String payload){

        try {
            HttpPost request = new HttpPost(url);

            StringEntity params = new StringEntity(payload);
            LOG.info(payload);
            request.addHeader("content-type", "application/json; charset=utf-8");
            request.setEntity(params);
            HttpResponse response = httpClient.execute(request);

            if (response.getStatusLine().getStatusCode() != 200) {
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/exception/CoordinatePayloadException.java
// @SuppressWarnings("serial")
// public class CoordinatePayloadException extends RuntimeException {
// 
//     public CoordinatePayloadException(String msg) {
// 	super(msg);
//     }
// }
// 
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/GetPayloadService.java
// public interface GetPayloadService {
// 
//     public String getJsonPayload(String url, String payload);
// 
// }


// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/impl/GetPayloadServiceImpl.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.digirati.themathmos.exception.CoordinatePayloadException;
import com.digirati.themathmos.service.GetPayloadService;

package com.digirati.themathmos.service.impl;




@Service(GetPayloadServiceImpl.SERVICE_NAME)
public class GetPayloadServiceImpl implements GetPayloadService{


    private static final Logger LOG = Logger.getLogger(GetPayloadServiceImpl.class);

    public static final String SERVICE_NAME = "getPayloadServiceImpl";

    HttpClient httpClient;

    GetPayloadServiceImpl(){

	httpClient = HttpClientBuilder.create().build(); //Use this instead
    }

    @Override
    public String getJsonPayload(String url, String payload){

        try {
            HttpPost request = new HttpPost(url);

            StringEntity params = new StringEntity(payload);
            LOG.info(payload);
            request.addHeader("content-type", "application/json; charset=utf-8");
            request.setEntity(params);
            HttpResponse response = httpClient.execute(request);

            if (response.getStatusLine().getStatusCode() != 200) {
                throw new CoordinatePayloadException("Failed : HTTP error code : "