Unverified Commit b99d8837 authored by 怡蘅's avatar 怡蘅 Committed by GitHub

feat: implement sns api (#14)

* feat: implement sns api * docs: update readme
parent 4b378a0b
...@@ -43,21 +43,21 @@ ...@@ -43,21 +43,21 @@
### 5. 关系链管理 ### 5. 关系链管理
- [ ] 添加好友 - [x] 添加好友
- [ ] 导入好友 - [x] 导入好友
- [ ] 更新好友 - [x] 更新好友
- [ ] 删除好友 - [x] 删除好友
- [ ] 删除所有好友 - [x] 删除所有好友
- [ ] 校验好友 - [x] 校验好友
- [ ] 拉取好友 - [x] 拉取好友
- [ ] 拉取指定好友 - [x] 拉取指定好友
- [ ] 添加黑名单 - [x] 添加黑名单
- [ ] 删除黑名单 - [x] 删除黑名单
- [ ] 拉取黑名单 - [x] 拉取黑名单
- [ ] 校验黑名单 - [x] 校验黑名单
- [ ] 添加分组 - [x] 添加分组
- [ ] 删除分组 - [x] 删除分组
- [ ] 拉取分组 - [x] 拉取分组
### 6. 群组管理 ### 6. 群组管理
......
package com.qcloud.im.core; package com.qcloud.im.core;
import com.qcloud.im.IMClient; import com.qcloud.im.IMClient;
import com.qcloud.im.model.request.FriendImportRequest; import com.qcloud.im.model.request.*;
import com.qcloud.im.model.response.FriendImportResult; import com.qcloud.im.model.response.*;
import com.qcloud.im.util.HttpUtil; import com.qcloud.im.util.HttpUtil;
import com.qcloud.im.util.JsonUtil; import com.qcloud.im.util.JsonUtil;
...@@ -14,16 +14,114 @@ import java.io.IOException; ...@@ -14,16 +14,114 @@ import java.io.IOException;
*/ */
public class SNS { public class SNS {
private static final String SERVICE_NAME = "sns"; private static final String SERVICE_NAME = "sns";
private static final String FRIEND_ADD_COMMAND = "friend_add";
private static final String FRIEND_IMPORT_COMMAND = "friend_import"; private static final String FRIEND_IMPORT_COMMAND = "friend_import";
private static final String FRIEND_UPDATE_COMMAND = "friend_update";
private static final String FRIEND_DELETE_COMMAND = "friend_delete";
private static final String FRIEND_DELETE_ALL_COMMAND = "friend_delete_all";
private static final String FRIEND_CHECK_COMMAND = "friend_check";
private static final String FRIEND_GET_COMMAND = "friend_get";
private static final String FRIEND_GET_LIST_COMMAND = "friend_get_list";
private static final String BLACK_LIST_ADD_COMMAND = "black_list_add";
private static final String BLACK_LIST_DELETE_COMMAND = "black_list_delete";
private static final String BLACK_LIST_GET_COMMAND = "black_list_get";
private static final String BLACK_LIST_CHECK_COMMAND = "black_list_check";
private static final String GROUP_ADD_COMMAND = "group_add";
private static final String GROUP_DELETE_COMMAND = "group_delete";
private static final String GROUP_GET_COMMAND = "group_get";
private final IMClient imClient; private final IMClient imClient;
public FriendAddResult friendAdd(FriendAddRequest friendAddRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, FRIEND_ADD_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(friendAddRequest), null);
return JsonUtil.str2Obj(result, FriendAddResult.class);
}
public FriendImportResult friendImport(FriendImportRequest friendImportRequest) throws IOException { public FriendImportResult friendImport(FriendImportRequest friendImportRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, FRIEND_IMPORT_COMMAND); String url = imClient.getUrl(SERVICE_NAME, FRIEND_IMPORT_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(friendImportRequest), null); String result = HttpUtil.post(url, JsonUtil.obj2Str(friendImportRequest), null);
return JsonUtil.str2Obj(result, FriendImportResult.class); return JsonUtil.str2Obj(result, FriendImportResult.class);
} }
public FriendUpdateResult friendUpdate(FriendUpdateRequest friendUpdateRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, FRIEND_UPDATE_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(friendUpdateRequest), null);
return JsonUtil.str2Obj(result, FriendUpdateResult.class);
}
public FriendDeleteResult friendDelete(FriendDeleteRequest friendDeleteRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, FRIEND_DELETE_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(friendDeleteRequest), null);
return JsonUtil.str2Obj(result, FriendDeleteResult.class);
}
public FriendDeleteAllResult friendDeleteAll(FriendDeleteAllRequest friendDeleteAllRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, FRIEND_DELETE_ALL_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(friendDeleteAllRequest), null);
return JsonUtil.str2Obj(result, FriendDeleteAllResult.class);
}
public FriendCheckResult friendCheck(FriendCheckRequest friendCheckRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, FRIEND_CHECK_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(friendCheckRequest), null);
return JsonUtil.str2Obj(result, FriendCheckResult.class);
}
public FriendGetResult friendGet(FriendGetRequest friendGetRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, FRIEND_GET_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(friendGetRequest), null);
return JsonUtil.str2Obj(result, FriendGetResult.class);
}
public FriendGetListResult friendGetList(FriendGetListRequest friendGetListRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, FRIEND_GET_LIST_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(friendGetListRequest), null);
return JsonUtil.str2Obj(result, FriendGetListResult.class);
}
public BlackListAddResult blackListAdd(BlackListAddRequest blackListAddRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, BLACK_LIST_ADD_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(blackListAddRequest), null);
return JsonUtil.str2Obj(result, BlackListAddResult.class);
}
public BlackListDeleteResult blackListDelete(BlackListDeleteRequest blackListDeleteRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, BLACK_LIST_DELETE_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(blackListDeleteRequest), null);
return JsonUtil.str2Obj(result, BlackListDeleteResult.class);
}
public BlackListGetResult blackListGet(BlackListGetRequest blackListGetRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, BLACK_LIST_GET_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(blackListGetRequest), null);
return JsonUtil.str2Obj(result, BlackListGetResult.class);
}
public BlackListCheckResult blackListCheck(BlackListCheckRequest blackListCheckRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, BLACK_LIST_CHECK_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(blackListCheckRequest), null);
return JsonUtil.str2Obj(result, BlackListCheckResult.class);
}
public GroupAddResult groupAdd(GroupAddRequest groupAddRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, GROUP_ADD_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(groupAddRequest), null);
return JsonUtil.str2Obj(result, GroupAddResult.class);
}
public GroupDeleteResult groupDelete(GroupDeleteRequest groupDeleteRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, GROUP_DELETE_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(groupDeleteRequest), null);
return JsonUtil.str2Obj(result, GroupDeleteResult.class);
}
public GroupGetResult groupGet(GroupGetRequest groupGetRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, GROUP_GET_COMMAND);
String result = HttpUtil.post(url, JsonUtil.obj2Str(groupGetRequest), null);
return JsonUtil.str2Obj(result, GroupGetResult.class);
}
public SNS(IMClient imClient) { public SNS(IMClient imClient) {
this.imClient = imClient; this.imClient = imClient;
} }
......
...@@ -15,11 +15,8 @@ public class AddFriendItem { ...@@ -15,11 +15,8 @@ public class AddFriendItem {
@JsonProperty("Remark") @JsonProperty("Remark")
private String remark; private String remark;
@JsonProperty("RemarkTime")
private Integer remarkTime;
@JsonProperty("GroupName") @JsonProperty("GroupName")
private List<String> groupName; private String groupName;
@JsonProperty("AddSource") @JsonProperty("AddSource")
private String addSource; private String addSource;
...@@ -27,24 +24,15 @@ public class AddFriendItem { ...@@ -27,24 +24,15 @@ public class AddFriendItem {
@JsonProperty("AddWording") @JsonProperty("AddWording")
private String addWording; private String addWording;
@JsonProperty("AddTime")
private Integer addTime;
@JsonProperty("CustomItem")
private List<CustomItem> CustomItemList;
public AddFriendItem() { public AddFriendItem() {
} }
public AddFriendItem(String toAccount, String remark, Integer remarkTime, List<String> groupName, String addSource, String addWording, Integer addTime, List<CustomItem> customItemList) { public AddFriendItem(String toAccount, String remark, String groupName, String addSource, String addWording) {
this.toAccount = toAccount; this.toAccount = toAccount;
this.remark = remark; this.remark = remark;
this.remarkTime = remarkTime;
this.groupName = groupName; this.groupName = groupName;
this.addSource = addSource; this.addSource = addSource;
this.addWording = addWording; this.addWording = addWording;
this.addTime = addTime;
CustomItemList = customItemList;
} }
public String getToAccount() { public String getToAccount() {
...@@ -63,19 +51,11 @@ public class AddFriendItem { ...@@ -63,19 +51,11 @@ public class AddFriendItem {
this.remark = remark; this.remark = remark;
} }
public Integer getRemarkTime() { public String getGroupName() {
return remarkTime;
}
public void setRemarkTime(Integer remarkTime) {
this.remarkTime = remarkTime;
}
public List<String> getGroupName() {
return groupName; return groupName;
} }
public void setGroupName(List<String> groupName) { public void setGroupName(String groupName) {
this.groupName = groupName; this.groupName = groupName;
} }
...@@ -94,20 +74,4 @@ public class AddFriendItem { ...@@ -94,20 +74,4 @@ public class AddFriendItem {
public void setAddWording(String addWording) { public void setAddWording(String addWording) {
this.addWording = addWording; this.addWording = addWording;
} }
public Integer getAddTime() {
return addTime;
}
public void setAddTime(Integer addTime) {
this.addTime = addTime;
}
public List<CustomItem> getCustomItemList() {
return CustomItemList;
}
public void setCustomItemList(List<CustomItem> customItemList) {
CustomItemList = customItemList;
}
} }
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 14:44
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BlackListAddRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("To_Account")
private List<String> toAccount;
public BlackListAddRequest() {
}
public BlackListAddRequest(String fromAccount, List<String> toAccount) {
this.fromAccount = fromAccount;
this.toAccount = toAccount;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<String> getToAccount() {
return toAccount;
}
public void setToAccount(List<String> toAccount) {
this.toAccount = toAccount;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 15:29
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BlackListCheckRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("To_Account")
private List<String> toAccount;
@JsonProperty("CheckType")
private String checkType;
public BlackListCheckRequest() {
}
public BlackListCheckRequest(String fromAccount, List<String> toAccount, String checkType) {
this.fromAccount = fromAccount;
this.toAccount = toAccount;
this.checkType = checkType;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<String> getToAccount() {
return toAccount;
}
public void setToAccount(List<String> toAccount) {
this.toAccount = toAccount;
}
public String getCheckType() {
return checkType;
}
public void setCheckType(String checkType) {
this.checkType = checkType;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 14:46
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BlackListDeleteRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("To_Account")
private List<String> toAccount;
public BlackListDeleteRequest() {
}
public BlackListDeleteRequest(String fromAccount, List<String> toAccount) {
this.fromAccount = fromAccount;
this.toAccount = toAccount;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<String> getToAccount() {
return toAccount;
}
public void setToAccount(List<String> toAccount) {
this.toAccount = toAccount;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author hyh
* @since 2021/07/31 15:27
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BlackListGetRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("StartIndex")
private Integer startIndex;
@JsonProperty("MaxLimited")
private Integer maxLimited;
@JsonProperty("LastSequence")
private Integer lastSequence;
public BlackListGetRequest() {
}
public BlackListGetRequest(String fromAccount, Integer startIndex, Integer maxLimited, Integer lastSequence) {
this.fromAccount = fromAccount;
this.startIndex = startIndex;
this.maxLimited = maxLimited;
this.lastSequence = lastSequence;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public Integer getStartIndex() {
return startIndex;
}
public void setStartIndex(Integer startIndex) {
this.startIndex = startIndex;
}
public Integer getMaxLimited() {
return maxLimited;
}
public void setMaxLimited(Integer maxLimited) {
this.maxLimited = maxLimited;
}
public Integer getLastSequence() {
return lastSequence;
}
public void setLastSequence(Integer lastSequence) {
this.lastSequence = lastSequence;
}
}
package com.qcloud.im.model.request; package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
/** /**
* @author hyh * @author hyh
* @since 2021/07/29 15:45 * @since 2021/07/29 15:45
*/ */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CustomItem { public class CustomItem {
@JsonProperty("Tag") @JsonProperty("Tag")
private String tag; private String tag;
@JsonProperty("Value") @JsonProperty("Value")
private String value; private Object value;
public CustomItem() { public CustomItem() {
} }
public CustomItem(String tag, String value) { public CustomItem(String tag, Object value) {
this.tag = tag; this.tag = tag;
this.value = value; this.value = value;
} }
...@@ -29,11 +31,19 @@ public class CustomItem { ...@@ -29,11 +31,19 @@ public class CustomItem {
this.tag = tag; this.tag = tag;
} }
public String getValue() { public Object getValue() {
return value; return value;
} }
public void setValue(String value) { public void setValue(Object value) {
this.value = value; this.value = value;
} }
@Override
public String toString() {
return "CustomItem{" +
"tag='" + tag + '\'' +
", value=" + value +
'}';
}
} }
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 14:08
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FriendAddRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("AddFriendItem")
private List<AddFriendItem> addFriendItemList;
@JsonProperty("AddType")
private String addType;
@JsonProperty("ForceAddFlags")
private Integer forceAddFlags;
public FriendAddRequest() {
}
public FriendAddRequest(String fromAccount, List<AddFriendItem> addFriendItemList, String addType, Integer forceAddFlags) {
this.fromAccount = fromAccount;
this.addFriendItemList = addFriendItemList;
this.addType = addType;
this.forceAddFlags = forceAddFlags;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<AddFriendItem> getAddFriendItemList() {
return addFriendItemList;
}
public void setAddFriendItemList(List<AddFriendItem> addFriendItemList) {
this.addFriendItemList = addFriendItemList;
}
public String getAddType() {
return addType;
}
public void setAddType(String addType) {
this.addType = addType;
}
public Integer getForceAddFlags() {
return forceAddFlags;
}
public void setForceAddFlags(Integer forceAddFlags) {
this.forceAddFlags = forceAddFlags;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 14:32
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FriendCheckRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("To_Account")
private List<String> toAccount;
@JsonProperty("CheckType")
private String checkType;
public FriendCheckRequest() {
}
public FriendCheckRequest(String fromAccount, List<String> toAccount, String checkType) {
this.fromAccount = fromAccount;
this.toAccount = toAccount;
this.checkType = checkType;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<String> getToAccount() {
return toAccount;
}
public void setToAccount(List<String> toAccount) {
this.toAccount = toAccount;
}
public String getCheckType() {
return checkType;
}
public void setCheckType(String checkType) {
this.checkType = checkType;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author hyh
* @since 2021/07/31 14:30
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FriendDeleteAllRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("DeleteType")
private String deleteType;
public FriendDeleteAllRequest() {
}
public FriendDeleteAllRequest(String fromAccount, String deleteType) {
this.fromAccount = fromAccount;
this.deleteType = deleteType;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public String getDeleteType() {
return deleteType;
}
public void setDeleteType(String deleteType) {
this.deleteType = deleteType;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 14:28
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FriendDeleteRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("To_Account")
private List<String> toAccount;
@JsonProperty("DeleteType")
private String deleteType;
public FriendDeleteRequest() {
}
public FriendDeleteRequest(String fromAccount, List<String> toAccount, String deleteType) {
this.fromAccount = fromAccount;
this.toAccount = toAccount;
this.deleteType = deleteType;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<String> getToAccount() {
return toAccount;
}
public void setToAccount(List<String> toAccount) {
this.toAccount = toAccount;
}
public String getDeleteType() {
return deleteType;
}
public void setDeleteType(String deleteType) {
this.deleteType = deleteType;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 14:41
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FriendGetListRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("To_Account")
private List<String> toAccount;
@JsonProperty("TagList")
private List<String> tagList;
public FriendGetListRequest() {
}
public FriendGetListRequest(String fromAccount, List<String> toAccount, List<String> tagList) {
this.fromAccount = fromAccount;
this.toAccount = toAccount;
this.tagList = tagList;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<String> getToAccount() {
return toAccount;
}
public void setToAccount(List<String> toAccount) {
this.toAccount = toAccount;
}
public List<String> getTagList() {
return tagList;
}
public void setTagList(List<String> tagList) {
this.tagList = tagList;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author hyh
* @since 2021/07/31 14:34
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FriendGetRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("StartIndex")
private Integer startIndex;
@JsonProperty("StandardSequence")
private Integer standardSequence;
@JsonProperty("CustomSequence")
private Integer customSequence;
public FriendGetRequest() {
}
public FriendGetRequest(String fromAccount, Integer startIndex, Integer standardSequence, Integer customSequence) {
this.fromAccount = fromAccount;
this.startIndex = startIndex;
this.standardSequence = standardSequence;
this.customSequence = customSequence;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public Integer getStartIndex() {
return startIndex;
}
public void setStartIndex(Integer startIndex) {
this.startIndex = startIndex;
}
public Integer getStandardSequence() {
return standardSequence;
}
public void setStandardSequence(Integer standardSequence) {
this.standardSequence = standardSequence;
}
public Integer getCustomSequence() {
return customSequence;
}
public void setCustomSequence(Integer customSequence) {
this.customSequence = customSequence;
}
}
package com.qcloud.im.model.request; package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List; import java.util.List;
...@@ -8,19 +9,20 @@ import java.util.List; ...@@ -8,19 +9,20 @@ import java.util.List;
* @author hyh * @author hyh
* @since 2021/07/29 15:19 * @since 2021/07/29 15:19
*/ */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FriendImportRequest extends GenericRequest { public class FriendImportRequest extends GenericRequest {
@JsonProperty("From_Account") @JsonProperty("From_Account")
private String fromAccount; private String fromAccount;
@JsonProperty("AddFriendItem") @JsonProperty("AddFriendItem")
private List<AddFriendItem> addFriendItemList; private List<ImportFriendItem> importFriendItemList;
public FriendImportRequest() { public FriendImportRequest() {
} }
public FriendImportRequest(String fromAccount, List<AddFriendItem> addFriendItemList) { public FriendImportRequest(String fromAccount, List<ImportFriendItem> importFriendItemList) {
this.fromAccount = fromAccount; this.fromAccount = fromAccount;
this.addFriendItemList = addFriendItemList; this.importFriendItemList = importFriendItemList;
} }
public String getFromAccount() { public String getFromAccount() {
...@@ -31,11 +33,11 @@ public class FriendImportRequest extends GenericRequest { ...@@ -31,11 +33,11 @@ public class FriendImportRequest extends GenericRequest {
this.fromAccount = fromAccount; this.fromAccount = fromAccount;
} }
public List<AddFriendItem> getAddFriendItemList() { public List<ImportFriendItem> getImportFriendItemList() {
return addFriendItemList; return importFriendItemList;
} }
public void setAddFriendItemList(List<AddFriendItem> addFriendItemList) { public void setImportFriendItemList(List<ImportFriendItem> importFriendItemList) {
this.addFriendItemList = addFriendItemList; this.importFriendItemList = importFriendItemList;
} }
} }
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 14:20
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FriendUpdateRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("UpdateItem")
private List<UpdateItem> updateItemList;
public FriendUpdateRequest() {
}
public FriendUpdateRequest(String fromAccount, List<UpdateItem> updateItemList) {
this.fromAccount = fromAccount;
this.updateItemList = updateItemList;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<UpdateItem> getUpdateItemList() {
return updateItemList;
}
public void setUpdateItemList(List<UpdateItem> updateItemList) {
this.updateItemList = updateItemList;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 15:33
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GroupAddRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("GroupName")
private List<String> groupName;
@JsonProperty("To_Account")
private List<String> toAccount;
public GroupAddRequest() {
}
public GroupAddRequest(String fromAccount, List<String> groupName, List<String> toAccount) {
this.fromAccount = fromAccount;
this.groupName = groupName;
this.toAccount = toAccount;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<String> getGroupName() {
return groupName;
}
public void setGroupName(List<String> groupName) {
this.groupName = groupName;
}
public List<String> getToAccount() {
return toAccount;
}
public void setToAccount(List<String> toAccount) {
this.toAccount = toAccount;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 15:41
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GroupDeleteRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("GroupName")
private List<String> groupName;
public GroupDeleteRequest() {
}
public GroupDeleteRequest(String fromAccount, List<String> groupName) {
this.fromAccount = fromAccount;
this.groupName = groupName;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public List<String> getGroupName() {
return groupName;
}
public void setGroupName(List<String> groupName) {
this.groupName = groupName;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 15:43
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GroupGetRequest extends GenericRequest {
@JsonProperty("From_Account")
private String fromAccount;
@JsonProperty("NeedFriend")
private String needFriend;
@JsonProperty("LastSequence")
private Integer lastSequence;
@JsonProperty("GroupName")
private List<String> groupName;
public GroupGetRequest() {
}
public GroupGetRequest(String fromAccount, String needFriend, Integer lastSequence, List<String> groupName) {
this.fromAccount = fromAccount;
this.needFriend = needFriend;
this.lastSequence = lastSequence;
this.groupName = groupName;
}
public String getFromAccount() {
return fromAccount;
}
public void setFromAccount(String fromAccount) {
this.fromAccount = fromAccount;
}
public String getNeedFriend() {
return needFriend;
}
public void setNeedFriend(String needFriend) {
this.needFriend = needFriend;
}
public Integer getLastSequence() {
return lastSequence;
}
public void setLastSequence(Integer lastSequence) {
this.lastSequence = lastSequence;
}
public List<String> getGroupName() {
return groupName;
}
public void setGroupName(List<String> groupName) {
this.groupName = groupName;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/29 15:37
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ImportFriendItem {
@JsonProperty("To_Account")
private String toAccount;
@JsonProperty("Remark")
private String remark;
@JsonProperty("RemarkTime")
private Integer remarkTime;
@JsonProperty("GroupName")
private List<String> groupName;
@JsonProperty("AddSource")
private String addSource;
@JsonProperty("AddWording")
private String addWording;
@JsonProperty("AddTime")
private Integer addTime;
@JsonProperty("CustomItem")
private List<CustomItem> customItemList;
public ImportFriendItem() {
}
public ImportFriendItem(String toAccount, String remark, Integer remarkTime, List<String> groupName, String addSource, String addWording, Integer addTime, List<CustomItem> customItemList) {
this.toAccount = toAccount;
this.remark = remark;
this.remarkTime = remarkTime;
this.groupName = groupName;
this.addSource = addSource;
this.addWording = addWording;
this.addTime = addTime;
this.customItemList = customItemList;
}
public String getToAccount() {
return toAccount;
}
public void setToAccount(String toAccount) {
this.toAccount = toAccount;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Integer getRemarkTime() {
return remarkTime;
}
public void setRemarkTime(Integer remarkTime) {
this.remarkTime = remarkTime;
}
public List<String> getGroupName() {
return groupName;
}
public void setGroupName(List<String> groupName) {
this.groupName = groupName;
}
public String getAddSource() {
return addSource;
}
public void setAddSource(String addSource) {
this.addSource = addSource;
}
public String getAddWording() {
return addWording;
}
public void setAddWording(String addWording) {
this.addWording = addWording;
}
public Integer getAddTime() {
return addTime;
}
public void setAddTime(Integer addTime) {
this.addTime = addTime;
}
public List<CustomItem> getCustomItemList() {
return customItemList;
}
public void setCustomItemList(List<CustomItem> customItemList) {
this.customItemList = customItemList;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author hyh
* @since 2021/07/31 14:24
*/
public class SnsItem {
@JsonProperty("Tag")
private String tag;
@JsonProperty("Value")
private Object value;
public SnsItem() {
}
public SnsItem(String tag, Object value) {
this.tag = tag;
this.value = value;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
}
package com.qcloud.im.model.request;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author hyh
* @since 2021/07/31 14:22
*/
public class UpdateItem {
@JsonProperty("To_Account")
private String toAccount;
@JsonProperty("SnsItem")
private List<SnsItem> snsItemList;
public UpdateItem() {
}
public UpdateItem(String toAccount, List<SnsItem> snsItemList) {
this.toAccount = toAccount;
this.snsItemList = snsItemList;
}
public String getToAccount() {
return toAccount;
}
public void setToAccount(String toAccount) {
this.toAccount = toAccount;
}
public List<SnsItem> getSnsItemList() {
return snsItemList;
}
public void setSnsItemList(List<SnsItem> snsItemList) {
this.snsItemList = snsItemList;
}
}
...@@ -41,4 +41,13 @@ public class BlackListAddResult extends GenericResult { ...@@ -41,4 +41,13 @@ public class BlackListAddResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "BlackListAddResult{" +
"resultItemList=" + resultItemList +
", failAccount=" + failAccount +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -41,4 +41,13 @@ public class BlackListCheckResult extends GenericResult { ...@@ -41,4 +41,13 @@ public class BlackListCheckResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "BlackListCheckResult{" +
"blackListCheckItemList=" + blackListCheckItemList +
", failAccount=" + failAccount +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -41,4 +41,13 @@ public class BlackListDeleteResult extends GenericResult { ...@@ -41,4 +41,13 @@ public class BlackListDeleteResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "BlackListDeleteResult{" +
"resultItemList=" + resultItemList +
", failAccount=" + failAccount +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -52,4 +52,14 @@ public class BlackListGetResult extends GenericResult { ...@@ -52,4 +52,14 @@ public class BlackListGetResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "BlackListGetResult{" +
"blackListItemList=" + blackListItemList +
", startIndex=" + startIndex +
", currentSequence=" + currentSequence +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -8,7 +8,7 @@ import java.util.List; ...@@ -8,7 +8,7 @@ import java.util.List;
* @author hyh * @author hyh
* @since 2021/07/30 15:14 * @since 2021/07/30 15:14
*/ */
public class FriendAddResult extends GenericResult{ public class FriendAddResult extends GenericResult {
@JsonProperty("ResultItem") @JsonProperty("ResultItem")
private List<ResultItem> resultItemList; private List<ResultItem> resultItemList;
...@@ -43,4 +43,13 @@ public class FriendAddResult extends GenericResult{ ...@@ -43,4 +43,13 @@ public class FriendAddResult extends GenericResult{
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "FriendAddResult{" +
"resultItemList=" + resultItemList +
", actionStatus='" + actionStatus + '\'' +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -50,4 +50,14 @@ public class FriendCheckInfoItem { ...@@ -50,4 +50,14 @@ public class FriendCheckInfoItem {
public void setResultInfo(String resultInfo) { public void setResultInfo(String resultInfo) {
this.resultInfo = resultInfo; this.resultInfo = resultInfo;
} }
@Override
public String toString() {
return "FriendCheckInfoItem{" +
"toAccount='" + toAccount + '\'' +
", relation='" + relation + '\'' +
", resultCode=" + resultCode +
", resultInfo='" + resultInfo + '\'' +
'}';
}
} }
...@@ -41,4 +41,13 @@ public class FriendCheckResult extends GenericResult { ...@@ -41,4 +41,13 @@ public class FriendCheckResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "FriendCheckResult{" +
"friendCheckInfoItemList=" + friendCheckInfoItemList +
", failAccount=" + failAccount +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -17,4 +17,11 @@ public class FriendDeleteAllResult extends GenericResult { ...@@ -17,4 +17,11 @@ public class FriendDeleteAllResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "FriendDeleteAllResult{" +
"errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -8,16 +8,13 @@ import java.util.List; ...@@ -8,16 +8,13 @@ import java.util.List;
* @author hyh * @author hyh
* @since 2021/07/30 16:56 * @since 2021/07/30 16:56
*/ */
public class FriendGetListResult { public class FriendGetListResult extends GroupGetResult {
@JsonProperty("InfoItem") @JsonProperty("InfoItem")
private List<FriendGetListInfoItem> infoItemList; private List<FriendGetListInfoItem> infoItemList;
@JsonProperty("Fail_Account") @JsonProperty("Fail_Account")
private List<String> failAccount; private List<String> failAccount;
@JsonProperty("ErrorDisplay")
private String errorDisplay;
public List<FriendGetListInfoItem> getInfoItemList() { public List<FriendGetListInfoItem> getInfoItemList() {
return infoItemList; return infoItemList;
} }
...@@ -34,11 +31,11 @@ public class FriendGetListResult { ...@@ -34,11 +31,11 @@ public class FriendGetListResult {
this.failAccount = failAccount; this.failAccount = failAccount;
} }
public String getErrorDisplay() { @Override
return errorDisplay; public String toString() {
} return "FriendGetListResult{" +
"infoItemList=" + infoItemList +
public void setErrorDisplay(String errorDisplay) { ", failAccount=" + failAccount +
this.errorDisplay = errorDisplay; '}';
} }
} }
...@@ -30,4 +30,12 @@ public class FriendImportResult extends GenericResult { ...@@ -30,4 +30,12 @@ public class FriendImportResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "FriendImportResult{" +
"resultItemList=" + resultItemList +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -52,4 +52,14 @@ public class GroupAddResult extends GenericResult { ...@@ -52,4 +52,14 @@ public class GroupAddResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "GroupAddResult{" +
"resultItemList=" + resultItemList +
", failAccount=" + failAccount +
", currentSequence=" + currentSequence +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -28,4 +28,12 @@ public class GroupDeleteResult extends GenericResult { ...@@ -28,4 +28,12 @@ public class GroupDeleteResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "GroupDeleteResult{" +
"currentSequence=" + currentSequence +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -41,4 +41,13 @@ public class GroupGetResult extends GenericResult { ...@@ -41,4 +41,13 @@ public class GroupGetResult extends GenericResult {
public void setErrorDisplay(String errorDisplay) { public void setErrorDisplay(String errorDisplay) {
this.errorDisplay = errorDisplay; this.errorDisplay = errorDisplay;
} }
@Override
public String toString() {
return "GroupGetResult{" +
"resultItemList=" + resultItemList +
", currentSequence=" + currentSequence +
", errorDisplay='" + errorDisplay + '\'' +
'}';
}
} }
...@@ -39,4 +39,13 @@ public class ResultItem { ...@@ -39,4 +39,13 @@ public class ResultItem {
public void setResultInfo(String resultInfo) { public void setResultInfo(String resultInfo) {
this.resultInfo = resultInfo; this.resultInfo = resultInfo;
} }
@Override
public String toString() {
return "ResultItem{" +
"toAccount='" + toAccount + '\'' +
", resultCode=" + resultCode +
", resultInfo='" + resultInfo + '\'' +
'}';
}
} }
...@@ -14,4 +14,28 @@ public class UserDataItem { ...@@ -14,4 +14,28 @@ public class UserDataItem {
@JsonProperty("ValueItem") @JsonProperty("ValueItem")
private List<ValueItem> valueItemList; private List<ValueItem> valueItemList;
public String getToAccount() {
return toAccount;
}
public void setToAccount(String toAccount) {
this.toAccount = toAccount;
}
public List<ValueItem> getValueItemList() {
return valueItemList;
}
public void setValueItemList(List<ValueItem> valueItemList) {
this.valueItemList = valueItemList;
}
@Override
public String toString() {
return "UserDataItem{" +
"toAccount='" + toAccount + '\'' +
", valueItemList=" + valueItemList +
'}';
}
} }
...@@ -11,7 +11,7 @@ public class ValueItem { ...@@ -11,7 +11,7 @@ public class ValueItem {
private String tag; private String tag;
@JsonProperty("Value") @JsonProperty("Value")
private String value; private Object value;
public String getTag() { public String getTag() {
return tag; return tag;
...@@ -21,11 +21,19 @@ public class ValueItem { ...@@ -21,11 +21,19 @@ public class ValueItem {
this.tag = tag; this.tag = tag;
} }
public String getValue() { public Object getValue() {
return value; return value;
} }
public void setValue(String value) { public void setValue(Object value) {
this.value = value; this.value = value;
} }
@Override
public String toString() {
return "ValueItem{" +
"tag='" + tag + '\'' +
", value=" + value +
'}';
}
} }
...@@ -11,6 +11,7 @@ import org.junit.Test; ...@@ -11,6 +11,7 @@ import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
...@@ -38,9 +39,7 @@ public class ProfileTest { ...@@ -38,9 +39,7 @@ public class ProfileTest {
@Test @Test
public void testPortraitSet() throws IOException { public void testPortraitSet() throws IOException {
ProfileItem profileItem = new ProfileItem("Tag_Profile_IM_Nick", "MyNickName"); ProfileItem profileItem = new ProfileItem("Tag_Profile_IM_Nick", "MyNickName");
List<ProfileItem> profileItemList = new ArrayList<>(); PortraitSetRequest request = new PortraitSetRequest("test1", Collections.singletonList(profileItem));
profileItemList.add(profileItem);
PortraitSetRequest request = new PortraitSetRequest("test1", profileItemList);
PortraitSetResult result = client.profile.portraitSet(request); PortraitSetResult result = client.profile.portraitSet(request);
System.out.println(result); System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus()); Assert.assertEquals("OK", result.getActionStatus());
...@@ -48,11 +47,9 @@ public class ProfileTest { ...@@ -48,11 +47,9 @@ public class ProfileTest {
@Test @Test
public void testPortraitGet() throws IOException { public void testPortraitGet() throws IOException {
List<String> toAccount = new ArrayList<>();
toAccount.add("test1");
List<String> tagList = new ArrayList<>(); List<String> tagList = new ArrayList<>();
tagList.add("Tag_Profile_IM_Nick"); tagList.add("Tag_Profile_IM_Nick");
PortraitGetRequest request = new PortraitGetRequest(toAccount, tagList); PortraitGetRequest request = new PortraitGetRequest(Collections.singletonList("test1"), tagList);
PortraitGetResult result = client.profile.portraitGet(request); PortraitGetResult result = client.profile.portraitGet(request);
System.out.println(result); System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus()); Assert.assertEquals("OK", result.getActionStatus());
......
package com.qcloud.im;
import com.qcloud.im.model.request.*;
import com.qcloud.im.model.response.*;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
/**
* @author hyh
* @since 2021/07/31 16:14
*/
public class SNSTest {
private static final Properties properties = new Properties();
private static final IMClient client;
static {
InputStream resourceAsStream = AccountTest.class.getClassLoader().getResourceAsStream("app.properties");
try {
properties.load(resourceAsStream);
} catch (IOException e) {
e.printStackTrace();
}
String key = properties.getProperty("key");
String identifier = properties.getProperty("identifier");
Long appId = Long.parseLong(properties.getProperty("appId"));
client = IMClient.getInstance(appId, identifier, key);
}
@Test
public void testFriendAdd() throws IOException {
AddFriendItem addFriendItem = new AddFriendItem();
addFriendItem.setToAccount("test2");
addFriendItem.setRemark("Mr.A");
addFriendItem.setGroupName("schoolmate");
addFriendItem.setAddSource("AddSource_Type_XXXXXXXX");
addFriendItem.setAddWording("Hi");
FriendAddRequest request = new FriendAddRequest();
request.setFromAccount("test1");
request.setAddFriendItemList(Collections.singletonList(addFriendItem));
request.setAddType("Add_Type_Both");
request.setForceAddFlags(1);
FriendAddResult result = client.sns.friendAdd(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testFriendImport() throws IOException {
ImportFriendItem importFriendItem = new ImportFriendItem();
importFriendItem.setToAccount("test2");
importFriendItem.setAddSource("AddSource_Type_XXXXXXXX");
FriendImportRequest request = new FriendImportRequest();
request.setFromAccount("test1");
request.setImportFriendItemList(Collections.singletonList(importFriendItem));
FriendImportResult result = client.sns.friendImport(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testFriendUpdate() throws IOException {
SnsItem snsItem = new SnsItem();
snsItem.setTag("Tag_SNS_Custom_testTag");
snsItem.setValue("Tag_SNS_IM_AddWording");
UpdateItem updateItem = new UpdateItem();
updateItem.setToAccount("test2");
updateItem.setSnsItemList(Collections.singletonList(snsItem));
FriendUpdateRequest request = new FriendUpdateRequest();
request.setFromAccount("test1");
request.setUpdateItemList(Collections.singletonList(updateItem));
FriendUpdateResult result = client.sns.friendUpdate(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testFriendDelete() throws IOException {
FriendDeleteRequest request = new FriendDeleteRequest();
request.setFromAccount("test1");
request.setToAccount(Collections.singletonList("test2"));
request.setDeleteType("Delete_Type_Both");
FriendDeleteResult result = client.sns.friendDelete(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testFriendDeleteAll() throws IOException {
FriendDeleteAllRequest request = new FriendDeleteAllRequest();
request.setFromAccount("test1");
request.setDeleteType("Delete_Type_Both");
FriendDeleteAllResult result = client.sns.friendDeleteAll(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testFriendCheck() throws IOException {
FriendCheckRequest request = new FriendCheckRequest();
request.setFromAccount("test1");
request.setToAccount(Collections.singletonList("test2"));
request.setCheckType("CheckResult_Type_Both");
FriendCheckResult result = client.sns.friendCheck(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testFriendGet() throws IOException {
FriendGetRequest request = new FriendGetRequest();
request.setFromAccount("test1");
request.setStartIndex(0);
request.setStandardSequence(0);
request.setCustomSequence(0);
FriendGetResult result = client.sns.friendGet(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testFriendGetList() throws IOException {
FriendGetListRequest request = new FriendGetListRequest();
request.setFromAccount("test1");
request.setToAccount(Collections.singletonList("test2"));
request.setTagList(Collections.singletonList("Tag_SNS_Custom_testTag"));
FriendGetListResult result = client.sns.friendGetList(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testBlackListAdd() throws IOException {
BlackListAddRequest request = new BlackListAddRequest();
request.setFromAccount("test1");
request.setToAccount(Collections.singletonList("test2"));
BlackListAddResult result = client.sns.blackListAdd(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testBlackListDelete() throws IOException {
BlackListDeleteRequest request = new BlackListDeleteRequest();
request.setFromAccount("test1");
request.setToAccount(Collections.singletonList("test2"));
BlackListDeleteResult result = client.sns.blackListDelete(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testBlackListGet() throws IOException {
BlackListGetRequest request = new BlackListGetRequest();
request.setFromAccount("test1");
request.setStartIndex(0);
request.setMaxLimited(10);
request.setLastSequence(0);
BlackListGetResult result = client.sns.blackListGet(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testBlackListCheck() throws IOException {
BlackListCheckRequest request = new BlackListCheckRequest();
request.setFromAccount("test1");
request.setToAccount(Collections.singletonList("test2"));
request.setCheckType("BlackCheckResult_Type_Both");
BlackListCheckResult result = client.sns.blackListCheck(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testGroupAdd() throws IOException {
GroupAddRequest request = new GroupAddRequest();
request.setFromAccount("test1");
request.setToAccount(Collections.singletonList("test2"));
request.setGroupName(Collections.singletonList("classmate"));
GroupAddResult result = client.sns.groupAdd(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testGroupDelete() throws IOException {
GroupDeleteRequest request = new GroupDeleteRequest();
request.setFromAccount("test1");
request.setGroupName(Collections.singletonList("classmate"));
GroupDeleteResult result = client.sns.groupDelete(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
@Test
public void testGroupGet() throws IOException {
GroupGetRequest request = new GroupGetRequest();
request.setFromAccount("test1");
request.setGroupName(Collections.singletonList("schoolmate"));
request.setNeedFriend("Need_Friend_Type_Yes");
request.setLastSequence(0);
GroupGetResult result = client.sns.groupGet(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment