Last Updated on : 2024-03-14 03:13:24download
The common interface for server-side API calling functions is in class IThingSmartRequest
.
There are the following interfaces available for calling:
/**
* Applicable to api interface request with session
* @param apiName: api name
* @param version: api version
* @param postData: Post sent data
* @param object: Data object returned by the server
* @param callback: callback
* @param <T>
*/
<T> void requestWithApiName(String apiName, String version, Map<String, Object> postData, Class<T> object, final IThingDataCallback<T> callback);
/**
* Applies to api interface requests without session
* @param apiName: api name
* @param version: api version
* @param postData: Post sent data
* @param object: Data object returned by the server
* @param callback: callback
* @param <T>
*/
<T> void requestWithApiNameWithoutSession(String apiName, String version, Map<String, Object> postData, Class<T> object, final IThingDataCallback<T> callback);
The calling method is as follows:ThingOSDevice.getRequestInstance()
.
Take the following interface as an example:
Interface Description | apiName | version | postData |
---|---|---|---|
Get a list of countries | tuya.m.country.list | 1.0 | - |
Map<String, Object> postData = null;
ThingOSDevice.getRequestInstance().requestWithApiNameWithoutSession("tuya.m.country.list", "1.0", postData, String.class, new IThingDataCallback<String>() {
@Override
public void onSuccess(String result) {
Log.i("TAG" , result);
}
@Override
public void onError(String errorCode, String errorMessage) {
Log.i("TAG" , errorCode);
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback