All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.logicommerce.sdk.resources.ResponseParser Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package com.logicommerce.sdk.resources;

import com.logicommerce.utilities.JsonConverterException;
import com.logicommerce.utilities.JsonMapper;

public class ResponseParser {

	private ResponseParser() {}

	public static  T parse(int statusCode, String body, Class type) throws ResponseException {
		if (statusCode > 399) {
			throw new ResponseException(body);
		}
		if (body == null || body.isBlank()) {
			return null;
		}
		JsonMapper jsonMapper = new JsonMapper<>(type);
		try {
			return jsonMapper.fromJson(body);
		} catch (JsonConverterException e) {
			throw new ResponseException(body, e);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy