diff --git a/.gitignore b/.gitignore index 32858aa..1b03658 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.idea/ +out/ + *.class # Mobile Tools for Java (J2ME) diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/src/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/net/irext/webapi/WebAPIs.java b/src/net/irext/webapi/WebAPIs.java new file mode 100644 index 0000000..af2cd25 --- /dev/null +++ b/src/net/irext/webapi/WebAPIs.java @@ -0,0 +1,271 @@ +package net.irext.webapi; + +import com.google.gson.Gson; +import net.irext.webapi.model.*; +import net.irext.webapi.utils.Constants; +import net.irext.webapi.utils.MD5Digest; +import net.irext.webapi.request.*; +import net.irext.webapi.response.*; +import okhttp3.*; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +/** + * Filename: WebAPIs.java + * Revised: Date: 2017-03-30 + * Revision: Revision: 1.0 + *
+ * Description: HTTP Request initializer + *
+ * Revision log:
+ * 2017-03-30: created by strawmanbobi
+ */
+public class WebAPIs {
+
+ @SuppressWarnings("all")
+ private static final String TAG = WebAPIs.class.getSimpleName();
+
+ private static WebAPIs mInstance = null;
+
+ private static final String URL_PREFIX = "http://irext.net/irext";
+
+ private static final String SERVICE_SIGN_IN = "/certificate/admin_login";
+ private static final String SERVICE_LIST_CATEGORIES = "/int/list_categories";
+ private static final String SERVICE_LIST_BRANDS = "/int/list_brands";
+ private static final String SERVICE_LIST_PROVINCES = "/int/list_provinces";
+ private static final String SERVICE_LIST_CITIES = "/int/list_cities";
+ private static final String SERVICE_LIST_OPERATORS = "/int/list_operators";
+ private static final String SERVICE_LIST_INDEXES = "/int/list_indexes";
+ private static final String SERVICE_DOWNLOAD_BIN = "/int/download_bin";
+
+ private int adminID;
+ private String token;
+
+ private OkHttpClient mHttpClient;
+
+ private WebAPIs() {
+ mHttpClient = new OkHttpClient();
+ }
+
+ private static void initializeInstance() {
+ mInstance = new WebAPIs();
+ }
+
+ @SuppressWarnings("unused")
+ public static WebAPIs getInstance() {
+ if (null == mInstance) {
+ initializeInstance();
+ }
+ return mInstance;
+ }
+
+ private String postToServer(String url, String json) throws IOException {
+ MediaType JSON
+ = MediaType.parse("application/json; charset=utf-8");
+
+ RequestBody body = RequestBody.create(JSON, json);
+ Request request = new Request.Builder()
+ .url(url)
+ .post(body)
+ .build();
+ Response response = mHttpClient.newCall(request).execute();
+ return response.body().string();
+ }
+
+ private InputStream postToServerForOctets(String url, String json) throws IOException {
+ MediaType JSON
+ = MediaType.parse("application/json; charset=utf-8");
+ RequestBody body = RequestBody.create(JSON, json);
+
+ Request request = new Request.Builder()
+ .url(url)
+ .post(body)
+ .build();
+
+ Response response = mHttpClient.newCall(request).execute();
+ return response.body().byteStream();
+ }
+
+ @SuppressWarnings("unused")
+ public Admin signIn(String user_name, String password) {
+ String signInURL = URL_PREFIX + SERVICE_SIGN_IN;
+ LoginRequest loginRequest = new LoginRequest();
+ loginRequest.setUser_name(user_name);
+ loginRequest.setPassword(MD5Digest.MD5(password));
+ String bodyJson = loginRequest.toJson();
+
+ try {
+ String response = postToServer(signInURL, bodyJson);
+ LoginResponse loginResponse = new Gson().fromJson(response, LoginResponse.class);
+ if(loginResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) {
+ Admin admin = loginResponse.getEntity();
+ if (0 != admin.getId() && null != admin.getToken()) {
+ adminID = admin.getId();
+ token = admin.getToken();
+ }
+ return admin;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unused")
+ public List
+ * Description: Admin bean
+ *
+ * Revision log:
+ * 2017-04-01: created by strawmanbobi
+ */
+public class Admin {
+
+ private int id;
+ private String user_name;
+ private String password;
+ private String token;
+ private String permissions;
+
+ public Admin() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getUser_name() {
+ return user_name;
+ }
+
+ public void setUser_name(String user_name) {
+ this.user_name = user_name;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String getPermissions() {
+ return permissions;
+ }
+
+ public void setPermissions(String permissions) {
+ this.permissions = permissions;
+ }
+}
diff --git a/src/net/irext/webapi/model/Brand.java b/src/net/irext/webapi/model/Brand.java
new file mode 100644
index 0000000..6a893d9
--- /dev/null
+++ b/src/net/irext/webapi/model/Brand.java
@@ -0,0 +1,124 @@
+package net.irext.webapi.model;
+
+/**
+ * Filename: Brand.java
+ * Revised: Date: 2017-03-28
+ * Revision: Revision: 1.0
+ *
+ * Description: Brand bean
+ *
+ * Revision log:
+ * 2017-03-28: created by strawmanbobi
+ */
+public class Brand {
+
+ private int id;
+ private String name;
+ private int category_id;
+ private String category_name;
+ private int status;
+ private String update_time;
+ private int priority;
+ private String name_en;
+ private String name_tw;
+ private String contributor;
+
+ public Brand(int id, String name, int category_id, String category_name, int status,
+ String update_time, int priority,
+ String name_en, String name_tw, String contributor) {
+ this.id = id;
+ this.name = name;
+ this.category_id = category_id;
+ this.category_name = category_name;
+ this.status = status;
+ this.update_time = update_time;
+ this.priority = priority;
+ this.name_en = name_en;
+ this.name_tw = name_tw;
+ this.contributor = contributor;
+ }
+
+ public Brand() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getCategory_id() {
+ return category_id;
+ }
+
+ public void setCategory_id(int category_id) {
+ this.category_id = category_id;
+ }
+
+ public String getCategory_name() {
+ return category_name;
+ }
+
+ public void setCategory_name(String category_name) {
+ this.category_name = category_name;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getUpdate_time() {
+ return update_time;
+ }
+
+ public void setUpdate_time(String update_time) {
+ this.update_time = update_time;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ public String getName_en() {
+ return name_en;
+ }
+
+ public void setName_en(String name_en) {
+ this.name_en = name_en;
+ }
+
+ public String getName_tw() {
+ return name_tw;
+ }
+
+ public void setName_tw(String name_tw) {
+ this.name_tw = name_tw;
+ }
+
+ public String getContributor() {
+ return contributor;
+ }
+
+ public void setContributor(String contributor) {
+ this.contributor = contributor;
+ }
+}
diff --git a/src/net/irext/webapi/model/Category.java b/src/net/irext/webapi/model/Category.java
new file mode 100644
index 0000000..035ffb9
--- /dev/null
+++ b/src/net/irext/webapi/model/Category.java
@@ -0,0 +1,93 @@
+package net.irext.webapi.model;
+
+/**
+ * Filename: Category.java
+ * Revised: Date: 2017-03-28
+ * Revision: Revision: 1.0
+ *
+ * Description: Category bean
+ *
+ * Revision log:
+ * 2017-03-28: created by strawmanbobi
+ */
+public class Category {
+
+ private int id;
+ private String name;
+ private int status;
+ private String update_time;
+ private String name_en;
+ private String name_tw;
+ private String contributor;
+
+ public Category(int id, String name, int status, String update_time,
+ String name_en, String name_tw, String contributor) {
+ this.id = id;
+ this.name = name;
+ this.status = status;
+ this.update_time = update_time;
+ this.name_en = name_en;
+ this.name_tw = name_tw;
+ this.contributor = contributor;
+ }
+
+ public Category() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getUpdate_time() {
+ return update_time;
+ }
+
+ public void setUpdate_time(String update_time) {
+ this.update_time = update_time;
+ }
+
+ public String getName_en() {
+ return name_en;
+ }
+
+ public void setName_en(String name_en) {
+ this.name_en = name_en;
+ }
+
+ public String getName_tw() {
+ return name_tw;
+ }
+
+ public void setName_tw(String name_tw) {
+ this.name_tw = name_tw;
+ }
+
+ public String getContributor() {
+ return contributor;
+ }
+
+ public void setContributor(String contributor) {
+ this.contributor = contributor;
+ }
+}
diff --git a/src/net/irext/webapi/model/City.java b/src/net/irext/webapi/model/City.java
new file mode 100644
index 0000000..b42a11a
--- /dev/null
+++ b/src/net/irext/webapi/model/City.java
@@ -0,0 +1,93 @@
+package net.irext.webapi.model;
+
+/**
+ * Filename: City.java
+ * Revised: Date: 2017-03-28
+ * Revision: Revision: 1.0
+ *
+ * Description: City bean
+ *
+ * Revision log:
+ * 2017-03-28: created by strawmanbobi
+ */
+public class City {
+
+ private int id;
+ private String code;
+ private String name;
+ private double longitude;
+ private double latitude;
+ private int status;
+ private String name_tw;
+
+ public City(int id, String code, String name, double longitude, double latitude,
+ int status, String name_tw) {
+ this.id = id;
+ this.code = code;
+ this.name = name;
+ this.longitude = longitude;
+ this.latitude = latitude;
+ this.status = status;
+ this.name_tw = name_tw;
+ }
+
+ public City() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getName_tw() {
+ return name_tw;
+ }
+
+ public void setName_tw(String name_tw) {
+ this.name_tw = name_tw;
+ }
+}
diff --git a/src/net/irext/webapi/model/RemoteIndex.java b/src/net/irext/webapi/model/RemoteIndex.java
new file mode 100644
index 0000000..6242d3f
--- /dev/null
+++ b/src/net/irext/webapi/model/RemoteIndex.java
@@ -0,0 +1,259 @@
+package net.irext.webapi.model;
+
+/**
+ * Filename: RemoteIndex.java
+ * Revised: Date: 2017-03-28
+ * Revision: Revision: 1.0
+ *
+ * Description: RemoteIndex bean
+ *
+ * Revision log:
+ * 2017-03-28: created by strawmanbobi
+ */
+public class RemoteIndex {
+
+ private int id;
+ private int category_id;
+ private String category_name;
+ private int brand_id;
+ private String brand_name;
+ private String city_code;
+ private String city_name;
+ private String operator_id;
+ private String operator_name;
+ private String protocol;
+ private String remote;
+ private String remote_map;
+ private int status;
+ private int sub_cate;
+ private int priority;
+ private String remote_number;
+ private String category_name_tw;
+ private String brand_name_tw;
+ private String city_name_tw;
+ private String operator_name_tw;
+ private String binary_md5;
+ private String contributor;
+ private String update_time;
+
+ public RemoteIndex(int id,
+ int category_id, String category_name, int brand_id, String brand_name,
+ String city_code, String city_name, String operator_id, String operator_name,
+ String protocol, String remote, String remote_map, int status, int sub_cate,
+ int priority, String remote_number,
+ String category_name_tw, String brand_name_tw,
+ String city_name_tw, String operator_name_tw,
+ String binary_md5, String contributor, String update_time) {
+ this.id = id;
+ this.category_id = category_id;
+ this.category_name = category_name;
+ this.brand_id = brand_id;
+ this.brand_name = brand_name;
+ this.city_code = city_code;
+ this.city_name = city_name;
+ this.operator_id = operator_id;
+ this.operator_name = operator_name;
+ this.protocol = protocol;
+ this.remote = remote;
+ this.remote_map = remote_map;
+ this.status = status;
+ this.sub_cate = sub_cate;
+ this.priority = priority;
+ this.remote_number = remote_number;
+ this.category_name_tw = category_name_tw;
+ this.brand_name_tw = brand_name_tw;
+ this.city_name_tw = city_name_tw;
+ this.operator_name_tw = operator_name_tw;
+ this.binary_md5 = binary_md5;
+ this.contributor = contributor;
+ this.update_time = update_time;
+ }
+
+ public RemoteIndex() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getCategory_id() {
+ return category_id;
+ }
+
+ public void setCategory_id(int category_id) {
+ this.category_id = category_id;
+ }
+
+ public String getCategory_name() {
+ return category_name;
+ }
+
+ public void setCategory_name(String category_name) {
+ this.category_name = category_name;
+ }
+
+ public int getBrand_id() {
+ return brand_id;
+ }
+
+ public void setBrand_id(int brand_id) {
+ this.brand_id = brand_id;
+ }
+
+ public String getBrand_name() {
+ return brand_name;
+ }
+
+ public void setBrand_name(String brand_name) {
+ this.brand_name = brand_name;
+ }
+
+ public String getCity_code() {
+ return city_code;
+ }
+
+ public void setCity_code(String city_code) {
+ this.city_code = city_code;
+ }
+
+ public String getCity_name() {
+ return city_name;
+ }
+
+ public void setCity_name(String city_name) {
+ this.city_name = city_name;
+ }
+
+ public String getOperator_id() {
+ return operator_id;
+ }
+
+ public void setOperator_id(String operator_id) {
+ this.operator_id = operator_id;
+ }
+
+ public String getOperator_name() {
+ return operator_name;
+ }
+
+ public void setOperator_name(String operator_name) {
+ this.operator_name = operator_name;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getRemote() {
+ return remote;
+ }
+
+ public void setRemote(String remote) {
+ this.remote = remote;
+ }
+
+ public String getRemote_map() {
+ return remote_map;
+ }
+
+ public void setRemote_map(String remote_map) {
+ this.remote_map = remote_map;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public int getSub_cate() {
+ return sub_cate;
+ }
+
+ public void setSub_cate(int sub_cate) {
+ this.sub_cate = sub_cate;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ public String getRemote_number() {
+ return remote_number;
+ }
+
+ public void setRemote_number(String remote_number) {
+ this.remote_number = remote_number;
+ }
+
+ public String getCategory_name_tw() {
+ return category_name_tw;
+ }
+
+ public void setCategory_name_tw(String category_name_tw) {
+ this.category_name_tw = category_name_tw;
+ }
+
+ public String getBrand_name_tw() {
+ return brand_name_tw;
+ }
+
+ public void setBrand_name_tw(String brand_name_tw) {
+ this.brand_name_tw = brand_name_tw;
+ }
+
+ public String getCity_name_tw() {
+ return city_name_tw;
+ }
+
+ public void setCity_name_tw(String city_name_tw) {
+ this.city_name_tw = city_name_tw;
+ }
+
+ public String getOperator_name_tw() {
+ return operator_name_tw;
+ }
+
+ public void setOperator_name_tw(String operator_name_tw) {
+ this.operator_name_tw = operator_name_tw;
+ }
+
+ public String getBinary_md5() {
+ return binary_md5;
+ }
+
+ public void setBinary_md5(String binary_md5) {
+ this.binary_md5 = binary_md5;
+ }
+
+ public String getContributor() {
+ return contributor;
+ }
+
+ public void setContributor(String contributor) {
+ this.contributor = contributor;
+ }
+
+ public String getUpdate_time() {
+ return update_time;
+ }
+
+ public void setUpdate_time(String update_time) {
+ this.update_time = update_time;
+ }
+}
diff --git a/src/net/irext/webapi/model/StbOperator.java b/src/net/irext/webapi/model/StbOperator.java
new file mode 100644
index 0000000..f909306
--- /dev/null
+++ b/src/net/irext/webapi/model/StbOperator.java
@@ -0,0 +1,93 @@
+package net.irext.webapi.model;
+
+/**
+ * Filename: StbOperator.java
+ * Revised: Date: 2017-03-28
+ * Revision: Revision: 1.0
+ *
+ * Description: StbOperator bean
+ *
+ * Revision log:
+ * 2017-03-28: created by strawmanbobi
+ */
+public class StbOperator {
+
+ private int id;
+ private String operator_id;
+ private String operator_name;
+ private String city_code;
+ private String city_name;
+ private int status;
+ private String operator_name_tw;
+
+ public StbOperator(int id, String operator_id, String operator_name,
+ String city_code, String city_name, int status, String operator_name_tw) {
+ this.id = id;
+ this.operator_id = operator_id;
+ this.operator_name = operator_name;
+ this.city_code = city_code;
+ this.city_name = city_name;
+ this.status = status;
+ this.operator_name_tw = operator_name_tw;
+ }
+
+ public StbOperator() {
+
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getOperator_id() {
+ return operator_id;
+ }
+
+ public void setOperator_id(String operator_id) {
+ this.operator_id = operator_id;
+ }
+
+ public String getOperator_name() {
+ return operator_name;
+ }
+
+ public void setOperator_name(String operator_name) {
+ this.operator_name = operator_name;
+ }
+
+ public String getCity_code() {
+ return city_code;
+ }
+
+ public void setCity_code(String city_code) {
+ this.city_code = city_code;
+ }
+
+ public String getCity_name() {
+ return city_name;
+ }
+
+ public void setCity_name(String city_name) {
+ this.city_name = city_name;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getOperator_name_tw() {
+ return operator_name_tw;
+ }
+
+ public void setOperator_name_tw(String operator_name_tw) {
+ this.operator_name_tw = operator_name_tw;
+ }
+}
diff --git a/src/net/irext/webapi/request/BaseRequest.java b/src/net/irext/webapi/request/BaseRequest.java
new file mode 100644
index 0000000..642e53c
--- /dev/null
+++ b/src/net/irext/webapi/request/BaseRequest.java
@@ -0,0 +1,48 @@
+package net.irext.webapi.request;
+
+import com.google.gson.Gson;
+
+/**
+ * Filename: BaseRequest.java
+ * Revised: Date: 2017-04-07
+ * Revision: Revision: 1.0
+ *
+ * Description: authentication factors included
+ *
+ * Revision log:
+ * 2017-04-07: created by strawmanbobi
+ */
+public class BaseRequest {
+
+ private int admin_id;
+ private String token;
+
+ public BaseRequest(int adminID, String token) {
+ this.admin_id = adminID;
+ this.token = token;
+ }
+
+ public BaseRequest() {
+
+ }
+
+ public int getAdmin_id() {
+ return admin_id;
+ }
+
+ public void setAdmin_id(int admin_id) {
+ this.admin_id = admin_id;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String toJson() {
+ return new Gson().toJson(this, this.getClass());
+ }
+}
diff --git a/src/net/irext/webapi/request/DownloadBinaryRequest.java b/src/net/irext/webapi/request/DownloadBinaryRequest.java
new file mode 100644
index 0000000..9cb09e6
--- /dev/null
+++ b/src/net/irext/webapi/request/DownloadBinaryRequest.java
@@ -0,0 +1,32 @@
+package net.irext.webapi.request;
+
+/**
+ * Filename: DownloadBinaryRequest.java
+ * Revised: Date: 2017-04-14
+ * Revision: Revision: 1.0
+ *
+ * Description: HTTP download IR binary
+ *
+ * Revision log:
+ * 2017-04-14: created by strawmanbobi
+ */
+public class DownloadBinaryRequest extends BaseRequest {
+
+ private int index_id;
+
+ public DownloadBinaryRequest(int index_id) {
+ this.index_id = index_id;
+ }
+
+ public DownloadBinaryRequest() {
+
+ }
+
+ public int getIndex_id() {
+ return index_id;
+ }
+
+ public void setIndex_id(int index_id) {
+ this.index_id = index_id;
+ }
+}
diff --git a/src/net/irext/webapi/request/ListBrandsRequest.java b/src/net/irext/webapi/request/ListBrandsRequest.java
new file mode 100644
index 0000000..79a75f6
--- /dev/null
+++ b/src/net/irext/webapi/request/ListBrandsRequest.java
@@ -0,0 +1,52 @@
+package net.irext.webapi.request;
+
+/**
+ * Filename: ListBrandsRequest.java
+ * Revised: Date: 2017-04-07
+ * Revision: Revision: 1.0
+ *
+ * Description: HTTP list brands request
+ *
+ * Revision log:
+ * 2017-04-07: created by strawmanbobi
+ */
+public class ListBrandsRequest extends BaseRequest {
+
+ private int category_id;
+ private int from;
+ private int count;
+
+ public ListBrandsRequest(int category_id, int from, int count) {
+ this.category_id = category_id;
+ this.from = from;
+ this.count = count;
+ }
+
+ public ListBrandsRequest() {
+
+ }
+
+ public int getCategory_id() {
+ return category_id;
+ }
+
+ public void setCategory_id(int category_id) {
+ this.category_id = category_id;
+ }
+
+ public int getFrom() {
+ return from;
+ }
+
+ public void setFrom(int from) {
+ this.from = from;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+}
diff --git a/src/net/irext/webapi/request/ListCategoriesRequest.java b/src/net/irext/webapi/request/ListCategoriesRequest.java
new file mode 100644
index 0000000..48760f3
--- /dev/null
+++ b/src/net/irext/webapi/request/ListCategoriesRequest.java
@@ -0,0 +1,42 @@
+package net.irext.webapi.request;
+
+/**
+ * Filename: ListCategoriesRequest.java
+ * Revised: Date: 2017-04-07
+ * Revision: Revision: 1.0
+ *
+ * Description: HTTP list categories request
+ *
+ * Revision log:
+ * 2017-04-07: created by strawmanbobi
+ */
+public class ListCategoriesRequest extends BaseRequest {
+
+ private int from;
+ private int count;
+
+ public ListCategoriesRequest(int from, int count) {
+ this.from = from;
+ this.count = count;
+ }
+
+ public ListCategoriesRequest() {
+
+ }
+
+ public int getFrom() {
+ return from;
+ }
+
+ public void setFrom(int from) {
+ this.from = from;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+}
diff --git a/src/net/irext/webapi/request/ListCitiesRequest.java b/src/net/irext/webapi/request/ListCitiesRequest.java
new file mode 100644
index 0000000..a3b8714
--- /dev/null
+++ b/src/net/irext/webapi/request/ListCitiesRequest.java
@@ -0,0 +1,32 @@
+package net.irext.webapi.request;
+
+/**
+ * Filename: ListCitiesRequest.java
+ * Revised: Date: 2017-04-07
+ * Revision: Revision: 1.0
+ *
+ * Description: HTTP list cities request
+ *
+ * Revision log:
+ * 2017-04-07: created by strawmanbobi
+ */
+public class ListCitiesRequest extends BaseRequest {
+
+ private String province_prefix;
+
+ public ListCitiesRequest(String province_prefix) {
+ this.province_prefix = province_prefix;
+ }
+
+ public ListCitiesRequest() {
+
+ }
+
+ public String getProvince_prefix() {
+ return province_prefix;
+ }
+
+ public void setProvince_prefix(String province_prefix) {
+ this.province_prefix = province_prefix;
+ }
+}
diff --git a/src/net/irext/webapi/request/ListIndexesRequest.java b/src/net/irext/webapi/request/ListIndexesRequest.java
new file mode 100644
index 0000000..74229de
--- /dev/null
+++ b/src/net/irext/webapi/request/ListIndexesRequest.java
@@ -0,0 +1,83 @@
+package net.irext.webapi.request;
+
+/**
+ * Filename: ListIndexesRequest.java
+ * Revised: Date: 2017-04-12
+ * Revision: Revision: 1.0
+ *
+ * Description: HTTP list remote indexes request
+ *
+ * Revision log:
+ * 2017-04-12: created by strawmanbobi
+ */
+public class ListIndexesRequest extends BaseRequest {
+
+ private int from;
+ private int count;
+ private int category_id;
+ private int brand_id;
+ private String city_code;
+ private String operator_id;
+
+ public ListIndexesRequest(int from, int count, int category_id, int brand_id,
+ String city_code, String operator_id) {
+ this.from = from;
+ this.count = count;
+ this.category_id = category_id;
+ this.brand_id = brand_id;
+ this.city_code = city_code;
+ this.operator_id = operator_id;
+ }
+
+ public ListIndexesRequest() {
+
+ }
+
+ public int getFrom() {
+ return from;
+ }
+
+ public void setFrom(int from) {
+ this.from = from;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public int getCategory_id() {
+ return category_id;
+ }
+
+ public void setCategory_id(int category_id) {
+ this.category_id = category_id;
+ }
+
+ public int getBrand_id() {
+ return brand_id;
+ }
+
+ public void setBrand_id(int brand_id) {
+ this.brand_id = brand_id;
+ }
+
+ public String getCity_code() {
+ return city_code;
+ }
+
+ public void setCity_code(String city_code) {
+ this.city_code = city_code;
+ }
+
+ public String getOperator_id() {
+ return operator_id;
+ }
+
+ public void setOperator_id(String operator_id) {
+ this.operator_id = operator_id;
+ }
+}
diff --git a/src/net/irext/webapi/request/ListOperatorsRequest.java b/src/net/irext/webapi/request/ListOperatorsRequest.java
new file mode 100644
index 0000000..121b2ab
--- /dev/null
+++ b/src/net/irext/webapi/request/ListOperatorsRequest.java
@@ -0,0 +1,52 @@
+package net.irext.webapi.request;
+
+/**
+ * Filename: ListOperatorsRequest.java
+ * Revised: Date: 2017-04-10
+ * Revision: Revision: 1.0
+ *
+ * Description: HTTP list STB operators request
+ *
+ * Revision log:
+ * 2017-04-10: created by strawmanbobi
+ */
+public class ListOperatorsRequest extends BaseRequest {
+
+ private int from;
+ private int count;
+ private String city_code;
+
+ public ListOperatorsRequest(int from, int count, String city_code) {
+ this.from = from;
+ this.count = count;
+ this.city_code = city_code;
+ }
+
+ public ListOperatorsRequest() {
+
+ }
+
+ public int getFrom() {
+ return from;
+ }
+
+ public void setFrom(int from) {
+ this.from = from;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public String getCity_code() {
+ return city_code;
+ }
+
+ public void setCity_code(String city_code) {
+ this.city_code = city_code;
+ }
+}
diff --git a/src/net/irext/webapi/request/LoginRequest.java b/src/net/irext/webapi/request/LoginRequest.java
new file mode 100644
index 0000000..aa29425
--- /dev/null
+++ b/src/net/irext/webapi/request/LoginRequest.java
@@ -0,0 +1,42 @@
+package net.irext.webapi.request;
+
+/**
+ * Filename: LoginRequest.java
+ * Revised: Date: 2017-04-07
+ * Revision: Revision: 1.0
+ *
+ * Description: HTTP admin login request
+ *
+ * Revision log:
+ * 2017-04-07: created by strawmanbobi
+ */
+public class LoginRequest extends BaseRequest {
+
+ private String user_name;
+ private String password;
+
+ public LoginRequest(String user_name, String password) {
+ this.user_name = user_name;
+ this.password = password;
+ }
+
+ public LoginRequest() {
+
+ }
+
+ public String getUser_name() {
+ return user_name;
+ }
+
+ public void setUser_name(String user_name) {
+ this.user_name = user_name;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/src/net/irext/webapi/response/BrandsResponse.java b/src/net/irext/webapi/response/BrandsResponse.java
new file mode 100644
index 0000000..327227f
--- /dev/null
+++ b/src/net/irext/webapi/response/BrandsResponse.java
@@ -0,0 +1,37 @@
+package net.irext.webapi.response;
+
+import net.irext.webapi.model.Brand;
+
+import java.util.List;
+
+/**
+ * Filename: BrandsResponse.java
+ * Revised: Date: 2017-04-07
+ * Revision: Revision: 1.0
+ *
+ * Description: List brands response
+ *
+ * Revision log:
+ * 2017-04-07: created by strawmanbobi
+ */
+public class BrandsResponse extends ServiceResponse {
+
+ private List
+ * Description: List categories response
+ *
+ * Revision log:
+ * 2017-04-07: created by strawmanbobi
+ */
+public class CategoriesResponse extends ServiceResponse {
+
+ private List
+ * Description: List cities response
+ *
+ * Revision log:
+ * 2017-04-07: created by strawmanbobi
+ */
+public class CitiesResponse extends ServiceResponse {
+
+ private List
+ * Description: List remote indexes response
+ *
+ * Revision log:
+ * 2017-04-12: created by strawmanbobi
+ */
+public class IndexesResponse extends ServiceResponse {
+
+ private List
+ * Description: HTTP Admin login response
+ *
+ * Revision log:
+ * 2017-03-31: created by strawmanbobi
+ */
+public class LoginResponse extends ServiceResponse {
+
+ private Admin entity;
+
+ public LoginResponse(Status status, Admin admin) {
+ super(status);
+ this.entity = admin;
+ }
+
+ public LoginResponse() {
+
+ }
+
+ public Admin getEntity() {
+ return entity;
+ }
+
+ public void setEntity(Admin entity) {
+ this.entity = entity;
+ }
+}
diff --git a/src/net/irext/webapi/response/OperatorsResponse.java b/src/net/irext/webapi/response/OperatorsResponse.java
new file mode 100644
index 0000000..4856989
--- /dev/null
+++ b/src/net/irext/webapi/response/OperatorsResponse.java
@@ -0,0 +1,37 @@
+package net.irext.webapi.response;
+
+import net.irext.webapi.model.StbOperator;
+
+import java.util.List;
+
+/**
+ * Filename: OperatorsResponse.java
+ * Revised: Date: 2017-04-10
+ * Revision: Revision: 1.0
+ *
+ * Description: List STB operators response
+ *
+ * Revision log:
+ * 2017-04-10: created by strawmanbobi
+ */
+public class OperatorsResponse extends ServiceResponse {
+
+ private List
+ * Description: HTTP Response base class
+ *
+ * Revision log:
+ * 2017-03-31: created by strawmanbobi
+ */
+public class ServiceResponse {
+
+ private Status status;
+
+ public ServiceResponse(Status status) {
+ this.status = status;
+ }
+
+ public ServiceResponse() {
+
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+}
diff --git a/src/net/irext/webapi/response/Status.java b/src/net/irext/webapi/response/Status.java
new file mode 100644
index 0000000..7c354d4
--- /dev/null
+++ b/src/net/irext/webapi/response/Status.java
@@ -0,0 +1,42 @@
+package net.irext.webapi.response;
+
+/**
+ * Filename: Status.java
+ * Revised: Date: 2017-03-31
+ * Revision: Revision: 1.0
+ *
+ * Description: HTTP response status
+ *
+ * Revision log:
+ * 2017-03-31: created by strawmanbobi
+ */
+public class Status {
+
+ private int code;
+ private String cause;
+
+ public Status(int code, String cause) {
+ this.code = code;
+ this.cause = cause;
+ }
+
+ public Status() {
+
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getCause() {
+ return cause;
+ }
+
+ public void setCause(String cause) {
+ this.cause = cause;
+ }
+}
diff --git a/src/net/irext/webapi/utils/Constants.java b/src/net/irext/webapi/utils/Constants.java
new file mode 100644
index 0000000..fa00765
--- /dev/null
+++ b/src/net/irext/webapi/utils/Constants.java
@@ -0,0 +1,175 @@
+package net.irext.webapi.utils;
+
+/**
+ * Filename: Constants.java
+ * Revised: Date: 2017-04-03
+ * Revision: Revision: 1.0
+ *
+ * Description: SDK Constants
+ *
+ * Revision log:
+ * 2017-04-03: created by strawmanbobi
+ */
+public class Constants {
+
+ public static final int ERROR_CODE_SUCCESS = 0;
+ public static final int ERROR_CODE_NETWORK_ERROR = -1;
+ public static final int ERROR_CODE_AUTH_FAILURE = 1;
+ public static final int ERROR_CODE_INVALID_CATEGORY = 2;
+ public static final int ERROR_CODE_INVALID_BRAND = 3;
+ public static final int ERROR_CODE_INVALID_PARAMETER = 4;
+
+ public enum CategoryID {
+ AIR_CONDITIONER(1),
+ TV(2),
+ STB(3),
+ NET_BOX(4),
+ IPTV(5),
+ DVD(6),
+ FAN(7),
+ PROJECTOR(8),
+ STEREO(9),
+ LIGHT(10),
+ BSTB(11),
+ CLEANING_ROBOT(12),
+ AIR_CLEANER(13);
+
+ private final int id;
+
+ CategoryID(int id) {
+ this.id = id;
+ }
+
+ public int getValue() {
+ return id;
+ }
+ }
+
+ public enum BinaryType {
+ TYPE_BINARY(0),
+ TYPE_HEXDECIMAL(1);
+
+ private final int type;
+
+ BinaryType(int type) {
+ this.type = type;
+ }
+
+ public int getValue() {
+ return type;
+ }
+ }
+
+ public enum ACPower {
+ POWER_ON(0),
+ POWER_OFF(1);
+
+ private final int power;
+
+ ACPower(int power) {
+ this.power = power;
+ }
+
+ public int getValue() {
+ return power;
+ }
+ }
+
+ public enum ACMode {
+ MODE_COOL(0),
+ MODE_HEAT(1),
+ MODE_AUTO(2),
+ MODE_FAN(3),
+ MODE_DEHUMIDITY(4);
+
+ private final int mode;
+
+ ACMode(int mode) {
+ this.mode = mode;
+ }
+
+ public int getValue() {
+ return mode;
+ }
+ }
+
+ public enum ACTemperature {
+ TEMP_16(0),
+ TEMP_17(1),
+ TEMP_18(2),
+ TEMP_19(3),
+ TEMP_20(4),
+ TEMP_21(5),
+ TEMP_22(6),
+ TEMP_23(7),
+ TEMP_24(8),
+ TEMP_25(9),
+ TEMP_26(10),
+ TEMP_27(11),
+ TEMP_28(12),
+ TEMP_29(13),
+ TEMP_30(14);
+
+ private final int temp;
+
+ ACTemperature(int temp) {
+ this.temp = temp;
+ }
+
+ public int getValue() {
+ return temp;
+ }
+ }
+
+ public enum ACWindSpeed {
+ SPEED_AUTO(0),
+ SPEED_LOW(1),
+ SPEED_MEDIUM(2),
+ SPEED_HIGH(3);
+
+ private final int speed;
+
+ ACWindSpeed(int speed) {
+ this.speed = speed;
+ }
+
+ public int getValue() {
+ return speed;
+ }
+ }
+
+ public enum ACSwing {
+ SWING_ON(0),
+ SWING_OFF(1);
+
+ private final int swing;
+
+ ACSwing(int swing) {
+ this.swing = swing;
+ }
+
+ public int getValue() {
+ return swing;
+ }
+ }
+
+ public enum ACFunction {
+ FUNCTION_SWITCH_POWER(1),
+ FUNCTION_CHANGE_MODE(2),
+ FUNCTION_TEMPERATURE_UP(3),
+ FUNCTION_TEMPERATURE_DOWN(4),
+ FUNCTION_SWITCH_WIND_SPEED(5),
+ FUNCTION_SWITCH_WIND_DIR(6),
+ FUNCTION_SWITCH_SWING(7);
+
+ private final int function;
+
+ ACFunction(int function) {
+ this.function = function;
+ }
+
+ public int getValue() {
+ return function;
+ }
+ }
+}
diff --git a/src/net/irext/webapi/utils/MD5Digest.java b/src/net/irext/webapi/utils/MD5Digest.java
new file mode 100644
index 0000000..1c48710
--- /dev/null
+++ b/src/net/irext/webapi/utils/MD5Digest.java
@@ -0,0 +1,40 @@
+package net.irext.webapi.utils;
+
+import java.security.MessageDigest;
+
+/**
+ * Filename: MD5Digest.java
+ * Revised: Date: 2017-04-03
+ * Revision: Revision: 1.0
+ *
+ * Description: MD5 digest algorithm
+ *
+ * Revision log:
+ * 2017-04-03: created by strawmanbobi
+ */
+public class MD5Digest {
+
+ public static String MD5(String content) {
+ String result = null;
+ try {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(content.getBytes());
+ byte b[] = md.digest();
+
+ int i;
+
+ StringBuffer buf = new StringBuffer("");
+ for (int offset = 0; offset < b.length; offset++) {
+ i = b[offset];
+ if (i < 0) i += 256;
+ if (i < 16) buf.append("0");
+ buf.append(Integer.toHexString(i));
+ }
+ result = buf.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return content;
+ }
+ return result;
+ }
+}