aligned with android-indexing api and decode sdk
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.irext.webapi">
|
||||||
|
|
||||||
>
|
|
||||||
|
|
||||||
<application android:allowBackup="true" android:supportsRtl="true">
|
<application android:allowBackup="true" android:supportsRtl="true">
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import net.irext.webapi.bean.ACStatus;
|
||||||
import net.irext.webapi.model.*;
|
import net.irext.webapi.model.*;
|
||||||
import net.irext.webapi.utils.Constants;
|
import net.irext.webapi.utils.Constants;
|
||||||
import net.irext.webapi.request.*;
|
import net.irext.webapi.request.*;
|
||||||
@@ -53,11 +54,12 @@ public class WebAPIs {
|
|||||||
private static final String SERVICE_LIST_INDEXES = "/indexing/list_indexes";
|
private static final String SERVICE_LIST_INDEXES = "/indexing/list_indexes";
|
||||||
private static final String SERVICE_DOWNLOAD_BIN = "/operation/download_bin";
|
private static final String SERVICE_DOWNLOAD_BIN = "/operation/download_bin";
|
||||||
private static final String SERVICE_ONLINE_DECODE = "/operation/decode";
|
private static final String SERVICE_ONLINE_DECODE = "/operation/decode";
|
||||||
|
private static final String SERVICE_GET_AC_PARAMETERS = "/operation/get_ac_parameters";
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
private OkHttpClient mHttpClient;
|
private final OkHttpClient mHttpClient;
|
||||||
|
|
||||||
private WebAPIs(String address, String appName) {
|
private WebAPIs(String address, String appName) {
|
||||||
if (null != address && null != appName) {
|
if (null != address && null != appName) {
|
||||||
@@ -93,7 +95,6 @@ public class WebAPIs {
|
|||||||
= MediaType.parse("application/json; charset=utf-8");
|
= MediaType.parse("application/json; charset=utf-8");
|
||||||
|
|
||||||
RequestBody body = RequestBody.create(JSON, json);
|
RequestBody body = RequestBody.create(JSON, json);
|
||||||
Log.d(TAG, "post URL = " + url);
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.post(body)
|
.post(body)
|
||||||
@@ -292,6 +293,7 @@ public class WebAPIs {
|
|||||||
int brandId,
|
int brandId,
|
||||||
String cityCode,
|
String cityCode,
|
||||||
String operatorId,
|
String operatorId,
|
||||||
|
int withParaData,
|
||||||
ListIndexesCallback onListIndexCallback) {
|
ListIndexesCallback onListIndexCallback) {
|
||||||
String listIndexesURL = URL_PREFIX + SERVICE_LIST_INDEXES;
|
String listIndexesURL = URL_PREFIX + SERVICE_LIST_INDEXES;
|
||||||
ListIndexesRequest listIndexesRequest = new ListIndexesRequest();
|
ListIndexesRequest listIndexesRequest = new ListIndexesRequest();
|
||||||
@@ -301,6 +303,7 @@ public class WebAPIs {
|
|||||||
listIndexesRequest.setBrandId(brandId);
|
listIndexesRequest.setBrandId(brandId);
|
||||||
listIndexesRequest.setCityCode(cityCode);
|
listIndexesRequest.setCityCode(cityCode);
|
||||||
listIndexesRequest.setOperatorId(operatorId);
|
listIndexesRequest.setOperatorId(operatorId);
|
||||||
|
listIndexesRequest.setWithParaData(withParaData);
|
||||||
listIndexesRequest.setFrom(0);
|
listIndexesRequest.setFrom(0);
|
||||||
listIndexesRequest.setCount(20);
|
listIndexesRequest.setCount(20);
|
||||||
String bodyJson = listIndexesRequest.toJson();
|
String bodyJson = listIndexesRequest.toJson();
|
||||||
@@ -324,8 +327,7 @@ public class WebAPIs {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void downloadBin(String remoteMap, int indexId,
|
public void downloadBin(String remoteMap, int indexId,
|
||||||
DownloadBinCallback downloadBinCallback) {
|
DownloadBinCallback downloadBinCallback) {
|
||||||
String fileName = IR_BIN_FILE_PREFIX + remoteMap + IR_BIN_FILE_SUFFIX;
|
String downloadURL = URL_PREFIX + SERVICE_DOWNLOAD_BIN;
|
||||||
String downloadURL = IR_BIN_DOWNLOAD_PREFIX + fileName;
|
|
||||||
DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest();
|
DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest();
|
||||||
downloadBinaryRequest.setId(id);
|
downloadBinaryRequest.setId(id);
|
||||||
downloadBinaryRequest.setToken(token);
|
downloadBinaryRequest.setToken(token);
|
||||||
@@ -335,7 +337,7 @@ public class WebAPIs {
|
|||||||
|
|
||||||
if (null != bodyJson) {
|
if (null != bodyJson) {
|
||||||
try {
|
try {
|
||||||
InputStream binStream = getFileByteStreamByURL(downloadURL);
|
InputStream binStream = postToServerForOctets(downloadURL, bodyJson);
|
||||||
|
|
||||||
if (null != binStream) {
|
if (null != binStream) {
|
||||||
downloadBinCallback.onDownloadBinSuccess(binStream);
|
downloadBinCallback.onDownloadBinSuccess(binStream);
|
||||||
@@ -350,13 +352,18 @@ public class WebAPIs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Deprecated
|
public int[] decodeIR(int indexId, ACStatus acStatus, int keyCode, int changeWindDir,
|
||||||
public int[] decodeIR(int indexId) {
|
Integer directDecode, Integer paraData) {
|
||||||
String decodeURL = URL_PREFIX + SERVICE_ONLINE_DECODE;
|
String decodeURL = URL_PREFIX + SERVICE_ONLINE_DECODE;
|
||||||
DecodeRequest decodeRequest = new DecodeRequest();
|
DecodeRequest decodeRequest = new DecodeRequest();
|
||||||
decodeRequest.setId(id);
|
decodeRequest.setId(id);
|
||||||
decodeRequest.setToken(token);
|
decodeRequest.setToken(token);
|
||||||
decodeRequest.setIndexId(indexId);
|
decodeRequest.setIndexId(indexId);
|
||||||
|
decodeRequest.setAcStatus(acStatus);
|
||||||
|
decodeRequest.setKeyCode(keyCode);
|
||||||
|
decodeRequest.setChangeWindDir(changeWindDir);
|
||||||
|
decodeRequest.setDirectDecode(directDecode);
|
||||||
|
decodeRequest.setParaData(paraData);
|
||||||
|
|
||||||
String bodyJson = decodeRequest.toJson();
|
String bodyJson = decodeRequest.toJson();
|
||||||
|
|
||||||
@@ -375,4 +382,30 @@ public class WebAPIs {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public ACParameters getACParameters(int indexId, int mode) {
|
||||||
|
String decodeURL = URL_PREFIX + SERVICE_GET_AC_PARAMETERS;
|
||||||
|
GetACParametersRequest getACParametersRequest = new GetACParametersRequest();
|
||||||
|
getACParametersRequest.setId(id);
|
||||||
|
getACParametersRequest.setToken(token);
|
||||||
|
getACParametersRequest.setIndexId(indexId);
|
||||||
|
getACParametersRequest.setMode(mode);
|
||||||
|
|
||||||
|
String bodyJson = getACParametersRequest.toJson();
|
||||||
|
if (null != bodyJson) {
|
||||||
|
try {
|
||||||
|
String response = postToServer(decodeURL, bodyJson);
|
||||||
|
|
||||||
|
ACParametersResponse acParametersResponse = new Gson().fromJson(response, ACParametersResponse.class);
|
||||||
|
|
||||||
|
if (acParametersResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) {
|
||||||
|
return acParametersResponse.getEntity();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package net.irext.webapi.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename: ACParameters.java
|
||||||
|
* Revised: Date: 2019-02-14
|
||||||
|
* Revision: Revision: 1.0
|
||||||
|
* <p>
|
||||||
|
* Description: AC parameters entity
|
||||||
|
* <p>
|
||||||
|
* Revision log:
|
||||||
|
* 2018-12-29: created by strawmanbobi
|
||||||
|
*/
|
||||||
|
public class ACParameters {
|
||||||
|
private int tempMin;
|
||||||
|
private int tempMax;
|
||||||
|
private int [] supportedModes;
|
||||||
|
private int []supportedWindSpeed;
|
||||||
|
private int []supportedSwing;
|
||||||
|
private int []supportedWindDirections;
|
||||||
|
|
||||||
|
public ACParameters(int tempMin, int tempMax, int[] supportedModes,
|
||||||
|
int[] supportedWindSpeed,
|
||||||
|
int[] supportedSwing, int[] supportedWindDirections) {
|
||||||
|
this.tempMin = tempMin;
|
||||||
|
this.tempMax = tempMax;
|
||||||
|
this.supportedModes = supportedModes;
|
||||||
|
this.supportedWindSpeed = supportedWindSpeed;
|
||||||
|
this.supportedSwing = supportedSwing;
|
||||||
|
this.supportedWindDirections = supportedWindDirections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ACParameters() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTempMin() {
|
||||||
|
return tempMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTempMin(int tempMin) {
|
||||||
|
this.tempMin = tempMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTempMax() {
|
||||||
|
return tempMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTempMax(int tempMax) {
|
||||||
|
this.tempMax = tempMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getSupportedModes() {
|
||||||
|
return supportedModes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupportedModes(int[] supportedModes) {
|
||||||
|
this.supportedModes = supportedModes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getSupportedWindSpeed() {
|
||||||
|
return supportedWindSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupportedWindSpeed(int[] supportedWindSpeed) {
|
||||||
|
this.supportedWindSpeed = supportedWindSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getSupportedSwing() {
|
||||||
|
return supportedSwing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupportedSwing(int[] supportedSwing) {
|
||||||
|
this.supportedSwing = supportedSwing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getSupportedWindDirections() {
|
||||||
|
return supportedWindDirections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupportedWindDirections(int[] supportedWindDirections) {
|
||||||
|
this.supportedWindDirections = supportedWindDirections;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,12 +18,17 @@ public class DecodeRequest extends BaseRequest {
|
|||||||
private ACStatus acStatus;
|
private ACStatus acStatus;
|
||||||
private int keyCode;
|
private int keyCode;
|
||||||
private int changeWindDir;
|
private int changeWindDir;
|
||||||
|
private Integer directDecode;
|
||||||
|
private Integer paraData;
|
||||||
|
|
||||||
public DecodeRequest(int indexId, ACStatus acStatus, int keyCode, int changeWindDir) {
|
public DecodeRequest(int indexId, ACStatus acStatus, int keyCode, int changeWindDir,
|
||||||
|
Integer directDecode, Integer paraData) {
|
||||||
this.indexId = indexId;
|
this.indexId = indexId;
|
||||||
this.acStatus = acStatus;
|
this.acStatus = acStatus;
|
||||||
this.keyCode = keyCode;
|
this.keyCode = keyCode;
|
||||||
this.changeWindDir = changeWindDir;
|
this.changeWindDir = changeWindDir;
|
||||||
|
this.directDecode = directDecode;
|
||||||
|
this.paraData = paraData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DecodeRequest() {
|
public DecodeRequest() {
|
||||||
@@ -61,4 +66,20 @@ public class DecodeRequest extends BaseRequest {
|
|||||||
public void setChangeWindDir(int changeWindDir) {
|
public void setChangeWindDir(int changeWindDir) {
|
||||||
this.changeWindDir = changeWindDir;
|
this.changeWindDir = changeWindDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getDirectDecode() {
|
||||||
|
return directDecode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirectDecode(Integer directDecode) {
|
||||||
|
this.directDecode = directDecode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getParaData() {
|
||||||
|
return paraData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParaData(Integer paraData) {
|
||||||
|
this.paraData = paraData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package net.irext.webapi.request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename: GetACParametersRequest.java
|
||||||
|
* Revised: Date: 2017-05-16
|
||||||
|
* Revision: Revision: 1.0
|
||||||
|
* <p>
|
||||||
|
* Description: HTTP server online
|
||||||
|
* <p>
|
||||||
|
* Revision log:
|
||||||
|
* 2019-02-14: created by strawmanbobi
|
||||||
|
*/
|
||||||
|
public class GetACParametersRequest extends BaseRequest {
|
||||||
|
private int indexId;
|
||||||
|
private int mode;
|
||||||
|
|
||||||
|
public GetACParametersRequest(int indexId, int mode) {
|
||||||
|
this.indexId = indexId;
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetACParametersRequest() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndexId() {
|
||||||
|
return indexId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndexId(int indexId) {
|
||||||
|
this.indexId = indexId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(int mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,14 +19,18 @@ public class ListIndexesRequest extends BaseRequest {
|
|||||||
private String cityCode;
|
private String cityCode;
|
||||||
private String operatorId;
|
private String operatorId;
|
||||||
|
|
||||||
|
// try index in IRIS with this flag set to 1
|
||||||
|
private int withParaData;
|
||||||
|
|
||||||
public ListIndexesRequest(int from, int count, int categoryId, int brandId,
|
public ListIndexesRequest(int from, int count, int categoryId, int brandId,
|
||||||
String cityCode, String operatorId) {
|
String cityCode, String operatorId, int withParaData) {
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.categoryId = categoryId;
|
this.categoryId = categoryId;
|
||||||
this.brandId = brandId;
|
this.brandId = brandId;
|
||||||
this.cityCode = cityCode;
|
this.cityCode = cityCode;
|
||||||
this.operatorId = operatorId;
|
this.operatorId = operatorId;
|
||||||
|
this.withParaData = withParaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListIndexesRequest() {
|
public ListIndexesRequest() {
|
||||||
@@ -80,4 +84,12 @@ public class ListIndexesRequest extends BaseRequest {
|
|||||||
public void setOperatorId(String operatorId) {
|
public void setOperatorId(String operatorId) {
|
||||||
this.operatorId = operatorId;
|
this.operatorId = operatorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getWithParaData() {
|
||||||
|
return withParaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWithParaData(int withParaData) {
|
||||||
|
this.withParaData = withParaData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package net.irext.webapi.response;
|
||||||
|
|
||||||
|
import net.irext.webapi.model.ACParameters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename: ACParametersResponse.java
|
||||||
|
* Revised: Date: 2017-05-16
|
||||||
|
* Revision: Revision: 1.0
|
||||||
|
* <p>
|
||||||
|
* Description: Air conditioner support parameters response
|
||||||
|
* <p>
|
||||||
|
* Revision log:
|
||||||
|
* 2019-02-14: created by strawmanbobi
|
||||||
|
*/
|
||||||
|
public class ACParametersResponse extends ServiceResponse {
|
||||||
|
|
||||||
|
private ACParameters entity;
|
||||||
|
|
||||||
|
public ACParametersResponse(Status status, ACParameters entity) {
|
||||||
|
super(status);
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ACParametersResponse() {
|
||||||
|
super(new Status());
|
||||||
|
this.entity = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ACParameters getEntity() {
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntity(ACParameters entity) {
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user