@Test public void testAddTemplate() throws Exception { String result = this.wxService.getTemplateMsgService().addTemplate("TM00015"); Assert.assertNotNull(result); System.err.println(result); }
@Override public String addTemplate(String shortTemplateId) throws WxErrorException { String url = API_URL_PREFIX + "/api_add_template"; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id_short", shortTemplateId); String responseContent = this.wxMpService.post(url, jsonObject.toString()); final JsonObject result = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (result.get("errcode").getAsInt() == 0) { return result.get("template_id").getAsString(); } throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP)); }
WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public String addTemplate(String shortTemplateId) throws WxErrorException { String url = API_URL_PREFIX + "/api_add_template"; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id_short", shortTemplateId); String responseContent = this.wxMpService.post(url, jsonObject.toString()); final JsonObject result = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (result.get("errcode").getAsInt() == 0) { return result.get("template_id").getAsString(); } throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP)); } }
WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public String addTemplate(String shortTemplateId) throws WxErrorException { String url = API_URL_PREFIX + "/api_add_template"; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id_short", shortTemplateId); String responseContent = this.wxMpService.post(url, jsonObject.toString()); final JsonObject result = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (result.get("errcode").getAsInt() == 0) { return result.get("template_id").getAsString(); } throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP)); } WxMpTemplateMsgServiceImpl(WxMpService wxMpService); }
WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public String addTemplate(String shortTemplateId) throws WxErrorException { String url = API_URL_PREFIX + "/api_add_template"; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id_short", shortTemplateId); String responseContent = this.wxMpService.post(url, jsonObject.toString()); final JsonObject result = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (result.get("errcode").getAsInt() == 0) { return result.get("template_id").getAsString(); } throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP)); } WxMpTemplateMsgServiceImpl(WxMpService wxMpService); @Override String sendTemplateMsg(WxMpTemplateMessage templateMessage); @Override boolean setIndustry(WxMpTemplateIndustry wxMpIndustry); @Override WxMpTemplateIndustry getIndustry(); @Override String addTemplate(String shortTemplateId); @Override List<WxMpTemplate> getAllPrivateTemplate(); @Override boolean delPrivateTemplate(String templateId); }
WxMpTemplateMsgServiceImpl implements WxMpTemplateMsgService { @Override public String addTemplate(String shortTemplateId) throws WxErrorException { String url = API_URL_PREFIX + "/api_add_template"; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("template_id_short", shortTemplateId); String responseContent = this.wxMpService.post(url, jsonObject.toString()); final JsonObject result = JSON_PARSER.parse(responseContent).getAsJsonObject(); if (result.get("errcode").getAsInt() == 0) { return result.get("template_id").getAsString(); } throw new WxErrorException(WxError.fromJson(responseContent, WxType.MP)); } WxMpTemplateMsgServiceImpl(WxMpService wxMpService); @Override String sendTemplateMsg(WxMpTemplateMessage templateMessage); @Override boolean setIndustry(WxMpTemplateIndustry wxMpIndustry); @Override WxMpTemplateIndustry getIndustry(); @Override String addTemplate(String shortTemplateId); @Override List<WxMpTemplate> getAllPrivateTemplate(); @Override boolean delPrivateTemplate(String templateId); static final String API_URL_PREFIX; }