Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

criando Asset connector, add e delete asset #36

Open
wants to merge 13 commits into
base: release
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.tuya.connector.open.ability.asset.connector;

import com.tuya.connector.api.annotations.*;
import com.tuya.connector.open.ability.asset.model.request.AssetRequest;
import com.tuya.connector.open.ability.asset.model.request.BatchAssetsAuthorizedRequest;
import com.tuya.connector.open.ability.asset.model.response.GetDevicesByAssetIdResponse;

/**
* <p> TODO
*
* @author @author [email protected]
* @since 2023/1/27 10:10
*/
public interface AssetConnector {

/**
* delete asset
*
* @param assetId
* @return
*/
@DELETE("/v1.0/iot-02/assets/{asset_id}")
Boolean deleteAsset(@Path(("asset_id")) String assetId);

/**
* add asset
*
* @param request
* @return
*/
@POST("/v1.0/iot-02/assets")
String addAsset(@Body AssetRequest request);


/**
* Authorize Assets to a User
*
* @param request
* @return
*/
@POST("/v1.0/iot-03/users/{user_id}/actions/batch-assets-authorized")
Boolean batchAssetsAuthorized(@Path(("user_id")) String userId, @Body BatchAssetsAuthorizedRequest request);

/**
* Unauthorize Assets to a User
*
* @param request
* @return
*/
@POST("/v1.0/iot-03/users/{user_id}/actions/batch-assets-unauthorized")
Boolean batchAssetsUnauthorized(@Path(("user_id")) String userId, @Body BatchAssetsAuthorizedRequest request);


/**
* Get Devices by Asset Id
*
* @param request
* @return
*/
@GET("/v1.0/iot-02/assets/{asset_id}/devices")
GetDevicesByAssetIdResponse getDevicesByAssetId(@Path(("asset_id")) String asset_id);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.tuya.connector.open.ability.asset.model.request;

import lombok.Data;

import java.io.Serializable;

/**
* Description TODO
*
* @author mario gozzi neto <[email protected]>
* @date 2023/1/27
*/
@Data
public class AssetRequest implements Serializable {

private static final long serialVersionUID = 155965236652121243L;
private String name;
private String meta_id;
private String parent_asset_id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.tuya.connector.open.ability.asset.model.request;

import lombok.Data;

import java.io.Serializable;

/**
* Description TODO
*
* @author mario gozzi neto <[email protected]>
* @date 2023/1/27
*/
@Data
public class BatchAssetsAuthorizedRequest implements Serializable {

private Boolean authorized_children;
private String asset_ids;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.tuya.connector.open.ability.asset.model.request;

import lombok.Data;

import java.io.Serializable;

/**
* Description TODO
*
* @author mario gozzi neto <[email protected]>
* @date 2023/1/27
*/
@Data
public class BatchAssetsUnauthorizedRequest implements Serializable {

private Boolean authorized_children;
private String asset_ids;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.tuya.connector.open.ability.asset.model.response;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
* Description TODO
*
* @author Chyern
* @date 2021/3/27
*/
@Data
public class Assets implements Serializable {

private static final long serialVersionUID = -729531291068553925L;
private List<Device> list;
private Boolean has_more;
private Integer total;

@Data
public static class Device implements Serializable {

private static final long serialVersionUID = -7824240582799706125L;
private Long active_time;
private String asset_id;
private String category;
private Long create_time;
private String icon;
private String id;
private String ip;
private String lat;
private String local_key;
private String lon;
private String name;
private Boolean online;
private String product_id;
private String product_name;
private Boolean sub;
private String time_zone;
private Long update_time;
private String uuid;
private String model;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.tuya.connector.open.ability.asset.model.response;

import lombok.Data;

@Data
public class GetDevicesByAssetIdItensResponse {
private String device_id;
private String asset_id;
private String asset_name;
private String device_name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.tuya.connector.open.ability.asset.model.response;

import lombok.Data;

import java.util.List;

@Data
public class GetDevicesByAssetIdResponse {
private List<GetDevicesByAssetIdItensResponse> list;
private String last_row_key;
private Integer total_size;
private Integer page_size;
private Boolean has_next;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.tuya.connector.open.ability.device.connector;

import com.tuya.connector.api.annotations.*;
import com.tuya.connector.api.model.Result;
import com.tuya.connector.open.ability.common.AbilityPage;
import com.tuya.connector.open.ability.device.model.request.DeviceCommandRequest;
import com.tuya.connector.open.ability.device.model.request.DeviceModifyRequest;
import com.tuya.connector.open.ability.device.model.response.DeviceSpecification;
import com.tuya.connector.open.ability.device.model.response.DeviceStatusLogResultRsp;
import com.tuya.connector.open.ability.device.model.response.DeviceStatuses;
import com.tuya.connector.open.ability.device.model.response.Devices;
import com.tuya.connector.open.ability.device.model.request.*;
import com.tuya.connector.open.ability.device.model.response.*;

import java.util.List;

Expand Down Expand Up @@ -148,4 +145,22 @@ AbilityPage<DeviceStatusLogResultRsp> deviceStatusLog(@Path("device_id") String
@Query("last_row_key") String lastRowKey,
@Query("codes") String codes,
@Query("size") Integer pageSize);

@POST("/v1.0/devices/{device_id}/door-lock/password-ticket")
DoorLockPasswordTicketResponse doorLockPasswordTicket(@Path("device_id") String deviceId);

@POST("/v2.0/devices/{device_id}/door-lock/temp-password")
DoorLockTempPasswordResponse doorLockTempPassword(@Path("device_id") String deviceId,
@Body DoorLockTempPasswordRequest doorLockTempPasswordRequest);

@DELETE("/v1.0/devices/{device_id}/door-lock/temp-passwords/{password_id}")
Result deleteTempPassword(@Path("device_id") String deviceId, @Path("password_id") String password_id);

@POST("/v1.0/devices/{device_id}/door-lock/password-free/open-door")
Result openDoor(@Path("device_id") String deviceId, @Body DoorLockFreePasswordOpenDoorRequest doorLockFreePasswordOpenDoorRequest);

@PUT("/v1.0/devices/{device_id}/door-lock/temp-passwords/{password_id}/modify-password")
Result modifyTempPassword(@Path("device_id") String deviceId, @Path("password_id") String password_id,
@Body DoorLockTempPasswordRequest doorLockTempPasswordRequest);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.tuya.connector.open.ability.device.model.request;

import lombok.Data;

@Data
public class DoorLockFreePasswordOpenDoorRequest {
private String ticket_id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.tuya.connector.open.ability.device.model.request;

import lombok.Data;

import java.util.List;

@Data
public class DoorLockTempPasswordRequest {

private String password;
private Long effective_time;
private Long invalid_time;
private String password_type;
private String phone;
private Integer type;
private String time_zone;
private String ticket_id;
private List<ScheduleListRequest> schedule_list;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.tuya.connector.open.ability.device.model.request;

import lombok.Data;

@Data
public class DoorLockTempPasswordResponse {
private Long id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.tuya.connector.open.ability.device.model.request;

import lombok.Data;

@Data
public class ScheduleListRequest {

private Long effective_time;
private Long invalid_time;
private Integer working_day;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.tuya.connector.open.ability.device.model.response;

import lombok.Data;

@Data
public class DoorLockPasswordTicketResponse {

/**
* The ID of the temporary key.
*/
private String ticket_id;

/**
* The temporary key. It can be used after decryption with AES based on the accessKey
* that is issued by the Cloud Development Platform.
*/
private String ticket_key;

/**
* Remaining validity period.
*/
private Long expire_time;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.tuya.connector.open.ability.user.connector;

import com.tuya.connector.api.annotations.Body;
import com.tuya.connector.api.annotations.DELETE;
import com.tuya.connector.api.annotations.POST;
import com.tuya.connector.api.annotations.Path;
import com.tuya.connector.open.ability.user.model.request.UserRequest;
import com.tuya.connector.open.ability.user.model.response.AddUserResponse;
import org.springframework.stereotype.Repository;

/**
* Description TODO
*
* @author Emerson Gil
* @date 2023/1/27
*/
@Repository
public interface UserConnector {

/**
* delete user
*
* @param userId
* @return
*/

@DELETE("/v1.0/iot-02/users/{user_id}")
Boolean deleteUser(@Path(("user_id")) String userId);

/**
* add user
*
* @param request
* @return
*/
@POST("/v1.0/iot-02/users")
AddUserResponse addUser(@Body UserRequest request);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.tuya.connector.open.ability.user.model.request;

import lombok.Data;

import java.io.Serializable;

/**
* Description TODO
*
* @author Emerson Gil
* @date 2023/1/27
*/
@Data
public class UserRequest implements Serializable {

private static final long serialVersionUID = 155965236652121243L;
private String username;
private String password;
private String country_code;
private String creator;
private String user_nick_name;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.tuya.connector.open.ability.user.model.response;

import lombok.Data;

import java.io.Serializable;

/**
* Description TODO
*
* @author Emerson Gil
* @date 2023/1/27
*/
@Data
public class AddUserResponse implements Serializable {

private String user_id;
}