Skip to content

Commit

Permalink
Merge pull request #556 from wshlovercn/SMS-111
Browse files Browse the repository at this point in the history
SMS-111 SDK 补充获取单个模板信息接口
  • Loading branch information
longbai authored May 27, 2022
2 parents 3a6eae0 + 61f290c commit e72333f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/qiniu/sms/SmsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,27 @@ public TemplateInfo describeTemplateItems(String auditStatus, int page, int page
return templateInfo;
}

/**
* 查询单个模板信息
*
* @param templateId 模板ID
*/
public Response describeTemplate(String templateId) throws QiniuException {
String requestUrl = String.format("%s/v1/template/%s", configuration.smsHost(), templateId);
return get(requestUrl);
}

/**
* 查询单个模板信息
*
* @param templateId 模板ID
*/
public TemplateInfo.Item describeTemplateItem(String templateId) throws QiniuException {
Response resp = describeTemplate(templateId);
TemplateInfo.Item item = Json.decode(resp.bodyString(), TemplateInfo.Item.class);
return item;
}

/**
* 创建模板
*
Expand Down
23 changes: 23 additions & 0 deletions src/test/java/test/com/qiniu/sms/SmsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,29 @@ public void testDescribeTemplateItems() {
}
}

@Test
@Tag("IntegrationTest")
public void testDescribeSingleTemplate() {
try {
Response response = smsManager.describeTemplate("templateId");
assertNotNull(response);
} catch (QiniuException e) {
assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode(401)));
}
}

@Test
@Tag("IntegrationTest")
public void testDescribeSingleTemplateItem() {
try {
TemplateInfo.Item item = smsManager.describeTemplateItem("templateId");
assertNotNull(item);
} catch (QiniuException e) {
assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode(401)));
}
}


@Test
@Tag("IntegrationTest")
public void testCreateTemplate() {
Expand Down

0 comments on commit e72333f

Please sign in to comment.