|
|
|
|
@@ -3,6 +3,7 @@ package net.irext.webapi;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.pm.ApplicationInfo;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import net.irext.webapi.model.*;
|
|
|
|
|
@@ -48,7 +49,7 @@ public class WebAPIs {
|
|
|
|
|
private static final String SERVICE_DOWNLOAD_BIN = "/operation/download_bin";
|
|
|
|
|
private static final String SERVICE_ONLINE_DECODE = "/operation/decode";
|
|
|
|
|
|
|
|
|
|
private int adminId;
|
|
|
|
|
private int id;
|
|
|
|
|
private String token;
|
|
|
|
|
|
|
|
|
|
private OkHttpClient mHttpClient;
|
|
|
|
|
@@ -123,14 +124,17 @@ public class WebAPIs {
|
|
|
|
|
appSignInRequest.setAndroidSignature(signature);
|
|
|
|
|
String bodyJson = appSignInRequest.toJson();
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "Android APP example sign-in request data : " + bodyJson);
|
|
|
|
|
String response = postToServer(signInURL, bodyJson);
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "Android APP example sign-in response data : " + response);
|
|
|
|
|
LoginResponse loginResponse = new Gson().fromJson(response, LoginResponse.class);
|
|
|
|
|
if (loginResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) {
|
|
|
|
|
UserApp admin = loginResponse.getEntity();
|
|
|
|
|
if (0 != admin.getId() && null != admin.getToken()) {
|
|
|
|
|
adminId = admin.getId();
|
|
|
|
|
token = admin.getToken();
|
|
|
|
|
signInCallback.onSignInSuccess(admin);
|
|
|
|
|
UserApp userApp = loginResponse.getEntity();
|
|
|
|
|
if (0 != userApp.getId() && null != userApp.getToken()) {
|
|
|
|
|
id = userApp.getId();
|
|
|
|
|
token = userApp.getToken();
|
|
|
|
|
signInCallback.onSignInSuccess(userApp);
|
|
|
|
|
} else {
|
|
|
|
|
signInCallback.onSignInFailed();
|
|
|
|
|
}
|
|
|
|
|
@@ -145,7 +149,7 @@ public class WebAPIs {
|
|
|
|
|
public void listCategories(int from, int count, ListCategoriesCallback listCategoriesCallback) {
|
|
|
|
|
String listCategoriesURL = URL_PREFIX + SERVICE_LIST_CATEGORIES;
|
|
|
|
|
ListCategoriesRequest listCategoriesRequest = new ListCategoriesRequest();
|
|
|
|
|
listCategoriesRequest.setAdminId(adminId);
|
|
|
|
|
listCategoriesRequest.setId(id);
|
|
|
|
|
listCategoriesRequest.setToken(token);
|
|
|
|
|
listCategoriesRequest.setFrom(from);
|
|
|
|
|
listCategoriesRequest.setCount(count);
|
|
|
|
|
@@ -171,7 +175,7 @@ public class WebAPIs {
|
|
|
|
|
ListBrandsCallback listBrandsCallback) {
|
|
|
|
|
String listBrandsURL = URL_PREFIX + SERVICE_LIST_BRANDS;
|
|
|
|
|
ListBrandsRequest listBrandsRequest = new ListBrandsRequest();
|
|
|
|
|
listBrandsRequest.setAdminId(adminId);
|
|
|
|
|
listBrandsRequest.setId(id);
|
|
|
|
|
listBrandsRequest.setToken(token);
|
|
|
|
|
listBrandsRequest.setCategoryId(categoryId);
|
|
|
|
|
listBrandsRequest.setFrom(from);
|
|
|
|
|
@@ -197,7 +201,7 @@ public class WebAPIs {
|
|
|
|
|
public void listProvinces(ListProvincesCallback listProvincesCallback) {
|
|
|
|
|
String listProvincesURL = URL_PREFIX + SERVICE_LIST_PROVINCES;
|
|
|
|
|
ListCitiesRequest listCitiesRequest = new ListCitiesRequest();
|
|
|
|
|
listCitiesRequest.setAdminId(adminId);
|
|
|
|
|
listCitiesRequest.setId(id);
|
|
|
|
|
listCitiesRequest.setToken(token);
|
|
|
|
|
String bodyJson = listCitiesRequest.toJson();
|
|
|
|
|
|
|
|
|
|
@@ -220,7 +224,7 @@ public class WebAPIs {
|
|
|
|
|
public void listCities(String prefix, ListCitiesCallback listCitiesCallback) {
|
|
|
|
|
String listCitiesURL = URL_PREFIX + SERVICE_LIST_CITIES;
|
|
|
|
|
ListCitiesRequest listCitiesRequest = new ListCitiesRequest();
|
|
|
|
|
listCitiesRequest.setAdminId(adminId);
|
|
|
|
|
listCitiesRequest.setId(id);
|
|
|
|
|
listCitiesRequest.setToken(token);
|
|
|
|
|
listCitiesRequest.setProvincePrefix(prefix);
|
|
|
|
|
String bodyJson = listCitiesRequest.toJson();
|
|
|
|
|
@@ -245,7 +249,7 @@ public class WebAPIs {
|
|
|
|
|
ListOperatersCallback listOperatersCallback) {
|
|
|
|
|
String listOperatorsURL = URL_PREFIX + SERVICE_LIST_OPERATORS;
|
|
|
|
|
ListOperatorsRequest listOperatorsRequest = new ListOperatorsRequest();
|
|
|
|
|
listOperatorsRequest.setAdminId(adminId);
|
|
|
|
|
listOperatorsRequest.setId(id);
|
|
|
|
|
listOperatorsRequest.setToken(token);
|
|
|
|
|
listOperatorsRequest.setCityCode(cityCode);
|
|
|
|
|
listOperatorsRequest.setFrom(0);
|
|
|
|
|
@@ -275,7 +279,7 @@ public class WebAPIs {
|
|
|
|
|
ListIndexesCallback onListIndexCallback) {
|
|
|
|
|
String listIndexesURL = URL_PREFIX + SERVICE_LIST_INDEXES;
|
|
|
|
|
ListIndexesRequest listIndexesRequest = new ListIndexesRequest();
|
|
|
|
|
listIndexesRequest.setAdminId(adminId);
|
|
|
|
|
listIndexesRequest.setId(id);
|
|
|
|
|
listIndexesRequest.setToken(token);
|
|
|
|
|
listIndexesRequest.setCategoryId(categoryId);
|
|
|
|
|
listIndexesRequest.setBrandId(brandId);
|
|
|
|
|
@@ -306,7 +310,7 @@ public class WebAPIs {
|
|
|
|
|
DownloadBinCallback downloadBinCallback) {
|
|
|
|
|
String downloadURL = URL_PREFIX + SERVICE_DOWNLOAD_BIN;
|
|
|
|
|
DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest();
|
|
|
|
|
downloadBinaryRequest.setAdminId(adminId);
|
|
|
|
|
downloadBinaryRequest.setId(id);
|
|
|
|
|
downloadBinaryRequest.setToken(token);
|
|
|
|
|
downloadBinaryRequest.setIndexId(indexId);
|
|
|
|
|
|
|
|
|
|
@@ -333,7 +337,7 @@ public class WebAPIs {
|
|
|
|
|
public int[] decodeIR(int indexId) {
|
|
|
|
|
String decodeURL = URL_PREFIX + SERVICE_ONLINE_DECODE;
|
|
|
|
|
DecodeRequest decodeRequest = new DecodeRequest();
|
|
|
|
|
decodeRequest.setAdminId(adminId);
|
|
|
|
|
decodeRequest.setId(id);
|
|
|
|
|
decodeRequest.setToken(token);
|
|
|
|
|
decodeRequest.setIndexId(indexId);
|
|
|
|
|
|
|
|
|
|
|