|
| 1 | +package cn.jpush.api.common; |
| 2 | + |
| 3 | + |
| 4 | +import java.util.HashMap; |
| 5 | +import java.util.Map; |
| 6 | + |
| 7 | +public class ClientConfig extends HashMap<String, Object> { |
| 8 | + |
| 9 | + private static ClientConfig instance = new ClientConfig(); |
| 10 | + |
| 11 | + public static final String DEVICE_HOST_NAME = "device.host.name"; |
| 12 | + public static final Object DEVICE_HOST_NAME_SCHEMA = String.class; |
| 13 | + |
| 14 | + public static final String DEVICES_PATH = "devices.path"; |
| 15 | + public static final Object DEVICES_PATH_SCHEMA = String.class; |
| 16 | + |
| 17 | + public static final String TAGS_PATH = "tags.path"; |
| 18 | + public static final Object TAGS_PATH_SCHEMA = String.class; |
| 19 | + |
| 20 | + public static final String ALIASES_PATH = "aliases.path"; |
| 21 | + public static final Object ALIASES_PATH_SCHEMA = String.class; |
| 22 | + |
| 23 | + public static final String PUSH_HOST_NAME = "push.host.name"; |
| 24 | + public static final Object PUSH_HOST_NAME_SCHEMA = String.class; |
| 25 | + |
| 26 | + public static final String PUSH_PATH = "push.path"; |
| 27 | + public static final Object PUSH_PATH_SCHEMA = String.class; |
| 28 | + |
| 29 | + public static final String PUSH_VALIDATE_PATH = "push.validate.path"; |
| 30 | + public static final Object PUSH_VALIDATE_PATH_SCHMEA = String.class; |
| 31 | + |
| 32 | + public static final String REPORT_HOST_NAME = "report.host.name"; |
| 33 | + public static final Object REPORT_HOST_NAME_SCHEMA = String.class; |
| 34 | + |
| 35 | + public static final String REPORT_RECEIVE_PATH = "report.receive.path"; |
| 36 | + public static final Object REPORT_RECEIVE_PATH_SCHEMA = String.class; |
| 37 | + |
| 38 | + public static final String REPORT_USER_PATH = "report.user.path"; |
| 39 | + public static final Object REPORT_USER_PATH_SCHEMA = String.class; |
| 40 | + |
| 41 | + public static final String REPORT_MESSAGE_PATH = "report.message.path"; |
| 42 | + public static final Object REPORT_MESSAGE_PATH_SCHEMA = String.class; |
| 43 | + |
| 44 | + private ClientConfig() { |
| 45 | + super(); |
| 46 | + this.put(DEVICE_HOST_NAME, "https://device.jpush.cn"); |
| 47 | + this.put(DEVICES_PATH, "/v3/devices"); |
| 48 | + this.put(TAGS_PATH, "/v3/tags"); |
| 49 | + this.put(ALIASES_PATH, "/v3/aliases"); |
| 50 | + |
| 51 | + this.put(PUSH_HOST_NAME, "https://api.jpush.cn"); |
| 52 | + this.put(PUSH_PATH, "/v3/push"); |
| 53 | + this.put(PUSH_VALIDATE_PATH, "/v3/push/validate"); |
| 54 | + |
| 55 | + this.put(REPORT_HOST_NAME, "https://report.jpush.cn"); |
| 56 | + this.put(REPORT_RECEIVE_PATH, "/v3/received"); |
| 57 | + this.put(REPORT_USER_PATH, "/v3/users"); |
| 58 | + this.put(REPORT_MESSAGE_PATH, "/v3/messages"); |
| 59 | + } |
| 60 | + |
| 61 | + public static ClientConfig getInstance() { |
| 62 | + return instance; |
| 63 | + } |
| 64 | + |
| 65 | + public static void setDeviceHostName(Map conf, String hostName) { |
| 66 | + conf.put(DEVICE_HOST_NAME, hostName); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Setup custom device api host name, if using the JPush privacy cloud. |
| 71 | + * @param hostName the custom api host name, default is JPush domain name |
| 72 | + */ |
| 73 | + public void setDeviceHostName(String hostName) { |
| 74 | + setDeviceHostName(this, hostName); |
| 75 | + } |
| 76 | + |
| 77 | + public static void setPushHostName(Map conf, String hostName) { |
| 78 | + conf.put(PUSH_HOST_NAME, hostName); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Setup custom push api host name, if using the JPush privacy cloud. |
| 83 | + * @param hostName the custom api host name, default is JPush domain name |
| 84 | + */ |
| 85 | + public void setPushHostName(String hostName) { |
| 86 | + setPushHostName(this, hostName); |
| 87 | + } |
| 88 | + |
| 89 | + public static void setReportHostName(Map conf, String hostName) { |
| 90 | + conf.put(REPORT_HOST_NAME, hostName); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Setup custom report api host name, if using the JPush privacy cloud. |
| 95 | + * @param hostName the custom api host name, default is JPush domain name |
| 96 | + */ |
| 97 | + public void setReportHostName(String hostName) { |
| 98 | + setReportHostName(this, hostName); |
| 99 | + } |
| 100 | + |
| 101 | +} |
0 commit comments