cn.jiguang.common.resp.APIConnectionException Java Examples
The following examples show how to use
cn.jiguang.common.resp.APIConnectionException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: jmessage-api-java-client Author: jpush File: GroupClient.java License: MIT License | 5 votes |
public ResponseWrapper updateGroupInfo(long gid, String groupName, String groupDesc, String avatar) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(gid > 0, "gid should more than 0."); if (StringUtils.isTrimedEmpty(groupName) && StringUtils.isTrimedEmpty(groupDesc) && StringUtils.isTrimedEmpty(avatar)) { Preconditions.checkArgument(false, "group name, group description and group avatar should not be null at the same time."); } JsonObject json = new JsonObject(); if (StringUtils.isNotEmpty(groupName)) { groupName = groupName.trim(); Preconditions.checkArgument(groupName.getBytes().length <= 64, "The length of group name must not more than 64 bytes."); Preconditions.checkArgument(!StringUtils.isLineBroken(groupName), "The group name must not contain line feed character."); json.addProperty(GroupPayload.GROUP_NAME, groupName); } if (StringUtils.isNotEmpty(groupDesc)) { groupDesc = groupDesc.trim(); Preconditions.checkArgument(groupDesc.getBytes().length <= 250, "The length of group description must not more than 250 bytes."); json.addProperty(GroupPayload.DESC, groupDesc); } if (StringUtils.isNotEmpty(avatar)) { avatar = avatar.trim(); json.addProperty(GroupPayload.AVATAR, avatar); } return _httpClient.sendPut(_baseUrl + groupPath + "/" + gid, json.toString()); }
Example #2
Source Project: jsms-api-java-client Author: jpush File: SMSClient.java License: MIT License | 5 votes |
/** * Modify SMS with schedule * * @param payload ScheduleSMSPayload * @param scheduleId id * @return ScheduleResult which includes schedule_id * @throws APIConnectionException connect exception * @throws APIRequestException request exception */ public ScheduleResult updateScheduleSMS(ScheduleSMSPayload payload, String scheduleId) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(null != payload, "Schedule SMS payload should not be null"); Preconditions.checkArgument(null != scheduleId, "Schedule id should not be null"); Preconditions.checkArgument(null != payload.getMobile(), "Mobile should not be null"); Preconditions.checkArgument(StringUtils.isMobileNumber(payload.getMobile()), "Invalid mobile number"); ResponseWrapper responseWrapper = _httpClient.sendPut(_baseUrl + _schedulePath + "/" + scheduleId, payload.toString()); return ScheduleResult.fromResponse(responseWrapper, ScheduleResult.class); }
Example #3
Source Project: jmessage-api-java-client Author: jpush File: UserClient.java License: MIT License | 5 votes |
/** * Get admins by appkey * * @param start The start index of the list * @param count The number that how many you want to get from list * @return admin user info list * @throws APIConnectionException connect exception * @throws APIRequestException request exception */ public UserListResult getAdminListByAppkey(int start, int count) throws APIConnectionException, APIRequestException { if (start < 0 || count <= 0 || count > 500) { throw new IllegalArgumentException("negative index or count must more than 0 and less than 501"); } ResponseWrapper response = _httpClient.sendGet(_baseUrl + adminPath + "?start=" + start + "&count=" + count); return UserListResult.fromResponse(response, UserListResult.class); }
Example #4
Source Project: jsms-api-java-client Author: jpush File: SMSClient.java License: MIT License | 5 votes |
/** * create sign * 其实两个接口可以合并 但没时间搞 * * @param payload {@link SignPayload } * @return SignResult * @throws APIConnectionException connect exception * @throws APIRequestException request exception */ public SignResult createSign(SignPayload payload) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(null != payload, "sign payload should not be null"); Preconditions.checkArgument(payload.getType() > 0 && payload.getType() <= 7, "type should be between 1 and 7"); Map<String, Object> params = new HashMap<String, Object>(); params.put(SignPayload.getSIGN(), payload.getSign()); if (!StringUtils.isEmpty(payload.getRemark())) { Preconditions.checkArgument(payload.getRemark().length() <= 100, "remark too long"); params.put(SignPayload.getREMARK(), payload.getRemark()); } params.put(SignPayload.getTYPE(), payload.getType()); Map<String, byte[]> fileParams = new HashMap<String, byte[]>(); File[] images = payload.getImages(); if (images != null && images.length > 0) { for (File file : payload.getImages()) { fileParams.put(file.getName(), getBytes(file)); } } String url = _baseUrl + _signPath; try { ResponseWrapper wrapper = doPostSign(url, params, fileParams, SignPayload.getIMAGES()); if (wrapper.responseCode != 200) { throw new APIRequestException(wrapper); } return SignResult.fromResponse(wrapper, SignResult.class); } catch (IOException e) { e.printStackTrace(); throw new IllegalArgumentException("fail to creat sign"); } }
Example #5
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 5 votes |
public String registerAdmins(String username, String password) throws APIConnectionException, APIRequestException { RegisterInfo payload = RegisterInfo.newBuilder() .setUsername(username) .setPassword(password) .build(); return _userClient.registerAdmins(payload).responseContent; }
Example #6
Source Project: jmessage-api-java-client Author: jpush File: ReportClient.java License: MIT License | 5 votes |
/** * Get user's message list with cursor, the cursor will effective in 120 seconds. * And will return same count of messages as first request. * @param username Necessary parameter. * @param cursor First request will return cursor * @return MessageListResult * @throws APIConnectionException connect exception * @throws APIRequestException request exception */ public MessageListResult v2GetUserMessagesByCursor(String username, String cursor) throws APIConnectionException, APIRequestException { StringUtils.checkUsername(username); if (null != cursor) { String requestUrl = mBaseReportPath + mV2UserPath + "/" + username + "/messages?cursor=" + cursor; ResponseWrapper response = _httpClient.sendGet(requestUrl); return MessageListResult.fromResponse(response, MessageListResult.class); } else { throw new IllegalArgumentException("the cursor parameter should not be null"); } }
Example #7
Source Project: jmessage-api-java-client Author: jpush File: ReportClient.java License: MIT License | 5 votes |
/** * Get user statistic, now time unit only supports DAY * @param startTime start time, format: yyyy-MM-dd * @param duration 0-60 * @return {@link UserStatListResult} * @throws APIConnectionException connect exception * @throws APIRequestException request exception */ public UserStatListResult getUserStatistic(String startTime, int duration) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(verifyDateFormat("DAY", startTime), "Illegal date format"); Preconditions.checkArgument(0 <= duration && duration <= 60, " 0 <= duration <= 60"); String url = mBaseReportPath + mV2StatisticPath + "/users?time_unit=DAY&start=" + startTime + "&duration=" + duration; ResponseWrapper responseWrapper = _httpClient.sendGet(url); return UserStatListResult.fromResponse(responseWrapper); }
Example #8
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 5 votes |
public CreateGroupResult createGroup(String owner, String gname, String desc, String avatar, int flag, String... userlist) throws APIConnectionException, APIRequestException { Members members = Members.newBuilder().addMember(userlist).build(); GroupPayload payload = GroupPayload.newBuilder() .setOwner(owner) .setName(gname) .setDesc(desc) .setMembers(members) .setAvatar(avatar) .setFlag(flag) .build(); return _groupClient.createGroup(payload); }
Example #9
Source Project: jmessage-api-java-client Author: jpush File: MessageClient.java License: MIT License | 5 votes |
public SendMessageResult sendMessage(MessagePayload payload) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(!(null == payload), "Message payload should not be null"); ResponseWrapper response = _httpClient.sendPost(_baseUrl + messagePath, payload.toString()); return SendMessageResult.fromResponse(response, SendMessageResult.class); }
Example #10
Source Project: jmessage-api-java-client Author: jpush File: MessageClient.java License: MIT License | 5 votes |
/** * Please use {@link cn.jmessage.api.reportv2.ReportClient#v2GetUserMessagesByCursor(String, String)} * Get message list with cursor, the cursor will effective in 120 seconds. And will * return same count of messages as first request. * @param cursor First request will return cursor * @return MessageListResult * @throws APIConnectionException connect exception * @throws APIRequestException request exception */ @Deprecated public MessageListResult getMessageListByCursor(String cursor) throws APIConnectionException, APIRequestException { if (null != cursor) { String requestUrl = reportBaseUrl + v2_messagePath + "?cursor=" + cursor; ResponseWrapper response = _httpClient.sendGet(requestUrl); return MessageListResult.fromResponse(response, MessageListResult.class); } else { throw new IllegalArgumentException("the cursor parameter should not be null"); } }
Example #11
Source Project: jmessage-api-java-client Author: jpush File: CrossAppClient.java License: MIT License | 5 votes |
/** * Add blacklist whose users belong to another app to a given user. * @param username The owner of the blacklist * @param blacklists CrossBlacklist array * @return No Content * @throws APIConnectionException connect exception * @throws APIRequestException request exception */ public ResponseWrapper addCrossBlacklist(String username, CrossBlacklist[] blacklists) throws APIConnectionException, APIRequestException { StringUtils.checkUsername(username); CrossBlacklistPayload payload = new CrossBlacklistPayload.Builder() .setCrossBlacklists(blacklists) .build(); return _httpClient.sendPut(_baseUrl + crossUserPath + "/" + username +"/blacklist", payload.toString()); }
Example #12
Source Project: jmessage-api-java-client Author: jpush File: GroupClient.java License: MIT License | 5 votes |
public GroupInfoResult getGroupInfo(long gid) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(gid > 0, "gid should more than 0."); ResponseWrapper response = _httpClient.sendGet(_baseUrl + groupPath + "/" + gid); return GroupInfoResult.fromResponse(response, GroupInfoResult.class); }
Example #13
Source Project: jmessage-api-java-client Author: jpush File: GroupClient.java License: MIT License | 5 votes |
public MemberListResult getGroupMembers(long gid) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(gid > 0, "gid should more than 0."); ResponseWrapper response = _httpClient.sendGet(_baseUrl + groupPath + "/" + gid + "/members"); return MemberListResult.fromResponse(response); }
Example #14
Source Project: jmessage-api-java-client Author: jpush File: GroupClient.java License: MIT License | 5 votes |
public GroupListResult getGroupListByAppkey(int start, int count) throws APIConnectionException, APIRequestException { if (start < 0 || count <= 0 || count > 500) { throw new IllegalArgumentException("negative index or count must more than 0 and less than 501"); } ResponseWrapper response = _httpClient.sendGet(_baseUrl + groupPath + "?start=" + start + "&count=" + count); return GroupListResult.fromResponse(response, GroupListResult.class); }
Example #15
Source Project: jmessage-api-java-client Author: jpush File: GroupClient.java License: MIT License | 5 votes |
public CreateGroupResult createGroup(GroupPayload payload) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(!(null == payload), "group payload should not be null"); ResponseWrapper response = _httpClient.sendPost(_baseUrl + groupPath, payload.toString()); return CreateGroupResult.fromResponse(response, CreateGroupResult.class); }
Example #16
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 4 votes |
public void updateGroupInfo(long gid, String groupName, String groupDesc, String avatar) throws APIConnectionException, APIRequestException { _groupClient.updateGroupInfo(gid, groupName, groupDesc, avatar); }
Example #17
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 4 votes |
public MessageListResult v2GetMessageListByCursor(String cursor) throws APIConnectionException, APIRequestException { return _reportClient.v2GetMessageListByCursor(cursor); }
Example #18
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 4 votes |
public GroupListResult getGroupListByAppkey(int start, int count) throws APIConnectionException, APIRequestException { return _groupClient.getGroupListByAppkey(start, count); }
Example #19
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 4 votes |
public void updateUserInfo(String username, UserPayload payload) throws APIConnectionException, APIRequestException { _userClient.updateUserInfo(username, payload); }
Example #20
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 4 votes |
public UserStateResult getUserState(String username) throws APIConnectionException, APIRequestException { return _userClient.getUserState(username); }
Example #21
Source Project: jiguang-java-client-common Author: jpush File: IHttpClient.java License: MIT License | 4 votes |
public ResponseWrapper sendDelete(String url) throws APIConnectionException, APIRequestException;
Example #22
Source Project: jiguang-java-client-common Author: jpush File: IHttpClient.java License: MIT License | 4 votes |
public ResponseWrapper sendDelete(String url, String content) throws APIConnectionException, APIRequestException;
Example #23
Source Project: jiguang-java-client-common Author: jpush File: NettyHttpClient.java License: MIT License | 4 votes |
@Override public ResponseWrapper sendGet(String url) throws APIConnectionException, APIRequestException { return sendGet(url, null); }
Example #24
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 4 votes |
public void deleteUser(String username) throws APIConnectionException, APIRequestException { _userClient.deleteUser(username); }
Example #25
Source Project: jiguang-java-client-common Author: jpush File: NettyHttpClient.java License: MIT License | 4 votes |
@Override public ResponseWrapper sendPut(String url, String content) throws APIConnectionException, APIRequestException { return sendHttpRequest(HttpMethod.PUT, url, content); }
Example #26
Source Project: jiguang-java-client-common Author: jpush File: NettyHttpClient.java License: MIT License | 4 votes |
@Override public ResponseWrapper sendPost(String url, String content) throws APIConnectionException, APIRequestException { return sendHttpRequest(HttpMethod.POST, url, content); }
Example #27
Source Project: jmessage-api-java-client Author: jpush File: JMessageClient.java License: MIT License | 4 votes |
public ResponseWrapper removeBlacklist(String username, String...users) throws APIConnectionException, APIRequestException { return _userClient.removeBlackList(username, users); }
Example #28
Source Project: jiguang-java-client-common Author: jpush File: NettyHttpClient.java License: MIT License | 4 votes |
public ResponseWrapper sendDelete(String url, String content) throws APIConnectionException, APIRequestException { return sendHttpRequest(HttpMethod.DELETE, url, content); }
Example #29
Source Project: jiguang-java-client-common Author: jpush File: NativeHttpClient.java License: MIT License | 4 votes |
public ResponseWrapper sendGet(String url) throws APIConnectionException, APIRequestException { return sendGet(url, null); }
Example #30
Source Project: jiguang-java-client-common Author: jpush File: NativeHttpClient.java License: MIT License | 4 votes |
public ResponseWrapper sendDelete(String url, String content) throws APIConnectionException, APIRequestException { return doRequest(url, content, RequestMethod.DELETE); }