package cn.ey.biz.module.external.api.fd.feign.config;

import java.io.IOException;
import java.io.Reader;
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.apache.commons.io.IOUtils;

import feign.FeignException;
import feign.Response;
import feign.codec.DecodeException;
import feign.codec.Decoder;

/**
 * 财务中台feign接口解码器
 * @author 86182
 *
 */
public class FdResponseDecoder implements Decoder {
	
	 private static final Charset UTF_8 = StandardCharsets.UTF_8;

	@Override
	public Object decode(Response response, Type type) throws IOException, DecodeException, FeignException {
		Reader asReader = response.body().asReader(UTF_8);
		String bodyStr = IOUtils.toString(asReader);
		return bodyStr;
		
	}	
}
