2020
2121public class DeviceClient {
2222 public static final String HOST_NAME_SSL = "https://device.jpush.cn" ;
23- public static final String DEVICE_PATH = "/v3/device " ;
24- public static final String TAG_PATH = "/v3/tag " ;
25- public static final String ALIAS_PATH = "/v3/alias " ;
23+ public static final String DEVICES_PATH = "/v3/devices " ;
24+ public static final String TAGS_PATH = "/v3/tags " ;
25+ public static final String ALIASES_PATH = "/v3/aliases " ;
2626
2727 private final NativeHttpClient _httpClient ;
2828
@@ -45,7 +45,7 @@ public DeviceClient(String masterSecret, String appKey, int maxRetryTimes, HttpP
4545 // -------------- device
4646
4747 public TagAliasResult getDeviceTagAlias (String registrationId ) throws APIConnectionException , APIRequestException {
48- String url = HOST_NAME_SSL + DEVICE_PATH + "/" + registrationId ;
48+ String url = HOST_NAME_SSL + DEVICES_PATH + "/" + registrationId ;
4949
5050 ResponseWrapper response = _httpClient .sendGet (url );
5151
@@ -55,7 +55,7 @@ public TagAliasResult getDeviceTagAlias(String registrationId) throws APIConnect
5555 public DefaultResult updateDeviceTagAlias (String registrationId , boolean clearAlias , boolean clearTag ) throws APIConnectionException , APIRequestException {
5656 Preconditions .checkArgument (clearAlias || clearTag , "It is not meaningful to do nothing." );
5757
58- String url = HOST_NAME_SSL + DEVICE_PATH + "/" + registrationId ;
58+ String url = HOST_NAME_SSL + DEVICES_PATH + "/" + registrationId ;
5959
6060 JsonObject top = new JsonObject ();
6161 if (clearAlias ) {
@@ -72,7 +72,7 @@ public DefaultResult updateDeviceTagAlias(String registrationId, boolean clearAl
7272
7373 public DefaultResult updateDeviceTagAlias (String registrationId , String alias ,
7474 Set <String > tagsToAdd , Set <String > tagsToRemove ) throws APIConnectionException , APIRequestException {
75- String url = HOST_NAME_SSL + DEVICE_PATH + "/" + registrationId ;
75+ String url = HOST_NAME_SSL + DEVICES_PATH + "/" + registrationId ;
7676
7777 JsonObject top = new JsonObject ();
7878 if (null != alias ) {
@@ -102,22 +102,22 @@ public DefaultResult updateDeviceTagAlias(String registrationId, String alias,
102102 // ------------- tags
103103
104104 public TagListResult getTagList () throws APIConnectionException , APIRequestException {
105- String url = HOST_NAME_SSL + TAG_PATH + "/list " ;
105+ String url = HOST_NAME_SSL + TAGS_PATH + "/" ;
106106
107107 ResponseWrapper response = _httpClient .sendGet (url );
108108
109109 return TagListResult .fromResponse (response , TagListResult .class );
110110 }
111111
112112 public BooleanResult isDeviceInTag (String theTag , String registrationID ) throws APIConnectionException , APIRequestException {
113- String url = HOST_NAME_SSL + TAG_PATH + "/" + theTag + "/exist?registration_id= " + registrationID ;
113+ String url = HOST_NAME_SSL + TAGS_PATH + "/" + theTag + "/registration_ids/ " + registrationID ;
114114 ResponseWrapper response = _httpClient .sendGet (url );
115115
116116 return BaseResult .fromResponse (response , BooleanResult .class );
117117 }
118118
119119 public DefaultResult addRemoveDevicesFromTag (String theTag , Set <String > toAddUsers , Set <String > toRemoveUsers ) throws APIConnectionException , APIRequestException {
120- String url = HOST_NAME_SSL + TAG_PATH + "/" + theTag ;
120+ String url = HOST_NAME_SSL + TAGS_PATH + "/" + theTag ;
121121
122122 JsonObject top = new JsonObject ();
123123 JsonObject registrationIds = new JsonObject ();
@@ -145,7 +145,7 @@ public DefaultResult addRemoveDevicesFromTag(String theTag, Set<String> toAddUse
145145 }
146146
147147 public DefaultResult deleteTag (String theTag , String platform ) throws APIConnectionException , APIRequestException {
148- String url = HOST_NAME_SSL + TAG_PATH + "/" + theTag ;
148+ String url = HOST_NAME_SSL + TAGS_PATH + "/" + theTag ;
149149 if (null != platform ) {
150150 url += "?platform=" + platform ;
151151 }
@@ -159,7 +159,7 @@ public DefaultResult deleteTag(String theTag, String platform) throws APIConnect
159159 // ------------- alias
160160
161161 public AliasDeviceListResult getAliasDeviceList (String alias , String platform ) throws APIConnectionException , APIRequestException {
162- String url = HOST_NAME_SSL + ALIAS_PATH + "/" + alias ;
162+ String url = HOST_NAME_SSL + ALIASES_PATH + "/" + alias ;
163163 if (null != platform ) {
164164 url += "?platform=" + platform ;
165165 }
@@ -170,7 +170,7 @@ public AliasDeviceListResult getAliasDeviceList(String alias, String platform) t
170170 }
171171
172172 public DefaultResult deleteAlias (String alias , String platform ) throws APIConnectionException , APIRequestException {
173- String url = HOST_NAME_SSL + ALIAS_PATH + "/" + alias ;
173+ String url = HOST_NAME_SSL + ALIASES_PATH + "/" + alias ;
174174 if (null != platform ) {
175175 url += "?platform=" + platform ;
176176 }
0 commit comments