Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMS-111 SDK 补充获取单个模板信息接口 #556

Merged
merged 2 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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