mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
added nfc model
This commit is contained in:
parent
91645d0893
commit
b31c7cc0f9
56
packages/comty.js/src/models/nfc/index.js
Normal file
56
packages/comty.js/src/models/nfc/index.js
Normal file
@ -0,0 +1,56 @@
|
||||
import request from "../../handlers/request"
|
||||
|
||||
export default class NFCModel {
|
||||
static async getOwnTags() {
|
||||
const { data } = await request({
|
||||
method: "GET",
|
||||
url: `/nfc/tags`
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
static async getTagById(id) {
|
||||
if (!id) {
|
||||
throw new Error("ID is required")
|
||||
}
|
||||
|
||||
const { data } = await request({
|
||||
method: "GET",
|
||||
url: `/nfc/tags/${id}`
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
static async getTagBySerial(serial) {
|
||||
if (!serial) {
|
||||
throw new Error("Serial is required")
|
||||
}
|
||||
|
||||
const { data } = await request({
|
||||
method: "GET",
|
||||
url: `/nfc/tag/serial/${serial}`
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
static async registerTag(serial, payload) {
|
||||
if (!serial) {
|
||||
throw new Error("Serial is required")
|
||||
}
|
||||
|
||||
if (!payload) {
|
||||
throw new Error("Payload is required")
|
||||
}
|
||||
|
||||
const { data } = await request({
|
||||
method: "POST",
|
||||
url: `/nfc/tag/${serial}`,
|
||||
data: payload
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user