package org.fouram.core.plugin.weixin.cp.core;

import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Oa.GET_APPROVAL_DETAIL;

import com.google.gson.JsonObject;

import lombok.NonNull;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpOaServiceImpl;

public class MyWxCpOaServiceImpl extends WxCpOaServiceImpl implements MyWxCpOaService {
	
	private final WxCpService mainService;
	
	public MyWxCpOaServiceImpl(WxCpService mainService) {
		super(mainService);
		this.mainService = mainService;
	}

	@Override
	public String getApprovalDetailToString(@NonNull String spNo) throws WxErrorException {
		JsonObject jsonObject = new JsonObject();
		jsonObject.addProperty("sp_no", spNo);
		final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_APPROVAL_DETAIL);
		String responseContent = this.mainService.post(url, jsonObject.toString());
		return responseContent;
	}
}