feat: integration with API Vega Cloud
This commit is contained in:
@@ -20,6 +20,22 @@ export const deviceCommandBody = z.object({
|
||||
})
|
||||
export type DeviceCommandBody = z.infer<typeof deviceCommandBody>
|
||||
|
||||
// Request query schema for GET endpoint
|
||||
export const deviceQueryParams = z.object({
|
||||
merchantName: z.string(),
|
||||
floorName: z.string(),
|
||||
unitNumber: z.string(),
|
||||
deviceName: z.string(),
|
||||
roomName: z.string(),
|
||||
deviceType: z.string(),
|
||||
commandType: z.string(),
|
||||
towerNumber: z.string(),
|
||||
timestamp: z.string().datetime(), // ISO8601
|
||||
nonce: z.string(),
|
||||
signature: z.string(),
|
||||
})
|
||||
export type DeviceQueryParams = z.infer<typeof deviceQueryParams>
|
||||
|
||||
// Response schemas
|
||||
export const deviceCommandResponseSchema = {
|
||||
200: z.object({
|
||||
@@ -45,6 +61,50 @@ export const deviceCommandResponseSchema = {
|
||||
status: z.literal('replay_attack_detected'),
|
||||
message: z.literal('Timestamp or nonce is invalid/has been reused'),
|
||||
}),
|
||||
404: z.object({
|
||||
status: z.literal('not_found'),
|
||||
message: z.literal('Device status not found'),
|
||||
}),
|
||||
500: z.object({
|
||||
status: z.literal('internal_error'),
|
||||
message: z.literal('Server error'),
|
||||
}),
|
||||
}
|
||||
|
||||
// Query response schema
|
||||
export const deviceQueryResponseSchema = {
|
||||
200: z.object({
|
||||
status: z.literal('success'),
|
||||
message: z.literal('command accepted'),
|
||||
data: z.object({
|
||||
floor: z.string(),
|
||||
unit: z.string(),
|
||||
device: z.string(),
|
||||
room: z.string(),
|
||||
devType: z.string(),
|
||||
code: z.string(),
|
||||
tower: z.string(),
|
||||
payload: z.string(),
|
||||
}),
|
||||
}),
|
||||
400: z.object({
|
||||
status: z.literal('invalid_request'),
|
||||
message: z.literal('Invalid request format'),
|
||||
}),
|
||||
401: z.union([
|
||||
z.object({
|
||||
status: z.literal('invalid_signature'),
|
||||
message: z.literal('Signature mismatch'),
|
||||
}),
|
||||
z.object({
|
||||
status: z.literal('invalid_api_key'),
|
||||
message: z.literal('API Key is not valid'),
|
||||
}),
|
||||
]),
|
||||
403: z.object({
|
||||
status: z.literal('replay_attack_detected'),
|
||||
message: z.literal('Timestamp or nonce is invalid/has been reused'),
|
||||
}),
|
||||
500: z.object({
|
||||
status: z.literal('internal_error'),
|
||||
message: z.literal('Server error'),
|
||||
|
||||
Reference in New Issue
Block a user