| | |
| | | package com.hdl.sdk.connect.cloud; |
| | | |
| | | import com.hdl.hdlhttp.HxHttp; |
| | | import com.hdl.hdlhttp.HxHttpBuilder; |
| | | import com.hdl.sdk.connect.bean.response.UpdateInfo; |
| | | import com.hdl.sdk.connect.cloud.bean.AiLoginInfo; |
| | | import com.hdl.sdk.connect.cloud.bean.GatewayInfo; |
| | | import com.hdl.sdk.connect.cloud.listener.GatewayListListener; |
| | | import com.hdl.sdk.connect.cloud.listener.GatewayListener; |
| | | import com.hdl.sdk.connect.cloud.listener.SibichiListener; |
| | | |
| | | import java.util.List; |
| | | |
| | | import io.reactivex.rxjava3.disposables.Disposable; |
| | | |
| | |
| | | |
| | | public static Disposable applyDeviceSecret(String supplier, String mac, String spk, CallBackListener callBack) { |
| | | return HxHttp.builder() |
| | | .url(HdlCloudApi.BASE_CHINA_URL + HdlCloudApi.APPLY_DEVICE_SECRET) |
| | | .url(HdlCloudApi.APPLY_DEVICE_SECRET) |
| | | .params("supplier", supplier) |
| | | .params("mac", mac) |
| | | .params("spk", spk) |
| | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 检查app是否更新 |
| | | * |
| | | * @return |
| | | */ |
| | | public static Disposable checkAppVersion(String versionCode, String appCode, CheckAppVersionListener listener) { |
| | | return HxHttp.builder() |
| | | .url(HdlCloudApi.CHECK_APP_VERSION_URL) |
| | | .params("version", versionCode) |
| | | .params("appCode", appCode) |
| | | .params("releaseSystem", "Android") |
| | | .build() |
| | | .post() |
| | | .subscribeWith(new HDLResponse<UpdateInfo>() { |
| | | @Override |
| | | public void onResponse(UpdateInfo response) { |
| | | listener.onSuccess(response); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | listener.onError(e); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取思必驰token |
| | | * |
| | | * @return |
| | | */ |
| | | public static Disposable getSibichiToken(String homeId, String clientId, SibichiListener listener) { |
| | | return HxHttp.builder() |
| | | .url(HdlCloudApi.GET_SIBICHI_TOKEN) |
| | | .params("homeId", homeId) |
| | | .params("clientId", clientId) |
| | | .build() |
| | | .post() |
| | | .subscribeWith(new HDLResponse<AiLoginInfo>() { |
| | | @Override |
| | | public void onResponse(AiLoginInfo response) { |
| | | listener.onSuccess(response); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | listener.onError(e); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取主网关 |
| | | */ |
| | | public static Disposable syncMainGateway(String homeId, GatewayListener listener) { |
| | | return syncGatewayList(homeId, new GatewayListListener() { |
| | | @Override |
| | | public void onSuccess(List<GatewayInfo> info) { |
| | | if (listener != null) { |
| | | if (info == null || info.isEmpty()) { |
| | | listener.onError(new HDLException(-5000, "搜索网关失败")); |
| | | } else { |
| | | listener.onSuccess(info.get(0)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLException e) { |
| | | if (listener != null) { |
| | | listener.onError(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 同步获取网关列表 |
| | | */ |
| | | public static Disposable syncGatewayList(String homeId, GatewayListListener listener) { |
| | | HxHttpBuilder httpBuilder = HxHttp.builder() |
| | | .params("homeId", homeId) |
| | | .url(HdlCloudApi.GET_GATEWAY_LIST); |
| | | return httpBuilder.build().post().subscribeWith(new HDLResponse<List<GatewayInfo>>() { |
| | | @Override |
| | | public void onResponse(List<GatewayInfo> response) { |
| | | if (listener != null) { |
| | | listener.onSuccess(response); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | if (listener != null) { |
| | | listener.onError(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |