use of me.chanjar.weixin.mp.bean.result.WxMpUserCumulate in project weixin-java-tools by chanjarster.
the class WxMpMiscAPITest method testGetUserCumulate.
@Test
public void testGetUserCumulate() throws WxErrorException, ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date beginDate = simpleDateFormat.parse("2015-01-01");
Date endDate = simpleDateFormat.parse("2015-01-02");
List<WxMpUserCumulate> cumulates = wxService.getUserCumulate(beginDate, endDate);
System.out.println(cumulates);
Assert.assertNotNull(cumulates);
}
use of me.chanjar.weixin.mp.bean.result.WxMpUserCumulate in project weixin-java-tools by chanjarster.
the class WxMpUserCumulateGsonAdapter method deserialize.
public WxMpUserCumulate deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
WxMpUserCumulate cumulate = new WxMpUserCumulate();
JsonObject summaryJsonObject = json.getAsJsonObject();
try {
String refDate = GsonHelper.getString(summaryJsonObject, "ref_date");
if (refDate != null) {
cumulate.setRefDate(SIMPLE_DATE_FORMAT.parse(refDate));
}
cumulate.setCumulateUser(GsonHelper.getInteger(summaryJsonObject, "cumulate_user"));
} catch (ParseException e) {
throw new JsonParseException(e);
}
return cumulate;
}
use of me.chanjar.weixin.mp.bean.result.WxMpUserCumulate in project weixin-java-tools by chanjarster.
the class WxMpServiceImpl method getUserCumulate.
@Override
public List<WxMpUserCumulate> getUserCumulate(Date beginDate, Date endDate) throws WxErrorException {
String url = "https://api.weixin.qq.com/datacube/getusercumulate";
JsonObject param = new JsonObject();
param.addProperty("begin_date", SIMPLE_DATE_FORMAT.format(beginDate));
param.addProperty("end_date", SIMPLE_DATE_FORMAT.format(endDate));
String responseContent = post(url, param.toString());
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement.getAsJsonObject().get("list"), new TypeToken<List<WxMpUserCumulate>>() {
}.getType());
}
Aggregations